|
@@ -28,14 +28,14 @@
|
|
|
>
|
|
|
<el-table-column
|
|
|
v-for="subr in column.subRequirements"
|
|
|
- :key="subr"
|
|
|
- :label="subr === 'null' ? '' : subr"
|
|
|
+ :key="subr.name"
|
|
|
+ :label="subr.name === 'null' ? '' : subr.name"
|
|
|
align="center"
|
|
|
>
|
|
|
<template slot-scope="scope">
|
|
|
<el-input-number
|
|
|
v-if="scope.row.canEdit"
|
|
|
- v-model="scope.row[`${column.name}_${subr}`].value"
|
|
|
+ v-model="scope.row[`${column.name}_${subr.name}`].value"
|
|
|
class="width-50"
|
|
|
:min="0"
|
|
|
:max="1"
|
|
@@ -43,11 +43,16 @@
|
|
|
step-strictly
|
|
|
:controls="false"
|
|
|
@change="
|
|
|
- () => unitChange(scope.row, `${column.name}_${subr}`)
|
|
|
+ () =>
|
|
|
+ unitChange(
|
|
|
+ scope.row,
|
|
|
+ `${column.name}_${subr.name}`,
|
|
|
+ subr.columnIndex
|
|
|
+ )
|
|
|
"
|
|
|
></el-input-number>
|
|
|
<span v-else>{{
|
|
|
- scope.row[`${column.name}_${subr}`].value
|
|
|
+ scope.row[`${column.name}_${subr.name}`].value
|
|
|
}}</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
@@ -71,7 +76,14 @@
|
|
|
:step="0.01"
|
|
|
step-strictly
|
|
|
:controls="false"
|
|
|
- @change="() => unitChange(scope.row, `${column.name}_null`)"
|
|
|
+ @change="
|
|
|
+ () =>
|
|
|
+ unitChange(
|
|
|
+ scope.row,
|
|
|
+ `${column.name}_null`,
|
|
|
+ column.columnIndex
|
|
|
+ )
|
|
|
+ "
|
|
|
></el-input-number>
|
|
|
<span v-else>{{ scope.row[`${column.name}_null`].value }}</span>
|
|
|
</template>
|
|
@@ -145,16 +157,22 @@ export default {
|
|
|
(item) => item.subRequirements[0].name !== null
|
|
|
);
|
|
|
if (!this.hasSubRequirements) {
|
|
|
- this.columns = requirements.map((item) => {
|
|
|
- return { name: item.name };
|
|
|
+ this.columns = requirements.map((item, index) => {
|
|
|
+ return { name: item.name, columnIndex: index + 1 };
|
|
|
});
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ let cindex = 0;
|
|
|
this.columns = requirements.map((item) => {
|
|
|
return {
|
|
|
name: item.name,
|
|
|
- subRequirements: item.subRequirements.map((subr) => subr.name + ""),
|
|
|
+ subRequirements: item.subRequirements.map((subr) => {
|
|
|
+ return {
|
|
|
+ name: subr.name + "",
|
|
|
+ columnIndex: ++cindex,
|
|
|
+ };
|
|
|
+ }),
|
|
|
};
|
|
|
});
|
|
|
},
|
|
@@ -171,15 +189,15 @@ export default {
|
|
|
(item) => item[1] !== columnIndex
|
|
|
);
|
|
|
},
|
|
|
- async unitChange(row, key) {
|
|
|
- const fieldName = key.split("_")[0];
|
|
|
- let columnIndex = this.columns.findIndex(
|
|
|
- (item) => item.name === fieldName
|
|
|
+ async unitChange(row, key, columnIndex) {
|
|
|
+ const [fieldName, nodeName] = key.split("_");
|
|
|
+ const totalVal = calcSum(
|
|
|
+ this.dataList.map((item) => item[key].value || 0)
|
|
|
);
|
|
|
- columnIndex += 1;
|
|
|
- const totalVal = calcSum(this.dataList.map((item) => item[key].value));
|
|
|
if (totalVal > 1) {
|
|
|
- this.$message.error(`${fieldName}列总和大于1,当前修改值将不会保存!`);
|
|
|
+ const columnName =
|
|
|
+ nodeName === "null" ? fieldName : `${fieldName}:${nodeName}`;
|
|
|
+ this.$message.error(`${columnName}列总和大于1,当前修改值将不会保存!`);
|
|
|
|
|
|
const rowIndex = this.dataList.findIndex(
|
|
|
(item) => item.courseCode === row.courseCode
|