| | |
| | | // 是否显示弹出层 |
| | | open: false, |
| | | Seachopen: false, |
| | | checkedNodes: [], |
| | | pacId: "", |
| | | // 总条数 |
| | | total: 0, |
| | |
| | | |
| | | /** 删除按钮操作 */ |
| | | handleDelete1(row) { |
| | | this.DataList = this.DataList.filter((item) => item.proId !== row.proId); |
| | | const tree = this.$refs.tree; |
| | | const node = tree.getNode(row.proId); // 根据节点的唯一标识获取节点对象 |
| | | if (node) { |
| | | node.setChecked(false); // 取消选中状态 |
| | | this.DataList = this.DataList.filter(item => item.proId !== row.proId); |
| | | // 从 checkedNodes 中移除 |
| | | const index = this.checkedNodes.indexOf(row.proId); |
| | | if (index > -1) { |
| | | this.checkedNodes.splice(index, 1); |
| | | } |
| | | const tree = this.$refs.tree; |
| | | const node = tree.getNode(row.proId); |
| | | if (node) { |
| | | node.setChecked(false); |
| | | } |
| | | this.updateTotalPrice(); |
| | | }, |
| | | |
| | | getSelectValue(val) { |
| | | this.form.tjProjectList.forEach((formitem) => { |
| | | if (formitem.proName == val) { |
| | |
| | | search(this.queryParams1).then((response) => { |
| | | this.Treedata = response.data.list; // 更新树形数据 |
| | | this.total1 = response.data.total; // 更新总条数 |
| | | this.pics = this.DataList.reduce((total, item) => total + item.priceOrd, 0); |
| | | |
| | | const selectedIds = this.DataList.map((item) => item.proId); |
| | | // 更新 checkedkey 使得选中的项目保持选中状态 |
| | | this.checkedkey = selectedIds.filter((id) => |
| | | this.Treedata.some((item) => item.proId === id) |
| | | ); |
| | | |
| | | this.pics = this.DataList.reduce( |
| | | (total, item) => total + item.priceOrd, |
| | | 0 |
| | | ); |
| | | // 确保在数据加载后保持选中状态 |
| | | this.$nextTick(() => { |
| | | this.$refs.tree.setCheckedKeys(this.checkedNodes); |
| | | }); |
| | | }); |
| | | this.loading = false; |
| | | }, |
| | |
| | | // }); |
| | | // }, |
| | | handleFilterInput() { |
| | | this.queryParams.page = 1; // 搜索时重置为第一页 |
| | | this.queryParams1.page = 1; // 搜索时重置为第一页 |
| | | this.getDataList(); // 调用接口获取数据 |
| | | // 在过滤后,重新设置选中状态 |
| | | this.$nextTick(() => { |
| | | this.$refs.tree.setCheckedKeys(this.checkedNodes); |
| | | }); |
| | | }, |
| | | |
| | | // 分页事件 |
| | |
| | | this.getDataList(); // 调用接口获取数据 |
| | | }, |
| | | |
| | | handleCurrentChecked(data, checked, checkedNodes) { |
| | | this.dataObj = data; |
| | | this.checkedObj = checked; |
| | | |
| | | handleCurrentChecked(data, checked, indeterminate) { |
| | | if (checked) { |
| | | // 检查是否已存在于 DataL |
| | | // 如果已选列表中不存在此项目,则添加 |
| | | if (!this.DataList.some(item => item.proId === data.proId)) { |
| | | this.DataList.push({ |
| | | proId: data.proId, |
| | | proName: data.proName, |
| | | priceOrd: data.proPrice, // 原价,确保赋值正确 |
| | | priceOrd: data.proPrice, |
| | | limits: 10, |
| | | priceNow: data.proPrice, |
| | | priceNow: data.proPrice |
| | | }); |
| | | } |
| | | // 添加到 checkedNodes 数组 |
| | | if (!this.checkedNodes.includes(data.proId)) { |
| | | this.checkedNodes.push(data.proId); |
| | | } |
| | | } else { |
| | | let index = this.DataList.findIndex( |
| | | (item) => item.proId === data.proId |
| | | ); |
| | | if (index !== -1) { |
| | | this.DataList.splice(index, 1); |
| | | // 取消选中时,从DataList中移除 |
| | | this.DataList = this.DataList.filter(item => item.proId !== data.proId); |
| | | // 从 checkedNodes 中移除 |
| | | const index = this.checkedNodes.indexOf(data.proId); |
| | | if (index > -1) { |
| | | this.checkedNodes.splice(index, 1); |
| | | } |
| | | } |
| | | this.pics = 0; |
| | | this.TotalPrice1 = 0; |
| | | this.DataList.forEach((item) => { |
| | | this.pics += item.priceOrd; |
| | | this.form.counterPrice += item.priceOrd; |
| | | this.TotalPrice1 += item.priceOrd; // 可以根据需要改成优惠价 `priceNow` |
| | | }); |
| | | }, |
| | | |
| | | // 更新优惠价和总价 |
| | | this.updateTotalPrice(); |
| | | }, |
| | | updateTotalPrice() { |
| | | // 计算所有项目的总优惠价 |
| | | this.form.xianprice = this.DataList.reduce((sum, item) => { |
| | | return sum.plus(new Big(item.priceNow || "0")); |
| | | }, new Big(0)).toNumber(); |
| | | |
| | | // 计算原价总和 |
| | | this.pics = this.DataList.reduce((total, item) => total + item.priceOrd, 0); |
| | | }, |
| | | spliceData() { |
| | | for (var i = 0; i < this.DataList.length; i++) { |
| | | for (var j = i + 1; j < this.DataList.length; j++) { |