diff --git a/src/utlis/proFunc.js b/src/utlis/proFunc.js index e5c6f78..1eb2e42 100644 --- a/src/utlis/proFunc.js +++ b/src/utlis/proFunc.js @@ -21,6 +21,27 @@ exports.objCopy = (from, to) => { } }; +//对象深拷贝 +function deepCopy(obj) { + if (typeof obj != 'object' || obj == null) { + return obj; + } + let copy; + if (Array.isArray(obj)) { + copy = []; + for (let i = 0; i < obj.length; i++) { + copy[i] = deepCopy(obj[i]); + } + } else { + copy = {}; + for (let key in obj) { + copy[key] = deepCopy(obj[key]); + } + } + return copy; +}; +exports.deepCopy = deepCopy; + //类似PB中的dddw的功能 add by pengjun exports.dddw = (arrayData, key, value, display) => { //console.log(arrayData,key,value,display) diff --git a/src/views/charge/charge.vue b/src/views/charge/charge.vue index df9514d..74880c7 100644 --- a/src/views/charge/charge.vue +++ b/src/views/charge/charge.vue @@ -15,15 +15,20 @@
- 查询 + 查询
- + 未收费 已收费 已退费 +
+ 发票号 + +
@@ -73,25 +78,27 @@
条码号 - +
档案号 - +
姓名 - +
-
- +
+ @@ -116,7 +123,7 @@ - + @@ -132,24 +139,25 @@
-
收费方式:
+
{{ query.chargeFlag == 'B' ? '退' : '收' }}费方式:
- + @@ -157,32 +165,35 @@
-
待收费项目:
+
{{ query.chargeFlag == 'N' ? '待收' : (query.chargeFlag == 'Y' ? + '已收' : '已退') }}费项目:
- - + + - + - + - + @@ -222,7 +233,7 @@ import moment from 'moment'; import { mapState, mapActions } from "vuex"; import { getapi, postapi, putapi, deletapi } from "@/api/api"; -import { tcdate, dddw, arrayExistObj } from "../../utlis/proFunc"; +import { tcdate, dddw, arrayExistObj, deepCopy } from "../../utlis/proFunc"; import PatientRegisterQuery from "../../components/patientRegister/patientRegisterQuery.vue"; import PatientRegisterRefuseList from "../../components/patientRegister/PatientRegisterRefuseList.vue"; @@ -234,7 +245,14 @@ export default { }, data() { return { - query: { chargeFlag: 'N' },//查询条件 + query: { + chargeFlag: 'N', + dateRange: null, + patientRegisterNo: '', + patientNo: '', + invoiceNo: '', + patientName: '', + },//查询条件 patientList: [],//人员列表 form: { id: null, @@ -288,9 +306,10 @@ export default { ], }, chargePays: [], //收支方式 + chargePaysInit: [], //收支方式(初始状态) asbItemsForFee: [], //待收费项目 selectedData: [], //选中项目 - cardRegister: [{ id: '00000000-0000-0000-0000-000000000000', idNo: '0001' }], //当前客户的会员卡 + cardRegister: [{ id: '00000000-0000-0000-0000-000000000000', cardNo: '0001' }], //当前客户的会员卡 cardRegisterAll: [], //所有客户的会员卡 }; }, @@ -314,19 +333,48 @@ export default { dddw, moment, //查询人员列表数据 - Query() { + Query(type) { let url = '', body = {}; - console.log('query', this.query); + console.log('query', type, this.query); + + // { + // "skipCount": 2147483647, + // "sorting": "string", + // "patientName": "string", + // "patientNo": "string", + // "patientRegisterNo": "string", + // "invoiceNo": "string", + // "startDate": "string", + // "endDate": "string", + // "maxResultCount": 0 + // } + if (type == 'patientRegisterNo') { + if (!this.query.patientRegisterNo) return; + body = { patientRegisterNo: this.query.patientRegisterNo }; + } else if (type == 'patientNo') { + if (!this.query.patientNo) return; + body = { patientNo: this.query.patientNo }; + } else if (type == 'invoiceNo' && this.query.chargeFlag != 'N') { + if (!this.query.invoiceNo) return; + body = { invoiceNo: this.query.invoiceNo }; + } else { + if (this.query.dateRange) { + body.startDate = moment(this.query.dateRange[0]).format('yyyy-MM-DD'); + body.endDate = moment(this.query.dateRange[1]).format('yyyy-MM-DD'); + } + // if(this.query.patientName){ + // body.patientName = this.query.patientName; + // } + } + switch (this.query.chargeFlag) { case 'Y': //已收费 url = '/api/app/patientregister/getpatientregisterchargelist'; - break; case 'B': //已退费 url = '/api/app/patientregister/getpatientregisterchargebacklist'; - break; default: //未收费 @@ -337,6 +385,11 @@ export default { postapi(url, body).then(res => { if (res.code != - 1) { this.patientList = res.data.items; + if (this.patientList.length > 0) { + this.query.patientRegisterNo = this.patientList[0].patientRegisterNo; + this.query.patientName = this.patientList[0].patientName; + this.query.patientNo = this.patientList[0].patientNo; + } } }); @@ -344,6 +397,13 @@ export default { //人员列表点击 rowClick(row) { + this.query.patientRegisterNo = row.patientRegisterNo; + this.query.patientName = row.patientName; + this.query.patientNo = row.patientNo; + + this.chargePays = deepCopy(this.chargePaysInit); + //console.log(this.chargePays, this.chargePaysInit); + if (this.query.chargeFlag == 'B') { this.form.chargeFlag = '1'; } else { @@ -359,55 +419,53 @@ export default { this.form.invoiceNo = ''; this.form.invoiceOrgName = row.patientName; } - this.getCardRegister(row.idNo); - this.getAsbItemsForFee(row.patientRegisterId, row.chargeId); + //获取个人会员卡信息 + this.getCardRegister(row.idNo); - if (this.query.chargeFlag == 'Y') { - this.getChargePayByChargeId(row.chargeId); - this.getChargeAsbByChargeid(row.chargeId); - } else if (this.query.chargeFlag == 'B') { - this.getChargeBackPayByChargeBackId(row.chargeBackId); - this.getChargeAsbByChargeid(row.chargeId); - } + switch (this.query.chargeFlag) { + case 'N': + this.getAsbItemsForFee(row.patientRegisterId); + break; + case 'Y': + this.getChargePayByChargeId(row.chargeId); + this.getChargeAsbByChargeid(row.chargeId); + break; + default: + this.getChargeBackPayByChargeBackId(row.chargeBackId); + this.getChargeAsbByChargeid(row.chargeId); + break; + } }, //获取项目列表 - async getAsbItemsForFee(patientRegisterId, chargeId) { + async getAsbItemsForFee(patientRegisterId) { //待收费项目列表 this.asbItemsForFee = []; - if (this.query.chargeFlag == 'N') { - getapi(`/api/app/registerasbitem/getlistinpatientregisterid?PatientRegisterId=${patientRegisterId}`) - .then(res => { - if (res.code == 1) { - this.asbItemsForFee = res.data; - - for (let i = this.asbItemsForFee.length - 1; i >= 0; i--) { - if (this.asbItemsForFee[i].isCharge == 'Y') { - this.asbItemsForFee.splice(i, 1); - continue; - } - this.asbItemsForFee[i].chargePriceOri = this.asbItemsForFee[i].chargePrice; - this.asbItemsForFee[i].discount = Math.round(10000 * this.asbItemsForFee[i].chargePrice / this.asbItemsForFee[i].standardPrice) / 100; - this.asbItemsForFee[i].standTotal = this.asbItemsForFee[i].amount * this.asbItemsForFee[i].standardPrice; - this.asbItemsForFee[i].total = this.asbItemsForFee[i].amount * this.asbItemsForFee[i].chargePrice; - } - //勾选已收费项目 - this.toCharge(patientRegisterId); - } - }); - } else { - //已收费项目列表 - getapi(`/api/app/registerasbitem/getlistinpatientregisterid?PatientRegisterId=${chargeId}`) - .then(res => { - if (res.code == 1) { - this.asbItemsForFee = res.data; + getapi(`/api/app/registerasbitem/getlistinpatientregisterid?PatientRegisterId=${patientRegisterId}`) + .then(res => { + if (res.code == 1) { + this.asbItemsForFee = res.data; + + for (let i = this.asbItemsForFee.length - 1; i >= 0; i--) { + if (this.asbItemsForFee[i].isCharge == 'Y' || this.asbItemsForFee[i].payTypeFlag == '1') { + this.asbItemsForFee.splice(i, 1); + continue; + } + this.asbItemsForFee[i].chargePriceOri = this.asbItemsForFee[i].chargePrice; + this.asbItemsForFee[i].discount = Math.round(10000 * this.asbItemsForFee[i].chargePrice / this.asbItemsForFee[i].standardPrice) / 100; + this.asbItemsForFee[i].standTotal = this.asbItemsForFee[i].amount * this.asbItemsForFee[i].standardPrice; + this.asbItemsForFee[i].total = this.asbItemsForFee[i].amount * this.asbItemsForFee[i].chargePrice; } - }); - } + + //勾选已收费项目 + this.toCharge(patientRegisterId); + } + }); + }, @@ -430,7 +488,7 @@ export default { getCardRegister(idNo) { let body = { cardModeId: '0', idNo }; this.cardRegister = []; - getapi(`/api/app/cardregister/getcardregisterlist`, body).then(res => { + postapi(`/api/app/cardregister/getcardregisterlist`, body).then(res => { if (res.code != - 1) { this.cardRegister = res.data; } @@ -457,6 +515,7 @@ export default { creationTime: e.creationTime, }); }); + this.sumTotal(this.asbItemsForFee, this.form); } }); }, @@ -470,7 +529,7 @@ export default { lfind = arrayExistObj(this.chargePays, 'payModeId', e.payModeId); if (lfind > - 1) { this.chargePays[lfind].chargeMoney = e.chargeMoney; - this.chargePays[lfind].cardRegisterId = e.cardBillId; + this.chargePays[lfind].cardRegisterId = e.cardRegisterId; } }); } @@ -485,7 +544,7 @@ export default { lfind = arrayExistObj(this.chargePays, 'payModeId', e.payModeId); if (lfind > - 1) { this.chargePays[lfind].chargeMoney = e.backMoeny; - this.chargePays[lfind].cardRegisterId = e.cardBillId; + this.chargePays[lfind].cardRegisterId = e.cardRegisterId; } }); } @@ -505,20 +564,25 @@ export default { }, //根据明细算总价与折扣 - sumTotal() { + sumTotal(details, head) { let total = 0, totalOri = 0; - this.selectedData.forEach(e => { + + details.forEach(e => { totalOri += Math.round(e.amount * e.chargePriceOri * 100) / 100; //原始实收价格 total += Math.round(e.amount * e.chargePrice * 100) / 100; //当前实收价格 //console.log(total, e.chargePrice, e.amount) }); - this.form.total = total; - this.form.preTotal = total; + total = Math.round(total * 100) / 100; + totalOri = Math.round(totalOri * 100) / 100; + + head.total = total; + head.preTotal = total; if (totalOri == 0) { - this.form.discount = 100; + head.discount = 100; } else { - this.form.discount = Math.round(10000 * total / totalOri) / 100; + head.discount = Math.round(10000 * total / totalOri) / 100; } + }, //通过折扣计算总价与明细价格 @@ -602,7 +666,7 @@ export default { //勾选要收费的项目 handleSelectionChange(v) { this.selectedData = v; - this.sumTotal(); + this.sumTotal(this.selectedData, this.form); }, //调整明细折扣 @@ -617,7 +681,7 @@ export default { totalDetailsCur = Math.round(100 * row.amount * row.chargePrice) / 100; this.form.total = total + totalDetailsCur - totalDetailsOri; } - this.sumTotal(); + this.sumTotal(this.selectedData, this.form); }, @@ -626,7 +690,7 @@ export default { if (row.chargePriceOri != 0) { row.discount = Math.round(10000 * row.chargePrice / row.standardPrice) / 100; } - this.sumTotal(); + this.sumTotal(this.selectedData, this.form); }, //收费 @@ -823,9 +887,8 @@ export default { ], }; - if (isPreview) { - getapi(`/api/app/printreport/getpatientregisterguidereport?PatientRegisterId=${chargeId}`) + postapi(`/api/app/printreport/getchargereport?ChargeId=${chargeId}`) .then((res) => { if (res.code != -1) { toOutShell.ReportTable = res.data; @@ -837,7 +900,7 @@ export default { this.$message.warning(err); }); } else { - getapi(`/api/app/printreport/getpatientregisterguidereport?PatientRegisterId=${chargeId}`) + postapi(`/api/app/printreport/getchargereport?ChargeId=${chargeId}`) .then((res) => { if (res.code != -1) { toOutShell.ReportTable = res.data; @@ -952,10 +1015,11 @@ export default { if (res.code == 1) { this.dict.payMode = res.data; //未收费时 - this.chargePays = []; + this.chargePaysInit = []; this.dict.payMode.forEach(e => { - this.chargePays.push({ chargeId: null, payModeId: e.id, chargeMoney: 0, cardBillId: null }) - }) + this.chargePaysInit.push({ chargeId: null, payModeId: e.id, chargeMoney: 0, cardBillId: null }) + }); + this.chargePays = deepCopy(this.chargePaysInit); } });