diff --git a/src/views/toschoolinfomanage/addModal.vue b/src/views/toschoolinfomanage/addModal.vue index ef9f9c7..421c2a3 100644 --- a/src/views/toschoolinfomanage/addModal.vue +++ b/src/views/toschoolinfomanage/addModal.vue @@ -2,7 +2,7 @@ + 当前状态: @@ -14,102 +15,222 @@ 取消 - 保存 + 保存 + + - + + + {{ safeDetail.schoolName || safeDetail.school || "-" }} + + + {{ safeDetail.grade || safeDetail.gradeLevel || "-" }} + + + {{ + Array.isArray(safeDetail.schoolBusinessUser) + ? safeDetail.schoolBusinessUser.join(",") + : safeDetail.schoolBusinessUser || "-" + }} + + + {{ safeDetail.startTime?.split("T")[0] }} + + - - - {{ safeDetail.schoolName || safeDetail.school || "-" }} - - - {{ safeDetail.grade || safeDetail.gradeLevel || "-" }} - - - {{ - Array.isArray(safeDetail.schoolBusinessUser) - ? safeDetail.schoolBusinessUser.join(",") - : safeDetail.schoolBusinessUser || "-" - }} - - - {{ safeDetail.startTime?.split("T")[0] }} - - + - - - - - + + + {{ safeDetail.isDiscussion ? "已开展" : "未开展" }} + + {{ safeDetail.discussion || "-" }} + + + + {{ safeDetail.isClassMeeting ? "已开展" : "未开展" }} + + {{ safeDetail.classMeeting || "-" }} + + + + + + 问题总数:{{ safeDetail.feedbackQuestions?.length }} + 未解决问题:{{ unresolvedCount }} + + + - {{ safeDetail.isDiscussion ? "已开展" : "未开展" }} - - {{ safeDetail.discussion || "-" }} - - - - {{ safeDetail.isClassMeeting ? "已开展" : "未开展" }} - - {{ safeDetail.classMeeting || "-" }} - - - - - - 问题总数:{{ safeDetail.feedbackQuestions?.length }} - - 未解决问题:{{ handleUnHandleQust(safeDetail.feedbackQuestions) }} - - - - - - 问题类型: {{ queType[i.questionType] }} - - - {{ i.question }} - - - 解决情况 - - 解决情况描述111111111111111 + + 问题类型: {{ queType[i.questionType] }} - - + {{ i.question }} + + + 解决时间:{{ i.endTime.split("T")[0] }} + + {{ i.solution }} + + + + 标记已解决 + + + + + + + + + + + + + + 需求+解决方案 + + + + + - 标记已解决 - - - - + 添加执行记录 + + + {{ finishRecord ? "修改完结情况" : "添加完结情况" }} + + - - - - + + + + + + 执行记录{{ index + 1 }}:{{ record.time.split("T")[0] }} + + + {{ record.content }} + + + + + + + + + + 完结情况:{{ finishRecord.time.split("T")[0] }} + + + {{ finishRecord.content }} + + + + + + + + + + + + + + + + + + + + 取消 + 确认 + + @@ -124,16 +245,91 @@ import { } from "@/api/toschoolinfomanage"; import { setFips } from "crypto"; -const activeName = ref(0); +const activeName = ref(0); const handleClick = (tab: TabsPaneContext, event: Event) => { - console.log(tab, event); + console.log(tab.props.name, event); + activeName.value = tab.props.name; }; -const props = defineProps<{ visible: boolean; detailData: any }>(); +const props = defineProps<{ + visible: boolean; + detailData: any; + editModalLoading: boolean; + isDetail: boolean; +}>(); const emit = defineEmits<{ (e: "update:visible", value: boolean): void; + (e: "handleReset"): void; }>(); +// 操作弹窗相关数据 +const operationDialogVisible = ref(false); +const operationType = ref(""); // 操作类型:markSolved, addRecord, addFinish +const operationForm = reactive({ + operationTime: "", + operationContent: "" +}); +const operationFormRef = ref(); + +// 执行记录和完结情况数据 +const executionRecords = ref>([]); +const finishRecord = ref<{ time: string; content: string } | null>(null); + +// 从父级 detailData.solutionRecord 回显本地显示数据 +watch( + () => props.detailData, + val => { + const sr = (val as any)?.solutionRecord || {}; + // 执行记录回显 + const recs = Array.isArray(sr?.record) ? sr.record : []; + executionRecords.value = recs.map((r: any) => ({ + time: r?.executionTime || "", + content: r?.executionRecords || "" + })); + // 完结情况回显 + if (sr?.endRecordTime || sr?.endRecord) { + finishRecord.value = { + time: sr?.endRecordTime || "", + content: sr?.endRecord || "" + }; + } else { + finishRecord.value = null; + } + }, + { immediate: true, deep: true } +); + +// 当前标记“已解决”的问题项 +const currentMarkedQuestion = ref(null); + +// 根据操作类型动态显示文案 +const operationContentLabel = computed(() => { + switch (operationType.value) { + case "markSolved": + return "解决情况"; + case "addRecord": + return "执行记录"; + case "addFinish": + return "完结情况"; + default: + return "操作内容"; + } +}); + +// 表单验证规则 +const operationRules: FormRules = { + operationTime: [ + { required: true, message: "请选择操作时间", trigger: "change" } + ], + operationContent: [ + { + required: true, + message: `请输入${operationContentLabel.value}`, + trigger: "blur" + } + ] +}; + const dialogVisible = computed({ get: () => props.visible, set: v => emit("update:visible", v) @@ -141,6 +337,7 @@ const dialogVisible = computed({ const closeModal = () => { emit("update:visible", false); + activeName.value = 0; }; const queType = { 1: "学校领导班子", @@ -154,10 +351,7 @@ const queType = { * @param data */ const handleUnHandleQust = (data: Array) => { - return (data || []).map(i => { - // 利用solution为空判断为未解决问题 - return !i.solution; - }).length; + return (data || []).filter(i => !i?.solution).length; }; const sortData = (data: Array) => { const categorizedData = [ @@ -186,14 +380,157 @@ const statusText = computed(() => const statusType = computed(() => safeDetail.value?.solutionEnd ? "success" : "warning" ); -const markTitle = () => { - console.log("标记已解决"); +const solutionText = computed({ + get: () => safeDetail.value?.solutionRecord?.solution || "", + set: (value: string) => { + if (!safeDetail.value.solutionRecord) { + safeDetail.value.solutionRecord = {}; + } + safeDetail.value.solutionRecord.solution = value; + } +}); + +// 未解决问题数量(依赖每个问题项的 solution 字段,确保标记已解决后自动更新) +const unresolvedCount = computed(() => { + const list = (safeDetail.value?.feedbackQuestions as any[]) || []; + return list.filter(item => !item?.solution).length; +}); +const markTitle = (data: any) => { + console.log("标记已解决", data); + operationType.value = "markSolved"; + currentMarkedQuestion.value = data; + // 预填已有值 + operationForm.operationTime = data?.endTime || ""; + operationForm.operationContent = data?.solution || ""; + operationFormRef.value?.clearValidate(); + operationDialogVisible.value = true; +}; +const addRecord = () => { + console.log("添加执行记录"); + operationType.value = "addRecord"; + operationDialogVisible.value = true; +}; +const addFinish = () => { + console.log("添加完结情况"); + operationType.value = "addFinish"; + const sr = (props.detailData as any)?.solutionRecord; + // 优先从父级已有完结情况预填,其次使用本地 finishRecord + if (sr && (sr.endRecordTime || sr.endRecord)) { + operationForm.operationTime = sr.endRecordTime || ""; + operationForm.operationContent = sr.endRecord || ""; + } else if (finishRecord.value) { + operationForm.operationTime = finishRecord.value.time; + operationForm.operationContent = finishRecord.value.content; + } else { + // 重置表单 + operationForm.operationTime = ""; + operationForm.operationContent = ""; + } + operationDialogVisible.value = true; +}; + +// 操作弹窗相关方法 +const closeOperationDialog = () => { + operationDialogVisible.value = false; + // 重置表单 + operationForm.operationTime = ""; + operationForm.operationContent = ""; + // 清除表单验证状态 + operationFormRef.value?.clearValidate(); + // 重置当前标记项 + currentMarkedQuestion.value = null; +}; + +const confirmOperation = async () => { + if (!operationFormRef.value) return; + + try { + await operationFormRef.value.validate(); + + const { operationTime, operationContent } = operationForm; + + // 根据操作类型处理数据 + switch (operationType.value) { + case "addRecord": + // 添加执行记录 + executionRecords.value.push({ + time: operationTime, + content: operationContent + }); + // 同步到父数据 solutionRecord.record + if (!props.detailData.solutionRecord) + props.detailData.solutionRecord = {} as any; + if (!Array.isArray(props.detailData.solutionRecord.record)) + props.detailData.solutionRecord.record = []; + props.detailData.solutionRecord.record.push({ + executionTime: operationTime, + executionRecords: operationContent + }); + break; + case "addFinish": + // 添加或修改完结情况 + finishRecord.value = { + time: operationTime, + content: operationContent + }; + // 同步到父数据 solutionRecord.endRecordTime / endRecord + if (!props.detailData.solutionRecord) + props.detailData.solutionRecord = {} as any; + props.detailData.solutionRecord.endRecordTime = operationTime; + props.detailData.solutionRecord.endRecord = operationContent; + break; + case "markSolved": + // 将提交的数据写回当前问题项 + if (currentMarkedQuestion.value) { + currentMarkedQuestion.value.endTime = operationTime; + currentMarkedQuestion.value.solution = operationContent; + } + break; + } + + console.log("确认操作", { + type: operationType.value, + time: operationTime, + content: operationContent + }); + closeOperationDialog(); + } catch (error) { + console.log("表单验证失败", error); + } }; function onClickCancel() { console.log("取消"); + emit("update:visible", false); + // 清空本地临时数据 + executionRecords.value = []; + finishRecord.value = null; + currentMarkedQuestion.value = null; + operationForm.operationTime = ""; + operationForm.operationContent = ""; + activeName.value = 0; + operationFormRef.value?.clearValidate(); } function onClickSave() { - console.log("保存"); + console.log("保存", props.detailData); + let copyParams = JSON.parse(JSON.stringify(props.detailData)); + delete copyParams.solutionEnd; + addOrEditApi(copyParams).then(res => { + if (res.code === 200) { + ElMessage.success("提交成功"); + // 关闭弹窗 + emit("update:visible", false); + // 清空本地临时数据 + executionRecords.value = []; + finishRecord.value = null; + currentMarkedQuestion.value = null; + operationForm.operationTime = ""; + operationForm.operationContent = ""; + activeName.value = 0; + operationFormRef.value?.clearValidate(); + // 通知父级刷新列表(复用父级的handleReset实现刷新) + emit("handleReset"); + } + }); } @@ -202,6 +539,9 @@ function onClickSave() { display: flex; align-items: center; justify-content: space-between; + padding-bottom: 10px; + border-bottom: 1px solid #ccc; + margin-bottom: 10px; } .status-box { display: flex; diff --git a/src/views/toschoolinfomanage/index.vue b/src/views/toschoolinfomanage/index.vue index 5b8873e..ec32409 100644 --- a/src/views/toschoolinfomanage/index.vue +++ b/src/views/toschoolinfomanage/index.vue @@ -38,7 +38,6 @@ v-model="query.people" placeholder="请选择赴校人员" clearable - multiple filterable style="width: 300px" > @@ -125,7 +124,11 @@ - 详情 跟进 @@ -157,7 +160,13 @@ - +