代码格式修改
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form v-show="showSearch" ref="queryForm" :model="queryParams" size="small" :inline="true" label-width="68px">
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
@@ -50,7 +50,7 @@
|
||||
>
|
||||
<!-- 引入诊断报告明细组件 -->
|
||||
<DiagnosticDetails
|
||||
:reportData="currentReport"
|
||||
:report-data="currentReport"
|
||||
@submission-success="handleSubmissionSuccess"
|
||||
/>
|
||||
</el-dialog>
|
||||
@@ -66,13 +66,13 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listSubmissions } from "@/api/diagnostic/submissions";
|
||||
import { getInfoId } from "@/api/diagnostic/info";
|
||||
import { getTerm } from "@/api/diagnostic/DiaReportRelease";
|
||||
import DiagnosticDetails from "@/views/diagnostic/details/index";
|
||||
import { listSubmissions } from '@/api/diagnostic/submissions'
|
||||
import { getInfoId } from '@/api/diagnostic/info'
|
||||
import { getTerm } from '@/api/diagnostic/DiaReportRelease'
|
||||
import DiagnosticDetails from '@/views/diagnostic/details/index'
|
||||
|
||||
export default {
|
||||
name: "Submissions",
|
||||
name: 'Submissions',
|
||||
components: {
|
||||
DiagnosticDetails
|
||||
},
|
||||
@@ -95,125 +95,125 @@ export default {
|
||||
dialogVisible: false,
|
||||
currentReport: {},
|
||||
formData: {
|
||||
content: "",
|
||||
content: '',
|
||||
},
|
||||
};
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
this.getTermOptions();
|
||||
this.getList()
|
||||
this.getTermOptions()
|
||||
},
|
||||
methods: {
|
||||
/** 查询学生报提交记录列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
this.loading = true
|
||||
listSubmissions(this.queryParams).then(response => {
|
||||
this.submissionsList = response.rows;
|
||||
this.loadSubmittedStatus(); // 加载本地保存的提交状态
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
this.submissionsList = response.rows
|
||||
this.loadSubmittedStatus() // 加载本地保存的提交状态
|
||||
this.total = response.total
|
||||
this.loading = false
|
||||
}).catch(error => {
|
||||
console.error('获取提交记录失败', error);
|
||||
this.loading = false;
|
||||
this.$message.error("获取提交记录失败");
|
||||
});
|
||||
console.error('获取提交记录失败', error)
|
||||
this.loading = false
|
||||
this.$message.error('获取提交记录失败')
|
||||
})
|
||||
},
|
||||
|
||||
/** 处理分页事件 */
|
||||
handlePagination(pagination) {
|
||||
this.queryParams.pageNum = pagination.page;
|
||||
this.queryParams.pageSize = pagination.limit;
|
||||
this.getList();
|
||||
this.queryParams.pageNum = pagination.page
|
||||
this.queryParams.pageSize = pagination.limit
|
||||
this.getList()
|
||||
},
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
this.queryParams.pageNum = 1
|
||||
this.getList()
|
||||
},
|
||||
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
this.resetForm('queryForm')
|
||||
this.handleQuery()
|
||||
},
|
||||
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.id);
|
||||
this.single = selection.length !== 1;
|
||||
this.multiple = !selection.length;
|
||||
this.ids = selection.map(item => item.id)
|
||||
this.single = selection.length !== 1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
|
||||
/** 获取学期选项数据 */
|
||||
getTermOptions() {
|
||||
getTerm().then(response => {
|
||||
this.yearOptions = response.data;
|
||||
this.yearOptions = response.data
|
||||
}).catch(error => {
|
||||
console.error('获取学期选项失败', error);
|
||||
this.$message.error("获取学期数据失败");
|
||||
});
|
||||
console.error('获取学期选项失败', error)
|
||||
this.$message.error('获取学期数据失败')
|
||||
})
|
||||
},
|
||||
|
||||
/** 填写报表按钮操作 */
|
||||
handleFillReport(row) {
|
||||
this.currentReport = row; // 存储当前报表数据
|
||||
this.currentReport = row // 存储当前报表数据
|
||||
// 调用getInfoId方法
|
||||
getInfoId(row.relId).then(response => {
|
||||
console.log(response)
|
||||
}).catch(error => {
|
||||
console.error('获取信息ID失败', error);
|
||||
this.$message.error("获取信息ID失败");
|
||||
});
|
||||
this.dialogVisible = true; // 打开全屏弹窗
|
||||
console.error('获取信息ID失败', error)
|
||||
this.$message.error('获取信息ID失败')
|
||||
})
|
||||
this.dialogVisible = true // 打开全屏弹窗
|
||||
},
|
||||
|
||||
/** 提交表单 */
|
||||
submitForm() {
|
||||
this.$message.success("提交成功!");
|
||||
this.dialogVisible = false;
|
||||
this.$message.success('提交成功!')
|
||||
this.dialogVisible = false
|
||||
},
|
||||
|
||||
/** 关闭弹窗时重置表单 */
|
||||
handleDialogClose() {
|
||||
this.formData.content = ""; // 清空表单
|
||||
this.formData.content = '' // 清空表单
|
||||
},
|
||||
|
||||
// ====================== 新增状态管理逻辑 ======================
|
||||
/** 处理子组件提交成功事件 */
|
||||
handleSubmissionSuccess(reportId) {
|
||||
// 更新内存中的状态
|
||||
const index = this.submissionsList.findIndex(item => item.id === reportId);
|
||||
const index = this.submissionsList.findIndex(item => item.id === reportId)
|
||||
if (index !== -1) {
|
||||
this.$set(this.submissionsList[index], 'status', '2'); // 状态码'2'表示已填写
|
||||
this.saveSubmittedStatus(reportId); // 保存到localStorage
|
||||
this.$message.success('状态已更新为"已填写"');
|
||||
this.$set(this.submissionsList[index], 'status', '2') // 状态码'2'表示已填写
|
||||
this.saveSubmittedStatus(reportId) // 保存到localStorage
|
||||
this.$message.success('状态已更新为"已填写"')
|
||||
}
|
||||
},
|
||||
|
||||
/** 保存提交状态到localStorage */
|
||||
saveSubmittedStatus(reportId) {
|
||||
try {
|
||||
const submittedReports = JSON.parse(localStorage.getItem('submittedReports')) || {};
|
||||
submittedReports[reportId] = true;
|
||||
localStorage.setItem('submittedReports', JSON.stringify(submittedReports));
|
||||
const submittedReports = JSON.parse(localStorage.getItem('submittedReports')) || {}
|
||||
submittedReports[reportId] = true
|
||||
localStorage.setItem('submittedReports', JSON.stringify(submittedReports))
|
||||
} catch (error) {
|
||||
console.error('保存提交状态失败:', error);
|
||||
console.error('保存提交状态失败:', error)
|
||||
}
|
||||
},
|
||||
|
||||
/** 从localStorage加载提交状态 */
|
||||
loadSubmittedStatus() {
|
||||
try {
|
||||
const submittedReports = JSON.parse(localStorage.getItem('submittedReports')) || {};
|
||||
const submittedReports = JSON.parse(localStorage.getItem('submittedReports')) || {}
|
||||
this.submissionsList = this.submissionsList.map(item => {
|
||||
return {
|
||||
...item,
|
||||
status: submittedReports[item.id] ? '2' : item.status // 若已提交,设置状态为'2'
|
||||
};
|
||||
});
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('加载提交状态失败:', error);
|
||||
console.error('加载提交状态失败:', error)
|
||||
}
|
||||
},
|
||||
|
||||
@@ -224,8 +224,8 @@ export default {
|
||||
'0': '填写中',
|
||||
'1': '停用',
|
||||
'2': '已填写'
|
||||
};
|
||||
return statusMap[status] || '未知状态';
|
||||
}
|
||||
return statusMap[status] || '未知状态'
|
||||
},
|
||||
|
||||
/** 获取状态标签类型 */
|
||||
@@ -234,16 +234,16 @@ export default {
|
||||
'0': 'success', // 填写中:绿色
|
||||
'1': 'danger', // 停用:红色
|
||||
'2': 'primary' // 已填写:蓝色
|
||||
};
|
||||
return typeMap[status] || 'info';
|
||||
}
|
||||
return typeMap[status] || 'info'
|
||||
},
|
||||
|
||||
/** 获取状态标签效果 */
|
||||
getStatusEffect(status) {
|
||||
return status === '2' ? 'light' : 'dark'; // 已填写使用浅色标签
|
||||
return status === '2' ? 'light' : 'dark' // 已填写使用浅色标签
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
Reference in New Issue
Block a user