| | |
| | | }, |
| | | /** 登记提交按钮 */ |
| | | /** 登记提交按钮 */ |
| | | 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") { |
| | |
| | | handleChangesName(params) { |
| | | 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"; |
| | |
| | | }, |
| | | |
| | | // 最后提交按钮 |
| | | 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> |