| | |
| | | <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> |
| | |
| | | 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; |
| | |
| | | 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) { |
| | |
| | | // 是子节点 |
| | | 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)) { |
| | |
| | | } |
| | | }); |
| | | this.tableData = res.data; |
| | | console.log(`output->this.tableData`, this.tableData); |
| | | this.selectDataList(); |
| | | }); |
| | | }, |
| | |
| | | this.$message.error("添加失败"); |
| | | } |
| | | |
| | | console.log(res); |
| | | this.$message.success("添加成功"); |
| | | this.addTreeForm = { |
| | | addTypeArr: [], |
| | |
| | | this.getTableByClick(this.selectData); |
| | | }, |
| | | changeCascader(data) { |
| | | console.log(`output->----------`, data); |
| | | this.addTreeForm.addTypeArr = data; |
| | | }, |
| | | closeAddTreeForm() { |
| | |
| | | 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) { |
| | |
| | | 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) { |
| | |
| | | } |
| | | }); |
| | | }, |
| | | 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) => { |