代码格式修改
This commit is contained in:
@@ -62,16 +62,16 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { filloutreportlistinfo } from "@/api/diagnostic/DiaFillOutReport";
|
||||
import { Message } from "element-ui";
|
||||
import { filloutreportlistinfo } from '@/api/diagnostic/DiaFillOutReport'
|
||||
import { Message } from 'element-ui'
|
||||
|
||||
export default {
|
||||
name: "Details",
|
||||
name: 'Details',
|
||||
props: {
|
||||
// 接收父组件传递的stuNo
|
||||
stuNo: {
|
||||
type: String,
|
||||
default: ""
|
||||
default: ''
|
||||
},
|
||||
// 接收父组件传递的rowData
|
||||
rowData: {
|
||||
@@ -90,80 +90,80 @@ export default {
|
||||
stuNo: null // 用于存储学号
|
||||
},
|
||||
// 头部信息
|
||||
reportName: "未命名报表",
|
||||
studentName: "-", // 姓名
|
||||
deptName: "-", // 班级
|
||||
reportName: '未命名报表',
|
||||
studentName: '-', // 姓名
|
||||
deptName: '-', // 班级
|
||||
// 表单数据
|
||||
detailFormData: { detailsList: [] }
|
||||
};
|
||||
},
|
||||
created() {
|
||||
// 初始化时获取数据
|
||||
this.queryParams.reportId = this.$route.params.reportId || "1";
|
||||
this.queryParams.stuNo = this.stuNo; // 设置学号参数
|
||||
this.getList();
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
// 监听stuNo变化,重新获取数据
|
||||
stuNo(newVal) {
|
||||
if (newVal) {
|
||||
this.queryParams.stuNo = newVal;
|
||||
this.getList();
|
||||
this.queryParams.stuNo = newVal
|
||||
this.getList()
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
// 初始化时获取数据
|
||||
this.queryParams.reportId = this.$route.params.reportId || '1'
|
||||
this.queryParams.stuNo = this.stuNo // 设置学号参数
|
||||
this.getList()
|
||||
},
|
||||
methods: {
|
||||
headerCellClassName({ column }) {
|
||||
if (column.label === '广西水利电力职业技术学院') {
|
||||
return 'school-header';
|
||||
return 'school-header'
|
||||
} else if (column.label === this.reportName) {
|
||||
return 'report-header';
|
||||
return 'report-header'
|
||||
} else if (column.label.includes('学号:')) {
|
||||
return 'student-header';
|
||||
return 'student-header'
|
||||
}
|
||||
return '';
|
||||
return ''
|
||||
},
|
||||
|
||||
// 计算合并规则的方法 - 保持原始顺序
|
||||
getSpanArr(data) {
|
||||
this.spanArr = [];
|
||||
this.qcSpanArr = [];
|
||||
this.spanArr = []
|
||||
this.qcSpanArr = []
|
||||
|
||||
// 记录上一行的维度和质控点
|
||||
let prevDimension = null;
|
||||
let prevQcPoint = null;
|
||||
let prevDimension = null
|
||||
let prevQcPoint = null
|
||||
|
||||
// 记录当前维度和质控点的合并行数
|
||||
let currentDimensionRowspan = 0;
|
||||
let currentQcRowspan = 0;
|
||||
let currentDimensionRowspan = 0
|
||||
let currentQcRowspan = 0
|
||||
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
const current = data[i];
|
||||
const current = data[i]
|
||||
|
||||
// 处理维度名称列的合并
|
||||
if (prevDimension === null || prevDimension !== current.dimensionName) {
|
||||
// 新维度,开始新的合并组
|
||||
this.spanArr.push(1);
|
||||
currentDimensionRowspan = 1;
|
||||
prevDimension = current.dimensionName;
|
||||
this.spanArr.push(1)
|
||||
currentDimensionRowspan = 1
|
||||
prevDimension = current.dimensionName
|
||||
} else {
|
||||
// 延续当前维度的合并组
|
||||
this.spanArr[i - currentDimensionRowspan] += 1;
|
||||
this.spanArr.push(0);
|
||||
currentDimensionRowspan += 1;
|
||||
this.spanArr[i - currentDimensionRowspan] += 1
|
||||
this.spanArr.push(0)
|
||||
currentDimensionRowspan += 1
|
||||
}
|
||||
|
||||
// 处理质控点名称列的合并
|
||||
if (prevDimension !== current.dimensionName || prevQcPoint !== current.qualityControlPointName) {
|
||||
// 新维度或新质控点,开始新的合并组
|
||||
this.qcSpanArr.push(1);
|
||||
currentQcRowspan = 1;
|
||||
prevQcPoint = current.qualityControlPointName;
|
||||
this.qcSpanArr.push(1)
|
||||
currentQcRowspan = 1
|
||||
prevQcPoint = current.qualityControlPointName
|
||||
} else {
|
||||
// 延续当前质控点的合并组
|
||||
this.qcSpanArr[i - currentQcRowspan] += 1;
|
||||
this.qcSpanArr.push(0);
|
||||
currentQcRowspan += 1;
|
||||
this.qcSpanArr[i - currentQcRowspan] += 1
|
||||
this.qcSpanArr.push(0)
|
||||
currentQcRowspan += 1
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -171,41 +171,41 @@ export default {
|
||||
// 合并单元格的方法
|
||||
objectSpanMethod({ row, column, rowIndex, columnIndex }) {
|
||||
if (columnIndex === 0) { // 维度名称列
|
||||
const _row = this.spanArr[rowIndex];
|
||||
const _col = _row > 0 ? 1 : 0;
|
||||
const _row = this.spanArr[rowIndex]
|
||||
const _col = _row > 0 ? 1 : 0
|
||||
return {
|
||||
rowspan: _row,
|
||||
colspan: _col
|
||||
};
|
||||
}
|
||||
} else if (columnIndex === 1) { // 质控点名称列
|
||||
const _row = this.qcSpanArr[rowIndex];
|
||||
const _col = _row > 0 ? 1 : 0;
|
||||
const _row = this.qcSpanArr[rowIndex]
|
||||
const _col = _row > 0 ? 1 : 0
|
||||
return {
|
||||
rowspan: _row,
|
||||
colspan: _col
|
||||
};
|
||||
}
|
||||
}
|
||||
// 其他列不合并
|
||||
return { rowspan: 1, colspan: 1 };
|
||||
return { rowspan: 1, colspan: 1 }
|
||||
},
|
||||
|
||||
async getList() {
|
||||
try {
|
||||
this.loading = true;
|
||||
this.loading = true
|
||||
// 构建包含reportId和stuNo的查询参数
|
||||
const params = {
|
||||
reportId: this.queryParams.reportId,
|
||||
stuNo: this.queryParams.stuNo
|
||||
};
|
||||
const response = await filloutreportlistinfo(params);
|
||||
}
|
||||
const response = await filloutreportlistinfo(params)
|
||||
|
||||
// 提取头部信息
|
||||
if (response.rows.length > 0) {
|
||||
const firstRecord = response.rows[0];
|
||||
this.reportName = firstRecord.reportName || "未命名报表";
|
||||
this.stuNo = firstRecord.stuNo || "-";
|
||||
this.studentName = firstRecord.studentName || "-";
|
||||
this.deptName = firstRecord.deptName || "-";
|
||||
const firstRecord = response.rows[0]
|
||||
this.reportName = firstRecord.reportName || '未命名报表'
|
||||
this.stuNo = firstRecord.stuNo || '-'
|
||||
this.studentName = firstRecord.studentName || '-'
|
||||
this.deptName = firstRecord.deptName || '-'
|
||||
}
|
||||
|
||||
// 处理表格数据
|
||||
@@ -217,25 +217,25 @@ export default {
|
||||
schoolQualifiedStandard: item.schoolQualifiedStandard,
|
||||
secondaryCollegeStandard: item.secondaryCollegeStandard,
|
||||
personalTargetStandard: item.personalTargetStandard,
|
||||
completionStatus: item.completionStatus || "",
|
||||
reasonForIncompletion: item.reasonForIncompletion || "",
|
||||
improvementActions: item.improvementActions || ""
|
||||
}));
|
||||
completionStatus: item.completionStatus || '',
|
||||
reasonForIncompletion: item.reasonForIncompletion || '',
|
||||
improvementActions: item.improvementActions || ''
|
||||
}))
|
||||
|
||||
this.detailFormData.detailsList = [...this.detailsList];
|
||||
this.detailFormData.detailsList = [...this.detailsList]
|
||||
|
||||
// 计算合并规则(保持原始顺序)
|
||||
this.getSpanArr(this.detailsList);
|
||||
this.getSpanArr(this.detailsList)
|
||||
} catch (error) {
|
||||
console.error("数据获取失败:", error);
|
||||
Message.error("数据获取失败: " + error.message);
|
||||
this.detailsList = [];
|
||||
console.error('数据获取失败:', error)
|
||||
Message.error('数据获取失败: ' + error.message)
|
||||
this.detailsList = []
|
||||
} finally {
|
||||
this.loading = false;
|
||||
this.loading = false
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
Reference in New Issue
Block a user