lkk
2025-01-08 09d95b97911084ff55d01c4122e7548c1923c012
体检费用
2个文件已修改
262 ■■■■■ 已修改文件
src/api/system/package.js 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/system/package/index.vue 253 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/system/package.js
@@ -196,4 +196,13 @@
    method: 'get',
    params: query
  })
}
// 体检套餐新增修改接口
export function saveOreditTjPacNew(data) {
  return request({
    url: '/system/package/saveOreditTjPacNew',
    method: 'post',
    data: data
  })
}
src/views/system/package/index.vue
@@ -425,11 +425,32 @@
            style="width: 150px"
          />
        </el-form-item>
        <el-form-item label="原价" prop="counterPrice">
        <el-form-item label="原价" prop="pics">
          <el-input
            v-model="form.counterPrice"
            v-model="pics"
            placeholder="请输入原价"
            style="width: 150px"
          />
        </el-form-item>
        <el-form-item label="折扣">
          <el-input-number
            ref="inputNumber"
            style="width: 150px"
            v-model="youhui"
            :precision="2"
            :step="0.1"
            :max="10"
            :min="1"
            @change="numberChange"
          ></el-input-number>
        </el-form-item>
        <el-form-item label="优惠价">
          <el-input
            ref="inputName"
            v-model="form.xianprice"
            placeholder="优惠价"
            clearable
            style="width: 140px"
          />
        </el-form-item>
        <el-form-item label="体检类别" prop="tjCategory">
@@ -541,7 +562,7 @@
            </el-tree>
          </div>
        </el-col>
       <!--  <el-col :span="6">
        <!--  <el-col :span="6">
          <div
            style="text-align: center; margin-bottom: 10px; margin-top: 10px"
          >
@@ -567,20 +588,44 @@
        <el-col :span="11">
          <div class="grid-content bg-purple">
            <div
              style="text-align: center; margin-bottom: 10px; margin-top: 10px; margin-left: 16%;"
              style="
                text-align: center;
                margin-bottom: 10px;
                margin-top: 10px;
                margin-left: 16%;
              "
            >
              已选项目列表
            </div>
            <el-table
              :data="DataList"
              border
              style="width: 80%; margin-left: 18%;"
              style="width: 80%; margin-left: 18%"
              height="400"
              :span-method="objectSpanMethod"
            >
              <el-table-column prop="propinName" label="检查项目" >
              <el-table-column prop="proName" label="检查项目">
              </el-table-column>
              <el-table-column prop="proPrice" label="原价" align="center" >
              <el-table-column prop="proPrice" label="原价" align="center">
              </el-table-column>
              <el-table-column label="折扣">
                <template slot-scope="scope">
                  <!-- 只输入纯数字折扣 -->
                  <el-input
                    v-model.number="scope.row.limits"
                    @input="calculateDiscount(scope.row)"
                    placeholder="输入折扣"
                    size="small"
                    type="number"
                    min="0"
                    step="0.1"
                    max="10"
                  >
                  </el-input>
                </template>
              </el-table-column>
              <el-table-column prop="priceNow" label="优惠价" align="center">
              </el-table-column>
              <!-- <el-table-column prop="proName" label="明细项目" width="260px">
              </el-table-column> -->
@@ -603,7 +648,7 @@
                </template> 
              </el-table-column>-->
            </el-table>
            <h3 style="font-weight: 600">合计:{{ pics }}元</h3>
            <!-- <h3 style="font-weight: 600">合计:{{ pics }}元</h3> -->
          </div>
        </el-col>
      </el-row>
@@ -652,8 +697,10 @@
  getAllList,
  updateProject,
  getPacTjProjectList,
  saveOreditTjPacNew,
} from "@/api/system/package";
import { Message } from "element-ui";
import Big from "big.js";
export default {
  name: "Package",
  dicts: ["sys_normal_disable", "sys_yes_no", "dict_tjtype"],
@@ -675,6 +722,7 @@
      DataList: [],
      list1: true,
      activeName: "1",
      num: 1,
      checkedObj: {},
      dataObj: {},
      Treedata: [],
@@ -733,8 +781,13 @@
        pacRemark: null,
      },
      // 表单参数
      form: {},
      form: {
        xianprice: null, // 优惠价
        counterPrice: null, //原价
        limits: 10,
      },
      forms: {},
      youhui: 10,
      // 表单校验
      rules: {
        deleted: [
@@ -770,6 +823,7 @@
      this.$refs.tree.filter(val);
    },
  },
  created() {
    this.getList();
    this.getKeyword();
@@ -782,9 +836,9 @@
    filterNode(value, data) {
      if (!value) return true;
      // return data.proName.indexOf(value) !== -1;
      if(data.proName.indexOf(value) !== -1){
      if (data.proName.indexOf(value) !== -1) {
        return data.proName.indexOf(value) !== -1;
      }else{
      } else {
        return data.proEngName.indexOf(value) !== -1;
      }
    },
@@ -1055,7 +1109,55 @@
      return this.form.tjProjectList;
    },
    //  // 默认接受四个值 { 当前行的值, 当前列的值, 行的下标, 列的下标 }
    numberChange(currentValue, oldValue) {
      this.$confirm("确定修改所有子项的折扣吗?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.youhui = currentValue;
          /*    if (this.youhui < 10) {
            this.youhui = 10;
            // this.$modal.msgError(`该人员最高优惠权限为${this.getInfodis}折`);
          } */
          this.DataList.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));
            item.priceNow = result.toNumber();
            this.form.xianprice = this.DataList.reduce((sum, item) => {
              return sum.plus(new Big(item.priceNow || "0"));
            }, new Big(0));
          });
        })
        .catch(() => {
          this.youhui = oldValue;
        });
    },
    updateProPrice(row) {
      const proPrice = new Big(row.proPrice);
      const limits = new Big(row.limits);
      const result = proPrice.times(limits.div(10)); // ordPrice * (discount / 10)
      row.priceNow = result.toNumber();
      this.form.xianprice = this.DataList.reduce((sum, item) => {
        return sum.plus(new Big(item.priceNow || "0"));
      }, new Big(0)).toNumber();
      this.youhui =
        (Math.floor((this.form.xianprice / this.pics) * 100) / 100) * 10;
    },
    calculateDiscount(row) {
      if (row.limits > 10) {
        row.limits = 10; // 强制将值设置为最大值
      } else if (row.limits < 0) {
        row.limits = 0; // 强制将值设置为最小值
      }
      this.updateProPrice(row); // 更新价格或其他逻辑
    },
    // 默认接受四个值 { 当前行的值, 当前列的值, 行的下标, 列的下标 }
    objectSpanMethod({ row, column, rowIndex, columnIndex }) {
      let fields = ["propinName"];
      let cellValue = row[column.property];
@@ -1092,7 +1194,19 @@
            this.Treedata.forEach((item1) => {
              if (item.proId == item1.proId) {
                this.checkedkey.push(item1.proId);
                let proId = item1.proId;
                this.DataList.push(item1);
                this.DataList.forEach((item1) => {
                  item1.limits = 10;
                  if (item1.limits > 10) {
                    item1.limits = 10; // 强制将值设置为最大值
                  } else if (item1.limits < 0) {
                    item1.limits = 0; // 强制将值设置为最小值
                  }
                  this.updateProPrice(item1); // 更新价格或其他逻辑
                });
                /* let proId = item1.proId;
                getProSonDxList(proId).then((res) => {
                  this.TreedataList = res.data.list;
                  this.TreedataList.forEach((item2) => {
@@ -1112,14 +1226,23 @@
                      });
                    }
                  });
                });
                }); */
              }
            });
          });
        } else {
          this.checkedkey.push(this.Treedata[0].proId);
          let proId = this.Treedata[0].proId;
          getProSonDxList(proId).then((res) => {
          this.TreedataList = this.Treedata.filter(
            (item) => item.proId == proId
          );
          // 将第一个项目添加到 DataList
          this.TreedataList.forEach((item) => {
            this.checkedListkey.push(item.proId);
            this.DataList.push(item);
          });
          /*  getProSonDxList(proId).then((res) => {
            this.TreedataList = res.data.list;
            this.TreedataList.forEach((item) => {
              item.disabled = true;
@@ -1134,12 +1257,60 @@
                this.pics += item.proPrice;
              });
            });
          });
          }); */
        }
        this.pics = this.DataList.reduce(
          (total, item) => total + item.proPrice,
          0
        );
        this.loading = false;
      });
    },
    handleCurrentChecked(data, checked, checkedNodes) {
      this.dataObj = data;
      this.checkedObj = checked;
      if (checked == true) {
        // 将选中的项目添加到 DataList
        this.checkedListkey.push(data.proId);
        this.DataList.push({
          proId: data.proId,
          proName: data.proName,
          proPrice: data.proPrice, // 原价
          limits: 10, // 默认折扣(100%)
          priceNow: data.proPrice, // 默认优惠价与原价相同
        });
        // 重新计算总价
        this.pics = 0;
        this.TotalPrice1 = 0;
        this.DataList.forEach((item) => {
          this.pics += item.proPrice;
          this.form.counterPrice += item.proPrice;
          this.TotalPrice1 += item.proPrice; // 可以根据需要改成优惠价 `priceNow`
        });
      } else if (checked == false) {
        // 从 DataList 中移除取消选中的项目
        let index = this.DataList.findIndex(
          (item) => item.proId === data.proId
        );
        if (index !== -1) {
          this.DataList.splice(index, 1);
        }
        // 重新计算总价
        this.pics = 0;
        this.TotalPrice1 = 0;
        this.DataList.forEach((item) => {
          this.pics += item.proPrice;
          this.form.counterPrice += item.proPrice;
          this.TotalPrice1 += item.proPrice; // 可以根据需要改成优惠价 `priceNow`
        });
      }
    },
    /* handleCurrentChecked(data, checked, checkedNodes) {
      this.dataObj = data;
      this.checkedObj = checked;
      if (checked == true) {
@@ -1190,7 +1361,7 @@
          });
        });
      }
    },
    }, */
    spliceData() {
      for (var i = 0; i < this.DataList.length; i++) {
@@ -1256,6 +1427,52 @@
    /** 提交按钮 */
    submitForm() {
      console.log(this.form, 999);
      this.form.limits = this.youhui;
      this.form.price = this.pics;
      this.form.priceNow = this.queryParams.xianprice;
      if (this.keys) {
        this.form.keywords = this.keys; // 如果有 this.keys,则直接赋值
      } else {
        this.form.keywords = this.form.keywords.toString(); // 如果没有,则将 this.form.keywords 转成字符串
      }
      let packageProjects = []; // 定义一个空数组
      this.DataList.forEach((item) => {
        packageProjects.push({
          proName: item.proName,
          proId: item.proId,
          priceNow: item.priceNow,
          limits: item.limits,
          priceOrd: item.proPrice,
        });
      });
      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,
        keywords: this.form.keywords,
        sort: this.form.sort,
        retailPrice: this.form.retailPrice,
        tjCategory: this.form.tjCategory,
        pacRemark: this.form.pacRemark,
        detail: this.form.detail,
      };
      saveOreditTjPacNew(data).then((res) => {
        console.log(res, 555);
        this.open = false;
        this.getList();
      });
    },
    /* submitForm() {
      if (this.form.pacName) {
        this.form.tjProjectList = [];
        if (this.DataList.length != 0) {
@@ -1319,7 +1536,7 @@
      } else {
        Message.warning("请先填写套餐名称");
      }
    },
    }, */
    /** 删除按钮操作 */
    handleDelete(row) {
      const pacIds = row.pacId || this.ids;