From 410d5bf8bc5ef56be822105e71dac02f43aa9463 Mon Sep 17 00:00:00 2001 From: wwl <xchao828@163.com> Date: 星期四, 16 一月 2025 17:29:13 +0800 Subject: [PATCH] 1 --- src/views/system/tijian/index.vue | 218 +++++++++++++++++++++++++++--------------------------- 1 files changed, 110 insertions(+), 108 deletions(-) diff --git a/src/views/system/tijian/index.vue b/src/views/system/tijian/index.vue index fc8f1dd..f082f7c 100644 --- a/src/views/system/tijian/index.vue +++ b/src/views/system/tijian/index.vue @@ -929,7 +929,7 @@ style="width: 150px" ></el-input> </el-form-item> - <el-form-item label="浼樻儬"> + <el-form-item label="鎶樻墸"> <!-- {{ discount }} --> <el-input-number ref="inputNumber" @@ -1441,6 +1441,7 @@ }, data() { return { + isSubmitting: false, open1: false, filterage: "", checkedkeys: [], @@ -1502,7 +1503,6 @@ taocan: false, top: true, value: "2", - getInfodis: "", srcUrl: "", hides: false, hide: true, @@ -1642,7 +1642,7 @@ cusIsvip: null, }, // 娣诲姞 - + lastXianPrice: 0, // 琛ㄥ崟鍙傛暟 // 琛ㄥ崟鍙傛暟 obj: {}, @@ -1777,13 +1777,17 @@ }) .catch(() => {}); }, + handleManualChange(row) { + console.log("杩欐槸涓诲姩鍑哄彂鐨�"); + this.updateProPrice(row); + }, validateDiscount(row) { - if (row.discount > 10) { - row.discount = 10; // 寮哄埗灏嗗�艰缃负鏈�澶у�� - } else if (row.discount < 0) { - row.discount = 0; // 寮哄埗灏嗗�艰缃负鏈�灏忓�� + console.log("杞簡") + if (this.TotalPrice !== undefined && !isNaN(this.TotalPrice) && this.TotalPrice !== this.lastXianPrice) { + console.log("杩涘叆浜�") + this.updateProPrice1(row); + this.lastXianPrice = this.TotalPrice; } - this.updateProPrice(row); // 鏇存柊浠锋牸鎴栧叾浠栭�昏緫 }, isAll(value) { return value === "" || value === null; @@ -1801,7 +1805,33 @@ this.discount = (Math.floor((this.TotalPrice / this.TotalPrice1) * 100) / 100) * 10; }, + updateProPrice1(row) { + console.log("杩涘叆浜�1") + const ordPrice = new Big(row.ordPrice); + const discount = new Big(row.discount); + const result = ordPrice.times(discount.div(10)); + row.nowPrice = result.toNumber(); + const totalYsPrice = this.tableData1.reduce((sum, item) => { + return sum.plus(new Big(item.nowPrice || '0')); + }, new Big(0)); + const totalYsPriceNum = totalYsPrice.toNumber(); + if (this.TotalPrice !== undefined && !isNaN(this.TotalPrice)) { + const xianPrice = new Big(this.TotalPrice); + const diff = xianPrice.minus(totalYsPriceNum); + if (!diff.eq(0) && this.tableData1.length > 0) { + const lastItem = this.tableData1[this.tableData1.length - 1]; + const newYsPrice = new Big(lastItem.nowPrice).plus(diff).toNumber(); + this.$set(this.tableData1[this.tableData1.length - 1], 'nowPrice', newYsPrice); + } + } + // Update youhui calculation + if (this.TotalPrice1 !== 0 && this.TotalPrice !== 0) { + this.discount = (Math.floor((this.TotalPrice / this.TotalPrice1) * 100) / 100) * 10; + } else { + this.discount = 0; + } + }, openname() { this.$refs.bbb.open = true; this.$refs.bbb.title = "鎼滅储濮撳悕"; @@ -1925,11 +1955,9 @@ }, getList1() { getInfo().then((response) => { - this.getInfodis = response.user.discount; + this.hospName = response.hospName; - if (this.getInfodis === null) { - this.isfalse = true; - } + }); getIsRequired().then((response) => { this.showHidden = response.data; @@ -2154,10 +2182,8 @@ /** 鏌ヨ淇℃伅鍒楄〃 */ getList() { getInfo().then((response) => { - this.getInfodis = response.user.discount; - if (this.getInfodis === null) { - this.isfalse = true; - } + + }); let cusSex = this.form.cusSex; //鍏ㄩ儴濂楅 @@ -2241,10 +2267,7 @@ }) .then(() => { this.discount = currentValue; - if (this.discount < this.getInfodis) { - this.discount = this.getInfodis; - // this.$modal.msgError(`璇ヤ汉鍛樻渶楂樹紭鎯犳潈闄愪负${this.getInfodis}鎶榒); - } + this.tableData1.forEach((item) => { item.discount = this.discount; const ordPrice = new Big(item.ordPrice); @@ -3355,118 +3378,99 @@ var cusId = this.form.cusIdcard; } else { this.$message.warning("璇峰厛濉啓淇℃伅锛屽啀閫変綋妫�鍐呭"); + return; // 濡傛灉娌℃湁韬唤璇佸彿鐮侊紝鍋滄鎵ц } + let _this = this; + + // 鍒濆鍖栧彉閲� + this.isSubmitting = true; // 寮�濮嬫彁浜ゆ椂璁剧疆鏍囧織 + this.TotalPrice1 = 0; // 鍒濆鍖栧簲鏀堕噾棰� + this.TotalPrice = 0; // 鍒濆鍖栧疄鏀堕噾棰� + this.discount = 10; // 鍒濆鍖栨姌鎵d负10锛�100%锛� + + // 鍒ゆ柇鏄惁鏈夐�変腑鐨勫椁� if (this.tableData.length != 0) { - this.tableData.forEach((item) => { - _this.pacId = item.pacId; - }); + _this.pacId = this.tableData[0].pacId; } else { _this.pacId = ""; } + this.proIds = []; - if (this.DataList.length != 0) { - this.DataList.forEach((item) => { + + // 澶勭悊閫変腑鐨勯」鐩� + const newItemsToAdd = []; + const allItems = [...this.DataList, ...this.DataLists]; // 鍚堝苟鎵�鏈夐」鐩� + + allItems.forEach((item) => { + if (!this.proIds.includes(item.proId)) { + newItemsToAdd.push(item); this.proIds.push(item.proId); - }); - } - if (this.DataLists.length != 0) { - this.DataLists.forEach((item) => { - this.proIds.push(item.proId); - }); - } + } + }); + + // 鍑嗗鏁版嵁 let data = { cusId, pacId: _this.pacId, proIds: this.proIds, }; + + // 鏍规嵁浣撴绫诲瀷閫夋嫨涓嶅悓鐨勫鐞嗘柟娉� if (this.form.tjType == 1) { tuantiqueren(data).then((response) => { if (response.code == 200) { - let cusId = this.form.cusIdcard; - this.proIds = []; - getTransitionList1(cusId).then((response) => { - this.tableData1 = response.data; - this.TotalPrice1 = 0; - if (this.tableData1) { - this.tableData1.forEach((item) => { - if (item.tjCategory != null) { - this.tjCategory = item.tjCategory; - } - if (item.pacName == "鍗曢」") { - item.list.forEach((item9) => { - this.treeList.push(item9.proId); - }); - } - this.TotalPrice = 0; - this.TotalPrice1 += item.ordPrice; - this.TotalPrice += item.nowPrice; - - this.pacName = item.pacName; - }); - - this.TotalPrice = this.tableData1.reduce((sum, item) => { - return sum.plus(new Big(item.nowPrice || "0")); - }, new Big(0)); - this.discount = - (Math.floor((this.TotalPrice / this.TotalPrice1) * 100) / - 100) * - 10; - this.list1 = false; - this.list3 = true; - this.list2 = false; - } else { - this.list1 = true; - this.TotalPrice = 0; - } - }); - } else { + this.processOrderItems(cusId); } + this.isSubmitting = false; // 鎻愪氦瀹屾垚鍚庨噸缃爣蹇� + }).catch(() => { + this.isSubmitting = false; // 纭繚鍦ㄩ敊璇儏鍐典笅涔熼噸缃爣蹇� }); } else { getaddtTransition(data).then((response) => { if (response.code == 200) { - let cusId = this.form.cusIdcard; - this.proIds = []; - getTransitionList1(cusId).then((response) => { - this.tableData1 = response.data; - this.TotalPrice1 = 0; - if (this.tableData1) { - this.tableData1.forEach((item) => { - if (item.tjCategory != null) { - this.tjCategory = item.tjCategory; - } - if (item.pacName == "鍗曢」") { - item.list.forEach((item9) => { - this.treeList.push(item9.proId); - }); - } - this.TotalPrice = 0; - this.TotalPrice1 += item.ordPrice; - this.TotalPrice += item.nowPrice; - - this.pacName = item.pacName; - }); - this.discount = - (Math.floor((this.TotalPrice / this.TotalPrice1) * 100) / - 100) * - 10; - - this.list1 = false; - this.list3 = true; - this.list2 = false; - } else { - this.list1 = true; - this.TotalPrice = 0; - } - }); - } else { + this.processOrderItems(cusId); } + this.isSubmitting = false; // 鎻愪氦瀹屾垚鍚庨噸缃爣蹇� + }).catch(() => { + this.isSubmitting = false; // 纭繚鍦ㄩ敊璇儏鍐典笅涔熼噸缃爣蹇� }); } + this.taocan = false; this.defaultKeys = []; this.DataLists = []; + }, + + // 澶勭悊璁㈠崟椤圭洰 + processOrderItems(cusId) { + getTransitionList1(cusId).then((response) => { + this.tableData1 = response.data; + if (this.tableData1) { + this.tableData1.forEach((item) => { + if (item.tjCategory != null) { + this.tjCategory = item.tjCategory; + } + if (item.pacName == "鍗曢」") { + item.list.forEach((item9) => { + this.treeList.push(item9.proId); + }); + } + this.TotalPrice1 += item.ordPrice || 0; // 绱姞搴旀敹閲戦 + this.TotalPrice += item.nowPrice || 0; // 绱姞瀹炴敹閲戦 + }); + // 璁$畻鎶樻墸 + this.discount = this.TotalPrice1 > 0 ? + (Math.floor((this.TotalPrice / this.TotalPrice1) * 100) / 100) * 10 : 0; + + this.list1 = false; + this.list3 = true; + this.list2 = false; + } else { + this.list1 = true; + this.TotalPrice = 0; + } + }); }, submitCheckinfee() { let _this = this; @@ -3632,9 +3636,7 @@ } this.discount = (this.formInline.paidIn / this.formInline.price) * 10; - if (this.discount <= this.getInfodis) { - this.discount = this.getInfodis; - } + } else { this.discount = 10; this.formInline.paidIn = "0.00"; -- Gitblit v1.8.0