| | |
| | | </el-col> |
| | | <el-col v-if="checkPermi(['standard:standardLibrary:add'])" :span="4" |
| | | style="text-align: center; line-height: 30px"> |
| | | <el-button circle icon="el-icon-plus" size="mini" type="primary" @click="addDia = true"></el-button> |
| | | <el-button circle icon="el-icon-plus" size="mini" type="primary" @click="openAddDia"></el-button> |
| | | </el-col> |
| | | </el-row> |
| | | <el-tree ref="tree" v-loading="treeLoad" :allow-drop="allowDrop" :data="list" |
| | |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <!-- <el-pagination :current-page="currentPage" :page-size="300" :total="total" layout="total" |
| | | style="position: absolute; right: 16px; bottom: 1px" @current-change="handleCurrentChange"> |
| | | </el-pagination> --> |
| | | <p style="text-align: right;margin-right: 20px;color: #333;">共{{ total }}条</p> |
| | | </el-row> |
| | | </div> |
| | |
| | | <span class="required-span">* </span>型号: |
| | | </el-col> |
| | | <el-col :offset="1" :span="16"> |
| | | <el-input v-model="addOb.model" clearable placeholder="请输入型号" size="small" |
| | | @keyup.enter.native="addStandardTree"></el-input> |
| | | <el-input v-model="addOb.modelName" clearable placeholder="请输入型号" size="small"></el-input> |
| | | </el-col> |
| | | </el-row> |
| | | </div> |
| | |
| | | <span class="required-span">* </span>型号: |
| | | </el-col> |
| | | <el-col :offset="1" :span="16"> |
| | | <el-input v-model="addOb.model" clearable placeholder="请输入型号" size="small" |
| | | @keyup.enter.native="updateStandardTree"></el-input> |
| | | <el-input v-model="addOb.modelName" clearable placeholder="请输入型号" size="small"></el-input> |
| | | </el-col> |
| | | </el-row> |
| | | </div> |
| | |
| | | <el-input v-model="scope.row.conductorType" clearable placeholder="导体类型" size="small"></el-input> |
| | | </template> |
| | | </el-table-column> |
| | | <!-- <el-table-column align="center" label="单价" width="120">--> |
| | | <!-- <template slot-scope="scope">--> |
| | | <!-- <el-input v-model="scope.row.price" clearable placeholder="单价" size="small"></el-input>--> |
| | | <!-- </template>--> |
| | | <!-- </el-table-column>--> |
| | | <!-- <el-table-column align="center" label="工时系数" width="120">--> |
| | | <!-- <template slot-scope="scope">--> |
| | | <!-- <el-input v-model="scope.row.manHour" clearable placeholder="工时系数" size="small"></el-input>--> |
| | | <!-- </template>--> |
| | | <!-- </el-table-column>--> |
| | | <el-table-column align="center" label="操作" width="70"> |
| | | <template slot-scope="scope"> |
| | | <el-button circle icon="el-icon-minus" size="mini" type="danger" |
| | |
| | | factory: [], |
| | | addDia: false, |
| | | updateDia: false, // 修改树名字弹框 |
| | | oldModel: "", |
| | | addOb: { |
| | | factory: null, |
| | | laboratory: null, |
| | | sampleType: null, |
| | | sample: null, |
| | | model: null, |
| | | id: '', |
| | | modelName: null, |
| | | parentLevel: '', |
| | | parentId: '', |
| | | }, |
| | | laboratory: [], |
| | | addLoad: false, |
| | |
| | | }; |
| | | }, |
| | | methods: { |
| | | // 修改最子级名字 |
| | | editTreeName(info) { |
| | | this.updateDia = true; |
| | | this.oldModel = info.label; |
| | | }, |
| | | // 拖拽时判定目标节点能否被放置 |
| | | // 'prev'、'inner' 和 'next',前、插入、后 |
| | | allowDrop(draggingNode, dropNode, type) { |
| | |
| | | this.upIndex++; |
| | | }, |
| | | handleNodeClick(val, node, el) { |
| | | //树的值 |
| | | if (node.childNodes.length === 0) { |
| | | this.isShowCopy = true; |
| | | } else { |
| | | this.isShowCopy = false; |
| | | } |
| | | // 判断是否为叶子节点 |
| | | this.isShowCopy = node.childNodes.length === 0; |
| | | |
| | | // 更新父节点信息 |
| | | this.addOb.parentLevel = node.data.level; |
| | | this.addOb.parentId = node.data.value; |
| | | this.addOb.id = node.data.value; |
| | | |
| | | // 初始化分页相关变量 |
| | | this.total = 0; |
| | | this.currentPage = 1; |
| | | this.selectTree = ""; |
| | | this.getNodeParent(node); |
| | | this.selectTree = this.selectTree.replace(" - ", ""); |
| | | let data = this.selectTree.split(" - "); |
| | | let data2 = ""; |
| | | for (let index = data.length - 1; index >= 0; index--) { |
| | | data2 += " - " + data[index]; |
| | | } |
| | | this.selectTree = data2.replace(" - ", ""); |
| | | if (node.childNodes.length === 0) { |
| | | |
| | | // 拼接树路径 |
| | | this.selectTree = this.getReversedTreePath(node); |
| | | |
| | | // 如果是叶子节点,调用特定方法 |
| | | if (this.isShowCopy) { |
| | | this.selectsStandardMethodByFLSSM(); |
| | | } |
| | | let trees = this.selectTree.split(" - "); |
| | | this.addOb.factory = trees[0]; |
| | | this.addOb.laboratory = trees[1]; |
| | | this.addOb.sampleType = trees[2]; |
| | | this.addOb.sample = trees[3]; |
| | | }, |
| | | getNodeParent(val) { |
| | | if (val.parent != null) { |
| | | if (val.data.children === null) { |
| | | this.selectTree += " - " + val.label + " - " + "null"; |
| | | } else { |
| | | this.selectTree += " - " + val.label; |
| | | |
| | | /** |
| | | * 获取反向拼接的树路径字符串 |
| | | * @param {Object} node - 当前节点 |
| | | * @returns {string} - 反向拼接的树路径 |
| | | */ |
| | | getReversedTreePath(node) { |
| | | const pathParts = []; |
| | | |
| | | // 递归获取父节点路径 |
| | | const collectParentLabels = (currentNode) => { |
| | | if (currentNode && currentNode.label) { |
| | | pathParts.unshift(currentNode.label); // 将当前节点标签插入到数组开头 |
| | | } |
| | | this.getNodeParent(val.parent); |
| | | } |
| | | if (currentNode.parent) { |
| | | collectParentLabels(currentNode.parent); // 递归处理父节点 |
| | | } |
| | | }; |
| | | |
| | | collectParentLabels(node); |
| | | |
| | | // 拼接路径并返回 |
| | | return pathParts.join(" - "); |
| | | }, |
| | | remove(node, data) { |
| | | this.$confirm("是否删除该层级", "提示", { |
| | | type: "error", |
| | | }) |
| | | .then(() => { |
| | | // this.treeLoad = true |
| | | }).then(() => { |
| | | this.selectTree = ""; |
| | | // 拼接树路径 |
| | | this.selectTree = this.getReversedTreePath(node); |
| | | delStandardTree({ tree: this.selectTree }).then((res) => { |
| | | this.$message.success("已删除"); |
| | | let arr = this.selectTree.split(" - "); |
| | | this.deleteStandard(this.list, arr[arr.length - 1]); |
| | | this.selectTree = ""; |
| | | this.getNodeParent(node); |
| | | this.selectTree = this.selectTree.replace(" - ", ""); |
| | | let data = this.selectTree.split(" - "); |
| | | let data2 = ""; |
| | | for (let index = data.length - 1; index >= 0; index--) { |
| | | data2 += " - " + data[index]; |
| | | } |
| | | this.selectTree = data2.replace(" - ", ""); |
| | | delStandardTree({ tree: this.selectTree }).then((res) => { |
| | | this.$message.success("已删除"); |
| | | let arr = this.selectTree.split(" - "); |
| | | this.deleteStandard(this.list, arr[arr.length - 1]); |
| | | this.selectTree = ""; |
| | | this.standardList = []; |
| | | this.productList = []; |
| | | }); |
| | | this.standardList = []; |
| | | this.productList = []; |
| | | }) |
| | | .catch((e) => { }); |
| | | }).catch((e) => { }); |
| | | }, |
| | | deleteStandard(arr, label) { |
| | | arr.forEach((item, index) => { |
| | |
| | | this.standardEnum = data; |
| | | }); |
| | | }, |
| | | // 打开新增弹框 |
| | | openAddDia () { |
| | | this.addDia = true |
| | | this.addOb.modelName = '' |
| | | }, |
| | | // 提交分类添加 |
| | | addStandardTree() { |
| | | if (this.addOb.sampleType == null || this.addOb.sampleType == "") { |
| | | this.$message.error("对象不存在"); |
| | | return; |
| | | } |
| | | if (this.addOb.model == null || this.addOb.model == "") { |
| | | if (this.addOb.modelName == null || this.addOb.modelName == "") { |
| | | this.$message.error("请填写型号"); |
| | | return; |
| | | } |
| | | this.addLoad = true; |
| | | addStandardTree(this.addOb) |
| | | .then((res) => { |
| | | this.$message.success("添加成功"); |
| | | this.addDia = false; |
| | | this.list |
| | | .find((a) => a.label == this.addOb.factory) |
| | | .children.find((a) => a.label == this.addOb.laboratory) |
| | | .children.find((a) => a.label == this.addOb.sampleType) |
| | | .children.find((a) => a.label == this.addOb.sample) |
| | | .children.push({ |
| | | code: "[5]", |
| | | label: this.addOb.model, |
| | | value: this.addOb.model, |
| | | }); |
| | | this.addLoad = false; |
| | | }) |
| | | .catch((e) => { |
| | | this.addDia = false; |
| | | this.addLoad = false; |
| | | }); |
| | | delete this.addOb.id; |
| | | addStandardTree(this.addOb).then((res) => { |
| | | this.$message.success("添加成功"); |
| | | this.addOb.modelName = ""; |
| | | this.addDia = false; |
| | | this.selectStandardTreeList(); |
| | | this.addLoad = false; |
| | | }).catch((e) => { |
| | | this.addLoad = false; |
| | | }); |
| | | }, |
| | | // 修改型号 |
| | | // 打开修改名字弹框 |
| | | editTreeName(info) { |
| | | this.updateDia = true; |
| | | this.addOb.modelName = info.label; |
| | | }, |
| | | // 提交修改型号 |
| | | updateStandardTree() { |
| | | if (this.addOb.sampleType == null || this.addOb.sampleType == "") { |
| | | this.$message.error("对象不存在"); |
| | | return; |
| | | } |
| | | if (this.addOb.model == null || this.addOb.model == "") { |
| | | if (this.addOb.modelName == null || this.addOb.modelName == "") { |
| | | this.$message.error("请填写型号"); |
| | | return; |
| | | } |
| | | this.addOb.oldModel = this.oldModel; |
| | | this.updateLoad = true; |
| | | updateStandardTree(this.addOb) |
| | | .then((res) => { |
| | | this.$message.success("添加成功"); |
| | | this.$tab.refreshPage(); |
| | | // this.selectStandardTreeList(); |
| | | this.updateDia = false; |
| | | this.updateLoad = false; |
| | | }) |
| | | .catch((e) => { |
| | | this.updateDia = false; |
| | | this.updateLoad = false; |
| | | }); |
| | | delete this.addOb.parentLevel; |
| | | delete this.addOb.parentId; |
| | | updateStandardTree(this.addOb).then((res) => { |
| | | this.$message.success("添加成功"); |
| | | this.selectStandardTreeList(); |
| | | this.addOb.modelName = ""; |
| | | this.updateDia = false; |
| | | this.updateLoad = false; |
| | | }).catch((e) => { |
| | | this.updateLoad = false; |
| | | }); |
| | | }, |
| | | selectsStandardMethodByFLSSM() { |
| | | this.tableLoad = true; |