qx
2025-07-04 4c4abb59d6ee838c61b851fcc7be93c0522c39c4
src/views/system/tijian/index.vue
@@ -181,7 +181,7 @@
                trigger: 'blur',
              },
            ]">
              <el-input v-model="form.cusPhone" placeholder="请输入联系电话" :disabled="isDisabled"
              <el-input v-model="form.cusPhone" placeholder="请输入联系电话" :disabled="isDisabled" maxlength="11"
                @input="form.cusPhone = $event.replace(/\s/g, '')" />
            </el-form-item>
@@ -285,7 +285,8 @@
      <el-tabs type="border-card" style="height: 560px; margin: 0 10px; width: 100%" v-model="activeNames"
        @tab-click="handleClick">
        <el-tab-pane label="套餐" name="first">
          <el-form :model="queryParam" ref="queryForm" size="small" :inline="true" v-if="showSearch" label-width="auto">
          <el-form :model="queryParam" ref="queryForm" size="small" :inline="true" v-if="showSearch" label-width="auto"
            @submit.native.prevent="handle">
            <el-form-item label="套餐名称" prop="pacName">
              <el-input v-model="queryParam.pacName" placeholder="请输入套餐名称" clearable @keyup.enter.native="handle" />
            </el-form-item>
@@ -957,6 +958,7 @@
      // valueUrl: "ws://192.168.1.3:6789/websocket",
      valueUrl: "ws://127.0.0.1:6789/websocket",
      valueUrls: "ws://127.0.0.1:6789/websocket",
      // valueUrls: "ws://"+getIp() +":6789/websocket",
      webSocket: null,
      // 身份证需要
@@ -1709,46 +1711,57 @@
    },
    /** 登记提交按钮 */
    /** 登记提交按钮 */
    submitForm() {
      let _this = this;
      if (!this.form.cusPhone || !this.form.cusName) {
        this.$message.warning("请填选必填项");
      } else {
        this.$refs["form"].validate((valid) => {
          if (valid) {
            // 创建表单数据的副本并去除空格
            const formData = { ...this.form };
            formData.cusName = formData.cusName ? formData.cusName.replace(/\s/g, '') : '';
            formData.cusPhone = formData.cusPhone ? formData.cusPhone.replace(/\s/g, '') : '';
            formData.cusIdcard = formData.cusIdcard ? formData.cusIdcard.replace(/\s/g, '') : '';
  submitForm() {
  let _this = this;
  if (!this.form.cusPhone || !this.form.cusName) {
    this.$message.warning("请填选必填项");
    return;
  }
            // 处理性别值
            if (formData.cusSex === "女") {
              formData.cusSex = 1;
            }
            if (formData.cusSex === "男") {
              formData.cusSex = 0;
            }
            if (formData.cusSex === "未知") {
              formData.cusSex = 2;
            }
            if (formData.tjType === "") {
              formData.tjType = this.dict.type.dict_team[0].value;
            }
  this.$refs["form"].validate((valid) => {
    if (valid) {
      // 创建表单数据的副本并去除空格
      const formData = { ...this.form };
      formData.cusName = formData.cusName ? formData.cusName.replace(/\s/g, '') : '';
      formData.cusPhone = formData.cusPhone ? formData.cusPhone.replace(/\s/g, '') : '';
      formData.cusIdcard = formData.cusIdcard ? formData.cusIdcard.replace(/\s/g, '') : '';
      // 添加 sfzImg 字段
      formData.sfzImg = this.imageUrl || ''; // 使用 base64 格式的头像数据,若为空则传空字符串
            addCustomer(formData).then((response) => {
              this.responseList = response.data;
              this.form.tjType = this.dict.type.dict_team[0].value;
              this.$modal.msgSuccess("新增成功");
              _this.tcShow = true;
              _this.isDisabled = true;
              _this.top = false;
            });
          }
        });
      // 处理性别值
      if (formData.cusSex === "女") {
        formData.cusSex = 1;
      }
    },
      if (formData.cusSex === "男") {
        formData.cusSex = 0;
      }
      if (formData.cusSex === "未知") {
        formData.cusSex = 2;
      }
      if (formData.tjType === "") {
        formData.tjType = this.dict.type.dict_team[0].value;
      }
      // 可选:检查 sfzImg 是否存在
      if (!formData.sfzImg) {
        this.$message.warning("请先获取身份证头像");
        return;
      }
      addCustomer(formData).then((response) => {
        this.responseList = response.data;
        this.form.tjType = this.dict.type.dict_team[0].value;
        this.$modal.msgSuccess("新增成功");
        _this.tcShow = true;
        _this.isDisabled = true;
        _this.top = false;
      }).catch((error) => {
        this.$modal.msgError("登记失败,请检查数据");
        console.error("Error in addCustomer:", error);
      });
    }
  });
},
    getmailType() {
      if (this.getType == "2") {
@@ -1926,11 +1939,15 @@
    // 最新使用webSocket通信
    readCardWebSocket(resultObj) {
      let _this = this;
      const isChineseChar = (char) => /[\u4E00-\u9FA5]/.test(char)
      if (resultObj.code === 200 && resultObj.data.name != null) {
        //回显相关数据
        _this.form.cusName = resultObj.data.name;
        _this.form.cusSex = resultObj.data.sex == "0" ? "女" : "男";
        if (isChineseChar(resultObj.data.sex)) {
          _this.form.cusSex = resultObj.data.sex == "女" ? 1 : 0
        } else {
          _this.form.cusSex = resultObj.data.sex;
        }
        _this.form.cusNational = resultObj.data.mz;
        _this.form.cusBrithday = resultObj.data.csrq;
        if (_this.form.cusBrithday) {
@@ -1985,7 +2002,7 @@
          //回显相关数据
          _this.form.cusName = resultObj.resultContent.partyName;
          _this.form.cusSex =
            resultObj.resultContent.gender == "0" ? "女" : "男";
            resultObj.resultContent.gender;
          _this.form.cusNational = resultObj.resultContent.nation;
          _this.form.cusBrithday = resultObj.resultContent.bornDay;
          if (_this.form.cusBrithday) {
@@ -2235,11 +2252,6 @@
      this.form.cusIdcard = params[0].sfzh;
      this.handleQuery();
    },
    // 上传头像
    handleAvatarSuccess(res, file) {
      this.imageUrl = URL.createObjectURL(file.raw);
    },
    beforeAvatarUpload(file) {
      const isJPG = file.type === "image/jpeg";
      const isLt2M = file.size / 1024 / 1024 < 2;
@@ -2282,7 +2294,7 @@
        dwId: this.form.firmId,
      };
      if (this.name) {
        let name= this.name.toLowerCase()
        let name = this.name.toLowerCase()
        getPackageListName(name).then((response) => {
          this.newpacName = response.data;
          this.loading = false;
@@ -2940,9 +2952,9 @@
        let Price = 0;
        if (this.tableData1) {
          this.tableData1.forEach((item) => {
            if (typeof item.nowPrice  === 'number') {
              item.nowPrice  = Number(item.nowPrice.toFixed(2));
          }
            if (typeof item.nowPrice === 'number') {
              item.nowPrice = Number(item.nowPrice.toFixed(3));
            }
            if (item.tjCategory != null) {
              this.tjCategory = item.tjCategory;
            }
@@ -2956,7 +2968,7 @@
            Price += item.nowPrice || 0; // 累加实收金额
            this.TotalPrice = Price.toFixed(2);
          });
          console.log( this.TotalPrice1,this.TotalPrice)
          console.log(this.TotalPrice1, this.TotalPrice)
          // 计算折扣
          this.discount = this.TotalPrice1 > 0 ?
            (Math.floor((this.TotalPrice / this.TotalPrice1) * 100) / 100) * 10 : 0;
@@ -3243,110 +3255,100 @@
    },
    // 最后提交按钮
    submitPrice() {
      let _this = this;
      this.loadingSubmit = true;
      if (_this.tjCategory !== "") {
        let List = _this.tableData1; //单个项目信息
        if (this.responseList.cusId) {
          var userId = this.responseList.cusId;
        } else {
          var userId = _this.form.cusId;
        }
        let tjType = _this.form.tjType;
        if (this.tableData[0]) {
          var pacId = this.tableData[0].pacId;
        }
  submitPrice() {
  let _this = this;
  this.loadingSubmit = true;
  if (_this.tjCategory !== "") {
    let List = _this.tableData1; // 单个项目信息
    if (this.responseList.cusId) {
      var userId = this.responseList.cusId;
    } else {
      var userId = _this.form.cusId;
    }
    let tjType = _this.form.tjType;
    if (this.tableData[0]) {
      var pacId = this.tableData[0].pacId;
    }
        //tjOrderList//这个是处理完的每一项套餐信息
        List.forEach((item) => {
          if (item.list) {
            item.list.forEach((item1) => {
              this.tjOrderList.push({
                proName: item1.proName,
                proPrice: item1.nowPrice,
                proId: item1.proId,
              });
            });
          } else if (item.tjProjectList) {
            item.tjProjectList.forEach((item1) => {
              this.tjOrderList.push({
                proName: item1.proName,
                proPrice: item1.priceNow,
                proId: item1.proId,
              });
            });
          } else {
            this.tjOrderList.push({
              proName: item.proName,
              proPrice: item.ysPrice,
              proId: item.proId,
            });
          }
    // tjOrderList 处理
    List.forEach((item) => {
      if (item.list) {
        item.list.forEach((item1) => {
          this.tjOrderList.push({
            proName: item1.proName,
            proPrice: item1.nowPrice,
            proId: item1.proId,
          });
        });
        let copeWith = this.TotalPrice1;
        let paidIn = this.TotalPrice.toString();
        let discount = this.discount;
        this.tjFlowingWater = { copeWith, paidIn, discount };
        const newArray = this.tableData1
          .filter((item) => item.discount < 10) // 过滤出 discount < 10 的项
          .map((item) => ({
            discount: item.discount,
            parentProId: item.parentProId,
            cusIdCard: item.cusId,
            yhj: item.nowPrice
          })); // 创建新的对象,包含 discount 和 id
        gaibianzhekou(newArray).then((res) => {
          this.loadingSubmit = false;
          if (res.code === 200) {
            let data;
            if (pacId || this.tjOrderList.length > 0) {
              data = {
                photo: this.srcUrl,
                pacId,
                tjOrderList: this.tjOrderList,
                tjFlowingWater: this.tjFlowingWater,
                userId,
                tjType,
                tjCategory: this.tjCategory,
                firmId: this.form.firmId,
                firmName: this.form.firmName,
                firmDeptName: this.form.firmDeptName,
              };
              this.listgetOrder(data);
            } else if (pacId || this.tjOrderList.length > 0) {
              data = {
                photo: this.srcUrl,
                tjOrderList: this.tjOrderList,
                tjFlowingWater: this.tjFlowingWater,
                userId,
                tjType,
                tjCategory: this.tjCategory,
                firmId: this.form.firmId,
                firmName: this.form.firmName,
                firmDeptName: this.form.firmDeptName,
              };
              this.listgetOrder(data);
            } else {
              this.loadingSubmit = false;
              this.$message({
                type: "warning ",
                message: "请选择套餐!",
              });
            }
          } else {
            this.loadingSubmit = false;
            this.$modal.msgError("改变折扣错误");
          }
      } else if (item.tjProjectList) {
        item.tjProjectList.forEach((item1) => {
          this.tjOrderList.push({
            proName: item1.proName,
            proPrice: item1.priceNow,
            proId: item1.proId,
          });
        });
      } else {
        this.loadingSubmit = false;
        this.$modal.msgError("请选择体检类别");
        this.tjOrderList.push({
          proName: item.proName,
          proPrice: item.ysPrice,
          proId: item.proId,
        });
      }
    },
    });
    let copeWith = this.TotalPrice1;
    let paidIn = this.TotalPrice.toString();
    let discount = this.discount;
    this.tjFlowingWater = { copeWith, paidIn, discount };
    const newArray = this.tableData1
      .filter((item) => item.discount < 10)
      .map((item) => ({
        discount: item.discount,
        parentProId: item.parentProId,
        cusIdCard: item.cusId,
        yhj: item.nowPrice,
      }));
    gaibianzhekou(newArray).then((res) => {
      this.loadingSubmit = false;
      if (res.code === 200) {
        let data;
        if (pacId || this.tjOrderList.length > 0) {
          data = {
            photo: this.srcUrl, // 保留原有 photo 字段(如果后端仍需要)
            sfzImg: this.imageUrl, // 添加 sfzImg 字段,优先使用服务器URL,若无则使用base64
            pacId,
            tjOrderList: this.tjOrderList,
            tjFlowingWater: this.tjFlowingWater,
            userId,
            tjType,
            tjCategory: this.tjCategory,
            firmId: this.form.firmId,
            firmName: this.form.firmName,
            firmDeptName: this.form.firmDeptName,
          };
          this.listgetOrder(data);
        } else {
          this.loadingSubmit = false;
          this.$message({
            type: "warning",
            message: "请选择套餐!",
          });
        }
      } else {
        this.loadingSubmit = false;
        this.$modal.msgError("改变折扣错误");
      }
    });
  } else {
    this.loadingSubmit = false;
    this.$modal.msgError("请选择体检类别");
  }
},
  },
};
</script>