fix
This commit is contained in:
@@ -1,332 +1,280 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
:title="form.id ? '编辑' : '新增'"
|
||||
v-model="visible"
|
||||
:width="900"
|
||||
:close-on-click-modal="false"
|
||||
draggable>
|
||||
<el-form
|
||||
ref="dataFormRef"
|
||||
:model="form"
|
||||
:rules="dataRules"
|
||||
label-width="120px"
|
||||
v-loading="loading">
|
||||
<el-row :gutter="24">
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="班号" prop="classCode">
|
||||
<el-select
|
||||
v-model="form.classCode"
|
||||
placeholder="请选择班号"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 100%">
|
||||
<el-option
|
||||
v-for="item in classList"
|
||||
:key="item.classCode"
|
||||
:label="item.classNo"
|
||||
:value="item.classCode">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="活动主题" prop="themeName">
|
||||
<el-input
|
||||
v-model="form.themeName"
|
||||
placeholder="请输入活动主题"
|
||||
clearable
|
||||
style="width: 100%" />
|
||||
</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
|
||||
style="width: 100%" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="活动时间" prop="recordDate">
|
||||
<el-date-picker
|
||||
v-model="form.recordDate"
|
||||
type="date"
|
||||
placeholder="选择活动时间"
|
||||
format="YYYY-MM-DD"
|
||||
value-format="YYYY-MM-DD"
|
||||
style="width: 100%" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="活动地点" prop="address">
|
||||
<el-input
|
||||
v-model="form.address"
|
||||
placeholder="请输入活动地点"
|
||||
clearable
|
||||
style="width: 100%" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="参加人数" prop="attendNum">
|
||||
<el-input-number
|
||||
v-model="form.attendNum"
|
||||
:min="0"
|
||||
placeholder="请输入参加人数"
|
||||
style="width: 100%" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="活动内容" prop="content">
|
||||
<Editor
|
||||
v-model:getHtml="form.content"
|
||||
:height="300"
|
||||
placeholder="请输入活动内容" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="活动图片" prop="attachment">
|
||||
<upload-file
|
||||
v-model="form.attachment"
|
||||
:limit="5"
|
||||
:fileSize="10"
|
||||
type="simple" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="活动图片2" prop="attachment2">
|
||||
<upload-file
|
||||
v-model="form.attachment2"
|
||||
:limit="5"
|
||||
:fileSize="10"
|
||||
type="simple" />
|
||||
</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>
|
||||
<el-dialog :title="form.id ? '编辑' : '新增'" v-model="visible" :width="900" :close-on-click-modal="false" draggable>
|
||||
<el-form ref="dataFormRef" :model="form" :rules="dataRules" label-width="120px" v-loading="loading">
|
||||
<el-row :gutter="24">
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="班号" prop="classCode">
|
||||
<el-select v-model="form.classCode" placeholder="请选择班号" clearable filterable style="width: 100%">
|
||||
<el-option v-for="item in classList" :key="item.classCode" :label="item.classNo" :value="item.classCode"> </el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="活动主题" prop="themeName">
|
||||
<el-input v-model="form.themeName" placeholder="请输入活动主题" clearable style="width: 100%" />
|
||||
</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 style="width: 100%" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="活动时间" prop="recordDate">
|
||||
<el-date-picker
|
||||
v-model="form.recordDate"
|
||||
type="date"
|
||||
placeholder="选择活动时间"
|
||||
format="YYYY-MM-DD"
|
||||
value-format="YYYY-MM-DD"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="活动地点" prop="address">
|
||||
<el-input v-model="form.address" placeholder="请输入活动地点" clearable style="width: 100%" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="参加人数" prop="attendNum">
|
||||
<el-input-number v-model="form.attendNum" :min="0" placeholder="请输入参加人数" style="width: 100%" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="活动内容" prop="content">
|
||||
<Editor v-model:getHtml="form.content" :height="300" placeholder="请输入活动内容" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="活动图片" prop="attachment">
|
||||
<upload-file v-model="form.attachment" :limit="5" :fileSize="10" type="simple" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="活动图片2" prop="attachment2">
|
||||
<upload-file v-model="form.attachment2" :limit="5" :fileSize="10" type="simple" />
|
||||
</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="ClassActivityFormDialog">
|
||||
import { ref, reactive, nextTick, onMounted } from 'vue'
|
||||
import { useMessage } from '/@/hooks/message'
|
||||
import { addObj, editObj, getDetail } from '/@/api/stuwork/classactivity'
|
||||
import { getClassListByRole } from '/@/api/basic/basicclass'
|
||||
import { queryAllSchoolYear } from '/@/api/basic/basicyear'
|
||||
import { getDicts } from '/@/api/admin/dict'
|
||||
import { CURRENT_SCHOOL_YEAR, CURRENT_SCHOOL_TERM } from '/@/config/global'
|
||||
import Editor from '/@/components/Editor/index.vue'
|
||||
import UploadFile from '/@/components/Upload/index.vue'
|
||||
import { ref, reactive, nextTick, onMounted } from 'vue';
|
||||
import { useMessage } from '/@/hooks/message';
|
||||
import { addObj, editObj, getDetail } from '/@/api/stuwork/classactivity';
|
||||
import { getClassListByRole } from '/@/api/basic/basicclass';
|
||||
import { queryAllSchoolYear } from '/@/api/basic/basicyear';
|
||||
import { getDicts } from '/@/api/admin/dict';
|
||||
import { CURRENT_SCHOOL_YEAR, CURRENT_SCHOOL_TERM } from '/@/config/global';
|
||||
import Editor from '/@/components/Editor/index.vue';
|
||||
import UploadFile from '/@/components/Upload/index.vue';
|
||||
|
||||
const emit = defineEmits(['refresh'])
|
||||
const emit = defineEmits(['refresh']);
|
||||
|
||||
// 定义变量内容
|
||||
const dataFormRef = ref()
|
||||
const visible = ref(false)
|
||||
const loading = ref(false)
|
||||
const operType = ref('add')
|
||||
const classList = ref<any[]>([])
|
||||
const schoolYearList = ref<any[]>([])
|
||||
const schoolTermList = ref<any[]>([])
|
||||
const currentSchoolYear = ref('')
|
||||
const currentSchoolTerm = ref('')
|
||||
const dataFormRef = ref();
|
||||
const visible = ref(false);
|
||||
const loading = ref(false);
|
||||
const operType = ref('add');
|
||||
const classList = ref<any[]>([]);
|
||||
const schoolYearList = ref<any[]>([]);
|
||||
const schoolTermList = ref<any[]>([]);
|
||||
const currentSchoolYear = ref('');
|
||||
const currentSchoolTerm = ref('');
|
||||
|
||||
// 提交表单数据
|
||||
const form = reactive({
|
||||
id: '',
|
||||
classCode: '',
|
||||
themeName: '',
|
||||
author: '',
|
||||
recordDate: '',
|
||||
address: '',
|
||||
attendNum: 0,
|
||||
content: '',
|
||||
attachment: '',
|
||||
attachment2: ''
|
||||
})
|
||||
id: '',
|
||||
classCode: '',
|
||||
themeName: '',
|
||||
author: '',
|
||||
recordDate: '',
|
||||
address: '',
|
||||
attendNum: 0,
|
||||
content: '',
|
||||
attachment: '',
|
||||
attachment2: '',
|
||||
});
|
||||
|
||||
// 定义校验规则
|
||||
const dataRules = {
|
||||
classCode: [
|
||||
{ required: true, message: '请选择班号', trigger: 'change' }
|
||||
],
|
||||
themeName: [
|
||||
{ required: true, message: '请输入活动主题', trigger: 'blur' }
|
||||
],
|
||||
author: [
|
||||
{ required: true, message: '请输入主持人', trigger: 'blur' }
|
||||
],
|
||||
address: [
|
||||
{ required: true, message: '请输入活动地点', trigger: 'blur' }
|
||||
],
|
||||
attendNum: [
|
||||
{ required: true, message: '请输入参加人数', trigger: 'blur' }
|
||||
]
|
||||
// activityTime 和 content 非必填,不需要验证规则
|
||||
}
|
||||
classCode: [{ required: true, message: '请选择班号', trigger: 'change' }],
|
||||
themeName: [{ required: true, message: '请输入活动主题', trigger: 'blur' }],
|
||||
author: [{ required: true, message: '请输入主持人', trigger: 'blur' }],
|
||||
address: [{ required: true, message: '请输入活动地点', trigger: 'blur' }],
|
||||
attendNum: [{ required: true, message: '请输入参加人数', trigger: 'blur' }],
|
||||
// activityTime 和 content 非必填,不需要验证规则
|
||||
};
|
||||
|
||||
// 打开弹窗
|
||||
const openDialog = async (type: string = 'add', row?: any) => {
|
||||
visible.value = true
|
||||
operType.value = type
|
||||
|
||||
// 重置表单数据
|
||||
nextTick(() => {
|
||||
dataFormRef.value?.resetFields()
|
||||
form.id = ''
|
||||
form.classCode = ''
|
||||
form.themeName = ''
|
||||
form.author = ''
|
||||
form.recordDate = ''
|
||||
form.address = ''
|
||||
form.attendNum = 0
|
||||
form.content = ''
|
||||
form.attachment = ''
|
||||
form.attachment2 = ''
|
||||
|
||||
// 编辑时填充数据
|
||||
if (type === 'edit' && row) {
|
||||
form.id = row.id
|
||||
form.classCode = row.classCode || ''
|
||||
form.themeName = row.themeName || ''
|
||||
form.author = row.author || ''
|
||||
form.recordDate = row.activityTime || row.recordDate || ''
|
||||
form.address = row.address || ''
|
||||
form.attendNum = row.attendNum || 0
|
||||
form.content = row.content || ''
|
||||
form.attachment = row.attachment || ''
|
||||
form.attachment2 = row.attachment2 || ''
|
||||
|
||||
// 如果需要获取详情
|
||||
if (row.id && !row.content) {
|
||||
loading.value = true
|
||||
getDetail(row.id).then((res: any) => {
|
||||
if (res.data) {
|
||||
form.content = res.data.content || ''
|
||||
form.attachment = res.data.attachment || ''
|
||||
form.attachment2 = res.data.attachment2 || ''
|
||||
}
|
||||
}).finally(() => {
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
visible.value = true;
|
||||
operType.value = type;
|
||||
|
||||
// 重置表单数据
|
||||
nextTick(() => {
|
||||
dataFormRef.value?.resetFields();
|
||||
form.id = '';
|
||||
form.classCode = '';
|
||||
form.themeName = '';
|
||||
form.author = '';
|
||||
form.recordDate = '';
|
||||
form.address = '';
|
||||
form.attendNum = 0;
|
||||
form.content = '';
|
||||
form.attachment = '';
|
||||
form.attachment2 = '';
|
||||
|
||||
// 编辑时填充数据
|
||||
if (type === 'edit' && row) {
|
||||
form.id = row.id;
|
||||
form.classCode = row.classCode || '';
|
||||
form.themeName = row.themeName || '';
|
||||
form.author = row.author || '';
|
||||
form.recordDate = row.activityTime || row.recordDate || '';
|
||||
form.address = row.address || '';
|
||||
form.attendNum = row.attendNum || 0;
|
||||
form.content = row.content || '';
|
||||
form.attachment = row.attachment || '';
|
||||
form.attachment2 = row.attachment2 || '';
|
||||
|
||||
// 如果需要获取详情
|
||||
if (row.id && !row.content) {
|
||||
loading.value = true;
|
||||
getDetail(row.id)
|
||||
.then((res: any) => {
|
||||
if (res.data) {
|
||||
form.content = res.data.content || '';
|
||||
form.attachment = res.data.attachment || '';
|
||||
form.attachment2 = res.data.attachment2 || '';
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 提交表单
|
||||
const onSubmit = async () => {
|
||||
if (!dataFormRef.value) return
|
||||
|
||||
await dataFormRef.value.validate(async (valid: boolean) => {
|
||||
if (!valid) return
|
||||
|
||||
loading.value = true
|
||||
try {
|
||||
const submitData = {
|
||||
classCode: form.classCode,
|
||||
schoolYear: currentSchoolYear.value || CURRENT_SCHOOL_YEAR, // 使用当前学年
|
||||
schoolTerm: currentSchoolTerm.value || CURRENT_SCHOOL_TERM, // 使用当前学期
|
||||
themeName: form.themeName,
|
||||
author: form.author,
|
||||
recordDate: form.recordDate || '',
|
||||
address: form.address,
|
||||
attendNum: String(form.attendNum || 0), // API文档示例中是字符串类型
|
||||
content: form.content || '',
|
||||
attachment: form.attachment || '',
|
||||
attachment2: form.attachment2 || ''
|
||||
}
|
||||
|
||||
if (operType.value === 'add') {
|
||||
await addObj(submitData)
|
||||
useMessage().success('新增成功')
|
||||
} else {
|
||||
await editObj({
|
||||
id: form.id,
|
||||
...submitData
|
||||
})
|
||||
useMessage().success('编辑成功')
|
||||
}
|
||||
visible.value = false
|
||||
emit('refresh')
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg || (operType.value === 'add' ? '新增失败' : '编辑失败'))
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
})
|
||||
}
|
||||
if (!dataFormRef.value) return;
|
||||
|
||||
await dataFormRef.value.validate(async (valid: boolean) => {
|
||||
if (!valid) return;
|
||||
|
||||
loading.value = true;
|
||||
try {
|
||||
const submitData = {
|
||||
classCode: form.classCode,
|
||||
schoolYear: currentSchoolYear.value || CURRENT_SCHOOL_YEAR, // 使用当前学年
|
||||
schoolTerm: currentSchoolTerm.value || CURRENT_SCHOOL_TERM, // 使用当前学期
|
||||
themeName: form.themeName,
|
||||
author: form.author,
|
||||
recordDate: form.recordDate || '',
|
||||
address: form.address,
|
||||
attendNum: String(form.attendNum || 0), // API文档示例中是字符串类型
|
||||
content: form.content || '',
|
||||
attachment: form.attachment || '',
|
||||
attachment2: form.attachment2 || '',
|
||||
};
|
||||
|
||||
if (operType.value === 'add') {
|
||||
await addObj(submitData);
|
||||
useMessage().success('新增成功');
|
||||
} else {
|
||||
await editObj({
|
||||
id: form.id,
|
||||
...submitData,
|
||||
});
|
||||
useMessage().success('编辑成功');
|
||||
}
|
||||
visible.value = false;
|
||||
emit('refresh');
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg || (operType.value === 'add' ? '新增失败' : '编辑失败'));
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 获取班级列表
|
||||
const getClassListData = async () => {
|
||||
try {
|
||||
const res = await getClassListByRole()
|
||||
if (res.data && Array.isArray(res.data)) {
|
||||
classList.value = res.data
|
||||
}
|
||||
} catch (err) {
|
||||
}
|
||||
}
|
||||
try {
|
||||
const res = await getClassListByRole();
|
||||
if (res.data && Array.isArray(res.data)) {
|
||||
classList.value = res.data;
|
||||
}
|
||||
} catch (err) {}
|
||||
};
|
||||
|
||||
// 获取学年列表并设置当前学年
|
||||
const getSchoolYearList = async () => {
|
||||
try {
|
||||
const res = await queryAllSchoolYear()
|
||||
if (res.data && Array.isArray(res.data)) {
|
||||
schoolYearList.value = res.data
|
||||
// 设置当前学年(如果列表中有的话)
|
||||
const currentYear = schoolYearList.value.find((item: any) => item.year === CURRENT_SCHOOL_YEAR)
|
||||
currentSchoolYear.value = currentYear ? currentYear.year : (schoolYearList.value.length > 0 ? schoolYearList.value[0].year : CURRENT_SCHOOL_YEAR)
|
||||
} else {
|
||||
currentSchoolYear.value = CURRENT_SCHOOL_YEAR
|
||||
}
|
||||
} catch (err) {
|
||||
currentSchoolYear.value = CURRENT_SCHOOL_YEAR
|
||||
}
|
||||
}
|
||||
try {
|
||||
const res = await queryAllSchoolYear();
|
||||
if (res.data && Array.isArray(res.data)) {
|
||||
schoolYearList.value = res.data;
|
||||
// 设置当前学年(如果列表中有的话)
|
||||
const currentYear = schoolYearList.value.find((item: any) => item.year === CURRENT_SCHOOL_YEAR);
|
||||
currentSchoolYear.value = currentYear ? currentYear.year : schoolYearList.value.length > 0 ? schoolYearList.value[0].year : CURRENT_SCHOOL_YEAR;
|
||||
} else {
|
||||
currentSchoolYear.value = CURRENT_SCHOOL_YEAR;
|
||||
}
|
||||
} catch (err) {
|
||||
currentSchoolYear.value = CURRENT_SCHOOL_YEAR;
|
||||
}
|
||||
};
|
||||
|
||||
// 获取学期字典并设置当前学期
|
||||
const getSchoolTermDict = async () => {
|
||||
try {
|
||||
const res = await getDicts('school_term')
|
||||
if (res.data && Array.isArray(res.data)) {
|
||||
schoolTermList.value = res.data.map((item: any) => ({
|
||||
label: item.label || item.dictLabel || item.name,
|
||||
value: item.value || item.dictValue || item.code
|
||||
}))
|
||||
// 设置当前学期
|
||||
const currentTerm = schoolTermList.value.find((item: any) => item.value === CURRENT_SCHOOL_TERM)
|
||||
currentSchoolTerm.value = currentTerm ? currentTerm.value : (schoolTermList.value.length > 0 ? schoolTermList.value[0].value : CURRENT_SCHOOL_TERM)
|
||||
} else {
|
||||
currentSchoolTerm.value = CURRENT_SCHOOL_TERM
|
||||
}
|
||||
} catch (err) {
|
||||
currentSchoolTerm.value = CURRENT_SCHOOL_TERM
|
||||
}
|
||||
}
|
||||
try {
|
||||
const res = await getDicts('school_term');
|
||||
if (res.data && Array.isArray(res.data)) {
|
||||
schoolTermList.value = res.data.map((item: any) => ({
|
||||
label: item.label || item.dictLabel || item.name,
|
||||
value: item.value || item.dictValue || item.code,
|
||||
}));
|
||||
// 设置当前学期
|
||||
const currentTerm = schoolTermList.value.find((item: any) => item.value === CURRENT_SCHOOL_TERM);
|
||||
currentSchoolTerm.value = currentTerm
|
||||
? currentTerm.value
|
||||
: schoolTermList.value.length > 0
|
||||
? schoolTermList.value[0].value
|
||||
: CURRENT_SCHOOL_TERM;
|
||||
} else {
|
||||
currentSchoolTerm.value = CURRENT_SCHOOL_TERM;
|
||||
}
|
||||
} catch (err) {
|
||||
currentSchoolTerm.value = CURRENT_SCHOOL_TERM;
|
||||
}
|
||||
};
|
||||
|
||||
// 初始化
|
||||
onMounted(() => {
|
||||
getClassListData()
|
||||
getSchoolYearList()
|
||||
getSchoolTermDict()
|
||||
})
|
||||
getClassListData();
|
||||
getSchoolYearList();
|
||||
getSchoolTermDict();
|
||||
});
|
||||
|
||||
// 暴露方法
|
||||
defineExpose({
|
||||
openDialog
|
||||
})
|
||||
openDialog,
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.mb20 {
|
||||
margin-bottom: 20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
@@ -1,531 +1,444 @@
|
||||
<template>
|
||||
<div class="modern-page-container">
|
||||
<div class="page-wrapper">
|
||||
<!-- 搜索表单卡片 -->
|
||||
<el-card v-show="showSearch" class="search-card" shadow="never">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span class="card-title">
|
||||
<el-icon class="title-icon"><Search /></el-icon>
|
||||
筛选条件
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
<el-form
|
||||
:model="state.queryForm"
|
||||
ref="searchFormRef"
|
||||
:inline="true"
|
||||
@keyup.enter="getDataList"
|
||||
class="search-form">
|
||||
<el-form-item label="学年" prop="schoolYear">
|
||||
<el-select
|
||||
v-model="state.queryForm.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-select
|
||||
v-model="state.queryForm.schoolTerm"
|
||||
placeholder="请选择学期"
|
||||
clearable
|
||||
style="width: 200px">
|
||||
<el-option
|
||||
v-for="item in schoolTermList"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="班号" prop="classCode">
|
||||
<el-select
|
||||
v-model="state.queryForm.classCode"
|
||||
placeholder="请选择班号"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 200px">
|
||||
<el-option
|
||||
v-for="item in classList"
|
||||
:key="item.classCode"
|
||||
:label="item.classNo"
|
||||
:value="item.classCode">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="getDataList">查询</el-button>
|
||||
<el-button icon="Refresh" @click="handleReset">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
<div class="modern-page-container">
|
||||
<div class="page-wrapper">
|
||||
<!-- 搜索表单卡片 -->
|
||||
<el-card v-show="showSearch" class="search-card" shadow="never">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span class="card-title">
|
||||
<el-icon class="title-icon"><Search /></el-icon>
|
||||
筛选条件
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
<el-form :model="state.queryForm" ref="searchFormRef" :inline="true" @keyup.enter="getDataList" class="search-form">
|
||||
<el-form-item label="学年" prop="schoolYear">
|
||||
<el-select v-model="state.queryForm.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-select v-model="state.queryForm.schoolTerm" placeholder="请选择学期" clearable style="width: 200px">
|
||||
<el-option v-for="item in schoolTermList" :key="item.value" :label="item.label" :value="item.value"> </el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="班号" prop="classCode">
|
||||
<el-select v-model="state.queryForm.classCode" placeholder="请选择班号" clearable filterable style="width: 200px">
|
||||
<el-option v-for="item in classList" :key="item.classCode" :label="item.classNo" :value="item.classCode"> </el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="getDataList">查询</el-button>
|
||||
<el-button icon="Refresh" @click="handleReset">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<!-- 内容卡片 -->
|
||||
<el-card class="content-card" shadow="never">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span class="card-title">
|
||||
<el-icon class="title-icon"><Document /></el-icon>
|
||||
班级活动列表
|
||||
</span>
|
||||
<div class="header-actions">
|
||||
<el-button
|
||||
icon="DataAnalysis"
|
||||
type="success"
|
||||
@click="handleStatistics">
|
||||
活动统计
|
||||
</el-button>
|
||||
<el-button
|
||||
icon="Plus"
|
||||
type="primary"
|
||||
@click="formDialogRef.openDialog()">
|
||||
新增
|
||||
</el-button>
|
||||
<right-toolbar
|
||||
v-model:showSearch="showSearch"
|
||||
class="ml10"
|
||||
@queryTable="getDataList">
|
||||
<TableColumnControl
|
||||
ref="columnControlRef"
|
||||
:columns="tableColumns"
|
||||
v-model="visibleColumns"
|
||||
trigger-type="default"
|
||||
trigger-circle
|
||||
@change="handleColumnChange"
|
||||
@order-change="handleColumnOrderChange"
|
||||
>
|
||||
<template #trigger>
|
||||
<el-tooltip class="item" effect="dark" content="列设置" placement="top">
|
||||
<el-button circle style="margin-left: 0;">
|
||||
<el-icon><Menu /></el-icon>
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</TableColumnControl>
|
||||
</right-toolbar>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<!-- 内容卡片 -->
|
||||
<el-card class="content-card" shadow="never">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span class="card-title">
|
||||
<el-icon class="title-icon"><Document /></el-icon>
|
||||
班级活动列表
|
||||
</span>
|
||||
<div class="header-actions">
|
||||
<el-button icon="DataAnalysis" type="success" @click="handleStatistics"> 活动统计 </el-button>
|
||||
<el-button icon="Plus" type="primary" @click="formDialogRef.openDialog()"> 新增 </el-button>
|
||||
<right-toolbar v-model:showSearch="showSearch" class="ml10" @queryTable="getDataList">
|
||||
<TableColumnControl
|
||||
ref="columnControlRef"
|
||||
:columns="tableColumns"
|
||||
v-model="visibleColumns"
|
||||
trigger-type="default"
|
||||
trigger-circle
|
||||
@change="handleColumnChange"
|
||||
@order-change="handleColumnOrderChange"
|
||||
>
|
||||
<template #trigger>
|
||||
<el-tooltip class="item" effect="dark" content="列设置" placement="top">
|
||||
<el-button circle style="margin-left: 0">
|
||||
<el-icon><Menu /></el-icon>
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</TableColumnControl>
|
||||
</right-toolbar>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- 表格 -->
|
||||
<el-table
|
||||
:data="state.dataList"
|
||||
v-loading="state.loading"
|
||||
stripe
|
||||
:cell-style="tableStyle.cellStyle"
|
||||
:header-cell-style="tableStyle.headerCellStyle"
|
||||
class="modern-table">
|
||||
<el-table-column type="index" label="序号" width="70" align="center">
|
||||
<template #header>
|
||||
<el-icon><List /></el-icon>
|
||||
</template>
|
||||
<template #default="{ $index }">
|
||||
{{ $index + 1 + ((state.pagination?.current || 1) - 1) * (state.pagination?.size || 10) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<template v-for="col in visibleColumnsSorted" :key="col.prop || col.label">
|
||||
<el-table-column
|
||||
v-if="checkColumnVisible(col.prop || '') && col.prop !== '操作'"
|
||||
:prop="col.prop"
|
||||
:label="col.label"
|
||||
:width="col.width"
|
||||
:min-width="col.minWidth"
|
||||
:show-overflow-tooltip="col.showOverflowTooltip !== false"
|
||||
:align="col.align || 'center'"
|
||||
:fixed="col.fixed">
|
||||
<template #header>
|
||||
<el-icon v-if="col.icon"><component :is="col.icon" /></el-icon>
|
||||
<span :style="{ marginLeft: col.icon ? '4px' : '0' }">{{ col.label }}</span>
|
||||
</template>
|
||||
<!-- 学期列特殊模板 -->
|
||||
<template v-if="col.prop === 'schoolTerm'" #default="scope">
|
||||
<el-tag size="small" type="primary" effect="plain" round>
|
||||
{{ formatSchoolTerm(scope.row.schoolTerm) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
<!-- 活动时间列特殊模板 -->
|
||||
<template v-else-if="col.prop === 'activityTime'" #default="scope">
|
||||
<span>{{ scope.row.activityTime || scope.row.recordDate || '-' }}</span>
|
||||
</template>
|
||||
<!-- 参加人数列特殊模板 -->
|
||||
<template v-else-if="col.prop === 'attendNum'" #default="scope">
|
||||
<el-tag v-if="scope.row.attendNum" size="small" type="success" effect="plain" round>
|
||||
{{ scope.row.attendNum }}
|
||||
</el-tag>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
<!-- 活动图片列特殊模板 -->
|
||||
<template v-else-if="col.prop === 'attachment'" #default="scope">
|
||||
<el-button
|
||||
v-if="scope.row.attachment"
|
||||
icon="Picture"
|
||||
link
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="handleViewImage(scope.row.attachment)">
|
||||
查看
|
||||
</el-button>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
<!-- 活动图片2列特殊模板 -->
|
||||
<template v-else-if="col.prop === 'attachment2'" #default="scope">
|
||||
<el-button
|
||||
v-if="scope.row.attachment2"
|
||||
icon="Picture"
|
||||
link
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="handleViewImage(scope.row.attachment2)">
|
||||
查看
|
||||
</el-button>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</template>
|
||||
<el-table-column label="操作" width="180" align="center" fixed="right">
|
||||
<template #header>
|
||||
<el-icon><Setting /></el-icon>
|
||||
<span style="margin-left: 4px">操作</span>
|
||||
</template>
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
icon="EditPen"
|
||||
link
|
||||
type="primary"
|
||||
@click="handleEdit(scope.row)">
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
icon="Delete"
|
||||
link
|
||||
type="danger"
|
||||
@click="handleDelete(scope.row)">
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<template #empty>
|
||||
<el-empty description="暂无数据" :image-size="120">
|
||||
<el-button type="primary" icon="Plus" @click="formDialogRef.openDialog()">新增活动</el-button>
|
||||
</el-empty>
|
||||
</template>
|
||||
</el-table>
|
||||
<!-- 表格 -->
|
||||
<el-table
|
||||
:data="state.dataList"
|
||||
v-loading="state.loading"
|
||||
stripe
|
||||
:cell-style="tableStyle.cellStyle"
|
||||
:header-cell-style="tableStyle.headerCellStyle"
|
||||
class="modern-table"
|
||||
>
|
||||
<el-table-column type="index" label="序号" width="70" align="center">
|
||||
<template #header>
|
||||
<el-icon><List /></el-icon>
|
||||
</template>
|
||||
<template #default="{ $index }">
|
||||
{{ $index + 1 + ((state.pagination?.current || 1) - 1) * (state.pagination?.size || 10) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<template v-for="col in visibleColumnsSorted" :key="col.prop || col.label">
|
||||
<el-table-column
|
||||
v-if="checkColumnVisible(col.prop || '') && col.prop !== '操作'"
|
||||
:prop="col.prop"
|
||||
:label="col.label"
|
||||
:width="col.width"
|
||||
:min-width="col.minWidth"
|
||||
:show-overflow-tooltip="col.showOverflowTooltip !== false"
|
||||
:align="col.align || 'center'"
|
||||
:fixed="col.fixed"
|
||||
>
|
||||
<template #header>
|
||||
<el-icon v-if="col.icon"><component :is="col.icon" /></el-icon>
|
||||
<span :style="{ marginLeft: col.icon ? '4px' : '0' }">{{ col.label }}</span>
|
||||
</template>
|
||||
<!-- 学期列特殊模板 -->
|
||||
<template v-if="col.prop === 'schoolTerm'" #default="scope">
|
||||
<el-tag size="small" type="primary" effect="plain" round>
|
||||
{{ formatSchoolTerm(scope.row.schoolTerm) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
<!-- 活动时间列特殊模板 -->
|
||||
<template v-else-if="col.prop === 'activityTime'" #default="scope">
|
||||
<span>{{ scope.row.activityTime || scope.row.recordDate || '-' }}</span>
|
||||
</template>
|
||||
<!-- 参加人数列特殊模板 -->
|
||||
<template v-else-if="col.prop === 'attendNum'" #default="scope">
|
||||
<el-tag v-if="scope.row.attendNum" size="small" type="success" effect="plain" round>
|
||||
{{ scope.row.attendNum }}
|
||||
</el-tag>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
<!-- 活动图片列特殊模板 -->
|
||||
<template v-else-if="col.prop === 'attachment'" #default="scope">
|
||||
<el-button v-if="scope.row.attachment" icon="Picture" link type="primary" size="small" @click="handleViewImage(scope.row.attachment)">
|
||||
查看
|
||||
</el-button>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
<!-- 活动图片2列特殊模板 -->
|
||||
<template v-else-if="col.prop === 'attachment2'" #default="scope">
|
||||
<el-button
|
||||
v-if="scope.row.attachment2"
|
||||
icon="Picture"
|
||||
link
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="handleViewImage(scope.row.attachment2)"
|
||||
>
|
||||
查看
|
||||
</el-button>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</template>
|
||||
<el-table-column label="操作" width="180" align="center" fixed="right">
|
||||
<template #header>
|
||||
<el-icon><Setting /></el-icon>
|
||||
<span style="margin-left: 4px">操作</span>
|
||||
</template>
|
||||
<template #default="scope">
|
||||
<el-button icon="EditPen" link type="primary" @click="handleEdit(scope.row)"> 编辑 </el-button>
|
||||
<el-button icon="Delete" link type="danger" @click="handleDelete(scope.row)"> 删除 </el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<template #empty>
|
||||
<el-empty description="暂无数据" :image-size="120">
|
||||
<el-button type="primary" icon="Plus" @click="formDialogRef.openDialog()">新增活动</el-button>
|
||||
</el-empty>
|
||||
</template>
|
||||
</el-table>
|
||||
|
||||
<!-- 分页 -->
|
||||
<div class="pagination-wrapper">
|
||||
<pagination
|
||||
@size-change="sizeChangeHandle"
|
||||
@current-change="currentChangeHandle"
|
||||
v-bind="state.pagination" />
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
<!-- 分页 -->
|
||||
<div class="pagination-wrapper">
|
||||
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination" />
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
|
||||
<!-- 新增/编辑表单弹窗 -->
|
||||
<form-dialog ref="formDialogRef" @refresh="getDataList" />
|
||||
<!-- 新增/编辑表单弹窗 -->
|
||||
<form-dialog ref="formDialogRef" @refresh="getDataList" />
|
||||
|
||||
<!-- 统计对话框 -->
|
||||
<el-dialog
|
||||
v-model="statisticsDialogVisible"
|
||||
title="班级活动统计"
|
||||
width="800px"
|
||||
destroy-on-close>
|
||||
<!-- 搜索条件 -->
|
||||
<el-form :inline="true" class="statistics-form">
|
||||
<el-form-item label="学年">
|
||||
<el-select
|
||||
v-model="statisticsQuery.schoolYear"
|
||||
placeholder="请选择学年"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 180px">
|
||||
<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="学期">
|
||||
<el-select
|
||||
v-model="statisticsQuery.schoolTerm"
|
||||
placeholder="请选择学期"
|
||||
clearable
|
||||
style="width: 180px">
|
||||
<el-option
|
||||
v-for="item in schoolTermList"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="getStatisticsData">查询</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<!-- 统计对话框 -->
|
||||
<el-dialog v-model="statisticsDialogVisible" title="班级活动统计" width="800px" destroy-on-close>
|
||||
<!-- 搜索条件 -->
|
||||
<el-form :inline="true" class="statistics-form">
|
||||
<el-form-item label="学年">
|
||||
<el-select v-model="statisticsQuery.schoolYear" placeholder="请选择学年" clearable filterable style="width: 180px">
|
||||
<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="学期">
|
||||
<el-select v-model="statisticsQuery.schoolTerm" placeholder="请选择学期" clearable style="width: 180px">
|
||||
<el-option v-for="item in schoolTermList" :key="item.value" :label="item.label" :value="item.value"> </el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="getStatisticsData">查询</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<!-- 统计表格 -->
|
||||
<el-table
|
||||
:data="statisticsData"
|
||||
v-loading="statisticsLoading"
|
||||
stripe
|
||||
max-height="400px"
|
||||
:cell-style="tableStyle.cellStyle"
|
||||
:header-cell-style="tableStyle.headerCellStyle">
|
||||
<el-table-column type="index" label="序号" width="70" align="center" />
|
||||
<el-table-column prop="classNo" label="班号" align="center" />
|
||||
<el-table-column prop="schoolYear" label="学年" align="center" />
|
||||
<el-table-column prop="schoolTerm" label="学期" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag size="small" type="primary" effect="plain" round>
|
||||
{{ formatSchoolTerm(row.schoolTerm) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="activityCount" label="活动次数" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag size="small" type="success" effect="plain" round>
|
||||
{{ row.activityCount }} 次
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!-- 统计表格 -->
|
||||
<el-table
|
||||
:data="statisticsData"
|
||||
v-loading="statisticsLoading"
|
||||
stripe
|
||||
max-height="400px"
|
||||
:cell-style="tableStyle.cellStyle"
|
||||
:header-cell-style="tableStyle.headerCellStyle"
|
||||
>
|
||||
<el-table-column type="index" label="序号" width="70" align="center" />
|
||||
<el-table-column prop="classNo" label="班号" align="center" />
|
||||
<el-table-column prop="schoolYear" label="学年" align="center" />
|
||||
<el-table-column prop="schoolTerm" label="学期" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag size="small" type="primary" effect="plain" round>
|
||||
{{ formatSchoolTerm(row.schoolTerm) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="activityCount" label="活动次数" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag size="small" type="success" effect="plain" round> {{ row.activityCount }} 次 </el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<template #footer>
|
||||
<el-button @click="statisticsDialogVisible = false">关闭</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button @click="statisticsDialogVisible = false">关闭</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="ClassActivity">
|
||||
import { reactive, ref, onMounted } from 'vue'
|
||||
import { BasicTableProps, useTable } from "/@/hooks/table";
|
||||
import { fetchList, delObj, statisticsByYearTerm } from "/@/api/stuwork/classactivity";
|
||||
import { getClassListByRole } from "/@/api/basic/basicclass";
|
||||
import { queryAllSchoolYear } from "/@/api/basic/basicyear";
|
||||
import { getDicts } from "/@/api/admin/dict";
|
||||
import { useMessage, useMessageBox } from "/@/hooks/message";
|
||||
import TableColumnControl from '/@/components/TableColumnControl/index.vue'
|
||||
import FormDialog from './form.vue'
|
||||
import { List, Calendar, Clock, Grid, Trophy, User, Location, UserFilled, Setting, Menu, Search, Document, EditPen, Picture, DataAnalysis } from '@element-plus/icons-vue'
|
||||
import { useTableColumnControl } from '/@/hooks/tableColumn'
|
||||
import { reactive, ref, onMounted } from 'vue';
|
||||
import { BasicTableProps, useTable } from '/@/hooks/table';
|
||||
import { fetchList, delObj, statisticsByYearTerm } from '/@/api/stuwork/classactivity';
|
||||
import { getClassListByRole } from '/@/api/basic/basicclass';
|
||||
import { queryAllSchoolYear } from '/@/api/basic/basicyear';
|
||||
import { getDicts } from '/@/api/admin/dict';
|
||||
import { useMessage, useMessageBox } from '/@/hooks/message';
|
||||
import TableColumnControl from '/@/components/TableColumnControl/index.vue';
|
||||
import FormDialog from './form.vue';
|
||||
import {
|
||||
List,
|
||||
Calendar,
|
||||
Clock,
|
||||
Grid,
|
||||
Trophy,
|
||||
User,
|
||||
Location,
|
||||
UserFilled,
|
||||
Setting,
|
||||
Menu,
|
||||
Search,
|
||||
Document,
|
||||
EditPen,
|
||||
Picture,
|
||||
DataAnalysis,
|
||||
} from '@element-plus/icons-vue';
|
||||
import { useTableColumnControl } from '/@/hooks/tableColumn';
|
||||
|
||||
// 定义变量内容
|
||||
const formDialogRef = ref()
|
||||
const searchFormRef = ref()
|
||||
const columnControlRef = ref()
|
||||
const showSearch = ref(true)
|
||||
const schoolYearList = ref<any[]>([])
|
||||
const schoolTermList = ref<any[]>([])
|
||||
const classList = ref<any[]>([])
|
||||
const formDialogRef = ref();
|
||||
const searchFormRef = ref();
|
||||
const columnControlRef = ref();
|
||||
const showSearch = ref(true);
|
||||
const schoolYearList = ref<any[]>([]);
|
||||
const schoolTermList = ref<any[]>([]);
|
||||
const classList = ref<any[]>([]);
|
||||
|
||||
// 统计相关变量
|
||||
const statisticsDialogVisible = ref(false)
|
||||
const statisticsLoading = ref(false)
|
||||
const statisticsData = ref<any[]>([])
|
||||
const statisticsDialogVisible = ref(false);
|
||||
const statisticsLoading = ref(false);
|
||||
const statisticsData = ref<any[]>([]);
|
||||
const statisticsQuery = reactive({
|
||||
schoolYear: '',
|
||||
schoolTerm: ''
|
||||
})
|
||||
schoolYear: '',
|
||||
schoolTerm: '',
|
||||
});
|
||||
|
||||
// 表格列配置
|
||||
const tableColumns = [
|
||||
{ prop: 'schoolYear', label: '学年', icon: Calendar },
|
||||
{ prop: 'schoolTerm', label: '学期', icon: Clock },
|
||||
{ prop: 'classNo', label: '班号', icon: Grid },
|
||||
{ prop: 'themeName', label: '活动主题', icon: Trophy, minWidth: 150 },
|
||||
{ prop: 'author', label: '主持人', icon: User },
|
||||
{ prop: 'activityTime', label: '活动时间', icon: Calendar, width: 120 },
|
||||
{ prop: 'address', label: '活动地点', icon: Location, minWidth: 150 },
|
||||
{ prop: 'attendNum', label: '参加人数', icon: UserFilled },
|
||||
{ prop: 'attachment', label: '活动图片', icon: Picture, width: 100 },
|
||||
{ prop: 'attachment2', label: '活动图片2', icon: Picture, width: 100 }
|
||||
]
|
||||
{ prop: 'schoolYear', label: '学年', icon: Calendar },
|
||||
{ prop: 'schoolTerm', label: '学期', icon: Clock },
|
||||
{ prop: 'classNo', label: '班号', icon: Grid },
|
||||
{ prop: 'themeName', label: '活动主题', icon: Trophy, minWidth: 150 },
|
||||
{ prop: 'author', label: '主持人', icon: User },
|
||||
{ prop: 'activityTime', label: '活动时间', icon: Calendar, width: 120 },
|
||||
{ prop: 'address', label: '活动地点', icon: Location, minWidth: 150 },
|
||||
{ prop: 'attendNum', label: '参加人数', icon: UserFilled },
|
||||
{ prop: 'attachment', label: '活动图片', icon: Picture, width: 100 },
|
||||
{ prop: 'attachment2', label: '活动图片2', icon: Picture, width: 100 },
|
||||
];
|
||||
|
||||
// 使用表格列控制 Hook
|
||||
const {
|
||||
visibleColumns,
|
||||
visibleColumnsSorted,
|
||||
checkColumnVisible,
|
||||
handleColumnChange,
|
||||
handleColumnOrderChange
|
||||
} = useTableColumnControl(tableColumns)
|
||||
const { visibleColumns, visibleColumnsSorted, checkColumnVisible, handleColumnChange, handleColumnOrderChange } = useTableColumnControl(tableColumns);
|
||||
|
||||
// 表格样式
|
||||
const tableStyle = {
|
||||
cellStyle: { padding: '8px 0' },
|
||||
headerCellStyle: { background: '#f5f7fa', color: '#606266', fontWeight: 'bold' }
|
||||
}
|
||||
cellStyle: { padding: '8px 0' },
|
||||
headerCellStyle: { background: '#f5f7fa', color: '#606266', fontWeight: 'bold' },
|
||||
};
|
||||
|
||||
// 配置 useTable
|
||||
const state: BasicTableProps = reactive<BasicTableProps>({
|
||||
queryForm: {
|
||||
schoolYear: '',
|
||||
schoolTerm: '',
|
||||
classCode: ''
|
||||
},
|
||||
pageList: fetchList,
|
||||
props: {
|
||||
item: 'records',
|
||||
totalCount: 'total'
|
||||
},
|
||||
createdIsNeed: true
|
||||
})
|
||||
queryForm: {
|
||||
schoolYear: '',
|
||||
schoolTerm: '',
|
||||
classCode: '',
|
||||
},
|
||||
pageList: fetchList,
|
||||
props: {
|
||||
item: 'records',
|
||||
totalCount: 'total',
|
||||
},
|
||||
createdIsNeed: true,
|
||||
});
|
||||
|
||||
// table hook
|
||||
const {
|
||||
getDataList,
|
||||
currentChangeHandle,
|
||||
sizeChangeHandle,
|
||||
tableStyle: _tableStyle
|
||||
} = useTable(state)
|
||||
const { getDataList, currentChangeHandle, sizeChangeHandle, tableStyle: _tableStyle } = useTable(state);
|
||||
|
||||
// 格式化学期
|
||||
const formatSchoolTerm = (value: string | number) => {
|
||||
if (value === null || value === undefined || value === '') {
|
||||
return '-'
|
||||
}
|
||||
const dictItem = schoolTermList.value.find(item => item.value == value)
|
||||
return dictItem ? dictItem.label : value
|
||||
}
|
||||
if (value === null || value === undefined || value === '') {
|
||||
return '-';
|
||||
}
|
||||
const dictItem = schoolTermList.value.find((item) => item.value == value);
|
||||
return dictItem ? dictItem.label : value;
|
||||
};
|
||||
|
||||
// 重置
|
||||
const handleReset = () => {
|
||||
searchFormRef.value?.resetFields()
|
||||
state.queryForm.schoolYear = ''
|
||||
state.queryForm.schoolTerm = ''
|
||||
state.queryForm.classCode = ''
|
||||
getDataList()
|
||||
}
|
||||
searchFormRef.value?.resetFields();
|
||||
state.queryForm.schoolYear = '';
|
||||
state.queryForm.schoolTerm = '';
|
||||
state.queryForm.classCode = '';
|
||||
getDataList();
|
||||
};
|
||||
|
||||
// 查看图片
|
||||
const handleViewImage = (url: string) => {
|
||||
if (url) {
|
||||
const urls = typeof url === 'string' ? url.split(',') : [url]
|
||||
urls.forEach((imgUrl: string) => {
|
||||
if (imgUrl.trim()) {
|
||||
window.open(imgUrl.trim(), '_blank')
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
if (url) {
|
||||
const urls = typeof url === 'string' ? url.split(',') : [url];
|
||||
urls.forEach((imgUrl: string) => {
|
||||
if (imgUrl.trim()) {
|
||||
window.open(imgUrl.trim(), '_blank');
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// 编辑
|
||||
const handleEdit = (row: any) => {
|
||||
formDialogRef.value?.openDialog('edit', row)
|
||||
}
|
||||
formDialogRef.value?.openDialog('edit', row);
|
||||
};
|
||||
|
||||
// 删除
|
||||
const handleDelete = async (row: any) => {
|
||||
const { confirm } = useMessageBox()
|
||||
try {
|
||||
await confirm('确定要删除该活动记录吗?')
|
||||
await delObj([row.id])
|
||||
useMessage().success('删除成功')
|
||||
getDataList()
|
||||
} catch (err: any) {
|
||||
if (err !== 'cancel') {
|
||||
useMessage().error(err.msg || '删除失败')
|
||||
}
|
||||
}
|
||||
}
|
||||
const { confirm } = useMessageBox();
|
||||
try {
|
||||
await confirm('确定要删除该活动记录吗?');
|
||||
await delObj([row.id]);
|
||||
useMessage().success('删除成功');
|
||||
getDataList();
|
||||
} catch (err: any) {
|
||||
if (err !== 'cancel') {
|
||||
useMessage().error(err.msg || '删除失败');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 获取学年列表
|
||||
const getSchoolYearList = async () => {
|
||||
try {
|
||||
const res = await queryAllSchoolYear()
|
||||
if (res.data && Array.isArray(res.data)) {
|
||||
schoolYearList.value = res.data
|
||||
} else {
|
||||
schoolYearList.value = []
|
||||
}
|
||||
} catch (err) {
|
||||
schoolYearList.value = []
|
||||
}
|
||||
}
|
||||
try {
|
||||
const res = await queryAllSchoolYear();
|
||||
if (res.data && Array.isArray(res.data)) {
|
||||
schoolYearList.value = res.data;
|
||||
} else {
|
||||
schoolYearList.value = [];
|
||||
}
|
||||
} catch (err) {
|
||||
schoolYearList.value = [];
|
||||
}
|
||||
};
|
||||
|
||||
// 获取学期字典
|
||||
const getSchoolTermDict = async () => {
|
||||
try {
|
||||
const res = await getDicts('school_term')
|
||||
if (res.data && Array.isArray(res.data)) {
|
||||
schoolTermList.value = res.data.map((item: any) => ({
|
||||
label: item.label || item.dictLabel || item.name,
|
||||
value: item.value || item.dictValue || item.code
|
||||
}))
|
||||
} else {
|
||||
schoolTermList.value = []
|
||||
}
|
||||
} catch (err) {
|
||||
schoolTermList.value = []
|
||||
}
|
||||
}
|
||||
try {
|
||||
const res = await getDicts('school_term');
|
||||
if (res.data && Array.isArray(res.data)) {
|
||||
schoolTermList.value = res.data.map((item: any) => ({
|
||||
label: item.label || item.dictLabel || item.name,
|
||||
value: item.value || item.dictValue || item.code,
|
||||
}));
|
||||
} else {
|
||||
schoolTermList.value = [];
|
||||
}
|
||||
} catch (err) {
|
||||
schoolTermList.value = [];
|
||||
}
|
||||
};
|
||||
|
||||
// 获取班级列表
|
||||
const getClassListData = async () => {
|
||||
try {
|
||||
const res = await getClassListByRole()
|
||||
if (res.data && Array.isArray(res.data)) {
|
||||
classList.value = res.data
|
||||
} else {
|
||||
classList.value = []
|
||||
}
|
||||
} catch (err) {
|
||||
classList.value = []
|
||||
}
|
||||
}
|
||||
try {
|
||||
const res = await getClassListByRole();
|
||||
if (res.data && Array.isArray(res.data)) {
|
||||
classList.value = res.data;
|
||||
} else {
|
||||
classList.value = [];
|
||||
}
|
||||
} catch (err) {
|
||||
classList.value = [];
|
||||
}
|
||||
};
|
||||
|
||||
// 打开统计对话框
|
||||
const handleStatistics = () => {
|
||||
// 使用当前搜索条件的学年和学期
|
||||
statisticsQuery.schoolYear = state.queryForm.schoolYear || ''
|
||||
statisticsQuery.schoolTerm = state.queryForm.schoolTerm || ''
|
||||
statisticsData.value = []
|
||||
statisticsDialogVisible.value = true
|
||||
}
|
||||
// 使用当前搜索条件的学年和学期
|
||||
statisticsQuery.schoolYear = state.queryForm.schoolYear || '';
|
||||
statisticsQuery.schoolTerm = state.queryForm.schoolTerm || '';
|
||||
statisticsData.value = [];
|
||||
statisticsDialogVisible.value = true;
|
||||
};
|
||||
|
||||
// 获取统计数据
|
||||
const getStatisticsData = async () => {
|
||||
// 必须选择学年或学期才能查询
|
||||
if (!statisticsQuery.schoolYear && !statisticsQuery.schoolTerm) {
|
||||
useMessage().warning('请选择学年或学期进行查询')
|
||||
return
|
||||
}
|
||||
statisticsLoading.value = true
|
||||
try {
|
||||
const res = await statisticsByYearTerm(
|
||||
statisticsQuery.schoolYear || undefined,
|
||||
statisticsQuery.schoolTerm || undefined
|
||||
)
|
||||
if (res.data && Array.isArray(res.data)) {
|
||||
statisticsData.value = res.data
|
||||
} else {
|
||||
statisticsData.value = []
|
||||
}
|
||||
} catch (err) {
|
||||
statisticsData.value = []
|
||||
} finally {
|
||||
statisticsLoading.value = false
|
||||
}
|
||||
}
|
||||
// 必须选择学年或学期才能查询
|
||||
if (!statisticsQuery.schoolYear && !statisticsQuery.schoolTerm) {
|
||||
useMessage().warning('请选择学年或学期进行查询');
|
||||
return;
|
||||
}
|
||||
statisticsLoading.value = true;
|
||||
try {
|
||||
const res = await statisticsByYearTerm(statisticsQuery.schoolYear || undefined, statisticsQuery.schoolTerm || undefined);
|
||||
if (res.data && Array.isArray(res.data)) {
|
||||
statisticsData.value = res.data;
|
||||
} else {
|
||||
statisticsData.value = [];
|
||||
}
|
||||
} catch (err) {
|
||||
statisticsData.value = [];
|
||||
} finally {
|
||||
statisticsLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 初始化
|
||||
onMounted(() => {
|
||||
getSchoolYearList()
|
||||
getSchoolTermDict()
|
||||
getClassListData()
|
||||
})
|
||||
getSchoolYearList();
|
||||
getSchoolTermDict();
|
||||
getClassListData();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
Reference in New Issue
Block a user