提交代码
This commit is contained in:
1 parent
25892480cc
commit
718ab4cb38
12 files changed
+1804
-309
No files matched your search
+1039
-269
File diff suppressed because it is too large.
Load diff
+94
-14
@@ -7,7 +7,7 @@
|
||||
<span class="student-name">{{ studentInfo?.studentName }}</span>
|
||||
<span class="student-detail">({{ studentInfo?.studentNo }})</span>
|
||||
<span class="student-detail">{{ studentInfo?.className }}</span>
|
||||
<span class="student-detail">{{ studentInfo?.bedName }}</span>
|
||||
<span class="student-detail">{{ studentInfo?.bedCode }}</span>
|
||||
</div>
|
||||
</el-form-item>
|
||||
|
||||
@@ -167,7 +167,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, computed, watch, onMounted } from 'vue';
|
||||
import { ref, reactive, computed, watch, onMounted, nextTick } from 'vue';
|
||||
import { ElMessage } from 'element-plus';
|
||||
import { Plus, InfoFilled, UploadFilled, Document, Loading, Download, Delete } from '@element-plus/icons-vue';
|
||||
// import ImagePreview from '@/components/ImagePreview/index.vue';
|
||||
@@ -367,7 +367,42 @@ const initForm = () => {
|
||||
|
||||
if (props.violationData) {
|
||||
console.log('违纪记录:编辑模式,violationData:', props.violationData);
|
||||
Object.assign(form, props.violationData);
|
||||
|
||||
// 处理违纪数据回显
|
||||
const violationDataCopy = { ...props.violationData };
|
||||
|
||||
// 确保disciplineTypeId是字符串类型(Element Plus select组件需要)
|
||||
if (violationDataCopy.disciplineTypeId !== null && violationDataCopy.disciplineTypeId !== undefined) {
|
||||
violationDataCopy.disciplineTypeId = violationDataCopy.disciplineTypeId.toString();
|
||||
}
|
||||
|
||||
// 确保scoreDeduction是数值类型
|
||||
if (violationDataCopy.scoreDeduction !== null && violationDataCopy.scoreDeduction !== undefined) {
|
||||
violationDataCopy.scoreDeduction = parseFloat(violationDataCopy.scoreDeduction) || 0;
|
||||
}
|
||||
|
||||
// 格式化日期(确保格式正确)
|
||||
if (violationDataCopy.disciplineDate) {
|
||||
// 如果是完整的日期时间,只取日期部分
|
||||
const dateStr = violationDataCopy.disciplineDate.toString();
|
||||
if (dateStr.includes(' ')) {
|
||||
violationDataCopy.disciplineDate = dateStr.split(' ')[0];
|
||||
} else if (dateStr.includes('T')) {
|
||||
violationDataCopy.disciplineDate = dateStr.split('T')[0];
|
||||
}
|
||||
}
|
||||
|
||||
Object.assign(form, violationDataCopy);
|
||||
|
||||
console.log('违纪记录:表单数据已更新:', form);
|
||||
|
||||
// 如果有违纪类型ID,触发违纪类型变化事件以设置扣分范围
|
||||
if (form.disciplineTypeId) {
|
||||
// 使用 nextTick 确保违纪类型列表已加载
|
||||
nextTick(() => {
|
||||
handleDisciplineTypeChange(form.disciplineTypeId);
|
||||
});
|
||||
}
|
||||
|
||||
// 如果是编辑模式,处理附件数据
|
||||
if (props.violationData.attachmentOssIds) {
|
||||
@@ -680,24 +715,56 @@ const handleConfirm = async () => {
|
||||
// 关闭弹窗
|
||||
const handleClose = () => {
|
||||
emit('close');
|
||||
resetForm();
|
||||
// 只重置违纪相关字段,保留学生基本信息
|
||||
Object.assign(form, {
|
||||
disciplineTypeId: '',
|
||||
disciplineTypeName: '',
|
||||
disciplineDate: new Date().toISOString().split('T')[0],
|
||||
disciplineReason: '',
|
||||
disciplineContent: '',
|
||||
scoreDeduction: 0,
|
||||
attachmentOssIds: ''
|
||||
});
|
||||
|
||||
attachmentList.value = [];
|
||||
currentTypeMinScore.value = 0;
|
||||
currentTypeMaxScore.value = 100;
|
||||
};
|
||||
|
||||
// 重置表单
|
||||
const resetForm = () => {
|
||||
// 保留学生基本信息(如果有的话)
|
||||
const preserveStudentInfo = props.studentInfo
|
||||
? {
|
||||
studentId: props.studentInfo.studentId || '',
|
||||
studentNo: props.studentInfo.studentNo || '',
|
||||
studentName: props.studentInfo.studentName || '',
|
||||
collegeId: props.studentInfo.collegeId || '',
|
||||
collegeName: props.studentInfo.collegeName || '',
|
||||
majorId: props.studentInfo.majorId || '',
|
||||
majorName: props.studentInfo.majorName || '',
|
||||
classId: props.studentInfo.classId || '',
|
||||
className: props.studentInfo.className || '',
|
||||
bedCode: props.studentInfo.bedCode || '' // 保留床位信息
|
||||
}
|
||||
: {
|
||||
studentId: '',
|
||||
studentNo: '',
|
||||
studentName: '',
|
||||
collegeId: '',
|
||||
collegeName: '',
|
||||
majorId: '',
|
||||
majorName: '',
|
||||
classId: '',
|
||||
className: '',
|
||||
bedCode: ''
|
||||
};
|
||||
|
||||
Object.assign(form, {
|
||||
studentId: '',
|
||||
studentNo: '',
|
||||
studentName: '',
|
||||
collegeId: '',
|
||||
collegeName: '',
|
||||
majorId: '',
|
||||
majorName: '',
|
||||
classId: '',
|
||||
className: '',
|
||||
...preserveStudentInfo,
|
||||
disciplineTypeId: '',
|
||||
disciplineTypeName: '',
|
||||
disciplineDate: '',
|
||||
disciplineDate: new Date().toISOString().split('T')[0], // 默认今天
|
||||
disciplineReason: '',
|
||||
disciplineContent: '',
|
||||
scoreDeduction: 0,
|
||||
@@ -730,6 +797,19 @@ watch(
|
||||
}
|
||||
);
|
||||
|
||||
// 监听违纪数据变化(新增)
|
||||
watch(
|
||||
() => props.violationData,
|
||||
(newViolationData) => {
|
||||
// 当违纪数据发生变化时,重新初始化表单
|
||||
if (newViolationData && props.modelValue) {
|
||||
console.log('违纪记录:监听到violationData变化,重新初始化表单:', newViolationData);
|
||||
initForm();
|
||||
}
|
||||
},
|
||||
{ immediate: true, deep: true }
|
||||
);
|
||||
|
||||
// 组件挂载
|
||||
onMounted(() => {
|
||||
getAllViolationTypes();
|
||||
|
||||
@@ -161,15 +161,14 @@
|
||||
@update:visible="(value) => (mainDialog.visible = value)"
|
||||
/>
|
||||
|
||||
<!-- 单个宿舍房间检查弹窗组件(修改使用) -->
|
||||
<DormHygieneCheckSingleDialog
|
||||
:visible="singleDialog.visible"
|
||||
:title="singleDialog.title"
|
||||
:room-info="currentEditData?.roomInfo"
|
||||
:check-info="currentEditData"
|
||||
@submit="handleSingleDialogSubmit"
|
||||
@close="handleSingleDialogClose"
|
||||
@update:visible="(value) => (singleDialog.visible = value)"
|
||||
<!-- 编辑宿舍卫生检查弹窗组件(修改使用) -->
|
||||
<DormHygieneCheckEditDialog
|
||||
:visible="editDialog.visible"
|
||||
:title="editDialog.title"
|
||||
:form-data="currentEditData"
|
||||
@submit="handleEditDialogSubmit"
|
||||
@close="handleEditDialogClose"
|
||||
@update:visible="(value) => (editDialog.visible = value)"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -179,6 +178,8 @@ import { ref, reactive, toRefs, onMounted, getCurrentInstance, ComponentInternal
|
||||
import ElMessage from 'element-plus/es/components/message/index';
|
||||
import ElMessageBox from 'element-plus/es/components/message-box/index';
|
||||
import ElLoading from 'element-plus/es/components/loading/index';
|
||||
// @ts-expect-error: request util import
|
||||
import request from '@/utils/request';
|
||||
import {
|
||||
listDormHygieneCheck,
|
||||
getDormHygieneCheck,
|
||||
@@ -194,7 +195,7 @@ import {
|
||||
DormHygieneCheckCompleteForm
|
||||
} from '@/api/xg/xgss/dormHygieneCheck/dormHygieneCheck/types';
|
||||
import DormHygieneCheckMainDialog from './DormHygieneCheckMainDialog.vue';
|
||||
import DormHygieneCheckSingleDialog from './DormHygieneCheckSingleDialog.vue';
|
||||
import DormHygieneCheckEditDialog from './DormHygieneCheckEditDialog.vue';
|
||||
|
||||
// 类型定义
|
||||
interface DialogOption {
|
||||
@@ -229,8 +230,8 @@ const mainDialog = reactive<DialogOption>({
|
||||
title: ''
|
||||
});
|
||||
|
||||
// 单个房间检查弹窗(修改)
|
||||
const singleDialog = reactive<DialogOption>({
|
||||
// 编辑宿舍卫生检查弹窗(修改)
|
||||
const editDialog = reactive<DialogOption>({
|
||||
visible: false,
|
||||
title: ''
|
||||
});
|
||||
@@ -326,9 +327,9 @@ const handleMainDialogClose = () => {
|
||||
reset();
|
||||
};
|
||||
|
||||
/** 单个房间检查弹窗关闭事件处理 */
|
||||
const handleSingleDialogClose = () => {
|
||||
singleDialog.visible = false;
|
||||
/** 编辑弹窗关闭事件处理 */
|
||||
const handleEditDialogClose = () => {
|
||||
editDialog.visible = false;
|
||||
currentEditData.value = null;
|
||||
};
|
||||
|
||||
@@ -346,13 +347,17 @@ const handleMainDialogSubmit = async (formData: any) => {
|
||||
}
|
||||
};
|
||||
|
||||
/** 单个房间检查弹窗提交事件处理 */
|
||||
const handleSingleDialogSubmit = async (formData: any) => {
|
||||
/** 编辑弹窗提交事件处理 */
|
||||
const handleEditDialogSubmit = async (formData: any) => {
|
||||
try {
|
||||
// 单个房间检查弹窗提交的是修改数据
|
||||
await updateDormHygieneCheck(formData);
|
||||
// 编辑弹窗提交的是修改数据,调用完整更新接口
|
||||
await request({
|
||||
url: '/dormHygieneCheck/dormHygieneCheck/updateCompleteData',
|
||||
method: 'put',
|
||||
data: formData
|
||||
});
|
||||
ElMessage.success('操作成功');
|
||||
singleDialog.visible = false;
|
||||
editDialog.visible = false;
|
||||
await getList();
|
||||
} catch (error) {
|
||||
console.error('提交失败:', error);
|
||||
@@ -400,8 +405,8 @@ const handleAdd = () => {
|
||||
|
||||
/** 修改按钮操作 */
|
||||
const handleUpdate = async (row?: DormHygieneCheckVO) => {
|
||||
singleDialog.visible = true;
|
||||
singleDialog.title = '修改宿舍卫生检查';
|
||||
editDialog.visible = true;
|
||||
editDialog.title = '修改宿舍卫生检查';
|
||||
|
||||
const loadingInstance = ElLoading.service({
|
||||
target: '.el-dialog__body',
|
||||
@@ -416,7 +421,7 @@ const handleUpdate = async (row?: DormHygieneCheckVO) => {
|
||||
} catch (error) {
|
||||
console.error('加载编辑数据失败:', error);
|
||||
ElMessage.error('加载数据失败,请重试');
|
||||
singleDialog.visible = false;
|
||||
editDialog.visible = false;
|
||||
} finally {
|
||||
loadingInstance.close();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user