From 5e6bca745ee55b6c71ccddcb753383c2c53e5958 Mon Sep 17 00:00:00 2001 From: qx <1084500556@qq.com> Date: 星期一, 28 七月 2025 17:37:52 +0800 Subject: [PATCH] qx --- src/views/hosp/order/index.vue | 174 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 168 insertions(+), 6 deletions(-) diff --git a/src/views/hosp/order/index.vue b/src/views/hosp/order/index.vue index 454434d..412f016 100644 --- a/src/views/hosp/order/index.vue +++ b/src/views/hosp/order/index.vue @@ -589,19 +589,33 @@ </el-tabs> </div> + <div class="grid-content bg-purple"> <div style="text-align: center; margin-bottom: 10px; margin-top: 9px"> 宸查�夐」鐩垪琛� </div> <el-table :data="DataList3" border style="width: 100%; table-layout: fixed" height="560" :span-method="objectspanmethod"> - <el-table-column prop="propinName" label="妫�鏌ラ」鐩�" width="200px" :show-overflow-tooltip="true"> + <el-table-column prop="propinName" label="妫�鏌ラ」鐩�" width="160px" :show-overflow-tooltip="true"> </el-table-column> - <el-table-column prop="proName" label="鏄庣粏椤圭洰" width="200px" :show-overflow-tooltip="true"> + <el-table-column prop="proName" label="鏄庣粏椤圭洰" width="160px" :show-overflow-tooltip="true"> </el-table-column> <el-table-column prop="sl" label="鏁伴噺" width="56px"> </el-table-column> <el-table-column prop="proPrice" label="鍘熶环" width="56px"> + </el-table-column> + <el-table-column label="鎶樻墸" width="150px"> + <template slot-scope="scope"> + <!-- @input="validateDiscount(scope.row)" --> + <el-input-number v-model.number="scope.row.discount" @change="handleManualChange(scope.row)" + placeholder="杈撳叆鎶樻墸" size="small" type="number" :precision="1" :step="0.1" :max="10" :min="0"> + </el-input-number> + </template> + </el-table-column> + <el-table-column prop="nowPrice" label="鐜颁环"> + <template slot-scope="scope"> + {{ scope.row.nowPrice ? scope.row.nowPrice.toFixed(2) : scope.row.nowPrice }} + </template> </el-table-column> <el-table-column label="鎿嶄綔" align="center" class-name="small-padding fixed-width" width="50px"> @@ -629,14 +643,24 @@ <el-input placeholder="鍘熶环" :value="TotalPrice1" disabled style="width: 90px"></el-input> </el-form-item> - <!-- 鎶樻墸璁惧畾 --> - <el-form-item label="鎶樻墸" style="display: flex"> + <!-- 鎶樻墸璁惧畾 --> + <!-- <el-form-item label="鎶樻墸" style="display: flex"> <el-input style="width: 90px" type="number" v-model="discount" :value="discount"></el-input> + </el-form-item> --> + + <el-form-item label="鎶樻墸"> + <!-- {{ discount }} --> + <el-input-number ref="inputNumber" style="width: 150px" v-model="discount" :precision="1" :step="0.1" + :max="10" :min="0" @change="debounceNumberChange"></el-input-number> </el-form-item> <!-- 搴斾粯閲戦 --> - <el-form-item label="搴斾粯" style="display: flex"> + <!-- <el-form-item label="搴斾粯" style="display: flex"> <el-input placeholder="搴斾粯閲戦" :value="TotalPrice1 * (discount / 10)" style="width: 90px"></el-input> + </el-form-item> --> + <el-form-item label="搴斾粯"> + <el-input placeholder="搴斾粯閲戦" v-model="TotalPrice" style="width: 206px" @input="changeXianjia" + @blur="numberChangeXianPrice(discount, discount)" /> </el-form-item> <!-- 浠樻绫诲瀷 --> @@ -1008,6 +1032,7 @@ TotalPrice1: 0, TotalPrice6: 0, TotalPrice7: 0, + TotalPrice: 0, numberList: [], dialogVisible: false, CheckBox: {}, @@ -2229,7 +2254,119 @@ } } }, - handleDel(row) { + handleManualChange(row) { + this.updateProPrice(row); + }, + + updateProPrice(row) { + if (row.proPrice == 0) { + row.discount = 10 + return + } else { + const ordPrice = new Big(row.proPrice); + const discount = new Big(row.discount); + const result = ordPrice.times(discount.div(10)); // ordPrice * (discount / 10) + row.nowPrice = result.toNumber(); + this.TotalPrice = this.DataList3.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; + } + }, + + debounceNumberChange(currentValue, oldValue) { + clearTimeout(this.debounceTimer); + this.debounceTimer = setTimeout(() => { + this.numberChange(currentValue, oldValue); + }, 300); + }, + // 鎶樻墸 + numberChange(currentValue, oldValue) { + this.$confirm("纭畾淇敼鎵�鏈夊瓙椤圭殑鎶樻墸鍚楋紵", "鎻愮ず", { + confirmButtonText: "纭畾", + cancelButtonText: "鍙栨秷", + type: "warning", + }) + .then(() => { + this.discount = currentValue; + this.DataList3.forEach((item) => { + item.discount = this.discount; + const ordPrice = new Big(item.proPrice.toString()); + const discount = new Big(item.discount.toString()); + const result = ordPrice.times(discount.div(10)); + item.nowPrice = result.toNumber(); + // this.TotalPrice = this.DataList3.reduce((sum, item) => { + // return sum.plus(new Big(item.nowPrice || "0")); + // }, new Big(0)); + this.TotalPrice = new Big(this.TotalPrice1 * (this.discount / 10)).toFixed(2) + }); + }) + .catch(() => { + this.discount = oldValue; + }); + }, + + changeXianjia() { + // 鍘熷鎶樻墸鐜囪绠� + if (this.TotalPrice1 !== 0) { + this.discount = + (Math.floor((this.TotalPrice / this.TotalPrice1) * 100) / 100) * 10; + } + }, + numberChangeXianPrice(currentValue, oldValue) { + // 濡傛灉鐜颁环娌℃湁鍙樺寲锛岀洿鎺ヨ繑鍥� + if (this.TotalPrice === this.lastXianPrice || !this.TotalPrice) { + console.log(2222333) + return; + } + this.$confirm("纭畾淇敼鎵�鏈夊瓙椤圭殑鎶樻墸鍚楋紵", "鎻愮ず", { + confirmButtonText: "纭畾", + cancelButtonText: "鍙栨秷", + type: "warning", + }) + .then(() => { + this.discount = currentValue; + // if (this.discount < this.getInfodis) { + // this.discount = this.getInfodis; + // } + let totalYsprice = new Big(0); + console.log(this.DataList3, 11111) + this.DataList3.forEach((item) => { + item.discount = this.discount; + const ordPrice = new Big(item.proPrice); + const discount = new Big(item.discount); + const result = ordPrice.times(discount.div(10)); + item.nowPrice = result.toNumber(); + totalYsprice = totalYsprice.plus(new Big(item.nowPrice)); + }); + if (!totalYsprice.eq(this.TotalPrice)) { + const diff = new Big(this.TotalPrice).minus(totalYsprice); + if (this.tableData1.length > 0) { + const lastItem = this.tableData3[this.tableData3.length - 1]; + const newYsPrice = new Big(lastItem.nowPrice) + .plus(diff) + .toNumber(); + // console.log( + // "hhh", + // this.tableData1[this.tableData1.length - 1].nowPrice, + // newYsPrice + // ); + this.$set( + this.tableData3[this.tableData3.length - 1], + "nowPrice", + newYsPrice + ); + } + } + this.lastXianPrice = this.TotalPrice; + }) + .catch(() => { + this.discount = oldValue; + }); + }, + + handleDel(row) { this.Datalists.forEach((item, index) => { if (item.proId == row.proId) { this.Datalists.splice(index, 1); @@ -2239,8 +2376,18 @@ }); } }); + this.DataList3.forEach((item, index) => { if (item.proId == row.proId) { + let proParentId = item.proParentId + // 鑾峰彇褰撳墠閫変腑鐨勮妭鐐筴ey + const currentCheckedKeys = this.$refs.tree.getCheckedKeys(); + + // 鍒涘缓涓�涓柊鏁扮粍锛岀Щ闄ゆ兂瑕佸彇娑堥�変腑鐨勮妭鐐筴ey锛堣繖閲屽亣璁炬槸1锛� + const newCheckedKeys = currentCheckedKeys.filter(key => key !== proParentId); + + // 浣跨敤setCheckedKeys鏂规硶鏇存柊閫変腑鐘舵�� + this.$refs.tree.setCheckedKeys(newCheckedKeys); this.DataList3.splice(index, 1); this.marryalls = 0; this.DataList3.forEach((item1) => { @@ -2248,21 +2395,36 @@ }); } }); + if (this.DataList3.length == 0) { + this.discount = 10 + this.checkedkey = [] + this.$refs.tree.setCheckedKeys([]) + this.TotalPrice1 = this.marryalls; + this.TotalPrice = new Big(this.TotalPrice1 * (this.discount / 10)) + } else if (this.DataList3.length == 1) { + this.discount = this.DataList3[0].discount + this.TotalPrice = new Big(this.TotalPrice1 * (this.discount / 10)).toFixed(2) + } this.DataList.forEach((item, index) => { if (item.proId == row.proId) { this.DataList.splice(index, 1); this.TotalPrice1 = 0; + this.TotalPrice = 0; this.DataList.forEach((item1) => { this.TotalPrice1 = item1.proPrice + this.TotalPrice1; + this.TotalPrice = new Big(this.TotalPrice1 * (this.discount / 10)) }); if (this.marryalls != 0) { this.TotalPrice1 += this.marryalls; + this.TotalPrice = new Big(this.TotalPrice1 * (this.discount / 10)) } } }); this.TotalPrice1 = 0; + this.TotalPrice = 0; this.DataList3.forEach((item) => { this.TotalPrice1 += item.proPrice; + this.TotalPrice = new Big(this.TotalPrice1 * (this.discount / 10)) }); }, /** 鍒犻櫎鎸夐挳鎿嶄綔 */ -- Gitblit v1.8.0