From 33de1cf5576373b99dc2a6ed4be097f4d6ad0892 Mon Sep 17 00:00:00 2001 From: lkk <364857242@qq.com> Date: 星期三, 30 七月 2025 10:58:03 +0800 Subject: [PATCH] 1111 --- src/views/system/package/index.vue | 141 +++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 129 insertions(+), 12 deletions(-) diff --git a/src/views/system/package/index.vue b/src/views/system/package/index.vue index 020d483..6bad63d 100644 --- a/src/views/system/package/index.vue +++ b/src/views/system/package/index.vue @@ -118,8 +118,12 @@ <el-form-item label="鎶樻墸"> <el-input-number style="width: 150px" v-model="youhui" :precision="2" :step="0.1" :max="10" :min="0.1" @change="debounceNumberChange" :debounce="3000"></el-input-number> </el-form-item> - <el-form-item label="鐜颁环" prop="xianprice"> + <!-- <el-form-item label="鐜颁环" prop="xianprice"> <el-input v-model="form.xianprice" placeholder="鐜颁环" clearable style="width: 140px" @input="changeXianjia" @blur="numberChangeXianPrice(youhui, youhui)" type="number" :debounce="3000" min="0"/> + </el-form-item> --> + <el-form-item label="鐜颁环" prop="xianprice"> + <el-input v-model="form.xianprice" placeholder="鐜颁环" clearable style="width: 140px" @input="changeXianjia" + type="number" :debounce="3000" min="0"/> </el-form-item> <el-form-item label="鍏抽敭瀛�" prop="keywords"> <el-select multiple v-model="form.keywords" placeholder="璇烽�夋嫨鍏抽敭瀛�" style="width: 160px" @change="sel" filterable clearable> @@ -147,7 +151,7 @@ <el-row style="display: flex; width: 1300px"> <el-col> <div style="text-align: center; margin-bottom: 10px; margin-top: 10px">椤圭洰鍒楄〃</div> - <el-input placeholder="杈撳叆鍏抽敭瀛楄繘琛岃繃婊�" v-model="filterText" @input="debounceFilter" clearable /> + <el-input placeholder="杈撳叆鍏抽敭瀛楄繘琛岃繃婊�" v-model="queryParams1.nr" @input="handleFilterInput" clearable /> <div class="tab3" style="height: 365px"> <el-tree class="filter-tree" @@ -158,6 +162,7 @@ node-key="proId" @check-change="handleCurrentChecked" :default-checked-keys="checkedkey" + :filter-node-method="filterNode" ref="tree" :render-content="renderContent" > @@ -291,6 +296,7 @@ page: 1, pageSize: 30, nr: "", + xb: "", }, form: { xianprice: null, @@ -315,11 +321,12 @@ this.getCategory(); }, methods: { - debounceFilter() { - clearTimeout(this.debounceTimer); - this.debounceTimer = setTimeout(() => { - this.filterTree(); - }, 600); + handleFilterInput() { + this.queryParams1.page = 1; + this.getDataList(); + this.$nextTick(() => { + this.$refs.tree.setCheckedKeys(this.checkedNodes); + }); }, filterTree() { if (!this.filterText) { @@ -328,6 +335,15 @@ } const filterTextLower = this.filterText.toLowerCase(); this.filteredTreeData = this.filterNodes(this.originalTreeData, filterTextLower); + }, + filterNode(value, data) { + if (!value) return true; + console.log(value, 6666); + + return ( + data.proName.indexOf(value) !== -1 || + (data.proEngName && data.proEngName.indexOf(value) !== -1) + ); }, filterNodes(nodes, filterText) { return nodes.filter(node => { @@ -413,9 +429,30 @@ this.keywordList = response.rows; }); }, - sel(val) { + /* sel(val) { let id = val; this.keys = id.join(","); + }, */ + sel(val) { + const maleId = "4"; // 鈥滅敺鈥濈殑 ID + const femaleId = "5"; // 鈥滃コ鈥濈殑 ID + let selectedIds = [...val]; // 澶嶅埗褰撳墠閫変腑鐨� ID 鏁扮粍 + + // 瀹炵幇鈥滅敺鈥濆拰鈥滃コ鈥濅簰鏂ラ�昏緫 + if (selectedIds.includes(maleId) && selectedIds.includes(femaleId)) { + selectedIds = selectedIds.slice(-1); // 淇濈暀鏈�鍚庨�変腑鐨勪竴涓� + this.$message.warning("鈥滅敺鈥濆拰鈥滃コ鈥濆叧閿瓧浜掓枼锛屽彧鑳介�夋嫨涓�涓紒"); + } + + // 鏇存柊 form.keywords 鍜� keys + this.form.keywords = selectedIds; + this.keys = selectedIds.join(","); + + // 璋冪敤 getDataList锛屼紶閫掓墍鏈夐�変腑鐨勫叧閿瓧 ID锛堥�楀彿鍒嗛殧锛� + // this.getDataList({ xb: this.keys }); + this.queryParams1.xb = this.keys; // 馃憟 鏇存柊鏌ヨ鍙傛暟 + this.queryParams1.page = 1; // 馃憟 鍒囨崲鏉′欢鏃堕噸缃〉鐮� + this.getDataList(); // 涓嶉渶瑕佸啀浼犲弬浜� }, getCategory() { this.loading = true; @@ -661,9 +698,10 @@ </span> ); }, - getDataList() { + getDataList(params = {}) { this.loading = true; - search(this.queryParams1).then((response) => { + const query = { ...this.queryParams1, ...params }; + search(query).then((response) => { this.Treedata = response.data.list; this.total1 = response.data.total; this.pics = this.DataList.reduce((total, item) => total + item.priceOrd, 0); @@ -672,8 +710,8 @@ this.$nextTick(() => { this.$refs.tree.setCheckedKeys(this.checkedNodes); this.initializing = false; - this.loading = false; }); + this.loading = false; }).catch(() => { this.loading = false; }); @@ -777,7 +815,7 @@ this.DataList = this.DataList.filter((item) => item.proParentId !== row.proParentId); this.TotalPrice1 = this.DataList.reduce((sum, item) => sum + item.priceOrd, 0); }, - submitForm() { + /* submitForm() { this.form.limits = this.youhui; this.form.price = this.pics; this.form.priceNow = this.form.xianprice; @@ -813,6 +851,85 @@ this.open = false; this.getList(); }); + }, */ + submitForm() { + // 妫�鏌ョ幇浠锋槸鍚﹀彂鐢熷彉鍖� + if (this.form.xianprice !== this.lastXianPrice) { + this.$confirm("纭畾淇敼鎵�鏈夊瓙椤圭殑鎶樻墸鍚楋紵", "鎻愮ず", { + confirmButtonText: "纭畾", + cancelButtonText: "鍙栨秷", + type: "warning", + }).then(() => { + // 鏇存柊鎵�鏈夊瓙椤圭殑鎶樻墸 + this.youhui = (Math.floor((this.form.xianprice / this.pics) * 100) / 100) * 10; + let totalYsprice = new Big(0); + this.DataList.forEach((item) => { + item.limits = this.youhui; + const ordPrice = new Big(item.priceOrd); + const discount = new Big(item.limits); + const result = ordPrice.times(discount.div(10)); + item.priceNow = result.toNumber(); + totalYsprice = totalYsprice.plus(new Big(item.priceNow)); + }); + + if (!totalYsprice.eq(this.form.xianprice)) { + const diff = new Big(this.form.xianprice).minus(totalYsprice); + if (this.DataList.length > 0) { + const lastItem = this.DataList[this.DataList.length - 1]; + const newYsPrice = new Big(lastItem.priceNow).plus(diff).toNumber(); + this.$set(this.DataList[this.DataList.length - 1], "priceNow", newYsPrice); + } + } + + // 淇濆瓨鏁版嵁 + return this.saveData(); + }).catch(() => { + // 鐢ㄦ埛鍙栨秷鎿嶄綔锛屾仮澶嶅師鏉ョ殑鐜颁环 + this.form.xianprice = this.lastXianPrice; + }); + } else { + // 鐜颁环娌℃湁鍙樺寲锛岀洿鎺ヤ繚瀛� + this.saveData(); + } + }, + // 鏂板涓�涓柟娉曞鐞嗕繚瀛橀�昏緫 + saveData() { + this.form.limits = this.youhui; + this.form.price = this.pics; + this.form.priceNow = this.form.xianprice; + if (this.keys) { + this.form.keywords = this.keys; + } + let packageProjects = []; + this.DataList.forEach((item) => { + packageProjects.push({ + proName: item.proName, + proId: item.proId, + priceNow: item.priceNow, + limits: item.limits, + priceOrd: item.priceOrd, + }); + }); + let data = { + pacName: this.form.pacName, + limits: this.form.limits, + pacStatus: this.form.pacStatus, + packageProjects: packageProjects, + newPrice: this.form.xianprice, + price: this.pics, + pacId: this.form.pacId || null, + isOnSale: this.form.isOnSale, + sort: this.form.sort, + retailPrice: this.form.retailPrice, + tjCategory: this.form.tjCategory, + pacRemark: this.form.pacRemark, + detail: this.form.detail, + }; + + return saveOreditTjPacNew(data).then((res) => { + this.open = false; + this.getList(); + }); }, handleDelete(row) { const pacIds = row.pacId || this.ids; -- Gitblit v1.8.0