| | |
| | | <el-form-item label="原价" prop="price"> |
| | | <el-input v-model="forms.price" placeholder="请输入原价" style="width: 130px" /> |
| | | </el-form-item> |
| | | <!-- <el-form-item label="折扣" prop="limits"> |
| | | <el-input v-model="forms.limits" placeholder="请输入折扣" style="width: 130px" @change="numberChange" /> |
| | | </el-form-item> --> |
| | | |
| | | <el-form-item label="优惠价" prop="ysPrice"> |
| | | <el-input v-model="forms.ysPrice" placeholder="请输入应收" style="width: 120px" /> |
| | | </el-form-item> |
| | |
| | | <el-input ref="inputName" v-model="queryParams.price" placeholder="合计" clearable style="width: 140px" /> |
| | | </el-form-item> |
| | | <el-form-item label="优惠"> |
| | | <el-input-number ref="inputNumber" style="width: 150px" v-model="youhui" :precision="2" :step="0.1" |
| | | :min="0" @change="numberChange"></el-input-number> |
| | | <el-input-number ref="inputNumber" style="width: 150px" v-model="youhui" :precision="1" :step="0.1" |
| | | :min="0" :max="20" @change="debounceNumberChange" :debounce="3000"></el-input-number> |
| | | </el-form-item> |
| | | <el-form-item label="现价"> |
| | | <el-input ref="inputName" v-model="queryParams.xianprice" placeholder="合计" clearable |
| | | style="width: 140px" /> |
| | | style="width: 140px" @input="changeXianjia" @blur="numberChangeXianPrice(youhui, youhui)" /> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button icon="el-icon-refresh" size="mini" @click="resetQuerys">重置</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | <el-table border v-loading="loading" :data="OnenewpacName" :row-class-name="tableRowClassName" height="478"> |
| | | <el-table-column label="项目名称" align="center" prop="proName" width="486"> |
| | | <el-table-column label="项目名称" align="center" prop="proName" width="410"> |
| | | |
| | | <template slot-scope="scope"> |
| | | {{ scope.row.proName }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="原价" align="center" prop="proPrice" width="85"></el-table-column> |
| | | <el-table-column label="折扣" width="85"> |
| | | <el-table-column label="折扣" width="151"> |
| | | <template slot-scope="scope"> |
| | | <!-- 只输入纯数字折扣 --> |
| | | <el-input v-model.number="scope.row.limits" @input="validateDiscount(scope.row)" placeholder="输入折扣" |
| | | size="small" type="number" min="0" step="1" max="10"> |
| | | </el-input> |
| | | <el-input-number v-model.number="scope.row.limits" @input="validateDiscount(scope.row)" |
| | | placeholder="输入折扣" size="small" type="number" :min="0" :step="0.1" :precision="1" :max="20"> |
| | | </el-input-number> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="现价" align="center" prop="ysPrice" width="85"></el-table-column> |
| | |
| | | </el-table-column> |
| | | </el-table> |
| | | <div style="font-size: 16px;margin-top: 10px;">项目总条数:<span style="font-weight: 700;margin-right: 5px;">{{ |
| | | newpacName.length }}</span>条</div> |
| | | newpacName.length }}</span>条</div> |
| | | </el-col> |
| | | <el-col :span="8" :xs="24"> |
| | | <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="46px" |
| | |
| | | <el-col :span="2" :xs="24"> |
| | | <div style="margin: 240% 16%"> |
| | | <el-button type="primary" size="medium " icon="el-icon-back" |
| | | style="writing-mode: vertical-rl; text-align: center;letter-spacing: 10px;" |
| | | @click="resetright">确 认</el-button> |
| | | style="writing-mode: vertical-rl; text-align: center;letter-spacing: 10px;" @click="resetright">确 |
| | | 认</el-button> |
| | | </div> |
| | | </el-col> |
| | | <el-col :span="8" :xs="24"> |
| | |
| | | this.updateProPrice(row); // 更新价格或其他逻辑 |
| | | }, |
| | | updateProPrice(row) { |
| | | |
| | | console.log('1234') |
| | | const proPrice = new Big(row.proPrice); |
| | | |
| | | const limits = new Big(row.limits); |
| | |
| | | }, new Big(0)).toNumber(); |
| | | this.youhui = (Math.floor((this.queryParams.xianprice / this.queryParams.price) * 100) / 100) * 10 |
| | | }, |
| | | debounceNumberChange(currentValue, oldValue) { |
| | | clearTimeout(this.debounceTimer); |
| | | this.debounceTimer = setTimeout(() => { |
| | | this.numberChange(currentValue, oldValue); |
| | | }, 300); |
| | | }, |
| | | changeXianjia() { |
| | | // 原始折扣率计算 |
| | | |
| | | |
| | | if (this.queryParams.price !== 0) { |
| | | this.youhui = (Math.floor((this.queryParams.xianprice / this.queryParams.price) * 100) / 100) * 10; |
| | | } |
| | | |
| | | }, |
| | | |
| | | getList() { |
| | | this.$nextTick(() => { |
| | | this.$refs.inputName.focus(); |
| | |
| | | this.handleQuery(); |
| | | }, |
| | | resetQuerys() { |
| | | this.OnenewpacName = [], |
| | | this.OnenewpacName = [], |
| | | this.queryParams.price = 0, |
| | | this.queryParams.xianprice = 0, |
| | | this.youhui = 0 |
| | |
| | | }); |
| | | |
| | | }, |
| | | numberChangeXianPrice(currentValue, oldValue) { |
| | | this.$confirm("确定修改所有子项的折扣吗?", "提示", { |
| | | confirmButtonText: "确定", |
| | | cancelButtonText: "取消", |
| | | type: "warning", |
| | | }) |
| | | .then(() => { |
| | | // 确保修改折扣的值 |
| | | this.youhui = currentValue; |
| | | // 如果折扣小于最小折扣值,修正折扣 |
| | | if (this.youhui < this.getInfodis) { |
| | | this.youhui = this.getInfodis; |
| | | } |
| | | let totalYsprice = new Big(0); // 初始化总 ysprice |
| | | // 遍历每个项目,更新每个子项的价格 |
| | | this.OnenewpacName.forEach((item) => { |
| | | item.limits = this.youhui; |
| | | const proPrice = new Big(item.proPrice); |
| | | const limits = new Big(item.limits); |
| | | const result = proPrice.times(limits.div(10)); // ordPrice * (discount / 10) |
| | | item.ysPrice = result.toNumber(); |
| | | totalYsprice = totalYsprice.plus(new Big(item.ysPrice)); |
| | | }); |
| | | // 如果总的 ysPrice 和查询参数中的 xianprice 不一致,进行调整 |
| | | if (!totalYsprice.eq(this.queryParams.xianprice)) { |
| | | const diff = new Big(this.queryParams.xianprice).minus(totalYsprice); |
| | | // 如果 OnenewpacName 数组不为空,调整最后一项的 ysPrice |
| | | if (this.OnenewpacName.length > 0) { |
| | | const lastItem = this.OnenewpacName[this.OnenewpacName.length - 1]; |
| | | const newYsPrice = new Big(lastItem.ysPrice).plus(diff).toNumber(); |
| | | // 使用 splice 替换最后一项,确保更新触发视图更新 |
| | | console.log("hhh"); |
| | | |
| | | this.$set(this.OnenewpacName[this.OnenewpacName.length - 1], 'ysPrice', newYsPrice); |
| | | |
| | | } |
| | | } |
| | | }) |
| | | .catch(() => { |
| | | // 如果取消修改,恢复原有的优惠值 |
| | | this.youhui = oldValue; |
| | | }); |
| | | }, |
| | | |
| | | |
| | | changegroupingName() { |
| | | if (this.selectionList.length <= 0) { |
| | |
| | | const existingItem = this.OnenewpacName.find(existing => existing.proId === item.proId); |
| | | if (!existingItem) { |
| | | newItemsToAdd.push(item); // 如果不存在相同项目,则添加到新数组 |
| | | this.updateProPrice(item); // 更新单个项目的价格 |
| | | this.updateProPrice(item); |
| | | } |
| | | }); |
| | | |