feat: 新增很多页面

This commit is contained in:
2026-01-14 01:06:25 +08:00
parent d437b4eded
commit 18f0fbce15
46 changed files with 7926 additions and 10 deletions

View File

@@ -0,0 +1,217 @@
<template>
<el-dialog
title="每周工作详情"
v-model="visible"
:close-on-click-modal="false"
draggable
width="1000px">
<div v-loading="loading" class="article-container">
<!-- 报纸文章样式 -->
<div class="article-header">
<h1 class="article-title">{{ detailData.title || '-' }}</h1>
<div class="article-meta">
<span class="article-author">作者{{ detailData.author || '-' }}</span>
<span class="article-time">{{ detailData.schoolYear || '-' }} {{ detailData.schoolTerm || '-' }}学期</span>
</div>
</div>
<div class="article-content" v-html="detailData.content || '-'"></div>
</div>
<template #footer>
<span class="dialog-footer">
<el-button type="primary" icon="Edit" @click="handleEdit"> </el-button>
<el-button type="danger" icon="Delete" @click="handleDelete"> </el-button>
<el-button @click="visible = false"> </el-button>
</span>
</template>
</el-dialog>
<!-- 编辑表单对话框 -->
<FormDialog ref="formDialogRef" @refresh="handleRefresh" />
</template>
<script setup lang="ts" name="WeekPlanDetail">
import { ref, reactive, nextTick, defineAsyncComponent } from 'vue'
import { useMessage, useMessageBox } from "/@/hooks/message";
import { getObj, delObjs } from '/@/api/stuwork/weekPlan'
const emit = defineEmits(['refresh']);
// 引入组件
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
// 定义变量内容
const formDialogRef = ref()
const visible = ref(false)
const loading = ref(false)
const detailId = ref('')
// 详情数据
const detailData = reactive({
id: '',
schoolYear: '',
schoolTerm: '',
title: '',
content: '',
author: ''
})
// 打开对话框
const openDialog = async (id: string) => {
visible.value = true
detailId.value = id
await nextTick()
getWeekPlanDetail(id)
}
// 获取详情
const getWeekPlanDetail = (id: string) => {
loading.value = true
getObj({ id: id }).then((res: any) => {
if (res.data) {
const data = Array.isArray(res.data) ? res.data[0] : res.data
if (data) {
Object.assign(detailData, {
id: data.id || '',
schoolYear: data.schoolYear || '',
schoolTerm: data.schoolTerm || '',
title: data.title || '',
content: data.content || '',
author: data.author || ''
})
}
}
}).catch((err: any) => {
console.error('获取详情失败', err)
useMessage().error('获取详情失败')
}).finally(() => {
loading.value = false
})
}
// 编辑
const handleEdit = () => {
if (detailId.value) {
formDialogRef.value?.openDialog(detailId.value)
}
}
// 删除
const handleDelete = async () => {
if (!detailId.value) return
try {
await useMessageBox().confirm('此操作将永久删除', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
} catch {
return
}
try {
await delObjs([detailId.value])
useMessage().success('删除成功')
visible.value = false
emit('refresh')
} catch (err: any) {
useMessage().error(err.msg || '删除失败')
}
}
// 刷新
const handleRefresh = () => {
if (detailId.value) {
getWeekPlanDetail(detailId.value)
}
emit('refresh')
}
// 暴露变量
defineExpose({
openDialog
});
</script>
<style scoped>
.article-container {
padding: 20px;
max-width: 100%;
}
.article-header {
border-bottom: 2px solid #e4e7ed;
padding-bottom: 20px;
margin-bottom: 30px;
}
.article-title {
font-size: 28px;
font-weight: bold;
color: #303133;
margin: 0 0 15px 0;
line-height: 1.5;
text-align: center;
}
.article-meta {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 14px;
color: #909399;
padding-top: 10px;
}
.article-author {
font-weight: 500;
}
.article-time {
font-style: italic;
}
.article-content {
font-size: 16px;
line-height: 1.8;
color: #606266;
text-align: justify;
word-wrap: break-word;
}
.article-content :deep(p) {
margin: 0 0 15px 0;
}
.article-content :deep(img) {
max-width: 100%;
height: auto;
display: block;
margin: 20px auto;
}
.article-content :deep(h1),
.article-content :deep(h2),
.article-content :deep(h3),
.article-content :deep(h4),
.article-content :deep(h5),
.article-content :deep(h6) {
margin: 20px 0 15px 0;
font-weight: bold;
}
.article-content :deep(ul),
.article-content :deep(ol) {
margin: 15px 0;
padding-left: 30px;
}
.article-content :deep(blockquote) {
border-left: 4px solid #409eff;
padding-left: 15px;
margin: 15px 0;
color: #909399;
font-style: italic;
}
</style>

View File

@@ -0,0 +1,212 @@
<template>
<el-dialog
:title="form.id ? '编辑' : '新增'"
v-model="visible"
:close-on-click-modal="false"
draggable
width="800px">
<el-form
ref="dataFormRef"
:model="form"
:rules="dataRules"
label-width="100px"
v-loading="loading">
<el-row :gutter="24">
<el-col :span="24" class="mb20">
<el-form-item label="标题" prop="title">
<el-input
v-model="form.title"
placeholder="请输入标题"
clearable />
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item label="内容" prop="content">
<Editor
v-model:get-html="form.content"
height="400"
placeholder="请输入内容" />
</el-form-item>
</el-col>
<el-col :span="12" class="mb20">
<el-form-item label="作者" prop="author">
<el-input
v-model="form.author"
placeholder="请输入作者"
clearable />
</el-form-item>
</el-col>
</el-row>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button @click="visible = false"> </el-button>
<el-button type="primary" @click="onSubmit" :disabled="loading"> </el-button>
</span>
</template>
</el-dialog>
</template>
<script setup lang="ts" name="WeekPlanDialog">
import { ref, reactive, nextTick, onMounted } from 'vue'
import { useMessage } from "/@/hooks/message";
import { getObj, addObj, putObj } from '/@/api/stuwork/weekPlan'
import { queryAllSchoolYear } from '/@/api/basic/basicyear'
import Editor from '/@/components/Editor/index.vue'
const emit = defineEmits(['refresh']);
// 定义变量内容
const dataFormRef = ref();
const visible = ref(false)
const loading = ref(false)
const schoolYearList = ref<any[]>([])
// 提交表单数据
const form = reactive({
id: '',
schoolYear: '',
schoolTerm: '',
title: '',
content: '',
author: ''
});
// 定义校验规则
const dataRules = ref({
schoolYear: [
{ required: false, message: '学年不能为空', trigger: 'blur' }
],
schoolTerm: [
{ required: false, message: '学期不能为空', trigger: 'blur' }
],
title: [
{ required: true, message: '标题不能为空', trigger: 'blur' }
],
content: [
{ required: true, message: '内容不能为空', trigger: 'blur' }
],
author: [
{ required: true, message: '作者不能为空', trigger: 'blur' }
]
})
// 打开弹窗
const openDialog = async (id?: string) => {
visible.value = true
// 重置表单数据
Object.assign(form, {
id: '',
schoolYear: '',
schoolTerm: '',
title: '',
content: '',
author: ''
})
// 确保学年列表已加载
if (schoolYearList.value.length === 0) {
await getSchoolYearList()
}
// 如果是新增设置学年为列表中的第一条数据学期默认为1
if (!id) {
// 设置学年为列表中的第一条数据
if (schoolYearList.value.length > 0) {
form.schoolYear = schoolYearList.value[0].year
}
// 设置学期默认为1
form.schoolTerm = '1'
} else {
// 编辑时,如果没有学年,也设置默认值
if (!form.schoolYear && schoolYearList.value.length > 0) {
form.schoolYear = schoolYearList.value[0].year
}
// 编辑时如果没有学期设置默认为1
if (!form.schoolTerm) {
form.schoolTerm = '1'
}
}
// 重置表单验证
nextTick(() => {
dataFormRef.value?.resetFields();
});
// 获取详情
if (id) {
form.id = id
getWeekPlanData(id)
}
};
// 提交
const onSubmit = async () => {
const valid = await dataFormRef.value.validate().catch(() => {});
if (!valid) return false;
try {
loading.value = true;
form.id ? await putObj(form) : await addObj(form);
useMessage().success(form.id ? '修改成功' : '添加成功');
visible.value = false;
emit('refresh');
} catch (err: any) {
useMessage().error(err.msg || '操作失败');
} finally {
loading.value = false;
}
};
// 初始化表单数据
const getWeekPlanData = (id: string) => {
loading.value = true
getObj({ id: id }).then((res: any) => {
if (res.data) {
// 处理返回数据,可能是对象或数组
const data = Array.isArray(res.data) ? res.data[0] : res.data
if (data) {
Object.assign(form, {
id: data.id || '',
schoolYear: data.schoolYear || '',
schoolTerm: data.schoolTerm || '',
title: data.title || '',
content: data.content || '',
author: data.author || ''
})
}
}
}).catch((err: any) => {
console.error('获取详情失败', err)
useMessage().error('获取详情失败')
}).finally(() => {
loading.value = false
})
}
// 获取学年列表
const getSchoolYearList = async () => {
try {
const res = await queryAllSchoolYear()
if (res.data) {
schoolYearList.value = Array.isArray(res.data) ? res.data : []
}
} catch (err) {
console.error('获取学年列表失败', err)
schoolYearList.value = []
}
}
// 初始化
onMounted(() => {
getSchoolYearList()
})
// 暴露变量
defineExpose({
openDialog
});
</script>

View File

@@ -0,0 +1,406 @@
<template>
<div class="layout-padding">
<div class="layout-padding-auto layout-padding-view">
<!-- 搜索表单 -->
<el-row v-show="showSearch">
<el-form :model="searchForm" ref="searchFormRef" :inline="true" @keyup.enter="handleSearch">
<el-form-item label="学年" prop="schoolYear">
<el-select
v-model="searchForm.schoolYear"
placeholder="请选择学年"
clearable
filterable
style="width: 200px">
<el-option
v-for="item in schoolYearList"
:key="item.year"
:label="item.year"
:value="item.year">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="学期" prop="schoolTerm">
<el-input
v-model="searchForm.schoolTerm"
placeholder="请输入学期"
clearable
style="width: 200px" />
</el-form-item>
<el-form-item label="月份" prop="month">
<el-date-picker
v-model="searchForm.month"
type="month"
placeholder="请选择月份"
format="YYYY-MM"
value-format="YYYY-MM"
clearable
style="width: 200px" />
</el-form-item>
<el-form-item label="学院" prop="deptCode">
<el-select
v-model="searchForm.deptCode"
placeholder="请选择学院"
clearable
filterable
style="width: 200px">
<el-option
v-for="item in deptList"
:key="item.deptCode"
:label="item.deptName"
:value="item.deptCode">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="班号" prop="classCode">
<el-select
v-model="searchForm.classCode"
placeholder="请选择班号"
clearable
filterable
style="width: 200px">
<el-option
v-for="item in filteredClassList"
:key="item.classCode"
:label="item.classNo"
:value="item.classCode">
</el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" plain icon="Search" @click="handleSearch">查询</el-button>
<el-button icon="Refresh" @click="handleReset">重置</el-button>
</el-form-item>
</el-form>
</el-row>
<!-- 操作按钮 -->
<el-row>
<div class="mb8" style="width: 100%">
<el-button
icon="Upload"
type="primary"
class="ml10"
@click="handleImport">
导入
</el-button>
<el-button
icon="DocumentChecked"
type="success"
class="ml10"
@click="handleCheck">
考核
</el-button>
<right-toolbar
v-model:showSearch="showSearch"
class="ml10 mr20"
style="float: right;"
@queryTable="getDataList">
</right-toolbar>
</div>
</el-row>
<!-- 表格 -->
<el-table
:data="state.dataList"
v-loading="state.loading"
border
:cell-style="tableStyle.cellStyle"
:header-cell-style="tableStyle.headerCellStyle"
@sort-change="sortChangeHandle">
<el-table-column type="index" label="序号" width="60" align="center" />
<el-table-column prop="schoolYear" label="学年" show-overflow-tooltip />
<el-table-column prop="schoolTerm" label="学期" show-overflow-tooltip />
<el-table-column prop="deptName" label="学院" show-overflow-tooltip />
<el-table-column prop="classNo" label="班号" show-overflow-tooltip />
<el-table-column prop="classMasterName" label="班主任" show-overflow-tooltip />
<el-table-column prop="buildingNo" label="教学楼号" show-overflow-tooltip />
<el-table-column prop="position" label="教室号" show-overflow-tooltip />
<el-table-column prop="score" label="评分" show-overflow-tooltip />
<el-table-column prop="note" label="检查记录" show-overflow-tooltip />
<el-table-column prop="month" label="月份" show-overflow-tooltip />
<el-table-column label="操作" width="150" align="center" fixed="right">
<template #default="scope">
<el-button
icon="Delete"
text
type="danger"
@click="handleDelete([scope.row.id])">
删除
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<pagination
@size-change="sizeChangeHandle"
@current-change="currentChangeHandle"
v-bind="state.pagination" />
</div>
<!-- 导入对话框 -->
<upload-excel
ref="uploadExcelRef"
:title="'导入教室月卫生'"
:url="'/stuwork/classroomhygienemonthly/importData'"
:temp-url="templateUrl"
@refreshDataList="getDataList" />
<!-- 考核对话框 -->
<el-dialog
v-model="checkDialogVisible"
title="教室卫生考核"
:close-on-click-modal="false"
draggable
width="500px">
<el-form
ref="checkFormRef"
:model="checkForm"
label-width="100px">
<el-form-item label="学年" prop="schoolYear">
<el-select
v-model="checkForm.schoolYear"
placeholder="请选择学年"
clearable
filterable
style="width: 100%">
<el-option
v-for="item in schoolYearList"
:key="item.year"
:label="item.year"
:value="item.year">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="学期" prop="schoolTerm">
<el-input
v-model="checkForm.schoolTerm"
placeholder="请输入学期"
clearable />
</el-form-item>
<el-form-item label="月份" prop="month">
<el-date-picker
v-model="checkForm.month"
type="month"
placeholder="请选择月份"
format="YYYY-MM"
value-format="YYYY-MM"
clearable
style="width: 100%" />
</el-form-item>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button @click="checkDialogVisible = false"> </el-button>
<el-button type="primary" @click="confirmCheck"> </el-button>
</span>
</template>
</el-dialog>
</div>
</template>
<script setup lang="ts" name="ClassRoomHygieneMonthly">
import { ref, reactive, defineAsyncComponent, computed, onMounted } from 'vue'
import { BasicTableProps, useTable } from "/@/hooks/table";
import { fetchList, delObjs, checkClassRoomHygieneMonthly } from "/@/api/stuwork/classroomhygienemonthly";
import { useMessage, useMessageBox } from "/@/hooks/message";
import { queryAllSchoolYear } from '/@/api/basic/basicyear'
import { getDeptList } from '/@/api/basic/basicclass'
import { getClassListByRole } from '/@/api/basic/basicclass'
// 引入组件
const UploadExcel = defineAsyncComponent(() => import('/@/components/Upload/Excel.vue'));
// 定义变量内容
const searchFormRef = ref()
const uploadExcelRef = ref()
const checkFormRef = ref()
// 搜索变量
const showSearch = ref(true)
const schoolYearList = ref<any[]>([])
const deptList = ref<any[]>([])
const classList = ref<any[]>([])
const checkDialogVisible = ref(false)
// 模板文件URL
const templateUrl = ref('assets/file/教室月卫生导入模板.xlsx')
// 考核表单
const checkForm = reactive({
schoolYear: '',
schoolTerm: '',
month: ''
})
// 搜索表单
const searchForm = reactive({
schoolYear: '',
schoolTerm: '',
month: '',
deptCode: '',
classCode: ''
})
// 根据学院筛选班级列表
const filteredClassList = computed(() => {
if (!searchForm.deptCode) {
return classList.value
}
return classList.value.filter((item: any) => item.deptCode === searchForm.deptCode)
})
// 配置 useTable
const state: BasicTableProps = reactive<BasicTableProps>({
queryForm: searchForm,
pageList: fetchList,
props: {
item: 'records',
totalCount: 'total'
}
})
// table hook
const {
getDataList,
currentChangeHandle,
sizeChangeHandle,
sortChangeHandle,
tableStyle
} = useTable(state)
// 查询
const handleSearch = () => {
getDataList()
}
// 重置
const handleReset = () => {
searchFormRef.value?.resetFields()
searchForm.schoolYear = ''
searchForm.schoolTerm = ''
searchForm.month = ''
searchForm.deptCode = ''
searchForm.classCode = ''
getDataList()
}
// 导入
const handleImport = () => {
(uploadExcelRef.value as any)?.show()
}
// 考核
const handleCheck = () => {
checkDialogVisible.value = true
Object.assign(checkForm, {
schoolYear: '',
schoolTerm: '',
month: ''
})
}
// 确认考核
const confirmCheck = async () => {
if (!checkForm.schoolYear || !checkForm.schoolTerm || !checkForm.month) {
useMessage().warning('请填写完整的考核信息')
return
}
// 格式化月份显示2026-01
const monthDisplay = checkForm.month
try {
await useMessageBox().confirm(
`是否确认对${monthDisplay}月进行考核?\n1如果当前指定年月份已经有考核数据则会做覆盖处理\n2考核对象为所有有评分的班级`,
'提示',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
dangerouslyUseHTMLString: false
}
)
} catch {
return
}
try {
await checkClassRoomHygieneMonthly({
schoolYear: checkForm.schoolYear,
schoolTerm: checkForm.schoolTerm,
month: checkForm.month
})
useMessage().success('考核成功')
checkDialogVisible.value = false
getDataList()
} catch (err: any) {
useMessage().error(err.msg || '考核失败')
}
}
// 删除操作
const handleDelete = async (ids: string[]) => {
try {
await useMessageBox().confirm('此操作将永久删除', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
} catch {
return
}
try {
await delObjs(ids)
getDataList()
useMessage().success('删除成功')
} catch (err: any) {
useMessage().error(err.msg || '删除失败')
}
}
// 获取学年列表
const getSchoolYearList = async () => {
try {
const res = await queryAllSchoolYear()
if (res.data) {
schoolYearList.value = Array.isArray(res.data) ? res.data : []
}
} catch (err) {
console.error('获取学年列表失败', err)
schoolYearList.value = []
}
}
// 获取学院列表
const getDeptListData = async () => {
try {
const res = await getDeptList()
if (res.data) {
deptList.value = Array.isArray(res.data) ? res.data : []
}
} catch (err) {
console.error('获取学院列表失败', err)
deptList.value = []
}
}
// 获取班号列表
const getClassListData = async () => {
try {
const res = await getClassListByRole()
if (res.data) {
classList.value = Array.isArray(res.data) ? res.data : []
}
} catch (err) {
console.error('获取班号列表失败', err)
classList.value = []
}
}
// 初始化
onMounted(() => {
getSchoolYearList()
getDeptListData()
getClassListData()
})
</script>