| | |
| | | <el-table-column label="套餐名称" align="center" prop="pacName" width="150px" fixed /> |
| | | <el-table-column label="原价" width="80px" align="center" prop="price" fixed></el-table-column> |
| | | <el-table-column label="折扣" width="80px" align="center" prop="limits" fixed></el-table-column> |
| | | <el-table-column label="优惠价" width="80px" align="center" prop="newPrice" fixed> |
| | | <el-table-column label="现价" width="80px" align="center" prop="newPrice" fixed> |
| | | </el-table-column> |
| | | <el-table-column label="单项列表" align="center" prop="allProName" width="1200px"> |
| | | </el-table-column> |
| | |
| | | |
| | | <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"/> |
| | | 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 |
| | |
| | | </el-input> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="priceNow" label="优惠价" width="80px" align="center"> |
| | | <el-table-column prop="priceNow" label="现价" width="80px" align="center"> |
| | | </el-table-column> |
| | | <el-table-column label="操作" align="center" width="80px"> |
| | | <template slot-scope="scope"> |
| | |
| | | }, |
| | | forms: {}, |
| | | youhui: 10, |
| | | initializing: true, // 初始化标志 |
| | | debounceTimer: null, |
| | | rules: {}, |
| | | rules: { |
| | | |
| | | }, |
| | | }; |
| | | }, |
| | | created() { |
| | |
| | | this.getKeyword(); |
| | | this.getCategory(); |
| | | }, |
| | | |
| | | methods: { |
| | | debounceNumberChange(currentValue, oldValue) { |
| | | clearTimeout(this.debounceTimer); |
| | |
| | | this.numberChange(currentValue, oldValue); |
| | | }, 300); |
| | | }, |
| | | numberChange(currentValue, oldValue) { |
| | | this.$confirm("确定修改所有子项的折扣吗?", "提示", { |
| | | confirmButtonText: "确定", |
| | | cancelButtonText: "取消", |
| | | type: "warning", |
| | | }) |
| | | .then(() => { |
| | | this.youhui = currentValue; |
| | | this.DataList.forEach((item) => { |
| | | item.limits = this.youhui; |
| | | const proPrice = new Big(item.priceOrd); |
| | | const limits = new Big(item.limits); |
| | | const result = proPrice.times(limits.div(10)); |
| | | item.priceNow = result.toNumber(); |
| | | }); |
| | | this.form.xianprice = this.DataList.reduce((sum, item) => { |
| | | return sum.plus(new Big(item.priceNow || "0")); |
| | | }, new Big(0)).toNumber(); |
| | | this.lastXianPrice = this.form.xianprice; |
| | | }) |
| | | .catch(() => { |
| | | this.youhui = oldValue; |
| | | }); |
| | | }, |
| | | |
| | | updateProPrice(row) { |
| | | const proPrice = new Big(row.priceOrd); |
| | | const limits = new Big(row.limits); |
| | |
| | | counterPrice: null, |
| | | limits: 10, |
| | | }; |
| | | this.initializing = true; |
| | | this.resetForm("form"); |
| | | }, |
| | | handleQuery() { |
| | |
| | | this.checkedListkey = []; |
| | | this.checkedNodes = []; |
| | | this.getDataList(); |
| | | this.youhui = 10 |
| | | }, |
| | | handleStatusChange(row) { |
| | | let data = { |
| | |
| | | }); |
| | | }, |
| | | handleUp() { |
| | | this.reset(); |
| | | this.title = "体检套餐信息维护"; |
| | | this.open = true; |
| | | getPacInFo(this.forms.pacId).then((response) => { |
| | |
| | | getPacInFo(row.pacId).then((response) => { |
| | | const data = response.data || {}; |
| | | Object.keys(data).forEach((key) => { |
| | | this.$set(this.form, key, data[key]); |
| | | this.$set(this.form, key, response.data[key]); |
| | | }); |
| | | this.youhui = data.limits || 10; |
| | | this.pics = data.price || 0; |
| | |
| | | this.checkedkey = this.DataList.map(item => item.proId || ''); |
| | | this.checkedListkey = [...this.checkedkey]; |
| | | this.checkedNodes = [...this.checkedkey]; |
| | | |
| | | return this.getDataList(); |
| | | |
| | | }).then(() => { |
| | | this.loading = false; |
| | | this.$nextTick(() => { |
| | |
| | | }).catch((error) => { |
| | | this.loading = false; |
| | | this.$message.error("加载数据失败"); |
| | | console.error(error); |
| | | }); |
| | | }, |
| | | addmembers() { |
| | |
| | | this.pics = this.DataList.reduce((total, item) => total + item.priceOrd, 0); |
| | | this.$nextTick(() => { |
| | | this.$refs.tree.setCheckedKeys(this.checkedNodes); |
| | | this.initializing = false; |
| | | }); |
| | | |
| | | }); |
| | | this.loading = false; |
| | | }, |
| | |
| | | }); |
| | | }, |
| | | handleCurrentChecked(data, checked, indeterminate) { |
| | | if (this.initializing) { |
| | | return; // 初始化时不处理 |
| | | } |
| | | if (checked) { |
| | | if (!this.DataList.some((item) => item.proId === data.proId)) { |
| | | this.DataList.push({ |
| | |
| | | if (!this.checkedNodes.includes(data.proId)) { |
| | | this.checkedNodes.push(data.proId); |
| | | } |
| | | this.updateTotalPrice(); |
| | | } else { |
| | | this.DataList = this.DataList.filter((item) => item.proId !== data.proId); |
| | | const index = this.checkedNodes.indexOf(data.proId); |
| | | if (index > -1) { |
| | | this.checkedNodes.splice(index, 1); |
| | | } |
| | | this.updateTotalPrice(); |
| | | } |
| | | this.updateTotalPrice(); |
| | | |
| | | }, |
| | | updateTotalPrice() { |
| | | this.form.xianprice = this.DataList.reduce((sum, item) => { |
| | |
| | | this.youhui = (Math.floor((this.form.xianprice / this.pics) * 100) / 100) * 10; |
| | | } |
| | | }, |
| | | numberChangeXianPrice(currentValue, oldValue) { |
| | | /* numberChangeXianPrice(currentValue, oldValue) { |
| | | if (this.form.xianprice === this.lastXianPrice || !this.form.xianprice) return; |
| | | clearTimeout(this.debounceTimer); |
| | | this.debounceTimer = setTimeout(() => { |
| | |
| | | this.youhui = oldValue; |
| | | }); |
| | | }, 500); |
| | | }, |
| | | }, */ |
| | | spliceData() { |
| | | for (var i = 0; i < this.DataList.length; i++) { |
| | | for (var j = i + 1; j < this.DataList.length; j++) { |
| | |
| | | this.TotalPrice1 = this.DataList.reduce((sum, item) => sum + item.priceOrd, 0); |
| | | }, |
| | | 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; |
| | |
| | | pacName: this.form.pacName, |
| | | limits: this.form.limits, |
| | | pacStatus: this.form.pacStatus, |
| | | packageProjects: packageProjects, |
| | | packageProjects: packageProjects, |
| | | newPrice: this.form.xianprice, |
| | | price: this.pics, |
| | | pacId: this.form.pacId || null, |
| | |
| | | pacRemark: this.form.pacRemark, |
| | | detail: this.form.detail, |
| | | }; |
| | | saveOreditTjPacNew(data).then((res) => { |
| | | |
| | | return saveOreditTjPacNew(data).then((res) => { |
| | | this.open = false; |
| | | this.getList(); |
| | | }); |