From c63125379d5d3bef6b7628625e8041a8de4a3015 Mon Sep 17 00:00:00 2001 From: pengjun <158915633@qq.com> Date: Thu, 13 Jul 2023 14:12:57 +0800 Subject: [PATCH] ss --- src/api/request.js | 4 +- .../patientRegister/PatientRegisterItem.vue | 316 +++++++++--------- src/utlis/istoken.js | 6 +- src/utlis/proFunc.js | 7 +- 4 files changed, 172 insertions(+), 161 deletions(-) diff --git a/src/api/request.js b/src/api/request.js index d53e156..0eddd25 100644 --- a/src/api/request.js +++ b/src/api/request.js @@ -14,8 +14,8 @@ const instance = axios.create({ //请求拦截 instance.interceptors.request.use( async function (config) { - console.log('old token:',localStorage.getItem("token")) - console.log('old expires_in',localStorage.getItem("expires_in")) + //console.log('old token:',localStorage.getItem("token")) + //console.log('old expires_in',localStorage.getItem("expires_in")) await yztoken(); let token = localStorage.getItem("token"); diff --git a/src/components/patientRegister/PatientRegisterItem.vue b/src/components/patientRegister/PatientRegisterItem.vue index c42baf5..416af60 100644 --- a/src/components/patientRegister/PatientRegisterItem.vue +++ b/src/components/patientRegister/PatientRegisterItem.vue @@ -26,14 +26,13 @@
- 保存 + 保存
- @@ -116,44 +115,65 @@ export default { // ] //批量更新组合项目 - batchEditAsb(body,msg){ + batchEditAsb(body, msg) { console.log(`/api/app/registerasbitem/updatemany`, body) postapi(`/api/app/registerasbitem/updatemany`, body) - .then((res) => { - console.log("onSubmit", res); - if (res.code == 1) { - if(msg){ - //未选项目中移除,已选项中添加 - this.getPatientRegisterAbs(this.patientRegisterForm.id) - this.$message.success(`${msg}操作成功`); - } - } - }) - .catch((err) => { - this.$message({ type: "error", message: `${msg}操作失败,原因:${err}` }); - }); + .then((res) => { + console.log("onSubmit", res); + if (res.code == 1) { + if (msg) { + //未选项目中移除,已选项中添加 + this.getPatientRegisterAbs(this.patientRegisterForm.id) + this.$message.success(`${msg}操作成功`); + } + } + }) + .catch((err) => { + this.$message({ type: "error", message: `${msg}操作失败,原因:${err}` }); + }); }, + //更新所选组合项目 - onSubmit() { - let body = [] + onSubmit(msg) { + let body = [],insBody=[] + if(!this.patientRegisterForm.id) return if (this.patientRegister.patientRegisterAbs.length < 1) { alert("暂无可操作的数据") return } for (let i = 0; i < this.patientRegister.patientRegisterAbs.length; i++) { - body.push({ - registerAsbitemId: this.patientRegister.patientRegisterAbs[i].id, - input: { - chargePrice: this.patientRegister.patientRegisterAbs[i].chargePrice, - payTypeFlag: this.patientRegister.patientRegisterAbs[i].payTypeFlag, + if(this.patientRegister.patientRegisterAbs[i].id){ + body.push({ + registerAsbitemId: this.patientRegister.patientRegisterAbs[i].id, + input: { + chargePrice: this.patientRegister.patientRegisterAbs[i].chargePrice, + payTypeFlag: this.patientRegister.patientRegisterAbs[i].payTypeFlag, + isCharge: this.patientRegister.patientRegisterAbs[i].isCharge, + amount: this.patientRegister.patientRegisterAbs[i].amount, + groupPackageId: this.patientRegister.patientRegisterAbs[i].groupPackageId + } + }) + }else{ + insBody.push({ + asbitemId: this.patientRegister.patientRegisterAbs[i].id, + patientRegisterId: this.patientRegisterForm.id, + standardPrice: this.patientRegister.patientRegisterAbs[i].price, + chargePrice: this.patientRegister.patientRegisterAbs[i].price, + payTypeFlag:this.patientRegister.patientRegisterAbs[i].payTypeFlag, isCharge: this.patientRegister.patientRegisterAbs[i].isCharge, amount: this.patientRegister.patientRegisterAbs[i].amount, groupPackageId: this.patientRegister.patientRegisterAbs[i].groupPackageId - } - }) + }) + } + } + if(body.length > 0 && insBody.length > 0){ + this.batchAddAsb(insBody, ''); + this.batchEditAsb(body, msg); + }else if(body.length > 0 && insBody.length < 1){ + this.batchEditAsb(body, msg); + }else if(body.length < 1 && insBody.length > 0){ + this.batchAddAsb(insBody, msg); } - this.batchEditAsb(body,'保存'); - }, //未选组合项目 勾选情况 @@ -164,15 +184,15 @@ export default { }, //批量添加组合项目 - batchAddAsb(body,msg){ + batchAddAsb(body, msg) { console.log(`/api/app/registerasbitem/createmany?CustomerOrgId=${this.patientRegisterForm.customerOrgId}`, body) postapi(`/api/app/registerasbitem/createmany?CustomerOrgId=${this.patientRegisterForm.customerOrgId}`, body) .then((res) => { - console.log("addAbs", res); + console.log("batchAddAsb", res); if (res.code == 1) { //未选项目中移除,已选项中添加 this.getPatientRegisterAbs(this.patientRegisterForm.id) - if(msg) this.$message.success(`${msg}操作成功`); + if (msg) this.$message.success(`${msg}操作成功`); } }) .catch((err) => { @@ -227,10 +247,10 @@ export default { }) } - this.batchAddAsb(body,'添加组合项目'); + this.batchAddAsb(body, '添加组合项目'); }, - + //人员已选组合项目 勾选情况 selecteditems(val) { @@ -238,7 +258,7 @@ export default { }, //批量删除组合项目 - batchDelAsb(body,msg){ + batchDelAsb(body, msg) { console.log(`/api/app/registerasbitem/deletemany`, body) postapi(`/api/app/registerasbitem/deletemany`, body) .then((res) => { @@ -247,12 +267,12 @@ export default { //项目类别过滤 组合项目,未过滤已选择的组合项目 this.getAsbItemByItemTypeAll() - if(msg){ + if (msg) { //未选项目中移除,已选项中添加 this.getPatientRegisterAbs(this.patientRegisterForm.id) this.$message.success(`${msg}操作成功`); } - + } }) .catch((err) => { @@ -289,7 +309,7 @@ export default { body = { registerAsbitemIds } - this.batchDelAsb(body,'删除组合项目'); + this.batchDelAsb(body, '删除组合项目'); }, @@ -319,18 +339,18 @@ export default { //体检登记的组合项目创建 - registerAsbitem(body) { - console.log("registerAsbitem"); - postapi( - `/api/app/register-asbitem?CustomerOrgId=${this.patientRegisterForm.customerOrgId}`, - body - ).then((res) => { - console.log("medicalPackageAsb", res); - if (res.code == 1) { - //未选项目中移除,已选项中添加 - } - }); - }, + // registerAsbitem(body) { + // console.log("registerAsbitem"); + // postapi( + // `/api/app/register-asbitem?CustomerOrgId=${this.patientRegisterForm.customerOrgId}`, + // body + // ).then((res) => { + // console.log("medicalPackageAsb", res); + // if (res.code == 1) { + // //未选项目中移除,已选项中添加 + // } + // }); + // }, //选中分组所包含的组合项目 getCustomerOrgGroupAsb(customerOrgGroupId, oldVal) { @@ -342,114 +362,87 @@ export default { this.patientRegister.customerOrgGroupAsb = res.data; //移除旧分组或套餐的组合项目 - this.removeGroupPackageAsb(oldVal); + this.removeGroupPackageAsb(); //添加新套餐的组合项目 - this.addCustomerOrgGroupAsb(customerOrgGroupId); + this.addCustomerOrgGroupAsb(customerOrgGroupId); } }); }, //选中套餐所包含的组合项目 - getMedicalPackageAsb(medicalPackageId, oldVal) { - console.log( - `/api/app/medical-package-detail/medical-package-in-asbitem?MedicalPackageId=${medicalPackageId}` - ); - getapi( - `/api/app/medical-package-detail/medical-package-in-asbitem?MedicalPackageId=${medicalPackageId}` - ).then((res) => { + getMedicalPackageAsb(medicalPackageId) { + console.log(`/api/app/medical-package-detail/medical-package-in-asbitem?MedicalPackageId=${medicalPackageId}`); + getapi(`/api/app/medical-package-detail/medical-package-in-asbitem?MedicalPackageId=${medicalPackageId}`) + .then((res) => { console.log("getMedicalPackageAsb", res); if (res.code == 1) { this.patientRegister.medicalPackageAsb = res.data; - //添加新套餐的组合项目 - this.addMedicalPackageAsb(medicalPackageId); - //移除旧分组或套餐的组合项目 - this.removeGroupPackageAsb(oldVal); + this.removeGroupPackageAsb(); - //刷新显示 未选组合项目 - this.getAsbItemByItemType() + //添加新套餐的组合项目 + this.addMedicalPackageAsb(medicalPackageId); } }); }, //添加新分组的组合项目 addCustomerOrgGroupAsb(groupPackageId) { - console.log('addCustomerOrgGroupAsb') - let finded = false; + let body = [] + let payTypeFlag = '0' + let lfind = -1 + let editCount = 0 + + if (this.patientRegisterForm.customerOrgId != this.dict.personOrgId) payTypeFlag = '1' for (let i = 0; i < this.patientRegister.customerOrgGroupAsb.length; i++) { - finded = false; - for (let j = 0; j < this.patientRegister.patientRegisterAbs.length; j++) { - if (this.patientRegister.customerOrgGroupAsb[i].asbitemId == this.patientRegister.patientRegisterAbs[j].asbitemId) { - this.patientRegister.patientRegisterAbs[j].groupPackageId = groupPackageId - this.patientRegisterAbsEdit.push({ ...this.patientRegister.patientRegisterAbs[j] }) - finded = true - } + lfind = arrayExistObj(this.patientRegister.patientRegisterAbs,'asbitemId',this.patientRegister.customerOrgGroupAsb[i].asbitemId) + if(lfind > - 1){ + this.patientRegister.patientRegisterAbs[lfind] = groupPackageId + editCount++ + continue } - if (!finded) { - let asbItem = { - asbitemId: this.patientRegister.customerOrgGroupAsb[i].id, // string($uuid) 组合项目 - asbitemName: this.patientRegister.customerOrgGroupAsb[i].displayName, // string($uuid) 组合项目 - patientRegisterId: this.patientRegisterForm.id, //string($uuid) 登记流水号 - standardPrice: this.patientRegister.customerOrgGroupAsb[i].price, //number($double) 标准价格 - chargePrice: this.patientRegister.customerOrgGroupAsb[i].price, // number($double) 实收价格 - payTypeFlag: "1", // string 支付方式,比如是0自费、2免费、1单位支付 - isCharge: "N", // string 是否已收费 - lisRequestId: null, // string($uuid)LIS申请ID - amount: 1, // integer($int32) 数量 - groupPackageId: groupPackageId, // string($uuid) 分组或者套餐ID - }; - console.log('i', i, asbItem) - - //待添加的项目在 删除缓存中 存在,则将移至已选中后,删除缓存中的数据 - let exist = arrayExistObj(this.patientRegisterAbsDel, 'asbitemId', asbItem.asbitemId) - if (exist > -1) { - this.patientRegister.patientRegisterAbs.push({ ...this.patientRegisterAbsDel[exist] }) - this.patientRegisterAbsDel.splice(exist, 1) - } else { - this.patientRegister.patientRegisterAbs.push(asbItem); - } + let pojo = { + asbitemId: this.patientRegister.customerOrgGroupAsb[i].asbitemId, + patientRegisterId: this.patientRegisterForm.id, + standardPrice: this.patientRegister.customerOrgGroupAsb[i].price, + chargePrice: this.patientRegister.customerOrgGroupAsb[i].customerOrgGroupDetailPrice, + payTypeFlag, + isCharge: "N", + amount: 1, + groupPackageId: groupPackageId } + body.push(pojo) + this.patientRegister.patientRegisterAbs.push({...pojo,asbitemName:this.patientRegister.customerOrgGroupAsb[i].displayName}) } + if(editCount>0) this.onSubmit() + if (body.length > 0 && this.patientRegisterForm.id) this.batchAddAsb(body, '更换分组'); + }, //添加新套餐的组合项目 addMedicalPackageAsb(groupPackageId) { - let finded = false; + let body = [] + let payTypeFlag = '0' + + if (this.patientRegisterForm.customerOrgId != this.dict.personOrgId) payTypeFlag = '1' for (let i = 0; i < this.patientRegister.medicalPackageAsb.length; i++) { - finded = false; - for (let j = 0; j < this.patientRegister.patientRegisterAbs.length; j++) { - if (this.patientRegister.medicalPackageAsb[i].asbitemId == this.patientRegister.patientRegisterAbs[j].asbitemId) { - this.patientRegister.patientRegisterAbs[j].groupPackageId = groupPackageId - this.patientRegisterAbsEdit.push({ ...this.patientRegister.patientRegisterAbs[j], }) - finded = true - } - } - if (!finded) { - let asbItem = { - asbitemId: this.patientRegister.medicalPackageAsb[i].id, // string($uuid) 组合项目 - asbitemName: this.patientRegister.medicalPackageAsb[i].displayName, // string($uuid) 组合项目 - patientRegisterId: this.patientRegisterForm.id, //string($uuid) 登记流水号 - standardPrice: this.patientRegister.medicalPackageAsb[i].price, //number($double) 标准价格 - chargePrice: this.patientRegister.medicalPackageAsb[i].price, // number($double) 实收价格 - payTypeFlag: "0", // string 支付方式,比如是0自费、2免费、1单位支付 - isCharge: "N", // string 是否已收费 - lisRequestId: null, // string($uuid)LIS申请ID - amount: 1, // integer($int32) 数量 - groupPackageId: groupPackageId, // string($uuid) 分组或者套餐ID - }; - - //待添加的项目在 删除缓存中 存在,则将移至已选中后,删除缓存中的数据 - let exist = arrayExistObj(this.patientRegisterAbsDel, 'asbitemId', asbItem.asbitemId) - if (exist > -1) { - this.patientRegister.patientRegisterAbs.push({ ...this.patientRegisterAbsDel[exist] }) - this.patientRegisterAbsDel.splice(exist, 1) - } else { - this.patientRegisterAbsAdd.push(asbItem); - } + let pojo = { + asbitemId: this.patientRegister.medicalPackageAsb[i].id, + patientRegisterId: this.patientRegisterForm.id, + standardPrice: this.patientRegister.medicalPackageAsb[i].price, + chargePrice: this.patientRegister.medicalPackageAsb[i].price, + payTypeFlag, + isCharge: "N", + amount: 1, + groupPackageId: groupPackageId } + body.push(pojo) + this.patientRegister.patientRegisterAbs.push({...pojo,asbitemName:this.patientRegister.medicalPackageAsb[i].displayName}) } + if (body.length > 0 && this.patientRegisterForm.id) this.batchAddAsb(body, '更换套餐'); + }, //移除旧分组或套餐的组合项目 @@ -457,14 +450,28 @@ export default { let body = {} let registerAsbitemIds = [] let chargeComplete = '' - + + //体检基本信息未保存时,删除所有所选项目 + if(!this.patientRegisterForm.id){ + this.patientRegister.patientRegisterAbs = [] + return + } + //删除已选 分组或套餐的组合项目 ,如已收费或 已检时,将 groupPackageId 置为null for (let i = 0; i < this.patientRegister.patientRegisterAbs.length; i++) { + if(!this.patientRegister.patientRegisterAbs[i].id){ + this.patientRegister.patientRegisterAbs.splice(i, 1) + i-- + continue + } if (this.patientRegister.patientRegisterAbs[i].isCharge == 'Y' || this.patientRegister.patientRegisterAbs[i].checkCompleteFlag != '0') { chargeComplete += this.patientRegister.patientRegisterAbs[i].asbitemName + ',' this.patientRegister.patientRegisterAbs[i].groupPackageId = null - } else{ - registerAsbitemIds.push(this.patientRegister.patientRegisterAbs[i].id) + } else { + //数据库有,才添加到待删除的数组中 + if(this.patientRegister.patientRegisterAbs[i].id){ + registerAsbitemIds.push(this.patientRegister.patientRegisterAbs[i].id) + } this.patientRegister.patientRegisterAbs.splice(i, 1) i-- } @@ -475,27 +482,30 @@ export default { } body = { registerAsbitemIds } - if(registerAsbitemIds.length > 0){ - this.batchDelAsb(body,''); + if (registerAsbitemIds.length > 0) { + this.batchDelAsb(body, ''); } - + let updateBody = [] - if (this.patientRegister.patientRegisterAbs.length > 0) { + if (this.patientRegister.patientRegisterAbs.length > 0) { for (let i = 0; i < this.patientRegister.patientRegisterAbs.length; i++) { - updateBody.push({ - registerAsbitemId: this.patientRegister.patientRegisterAbs[i].id, - input: { - chargePrice: this.patientRegister.patientRegisterAbs[i].chargePrice, - payTypeFlag: this.patientRegister.patientRegisterAbs[i].payTypeFlag, - isCharge: this.patientRegister.patientRegisterAbs[i].isCharge, - amount: this.patientRegister.patientRegisterAbs[i].amount, - groupPackageId: this.patientRegister.patientRegisterAbs[i].groupPackageId - } - }) + //数据库有,才添加到待更新的数组中 + if(this.patientRegister.patientRegisterAbs[i].id){ + updateBody.push({ + registerAsbitemId: this.patientRegister.patientRegisterAbs[i].id, + input: { + chargePrice: this.patientRegister.patientRegisterAbs[i].chargePrice, + payTypeFlag: this.patientRegister.patientRegisterAbs[i].payTypeFlag, + isCharge: this.patientRegister.patientRegisterAbs[i].isCharge, + amount: this.patientRegister.patientRegisterAbs[i].amount, + groupPackageId: this.patientRegister.patientRegisterAbs[i].groupPackageId + } + }) + } } - this.batchEditAsb(updateBody,''); + this.batchEditAsb(updateBody, ''); } - + }, //自定义计算列 @@ -507,11 +517,11 @@ export default { sums[index] = '合计'; return; } - if(index == 0 || index == 4 || index == 5){ + if (index == 0 || index == 4 || index == 5) { sums[index] = ''; return; } - const values = data.map(item => Number(item[column.property])); + const values = data.map(item => Number(item[column.property])); if (!values.every(value => isNaN(value))) { sums[index] = values.reduce((prev, curr) => { const value = Number(curr); @@ -528,8 +538,8 @@ export default { }); return sums; - }, - + }, + }, //监听事件 @@ -538,7 +548,7 @@ export default { "patientRegisterForm.customerOrgGroupId"(newVal, oldVal) { console.log("watch patientRegisterForm.customerOrgGroupId newVal:", newVal, " oldVal:", oldVal); if (newVal != oldVal) { - this.getCustomerOrgGroupAsb(newVal, oldVal); + this.getCustomerOrgGroupAsb(newVal); } }, @@ -546,13 +556,13 @@ export default { "patientRegisterForm.medicalPackageId"(newVal, oldVal) { console.log("watch patientRegisterForm.medicalPackageId newVal:", newVal, " oldVal:", oldVal); if (newVal != oldVal) { - this.getMedicalPackageAsb(newVal, oldVal); + this.getMedicalPackageAsb(newVal); } }, //体检信息触发分组的保存 "patientRegister.saveTimes"(newVal, oldVal) { - this.onSubmit() + this.onSubmit('') }, }, }; diff --git a/src/utlis/istoken.js b/src/utlis/istoken.js index 8e8ec89..8465973 100644 --- a/src/utlis/istoken.js +++ b/src/utlis/istoken.js @@ -3,14 +3,14 @@ import axios from "axios"; import mm from "@/utlis/mm"; export const yztoken = async () => { - console.log("验证"); + //console.log("验证"); //let dqtime = parseInt(new Date().getTime() / 1000); // 当前时间的时间戳 //let tokentime = parseInt(window.localStorage.getItem("expires_in")); //登录缓存后的时间戳 let dqtime = new Date().getTime(); // 当前时间的时间戳 let expires_in = parseInt(window.localStorage.getItem("expires_in")) - console.log("dqtime / expires_in",dqtime,expires_in) + //console.log("dqtime / expires_in",dqtime,expires_in) if (dqtime > expires_in) { - console.log("重新拉取"); + console.log("刷新 token dqtime / expires_in",dqtime,expires_in); //少于300秒 重新拉取 await axios .post( diff --git a/src/utlis/proFunc.js b/src/utlis/proFunc.js index 05aeea6..6744b28 100644 --- a/src/utlis/proFunc.js +++ b/src/utlis/proFunc.js @@ -109,13 +109,14 @@ exports.arrayReduce = function (arrFront, reduceArr, key) { }; //判断数组中 是否存在 某个值的对象记录 如不存在返回 - 1,存在返回相应的 序列 -exports.arrayExistObj = function (arrFront, key, value) { +exports.arrayExistObj = function (arr, key, value) { let ret = - 1 - for(let i = 0;i