|
@@ -49,6 +49,14 @@
|
|
|
<span>{{ scope.row.sublistName }}</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
+ <el-table-column label="权重" slot="weight" align="center">
|
|
|
+ <template v-slot="scope">
|
|
|
+ <span v-if="scope.row.weightErr" style="color: red">{{
|
|
|
+ scope.row.weight
|
|
|
+ }}</span>
|
|
|
+ <span v-else>{{ scope.row.weight }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
</tableList>
|
|
|
|
|
|
<div class="btns">
|
|
@@ -96,6 +104,7 @@
|
|
|
maxlength="6"
|
|
|
v-autoTrim="{ obj: form, key: 'weight' }"
|
|
|
v-model="form.weight"
|
|
|
+ :disabled="editType === 'edit' && isRoot"
|
|
|
>
|
|
|
</el-input>
|
|
|
</el-form-item>
|
|
@@ -223,6 +232,7 @@ export default {
|
|
|
{
|
|
|
label: "权重",
|
|
|
prop: "weight",
|
|
|
+ template: true,
|
|
|
},
|
|
|
{
|
|
|
label: "场景数量",
|
|
@@ -257,7 +267,7 @@ export default {
|
|
|
sceneStatueIds: null,
|
|
|
sceneTrafficIds: null,
|
|
|
seq: 0,
|
|
|
- sublistName: "根节点",
|
|
|
+ sublistName: "一级指标",
|
|
|
weight: 100,
|
|
|
},
|
|
|
],
|
|
@@ -306,6 +316,7 @@ export default {
|
|
|
checkedIdsA: [], // 交通事故列表已选
|
|
|
checkedIdsB: [], // 自然驾驶列表已选
|
|
|
checkedIdsC: [], // 标准法规列表已选
|
|
|
+ isRoot: false, // 是否是根节点
|
|
|
};
|
|
|
},
|
|
|
|
|
@@ -341,6 +352,13 @@ export default {
|
|
|
this.nameDiaTitle = "编辑指标";
|
|
|
this.editType = "edit";
|
|
|
this.indicatorsVisible = true;
|
|
|
+
|
|
|
+ if (row.parentId === "0") {
|
|
|
+ this.isRoot = true;
|
|
|
+ } else {
|
|
|
+ this.isRoot = false;
|
|
|
+ }
|
|
|
+
|
|
|
this.form.sublistName = row.sublistName;
|
|
|
this.form.weight = row.weight;
|
|
|
this.form.remarks = row.remarks;
|
|
@@ -351,6 +369,7 @@ export default {
|
|
|
addIndicators(row) {
|
|
|
this.nameDiaTitle = "添加指标";
|
|
|
this.editType = "add";
|
|
|
+
|
|
|
this.indicatorsVisible = true;
|
|
|
|
|
|
this.curNode = row;
|
|
@@ -403,6 +422,8 @@ export default {
|
|
|
}
|
|
|
this.curNode.children.push(node);
|
|
|
}
|
|
|
+console.log(this.getDataWay.data[0]);
|
|
|
+ this.checkWeightValidate();
|
|
|
|
|
|
this.indicatorsCancel();
|
|
|
}
|
|
@@ -473,6 +494,15 @@ export default {
|
|
|
this.checkedIdsB.length +
|
|
|
this.checkedIdsC.length;
|
|
|
|
|
|
+ // 选择场景总数为0 则去掉对应的规则名称和id
|
|
|
+ if (this.curNode.sceneNum === 0) {
|
|
|
+ this.curNode.packageAndRules = "";
|
|
|
+ this.curNode.ruleName = "";
|
|
|
+ } else {
|
|
|
+ this.curNode.packageAndRules = this.formA.rulesId;
|
|
|
+ this.curNode.ruleName = this.formA.ruleName;
|
|
|
+ }
|
|
|
+
|
|
|
// 选中数据分别传入对应的ids组
|
|
|
this.curNode.sceneTrafficIds = this.checkedIdsA.join(",");
|
|
|
this.curNode.sceneNaturalIds = this.checkedIdsB.join(",");
|
|
@@ -508,6 +538,32 @@ export default {
|
|
|
|
|
|
this.scenarioListsVisible = false;
|
|
|
},
|
|
|
+ // 校验权重
|
|
|
+ checkWeightValidate() {
|
|
|
+ this.allRowWeightErrFalse(this.getDataWay.data[0]);
|
|
|
+
|
|
|
+ let ids = [];
|
|
|
+
|
|
|
+ for (let index = 0; index < this.nodeList.length; index++) {
|
|
|
+ const element = this.nodeList[index];
|
|
|
+ if (element.children && element.children.length > 0) {
|
|
|
+ let total = 0;
|
|
|
+ let arr = [];
|
|
|
+ element.children.forEach((item) => {
|
|
|
+ console.log(this.nodeList);
|
|
|
+ total += +this.nodeList.find((i) => i.id === item.id)
|
|
|
+ .weight;
|
|
|
+ arr.push(item.id);
|
|
|
+ });
|
|
|
+ if (total != 100) {
|
|
|
+ ids.push(...arr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.rowWeightErrTrue(this.getDataWay.data[0], ids);
|
|
|
+ console.log(6);
|
|
|
+ console.log(this.getDataWay.data[0]);
|
|
|
+ },
|
|
|
// 深度优先遍历
|
|
|
/* deepFirstSearch(node, nodeList) {
|
|
|
if (node) {
|
|
@@ -537,6 +593,30 @@ export default {
|
|
|
}
|
|
|
return nodeList;
|
|
|
},
|
|
|
+ // 使全部节点 weightErr 为 false
|
|
|
+ allRowWeightErrFalse(node) {
|
|
|
+ if (node) {
|
|
|
+ node.weightErr = false;
|
|
|
+ var children = node.children;
|
|
|
+ if (children) {
|
|
|
+ for (var i = 0; i < children.length; i++)
|
|
|
+ this.allRowWeightErrFalse(children[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 使部分节点 weightErr 为 true
|
|
|
+ rowWeightErrTrue(node, arr) {
|
|
|
+ if (node) {
|
|
|
+ if (arr.includes(node.id)) {
|
|
|
+ node.weightErr = true;
|
|
|
+ }
|
|
|
+ var children = node.children;
|
|
|
+ if (children) {
|
|
|
+ for (var i = 0; i < children.length; i++)
|
|
|
+ this.rowWeightErrTrue(children[i], arr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
save(isAdd) {
|
|
|
this.nodeList = [];
|
|
|
this.deepFirstSearch(this.getDataWay.data[0], this.nodeList);
|