From 81a36e224bc95d7041bdaadd0fc12c35d4498850 Mon Sep 17 00:00:00 2001 From: XiaoRuby <3114200645@qq.com> Date: 星期六, 26 八月 2023 11:47:04 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- src/views/standardLibrary/index.vue | 66 ++++++--------------------------- 1 files changed, 12 insertions(+), 54 deletions(-) diff --git a/src/views/standardLibrary/index.vue b/src/views/standardLibrary/index.vue index ea759e3..979c4a6 100644 --- a/src/views/standardLibrary/index.vue +++ b/src/views/standardLibrary/index.vue @@ -44,13 +44,14 @@ <el-table :data="tableData" style="width: 100%; margin-bottom: 20px" - row-key="name" + row-key="id" border height="calc(100vh - 250px)" default-expand-all ref="multipleTable" @select="selectTr" @select-all="selectAll" + @selection-change="handleSelectionChange" :tree-props="{ children: 'children', hasChildren: 'hasChildren' }" > <el-table-column type="selection" label="搴忓彿"> </el-table-column> @@ -201,11 +202,10 @@ methods: { 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 +228,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,10 +251,8 @@ // 鏄瓙鑺傜偣 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); } if (!("children" in data)) { @@ -289,7 +284,6 @@ } }); this.tableData = res.data; - console.log(`output->this.tableData`, this.tableData); this.selectDataList(); }); }, @@ -352,7 +346,6 @@ this.$message.error("娣诲姞澶辫触"); } - console.log(res); this.$message.success("娣诲姞鎴愬姛"); this.addTreeForm = { addTypeArr: [], @@ -361,7 +354,6 @@ this.getTableByClick(this.selectData); }, changeCascader(data) { - console.log(`output->----------`, data); this.addTreeForm.addTypeArr = data; }, closeAddTreeForm() { @@ -408,21 +400,6 @@ this.isAllSelect = !this.isAllSelect; let data = this.tableData; this.toggleSelect(data, this.isAllSelect, "all"); - // 鑷畾涔� - if (this.isAllSelect) { - val.forEach((i) => { - if (i.id !== undefined) { - this.deleteList.push(i.id); - } else { - i.children.forEach((c) => { - this.deleteList.push(c.id); - }); - } - }); - } else { - this.deleteList.splice(0, this.deleteList.length); - } - console.log(`output->this.`, this.deleteList); }, //閫夋嫨鏌愯 selectTr(selection, row) { @@ -431,34 +408,6 @@ this.isAllSelect = row.isChecked; this.toggleSelect(row, row.isChecked, "tr"); }); - - if (row.isChecked === true) { - if (row.children !== undefined) { - row.children.forEach((i) => { - this.deleteList.push(i.id); - }); - } else { - this.deleteList.push(row.id); - } - } else if (row.isChecked === false) { - if (row.children !== undefined) { - row.children.forEach((i) => { - this.deleteList.findIndex((c, index) => { - if (c === i.id) { - this.deleteList.splice(index, 1); - return; - } - }); - }); - } - this.deleteList.findIndex((c, index) => { - if (c === row.id) { - this.deleteList.splice(index, 1); - return; - } - }); - } - console.log(`output->this.deleteList`, this.deleteList); }, //閫掑綊瀛愮骇 toggleSelect(data, flag, type) { @@ -492,6 +441,15 @@ } }); }, + handleSelectionChange(val) { + this.deleteList = [] + val.forEach((v) => { + if(v.id !== undefined){ + this.deleteList.push(v.id) + } + }) + console.log(`output->this.deleteList`,this.deleteList) + }, // 琛ㄦ牸鏍戝叏閮ㄩ�変腑閰嶇疆 缁撴潫 deleteListClick() { deleteListApi(this.deleteList).then((res) => { -- Gitblit v1.9.3