- 收费
- 退费
@@ -614,13 +614,16 @@ export default {
totalOri = Math.round(totalOri * 100) / 100;
head.total = total;
- head.preTotal = total;
+ //head.preTotal = total;
if (totalOri == 0) {
head.discount = 100;
} else {
head.discount = Math.round(10000 * total / totalOri) / 100;
}
+ //
+ this.findBalance()
+
},
//通过折扣计算总价与明细价格
@@ -639,10 +642,11 @@ export default {
});
totalPlan = Math.round(totalOri * discount) / 100;
this.form.total = totalPlan;
- this.form.preTotal = totalPlan;
+ //this.form.preTotal = totalPlan;
//明细和与总金额不符处理
this.handleBalance(totalPlan, totalCompute);
+ this.findBalance()
},
//通过总价计算折扣与明细价格
@@ -668,9 +672,11 @@ export default {
totalCompute += Math.round(100 * e.chargePrice * e.amount) / 100;
}
});
- this.form.preTotal = totalPlan;
+ //this.form.preTotal = totalPlan;
//明细和与总金额不符处理
this.handleBalance(totalPlan, totalCompute);
+
+ this.findBalance()
},
//明细合计金额与总金额不一致时,处理
@@ -688,19 +694,29 @@ export default {
},
//输入预收金额,计算找零
- findBalance() {
- this.form.balance = this.form.preTotal - this.form.total;
+ findBalance() {
+ this.form.balance = Math.round((this.form.preTotal - this.form.total)*100)/100;
},
//输入收费方式金额
inputMoney() {
- let total = Number(0);
+ // 现金 id = 01
+ let cashTotal= Number(0), unCashTotal= Number(0);
this.chargePays.forEach(e => {
- total += Number(e.chargeMoney);
+ console.log('e',e)
+ if(e.payModeId == '01'){
+ cashTotal += Number(e.chargeMoney);
+ }else{
+ unCashTotal += Number(e.chargeMoney);
+ }
});
- if (total > this.form.total) this.$message.warning("输入金额超过总金额");
+ this.form.preTotal = cashTotal + unCashTotal
+ this.findBalance()
+ if (unCashTotal > this.form.total) this.$message.warning(`数据校验失败:输入的非现金金额${unCashTotal}不能超过应收金额${this.form.total}!`);
+
},
+
//勾选要收费的项目
handleSelectionChange(v) {
this.selectedData = v;
@@ -732,9 +748,9 @@ export default {
},
//收费
- charge() {
+ btnCharge() {
let body = {};
- let total = 0;
+ let unCashTotal = Number(0) , cashTotal = Number(0);
let msg = '';
let chargePays = [];
let asbitems = [];
@@ -757,14 +773,17 @@ export default {
}
this.chargePays.forEach(e => {
- total += Number(e.chargeMoney);
+ if(e.payModeId == '01'){
+ cashTotal += Number(e.chargeMoney);
+ }else{
+ unCashTotal += Number(e.chargeMoney);
+ }
if (e.payModeId == '05' && e.chargeMoney) {
//console.log(e.payModeId,e.chargeMoney,e.cardRegisterId);
- if (!e.cardRegisterId) msg = '请先择会员卡号';
+ if (!e.cardRegisterId) msg = dddw(this.dict.payMode, "id", e.payModeId, "displayName") + '付费,必需选择会员卡号';
} else {
e.cardRegisterId = null;
- }
- return e;
+ }
});
if (msg) {
@@ -772,20 +791,34 @@ export default {
return;
}
- if (total != this.form.total) {
- this.$message.warning("收费方式合计金额与收费总金额不符");
+ //规避套现
+ if (unCashTotal > this.form.total) {
+ this.$message.warning("非现金收款不可大于应收金额!");
return;
}
+ if (unCashTotal + cashTotal < this.form.total) {
+ this.$message.warning("收费方式合计收款不可小于应收金额!");
+ return;
+ }
this.chargePays.forEach(e => {
if (e.chargeMoney) {
- chargePays.push({
- payModeId: e.payModeId,
- chargeMoney: e.chargeMoney,
- cardRegisterId: e.cardRegisterId,
- });
+ if(e.payModeId == '01'){
+ //现金支付,数据库中存找零后的现金
+ chargePays.push({
+ payModeId: e.payModeId,
+ chargeMoney: e.chargeMoney - this.form.balance,
+ cardRegisterId: e.cardRegisterId,
+ });
+ }else{
+ chargePays.push({
+ payModeId: e.payModeId,
+ chargeMoney: e.chargeMoney,
+ cardRegisterId: e.cardRegisterId,
+ });
+ }
}
});
@@ -828,16 +861,31 @@ export default {
//console.log('body',body);
postapi('/api/app/registerasbitem/registerasbitemcharge', body).then(res => {
if (res.code != -1) {
- this.$message.success("操作成功!");
- this.form.id = "操作成功!"; //防止重复提交收费
- this.Query();
+
+ this.form.id = res.data.chargeId; //可防止重复提交收费
+
+ this.$confirm("操作成功, 是否打印发票?", "提示", {
+ confirmButtonText: "是",
+ cancelButtonText: "否",
+ type: "warning",
+ }).then(() => {
+ this.chargePrint('0007', false, res.data.chargeId)
+ setTimeout(() => {
+ this.Query();
+ }, 1000)
+ }).catch((err) => {
+ if (err == "cancel") {
+ //this.$message.info("已取消删除");
+ this.Query();
+ }
+ });
}
});
},
//退费
- chargeBack() {
+ btnChargeBack() {
let chargeId = this.form.id;
let msg = '';
let chargeBackPays = [];
@@ -855,61 +903,73 @@ export default {
}
- this.chargePays.forEach(e => {
- total += Number(e.chargeMoney);
- if (e.payModeId == '05' && e.chargeMoney) {
- if (!e.cardRegisterId) msg = '请先择会员卡号';
- } else {
- e.cardRegisterId = null;
+ this.$confirm("是否确定执行退费操作?", "提示", {
+ confirmButtonText: "是",
+ cancelButtonText: "否",
+ type: "warning",
+ }).then(() => {
+ this.chargePays.forEach(e => {
+ total += Number(e.chargeMoney);
+ if (e.payModeId == '05' && e.chargeMoney) {
+ if (!e.cardRegisterId) msg = '请先择会员卡号';
+ } else {
+ e.cardRegisterId = null;
+ }
+ return e;
+ });
+
+ if (msg) {
+ this.$message.warning(msg);
+ return;
+ }
+ if (total != this.form.total) {
+ this.$message.warning("退费方式合计金额与退费总金额不符");
+ return;
}
- return e;
- });
- if (msg) {
- this.$message.warning(msg);
- return;
- }
- if (total != this.form.total) {
- this.$message.warning("退费方式合计金额与退费总金额不符");
- return;
- }
+ this.chargePays.forEach(e => {
+ if (e.chargeMoney) {
+ chargeBackPays.push({
+ payModeId: e.payModeId,
+ backMoeny: e.chargeMoney,
+ cardRegisterId: e.cardRegisterId,
+ });
+ }
+ });
- this.chargePays.forEach(e => {
- if (e.chargeMoney) {
- chargeBackPays.push({
- payModeId: e.payModeId,
- backMoeny: e.chargeMoney,
- cardRegisterId: e.cardRegisterId,
- });
+ // {
+ // "chargeId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
+ // "chargeBackPays": [
+ // {
+ // "payModeId": "string",
+ // "backMoeny": 0,
+ // "cardRegisterId": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
+ // }
+ // ]
+ // }
+ body = {
+ chargeId, chargeBackPays
}
- });
+ postapi('/api/app/registerasbitem/registerasbitemchargeback', body).then(res => {
+ if (res.code != -1) {
+ this.$message.success("操作成功!");
+ this.form.chargeFlag = '1'; //防止重复提交退费
+ this.Query();
+ }
+ });
- // {
- // "chargeId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
- // "chargeBackPays": [
- // {
- // "payModeId": "string",
- // "backMoeny": 0,
- // "cardRegisterId": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
- // }
- // ]
- // }
- body = {
- chargeId, chargeBackPays
- }
- postapi('/api/app/registerasbitem/registerasbitemchargeback', body).then(res => {
- if (res.code != -1) {
- this.$message.success("操作成功!");
- this.form.chargeFlag = '1'; //防止重复提交退费
- this.Query();
+ }).catch((err) => {
+ if (err == "cancel") {
+ this.$message.info("已取消删除");
}
- });
+ });
},
//收费打印
chargePrint(ReportCode, isPreview, chargeId) {
- if (chargeId.length < 1) {
+ console.log('ReportCode, isPreview, chargeId',ReportCode, isPreview, chargeId)
+ if (!chargeId) {
this.$message.info("人员信息尚未保存,不可执行此操作!");
return;
}
@@ -938,6 +998,12 @@ export default {
return this.$peisAPI.printPre(JSON.stringify(toOutShell));
}
})
+ .then(res =>{
+ console.log(res)
+ if(JSON.parse(res).code < 0){
+ this.$message.error(JSON.parse(res).message)
+ }
+ })
.catch(err => {
this.$message.warning(err);
});
@@ -950,6 +1016,12 @@ export default {
return this.$peisAPI.print(JSON.stringify(toOutShell));
}
})
+ .then(res =>{
+ console.log(res)
+ if(JSON.parse(res).code < 0){
+ this.$message.error(JSON.parse(res).message)
+ }
+ })
.catch(err => {
this.$message.warning(err);
});