From 8ef314c5ae48c2046a93bbae35099fe1636805b7 Mon Sep 17 00:00:00 2001 From: value <z1292839451@163.com> Date: 星期六, 26 八月 2023 15:37:37 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- src/views/standardLibrary/index.vue | 82 +++++++++++++++++++++++++++++++++-------- 1 files changed, 66 insertions(+), 16 deletions(-) diff --git a/src/views/standardLibrary/index.vue b/src/views/standardLibrary/index.vue index ea759e3..61d3565 100644 --- a/src/views/standardLibrary/index.vue +++ b/src/views/standardLibrary/index.vue @@ -25,6 +25,16 @@ <div class="table-header"> <div class="serve-btn"> <span class="tipMsg">{{ msg !== "" ? msg : "" }}</span> + <el-select v-model="versionValue" @change="changeSelect" clearable placeholder="璇烽�夋嫨鐗堟湰鍙�"> + <el-option + v-for="item in options" + :key="item.value" + :label="item.label" + :value="item.value" + > + </el-option> + </el-select> + <el-button type="primary" @click="addVersionFun">鏂板鐗堟湰鍙�</el-button> <el-button type="primary" icon="el-icon-plus" @@ -160,12 +170,16 @@ addSpecifications, deleteListApi, blurUpdateApi, + getVersion, + addVersion } from "@/api/standardLibrary"; import { selectproductModelApi } from "@/api/basicData/index"; export default { data() { return { + options:[], + versionValue: '', deleteList: [], msg: "", isAllSelect: false, @@ -198,14 +212,54 @@ created() { this.getStandardTree(); }, + mounted(){ + + }, methods: { + async initSelect(){ + this.options = []; + this.versionValue = ""; + const response = await getVersion({"specificationsId":this.selectData.id}); + if(response.code===200 && response.data.length>0){ + this.getTableByClick(this.selectData,response.data[0]) + for(let i=0;i<response.data.length;i++){ + this.options.push({ + value: response.data[i], + label: "V" + response.data[i] + }) + this.versionValue = response.data[0]; + } + } + }, + changeSelect(){ + this.tableData = []; + this.getTableByClick(this.selectData,this.versionValue); + }, + async insertVersion(){ + const resp = await addVersion({"specificationsId":this.selectData.id}); + if(resp.code===200){ + this.initSelect(); + this.$message({ + type: 'success', + message: resp.message + }); + } + }, + addVersionFun() { + this.$confirm('纭娣诲姞鏂扮殑鐗堟湰鍙峰悧?', '鎻愮ず', { + confirmButtonText: '纭畾', + cancelButtonText: '鍙栨秷', + type: 'warning' + }).then(() => { + this.insertVersion(); + }).catch(() => {}); + }, filterNode(value, data) { if (!value) return true; - return data.label.indexOf(value) !== -1; + return data.name.indexOf(value) !== -1; }, // 鑾峰彇bom鏍戠殑鏍囧噯鏁版嵁 async getStandardTree() { - console.log(`output->鎵ц鍔沗, "鎵ц鍔�"); const { data } = await getMaterialList(); this.standardTree = data.map((item) => { let name = null; @@ -228,14 +282,11 @@ const treeOptions = JSON.parse(JSON.stringify(this.standardTree)); this.getDefault(treeOptions, 0); this.formTypeOptions = treeOptions; - console.log(`output->===========`, "==========="); this.$nextTick().then(() => { const firstNode = document.querySelector( ".el-tree-node .el-tree-node__children .el-tree-node .el-tree-node__children .el-tree-node .el-tree-node__children .el-tree-node" ); - console.log(`output->firstNode`, firstNode); firstNode.click(); - // console.log(firstNode); }); }, getDefault(arr, index) { @@ -254,11 +305,10 @@ // 鏄瓙鑺傜偣 if (node.level === 4) { this.getParentData(node.parent, node.data.name); - console.log(`output->this.msg`, this.msg); // 瀛樹笅閫変腑鑺傜偣 this.selectData = data; - // eslint-disable-next-line prefer-const - this.getTableByClick(data); + this.getTableByClick(data,this.versionValue); + this.initSelect(); } if (!("children" in data)) { return; @@ -273,9 +323,10 @@ this.getParentData(node.parent, this.msg); } }, - async getTableByClick(data) { + async getTableByClick(data,versionVal) { await getProductList({ specificationsId: data.id, + version: versionVal }).then((res) => { res.data.forEach((i) => { if (i.name === undefined) { @@ -289,7 +340,6 @@ } }); this.tableData = res.data; - console.log(`output->this.tableData`, this.tableData); this.selectDataList(); }); }, @@ -358,10 +408,9 @@ addTypeArr: [], }; this.getStandardTree(); - this.getTableByClick(this.selectData); + this.getTableByClick(this.selectData,this.versionValue); }, changeCascader(data) { - console.log(`output->----------`, data); this.addTreeForm.addTypeArr = data; }, closeAddTreeForm() { @@ -422,7 +471,6 @@ } else { this.deleteList.splice(0, this.deleteList.length); } - console.log(`output->this.`, this.deleteList); }, //閫夋嫨鏌愯 selectTr(selection, row) { @@ -458,7 +506,6 @@ } }); } - console.log(`output->this.deleteList`, this.deleteList); }, //閫掑綊瀛愮骇 toggleSelect(data, flag, type) { @@ -499,7 +546,7 @@ message: res.message, type: "success", }); - this.getTableByClick(this.selectData); + this.getTableByClick(this.selectData,this.versionValue); }); }, async requiredOnfocus(scope) { @@ -514,7 +561,7 @@ message: res.message, type: "success", }); - this.getTableByClick(this.selectData); + this.getTableByClick(this.selectData,this.versionValue); }); }, }, @@ -650,6 +697,9 @@ width: 100%; padding-bottom: 6px; text-align: right; + .el-select{ + margin-right:20px; + } } .tipMsg { float: left; -- Gitblit v1.9.3