1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222 |
- <template>
- <div class="scenePacketListPanel">
- <div class="viewBox">
- <el-button icon="el-icon-view" @click="viewTree" type="primary"
- >预览</el-button
- >
- </div>
- <tableList ref="table" :columns="columns" :getDataWay="getDataWay">
- <el-table-column label="操作" slot="cgInfos" align="center" type="">
- <template v-slot="scope">
- <i
- v-if="
- (scope.row.children &&
- scope.row.children.length > 0) ||
- (!scope.row.children && scope.row.sceneNum === 0) ||
- (scope.row.children &&
- scope.row.children.length === 0 &&
- scope.row.sceneNum === 0)
- "
- @click="addIndicators(scope.row)"
- class="el-icon-plus elIcon"
- title="添加"
- ></i>
- <i
- @click="editRow(scope.row)"
- class="el-icon-edit-outline elIcon"
- title="编辑"
- ></i>
- <i
- v-if="scope.row.parentId != '0'"
- @click="delRow(scope.row)"
- class="el-icon-delete elIcon"
- title="删除"
- ></i>
- <i
- v-if="
- scope.row.parentId != '0' &&
- (!scope.row.children ||
- scope.row.children.length === 0)
- "
- @click="addScenario(scope.row)"
- class="el-icon-document-add elIcon"
- title="添加场景"
- ></i>
- </template>
- </el-table-column>
- <el-table-column label="指标名称" slot="sublistName" align="left">
- <template v-slot="scope">
- <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">
- <el-button
- type="primary"
- v-if="
- share === '0' ||
- share === '' ||
- ((roleCode === '0' || roleCode === '1') && share === '1')
- "
- @click="save(false)"
- >保存</el-button
- >
- <el-button
- type="primary"
- v-if="share === '0' || share === '1'"
- @click="save(true)"
- >另存为</el-button
- >
- <el-button type="primary" plain @click="cancel">取消</el-button>
- </div>
- <el-dialog
- :title="nameDiaTitle"
- :visible.sync="indicatorsVisible"
- width="690px"
- :close-on-click-modal="false"
- :close-on-press-escape="false"
- :before-close="indicatorsCancel"
- >
- <el-form
- ref="form"
- :model="form"
- :rules="rules"
- label-width="108px"
- >
- <el-form-item label="指标名称:" prop="sublistName">
- <el-input
- placeholder="请输入"
- maxlength="20"
- v-autoTrim="{ obj: form, key: 'sublistName' }"
- v-model="form.sublistName"
- >
- </el-input>
- </el-form-item>
- <el-form-item label="权重%:" prop="weight">
- <el-input
- placeholder="请输入"
- maxlength="6"
- v-autoTrim="{ obj: form, key: 'weight' }"
- v-model="form.weight"
- :disabled="editType === 'edit' && isRoot"
- >
- </el-input>
- </el-form-item>
- <el-form-item label="备注:" prop="remarks">
- <el-input
- v-autoTrim="{
- obj: form,
- key: 'remarks',
- }"
- v-model="form.remarks"
- type="textarea"
- placeholder="请输入"
- :autosize="{ minRows: 4, maxRows: 4 }"
- maxlength="300"
- ></el-input>
- </el-form-item>
- </el-form>
- <span slot="footer">
- <el-button type="primary" @click="indicatorsConfirm"
- >确 定</el-button
- >
- <el-button @click="indicatorsCancel">取 消</el-button>
- </span>
- </el-dialog>
- <el-dialog
- title="场景分类"
- :visible.sync="scenarioVisible"
- width="690px"
- :close-on-click-modal="false"
- :close-on-press-escape="false"
- :before-close="scenarioCancel"
- >
- <el-form
- ref="formA"
- :model="formA"
- :rules="rulesA"
- label-width="108px"
- >
- <el-form-item label="场景分类:" prop="sceneType">
- <el-select v-model="formA.sceneType">
- <el-option
- v-for="item in sceneTypeList"
- :label="item.caption"
- :value="item.code"
- :key="item.code"
- ></el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="评分规则:" prop="ruleNameArrayS">
- <el-cascader
- ref="cascader"
- v-model="formA.ruleNameArrayS"
- :options="ruleList"
- :props="props"
- @change="ruleSelChange"
- ></el-cascader>
- <!-- <el-select v-model="formA.rulesId" @change="ruleSelChange">
- <el-option
- v-for="item in ruleList"
- :label="item.ruleName"
- :value="item.rulesId"
- :key="item.rulesId"
- ></el-option>
- </el-select> -->
- </el-form-item>
- </el-form>
- <div class="tips">
- 解释:基于不同环境要素,在前述主题场景及两条路径的框架下进行场景的精确细分。细分维度包括天气、季节、温度、路况、车况等多种元素,所采纳元素的广度和深度既与需求有关,也与汽车智能化程度(感知能力)相关
- </div>
- <span slot="footer">
- <el-button type="primary" @click="scenarioConfirm"
- >下一步</el-button
- >
- <el-button @click="scenarioCancel">取 消</el-button>
- </span>
- </el-dialog>
- <el-dialog
- title="真实场景"
- :visible.sync="scenarioListsVisible"
- width="90%"
- class="scenarioListsDia"
- :close-on-click-modal="false"
- :close-on-press-escape="false"
- :before-close="scenarioListsCancel"
- >
- <real-scene-list ref="realScene"></real-scene-list>
- <span slot="footer">
- <el-button type="primary" @click="scenarioListsConfirm"
- >确 定</el-button
- >
- <el-button @click="scenarioListsCancel">取 消</el-button>
- </span>
- </el-dialog>
- <el-dialog
- v-if="generalizationVisible"
- :visible.sync="generalizationVisible"
- :title="generalizationDiaTitle"
- width="90%"
- class="generalizationDia"
- :close-on-click-modal="false"
- :close-on-press-escape="false"
- :before-close="generalizationCancel"
- >
- <el-steps :active="stepActive" align-center>
- <el-step title="第一步" description="选择场景模板"></el-step>
- <el-step title="第二步" description="场景泛化"></el-step>
- </el-steps>
- <div class="changeBtn">
- <el-button
- type="primary"
- v-if="stepActive === 2"
- @click="changeTemplate"
- >更换模板</el-button
- >
- </div>
- <div>
- <generalization-list
- v-if="stepActive === 1"
- ref="generalizationList"
- ></generalization-list>
- <generalization-detail
- v-if="stepActive === 2"
- ref="generalizationDetail"
- :id="generalizationId"
- :curId="curNode.id"
- :exampleId="curNode.exampleId"
- :ruleName="formA.ruleName"
- :rulesId="formA.rulesId"
- :ruleNameArrayS="formA.ruleNameArrayS"
- :genUrlType="genUrlType"
- @generalizationBegin="generalizationBegin"
- @generalizationDone="generalizationDone"
- ></generalization-detail>
- </div>
- <span slot="footer">
- <!-- <el-button
- v-if="stepActive === 2"
- type="primary"
- @click="generalizationPrev"
- >上一步</el-button
- > -->
- <el-button
- v-if="stepActive === 1"
- type="primary"
- @click="generalizationNext"
- >下一步</el-button
- >
- <el-button
- v-if="stepActive === 2"
- type="primary"
- @click="generalizationConfirm"
- >完成</el-button
- >
- <!-- <el-button @click="generalizationCancel">取 消</el-button> -->
- </span>
- </el-dialog>
- <el-dialog
- title="模板预览"
- v-if="templateViewVisible"
- :visible.sync="templateViewVisible"
- width="90%"
- class="templateViewDia"
- :close-on-click-modal="false"
- :close-on-press-escape="false"
- :before-close="templateViewClose"
- >
- <!-- <view-tree :data="treeData"></view-tree> -->
- <template-view
- :viewData="treeData"
- :errArr="weightErrIds"
- ></template-view>
- <span slot="footer">
- <el-button type="primary" @click="templateViewClose"
- >关 闭</el-button
- >
- </span>
- </el-dialog>
- </div>
- </template>
- <script>
- import searchLayout from "@/components/grid/searchLayout";
- import tableList from "@/components/grid/TableList";
- import toolbarTab from "@/components/toolbar/toolbarTab";
- import realSceneList from "./components/realSceneList";
- import generalizationList from "./components/generalizationList";
- import generalizationDetail from "./components/generalizationDetail";
- // import viewTree from "./components/elTree";
- import templateView from "./components/templateView";
- import { mapState } from "vuex";
- export default {
- name: "scenePacketList", // 场景测试包
- components: {
- searchLayout,
- tableList,
- toolbarTab,
- realSceneList,
- generalizationList,
- generalizationDetail,
- // viewTree,
- templateView,
- },
- data() {
- let validateNum = (rule, value, callback) => {
- // 修改一级指标时,权重值为number类型,其余为string
- if (typeof value === "number") {
- value = value + "";
- }
- if (value == 0 || value > 100) {
- callback(new Error(rule.message));
- return;
- }
- // if (value.startsWith("0")) {
- // callback(new Error(rule.message));
- // return;
- // }
- // if (value.includes(".")) {
- // callback(new Error(rule.message));
- // return;
- // }
- !/^(0|[1-9][0-9]*)(\.\d{1})?$/.test(value) &&
- callback(new Error(rule.message));
- callback();
- };
- let validateSublistName = (rule, value, callback) => {
- this.nodeList = [];
- this.deepFirstSearch(this.getDataWay.data[0], this.nodeList);
- let names = this.nodeList
- .filter((i) => i.id != this.form.id)
- .map((i) => i.sublistName);
- if (names.includes(value)) {
- callback(new Error(rule.message));
- return;
- } else {
- callback();
- }
- };
- return {
- packageId: "",
- share: "",
- columns: [
- {
- label: "操作",
- prop: "cgInfos",
- template: true,
- },
- {
- label: "指标名称",
- prop: "sublistName",
- template: true,
- },
- {
- label: "权重%",
- prop: "weight",
- template: true,
- },
- {
- label: "场景数量",
- prop: "sceneNum",
- },
- {
- label: "规则名称",
- prop: "ruleName",
- },
- {
- label: "备注",
- prop: "remarks",
- },
- ],
- getDataWay: {
- //加载表格数据
- dataType: "data",
- // 给出根节点
- data: [
- {
- children: null,
- id: "1",
- share: "",
- packageAndRules: "",
- packageLevel: 1,
- parentId: "0", // 判断根路径的标识
- remarks: "",
- rootId: null,
- ruleName: "",
- ruleNameArrayS: [],
- sceneGeneralizationIds: null,
- sceneNaturalIds: "",
- sceneNum: 0,
- sceneStatueIds: null,
- sceneTrafficIds: null,
- seq: 0,
- sublistName: "一级指标",
- weight: 100,
- // 配合view-tree即elTree使用
- treeNode: "一级指标" + " (" + 100 + "%)",
- },
- ],
- },
- idIndex: 1, // 用做新增加点id自加,因为id为空会报错
- nameDiaTitle: "", // 编辑该级节点信息的dialog的title
- indicatorsVisible: false, // 编辑指标dialog
- scenarioVisible: false, // 选择场景dialog
- scenarioListsVisible: false, // 真实场景列表dialog
- form: {
- sublistName: "",
- weight: "",
- remarks: "",
- id: "",
- },
- rules: {
- sublistName: [
- { required: true, message: "请输入", trigger: "blur" },
- {
- validator: validateSublistName,
- message: "指标名称重复",
- trigger: ["blur"],
- },
- ],
- weight: [
- { required: true, message: "请输入", trigger: "blur" },
- {
- validator: validateNum,
- message: "请输入大不于100且最多带有一位小数的正数",
- trigger: ["blur"],
- },
- ],
- },
- ruleList: [],
- formA: {
- sceneType: "1",
- ruleName: "",
- ruleNameArrayS: [],
- rulesId: "",
- },
- rulesA: {
- sceneType: [
- { required: true, message: "请选择", trigger: "change" },
- ],
- ruleNameArrayS: [
- { required: true, message: "请选择", trigger: "change" },
- ],
- },
- sceneTypeList: [
- { caption: "真实场景", code: "1" },
- { caption: "泛化场景", code: "2" },
- ],
- props: {
- multiple: false,
- label: "name",
- value: "code",
- },
- nodeList: [], // 把当前所有节点遍历到一个扁平数组
- curNode: {}, // 当前操作的节点
- editType: "", // 点操作编辑的类型 新增or编辑
- checkedIdsA: [], // 交通事故列表已选
- checkedIdsB: [], // 自然驾驶列表已选
- checkedIdsC: [], // 标准法规列表已选
- isRoot: false, // 是否是根节点
- templateViewVisible: false, // 模板预览dialog
- treeData: [],
- weightErrIds: [], // 存储weightErr为false的节点id的数组
- generalizationVisible: false, // 泛化dialog
- stepActive: 1, // 泛化步骤
- generalizationSceneId: "", // 泛化编号
- generalizationId: "", // 泛化详情id
- genUrlType: 1, // 1为从列表跳入的模板信息,2为泛化后的详情
- maxSceneCount: 0, // 可创建的最大场景数量
- originRuleList: [], // 原版的res.info
- };
- },
- computed: {
- ...mapState(["roleCode"]),
- generalizationDiaTitle() {
- if(this.stepActive != 2) {
- return "泛化场景"
- } else {
- return "泛化场景 " + this.generalizationSceneId
- }
- }
- },
- methods: {
- viewTree() {
- this.templateViewVisible = true;
- this.nodeList = [];
- // 遍历当前树 拿到所有节点的平行展开数组
- this.deepFirstSearch(this.getDataWay.data[0], this.nodeList);
- let arr = this.nodeList;
- this.nodeList = [];
- this.weightErrIds = [];
- arr.forEach((i) => {
- if (i.treeNode) {
- i.topic = i.treeNode;
- } else {
- i.topic = i.sublistName + " (" + i.weight + "%)";
- }
- i.parentid = i.parentId;
- if (i.parentId === "0") {
- i.isroot = true;
- } else {
- i.expanded = true;
- }
- if (i.weightErr) this.weightErrIds.push(i.id);
- });
- this.treeData = arr;
- },
- delRow(row) {
- this.$confirm("确认是否删除?", "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- }).then(() => {
- this.nodeList = [];
- this.deepFirstSearch(
- this.getDataWay.data[0],
- this.nodeList,
- row.parentId
- );
- let index = this.curNode.children.findIndex(
- (i) => i.id === row.id
- );
- this.curNode.children.splice(index, 1);
- let node = null;
- if (this.curNode.children && this.curNode.children.length > 0) {
- node = this.curNode.children[0];
- } else {
- // 解决删除该节点前,其父节点只有一个孩子时,场景数量还会存在的问题
- this.curNode.sceneNum = 0;
- node = this.curNode;
- }
- if (node.parentId != "0") {
- this.sceneNumUpdate(node);
- } else {
- this.curNode.sceneNum = 0;
- }
- this.checkWeightValidate();
- });
- },
- // 编辑该级节点信息
- editRow(row) {
- 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;
- this.form.id = row.id;
- this.curNode = row;
- },
- // 增加该级节点的子节点
- addIndicators(row) {
- this.nameDiaTitle = "添加指标";
- this.editType = "add";
- this.indicatorsVisible = true;
- this.curNode = row;
- },
- // 添加场景
- addScenario(row) {
- this.curNode = row;
- if (row.sceneGeneralizationIds) {
- this.formA.sceneType = "2";
- } else {
- this.formA.sceneType = "1";
- }
- if (row.packageAndRules) {
- this.formA.rulesId = row.packageAndRules;
- this.formA.ruleName = row.ruleName;
- this.formA.ruleNameArrayS = row.ruleNameArrayS;
- // this.formA.ruleName =
- // this.originRuleList.find(
- // (i) => i.rulesId === row.packageAndRules
- // ).ruleName || "";
- }
- this.scenarioVisible = true;
- },
- // 操作节点dialog的确定
- indicatorsConfirm() {
- this.$refs.form.validate((valid) => {
- if (valid) {
- if (this.editType == "edit") {
- // 编辑节点
- this.curNode.sublistName = this.form.sublistName;
- this.curNode.weight = this.form.weight;
- this.curNode.remarks = this.form.remarks;
- // 为了预览展示
- this.curNode.treeNode =
- this.form.sublistName +
- " (" +
- this.form.weight +
- "%)";
- } else {
- // 新增节点
- ++this.idIndex;
- let node = {
- children: null,
- id: this.idIndex + "",
- packageAndRules: "",
- packageLevel: 1,
- parentId: this.curNode.id || "",
- remarks: this.form.remarks || "",
- rootId: this.packageId,
- ruleName: "",
- ruleNameArrayS: [],
- sceneGeneralizationIds: null,
- sceneNaturalIds: "",
- sceneNum: 0,
- sceneStatueIds: null,
- sceneTrafficIds: null,
- seq: 0,
- sublistName: this.form.sublistName,
- weight: this.form.weight,
- treeNode:
- this.form.sublistName +
- " (" +
- this.form.weight +
- "%)",
- };
- if (!this.curNode.children) {
- this.curNode.children = [];
- }
- this.curNode.children.push(node);
- }
- this.nodeList = [];
- // 遍历当前树 拿到所有节点的平行展开数组
- this.deepFirstSearch(
- this.getDataWay.data[0],
- this.nodeList
- );
- // console.log(this.getDataWay.data);
- this.checkWeightValidate();
- this.indicatorsCancel();
- }
- });
- },
- // 操作节点dialog的取消
- indicatorsCancel() {
- this.$refs.form.resetFields();
- this.form.sublistName = "";
- this.form.weight = "";
- this.form.remarks = "";
- this.form.id = "";
- this.curNode = {};
- this.indicatorsVisible = false;
- },
- // 场景分类dialog的确定 下一步
- scenarioConfirm() {
- this.$refs.formA.validate((valid) => {
- if (valid) {
- this.scenarioVisible = false;
- // 真实场景
- if (this.formA.sceneType === "1") {
- this.scenarioListsVisible = true;
- // 切换到第一个tab页并清空所有tab页中查询条件
- this.$nextTick(() => {
- this.$refs.realScene.activeName = "1";
- this.$refs.realScene.doResetA();
- this.$refs.realScene.doResetB();
- this.$refs.realScene.doResetC();
- // 把选中数据对应的ids组分别传入tabs中,用于后续操作数据进行存储
- if (this.curNode.sceneTrafficIds) {
- this.$refs.realScene.checkedIdsA =
- this.curNode.sceneTrafficIds.split(",");
- }
- if (this.curNode.sceneNaturalIds) {
- this.$refs.realScene.checkedIdsB =
- this.curNode.sceneNaturalIds.split(",");
- }
- if (this.curNode.sceneStatueIds) {
- this.$refs.realScene.checkedIdsC =
- this.curNode.sceneStatueIds.split(",");
- }
- });
- } else {
- // 泛化场景
- if (this.curNode.exampleId) {
- // 进详情
- this.genUrlType = 2;
- this.stepActive = 2;
- } else {
- // 进列表
- this.genUrlType = 1;
- this.stepActive = 1;
- }
- this.generalizationVisible = true;
- }
- }
- });
- },
- // 场景分类dialog的取消
- scenarioCancel() {
- this.$refs.formA.resetFields();
- this.formA.sceneType = "1";
- this.formA.ruleName = "";
- this.formA.ruleNameArrayS = [];
- this.formA.rulesId = "";
- this.scenarioVisible = false;
- this.curNode = {};
- },
- // 选择真实场景dialog的确定
- scenarioListsConfirm() {
- // 获取选中的数据
- this.checkedIdsA = this.$refs.realScene.checkedIdsA;
- this.checkedIdsB = this.$refs.realScene.checkedIdsB;
- this.checkedIdsC = this.$refs.realScene.checkedIdsC;
- this.curNode.packageAndRules = this.formA.rulesId;
- this.curNode.ruleName = this.formA.ruleName;
- this.curNode.ruleNameArrayS = this.formA.ruleNameArrayS;
- this.curNode.sceneNum =
- this.checkedIdsA.length +
- this.checkedIdsB.length +
- this.checkedIdsC.length;
- // 选择场景总数为0 则去掉对应的规则名称和id
- if (this.curNode.sceneNum === 0) {
- this.curNode.packageAndRules = "";
- this.curNode.ruleName = "";
- this.curNode.ruleNameArrayS = [];
- } else {
- this.curNode.packageAndRules = this.formA.rulesId;
- this.curNode.ruleName = this.formA.ruleName;
- this.curNode.ruleNameArrayS = this.formA.ruleNameArrayS;
- }
- // 选中数据分别传入对应的ids组
- this.curNode.sceneTrafficIds = this.checkedIdsA.join(",");
- this.curNode.sceneNaturalIds = this.checkedIdsB.join(",");
- this.curNode.sceneStatueIds = this.checkedIdsC.join(",");
- // 清空泛化场景的数据
- this.curNode.exampleId = "";
- this.curNode.sceneGeneralizationIds = "";
- this.curNode.templateId = "";
- this.nodeList = [];
- // 遍历当前树 拿到所有节点的平行展开数组
- this.deepFirstSearch(this.getDataWay.data[0], this.nodeList);
- this.sceneNumUpdate(this.curNode);
- this.scenarioListsCancel();
- },
- // 选择真实场景dialog的取消
- scenarioListsCancel() {
- this.scenarioCancel();
- // 清空选中行数据
- this.$refs.realScene.$refs.tableA.$refs.ListTable.clearSelection();
- this.$refs.realScene.$refs.tableB.$refs.ListTable.clearSelection();
- this.$refs.realScene.$refs.tableC.$refs.ListTable.clearSelection();
- this.$refs.realScene.checkedIdsA = [];
- this.$refs.realScene.checkedIdsB = [];
- this.$refs.realScene.checkedIdsC = [];
- this.$refs.realScene.checkedArrA = [];
- this.$refs.realScene.checkedArrB = [];
- this.$refs.realScene.checkedArrC = [];
- this.$refs.realScene.selectedA = false;
- this.$refs.realScene.selectedB = false;
- this.$refs.realScene.selectedC = false;
- this.scenarioListsVisible = false;
- },
- // 泛化-上一步
- generalizationPrev() {
- this.stepActive = 1;
- },
- // 泛化-下一步
- generalizationNext() {
- let arr = [];
- if (
- this.$refs.generalizationList &&
- this.$refs.generalizationList.checkedArr
- ) {
- arr = this.$refs.generalizationList.checkedArr;
- } else {
- return;
- }
- if (arr.length === 0) {
- this.$message.warning("请先选择一条数据");
- return;
- } else if (arr.length > 1) {
- this.$message.warning("只能选择一条数据");
- return;
- }
- this.generalizationId = arr[0].id;
- this.generalizationSceneId = arr[0].sceneId;
- this.genUrlType = 1;
- this.stepActive = 2;
- },
- // 泛化-完成按钮
- generalizationConfirm() {
- this.$refs.generalizationDetail.done();
- },
- // 泛化-取消
- generalizationCancel() {
- this.$refs.formA.resetFields();
- this.formA.ruleName = "";
- this.formA.ruleNameArrayS = [];
- this.formA.rulesId = "";
- this.generalizationVisible = false;
- },
- // 开始泛化
- generalizationBegin() {
- this.generalizationCancel();
- this.curNode.sceneNum = "泛化中";
- this.curNode = {};
- },
- // 泛化完成回调
- generalizationDone(info, obj, isSuccess = true) {
- this.nodeList = [];
- // 遍历当前树 拿到所有节点的平行展开数组
- this.deepFirstSearch(this.getDataWay.data[0], this.nodeList);
- let node = this.nodeList.find((i) => i.id === obj.curId);
- if (node) {
- if (isSuccess) {
- node.exampleId = info.exampleId;
- node.sceneGeneralizationIds = info.sceneGeneralizationIds;
- node.sceneNum = info.sceneNum;
- node.id = info.sublistId;
- node.templateId = info.templateId;
- node.packageAndRules = obj.rulesId;
- node.ruleName = obj.ruleName;
- node.ruleNameArrayS = obj.ruleNameArrayS;
- } else {
- // 若泛化失败则清空对应字段
- node.exampleId = "";
- node.sceneGeneralizationIds = "";
- node.sceneNum = 0;
- node.templateId = "";
- node.packageAndRules = "";
- node.ruleName = "";
- node.ruleNameArrayS = [];
- }
- // 清空真实场景的数据
- node.sceneTrafficIds = "";
- node.sceneNaturalIds = "";
- node.sceneStatueIds = "";
- this.sceneNumUpdate(node);
- }
- },
- // 更换模板
- changeTemplate() {
- this.stepActive = 1;
- },
- // 校验权重
- 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) => {
- 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);
- },
- // 通过深度优先找节点
- deepFirstSearch(node, nodeList, id) {
- if (node) {
- // 有id则把对应节点赋给当前操作节点
- if (id && node.id === id) {
- this.curNode = node;
- }
- nodeList.push(node);
- var children = node.children;
- if (children) {
- for (var i = 0; i < children.length; i++)
- //每次递归的时候将 需要遍历的节点 和 节点所存储的数组传下去
- this.deepFirstSearch(children[i], nodeList, id);
- }
- }
- 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);
- for (let index = 0; index < this.nodeList.length; index++) {
- const element = this.nodeList[index];
- if (element.sceneNum === "泛化中") {
- this.$message.error("存在泛化中场景,请稍后进行保存");
- return;
- }
- if (element.sceneNum == 0) {
- this.$message.error("场景数量不能为0");
- return;
- }
- if (this.roleCode != "0" && this.roleCode != "1") {
- if (element.sceneNum > this.maxSceneCount) {
- this.$message.error(
- `场景数量不能超过${this.maxSceneCount}`
- );
- return;
- }
- }
- if (element.children && element.children.length > 0) {
- let total = 0;
- let arr = [];
- element.children.forEach((item) => {
- total += +this.nodeList.find((i) => i.id === item.id)
- .weight;
- arr.push(item.sublistName);
- });
- if (total != 100) {
- this.$message.error(
- `${arr.join(",")}等权重相加应为100`
- );
- return;
- }
- }
- }
- if (isAdd || !this.$route.query.packageId) {
- // 另存为或新增页面
- this.getDataWay.data[0].packageLevel = 1;
- } else {
- this.getDataWay.data[0].packageLevel = 0;
- }
- this.getDataWay.data[0].share = this.share;
- this.$axios({
- method: "post",
- url: this.$api.sceneLibrary.saveScenePackage,
- data: {
- params: this.getDataWay.data,
- },
- }).then((res) => {
- if (res.code == 200) {
- this.$message.success("保存成功");
- this.cancel();
- } else {
- this.$message.error(res.message || "保存失败");
- }
- });
- },
- cancel() {
- this.$router.replace({
- path: "/scenarioTestPackageManagementList",
- });
- },
- async getRuleList() {
- await this.$axios({
- method: "post",
- url: this.$api.sceneLibrary.queryCsbNew,
- data: {},
- }).then((res) => {
- if (res.code == 200 && res.info) {
- this.originRuleList = res.info;
- // let arr = [];
- // res.info.forEach((i, index) => {
- // arr[index] = Object.assign({}, i);
- // });
- // arr.forEach((i) => {
- // if (i.share === "1") i.ruleName = i.ruleName + "(公有)";
- // });
- // this.ruleList = arr;
- this.ruleList = res.info;
- } else {
- this.$message.error(res.message || "获取评分规则列表失败");
- }
- });
- },
- ruleSelChange(v) {
- let item = this.$refs.cascader.getCheckedNodes(true)[0].data.vo;
- this.formA.ruleName = item.ruleName;
- this.formA.rulesId = item.rulesId;
- // this.formA.ruleName = this.originRuleList.find(
- // (i) => i.rulesId === val
- // ).ruleName;
- },
- // 场景数量更新
- sceneNumUpdate(curNode) {
- let node = this.nodeList.find((i) => i.id === curNode.parentId);
- let sceneNum = 0;
- node.children.forEach((i) => {
- i.sceneNum != "泛化中" ? (sceneNum += i.sceneNum) : null;
- });
- node.sceneNum = sceneNum;
- if (node.parentId === "0") {
- return;
- }
- this.sceneNumUpdate(node);
- },
- templateViewClose() {
- this.templateViewVisible = false;
- this.treeData = [];
- },
- getCount() {
- this.$axios({
- method: "post",
- url: this.$api.sceneLibrary.getSceneParam,
- data: {},
- }).then((res) => {
- if (res.code == 200 && res.info) {
- this.maxSceneCount = res.info.numScenePerPackage || 0;
- } else {
- this.$message.error(res.message || "获取信息失败");
- }
- });
- },
- },
- mounted() {
- if (this.$route.query.packageId) {
- this.packageId = this.$route.query.packageId;
- this.share = this.$route.query.share;
- if (this.packageId) {
- this.$axios({
- method: "post",
- url: this.$api.sceneLibrary.queryScenePackageSublistList,
- data: {
- packageId: this.packageId,
- },
- }).then((res) => {
- if (res.code == 200 && res.info) {
- this.getDataWay.data = res.info;
- } else {
- this.$message.error(res.message || "获取信息失败");
- }
- });
- }
- }
- this.getRuleList();
- if (this.roleCode != "0" && this.roleCode != "1") {
- this.getCount();
- }
- },
- };
- </script>
- <style lang='less' scoped>
- .scenePacketListPanel {
- padding: 30px;
- .viewBox {
- padding: 0 10px 10px;
- }
- .tips {
- padding: 10px 0 10px 18px;
- font-size: 12px;
- color: @gray;
- }
- .scenarioListsDia,
- .generalizationDia {
- /deep/ .el-dialog__body {
- padding: 20px 60px;
- }
- }
- .generalizationDia {
- /deep/ .el-dialog__body {
- position: relative;
- .changeBtn {
- position: absolute;
- top: 20px;
- right: 60px;
- }
- }
- }
- .el-form {
- .el-input,
- .el-select,
- .el-cascader {
- width: 100%;
- }
- .el-cascader {
- height: 32px;
- line-height: 32px;
- }
- .el-select /deep/ .el-input, .el-cascader /deep/ .el-input {
- width: 100%;
- }
- }
- .btns {
- padding: 30px 0;
- text-align: center;
- }
- .templateViewDia {
- /deep/ .el-dialog {
- // max-height: 80%;
- height: calc(100% - 12vh - 15px);
- margin-top: 6vh !important;
- // height: 600px;
- // overflow: auto;
- // overflow: hidden;
- .el-dialog__body {
- // height: 100%;
- height: calc(100% - 130px);
- overflow: auto;
- &.toCenter {
- display: flex;
- justify-content: center;
- align-items: center;
- }
- }
- }
- }
- }
- </style>
|