9.18王德鹏/1
This commit is contained in:
@@ -27,7 +27,10 @@ const _sfc_main = {
|
||||
activeCategory: "sale_income",
|
||||
trxAmount: 0,
|
||||
selectedAccountId: null,
|
||||
selectedAccountName: ""
|
||||
selectedAccountName: "",
|
||||
// 收款/付款输入
|
||||
payments: { cash: 0, bank: 0, wechat: 0 },
|
||||
showMore: false
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@@ -54,6 +57,11 @@ const _sfc_main = {
|
||||
},
|
||||
counterpartyLabel() {
|
||||
return this.customerName || this.supplierName || "—";
|
||||
},
|
||||
// 收款/付款合计
|
||||
payTotal() {
|
||||
const p = this.payments || { cash: 0, bank: 0, wechat: 0 };
|
||||
return Number(p.cash || 0) + Number(p.bank || 0) + Number(p.wechat || 0);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -83,10 +91,19 @@ const _sfc_main = {
|
||||
recalc() {
|
||||
this.$forceUpdate();
|
||||
},
|
||||
recalcPay() {
|
||||
this.$forceUpdate();
|
||||
},
|
||||
async submit() {
|
||||
const isSaleOrPurchase = this.biz === "sale" || this.biz === "purchase";
|
||||
const payload = isSaleOrPurchase ? {
|
||||
type: this.biz === "sale" ? this.saleType : "purchase." + this.purchaseType,
|
||||
const isCollectOrPay = this.biz === "sale" && this.saleType === "collect" || this.biz === "purchase" && this.purchaseType === "pay";
|
||||
const saleTypeValue = this.biz === "sale" ? "sale." + this.saleType : "purchase." + this.purchaseType;
|
||||
const payload = isSaleOrPurchase ? isCollectOrPay ? [
|
||||
{ method: "cash", amount: Number(this.payments.cash || 0) },
|
||||
{ method: "bank", amount: Number(this.payments.bank || 0) },
|
||||
{ method: "wechat", amount: Number(this.payments.wechat || 0) }
|
||||
].filter((p) => p.amount > 0) : {
|
||||
type: saleTypeValue,
|
||||
orderTime: this.order.orderTime,
|
||||
customerId: this.order.customerId,
|
||||
supplierId: this.order.supplierId,
|
||||
@@ -102,7 +119,7 @@ const _sfc_main = {
|
||||
remark: this.order.remark
|
||||
};
|
||||
try {
|
||||
const url = isSaleOrPurchase ? "/api/orders" : "/api/other-transactions";
|
||||
const url = isSaleOrPurchase ? isCollectOrPay ? `/api/payments/${this.biz}` : "/api/orders" : "/api/other-transactions";
|
||||
await common_http.post(url, payload);
|
||||
common_vendor.index.showToast({ title: "已保存", icon: "success" });
|
||||
setTimeout(() => {
|
||||
@@ -116,6 +133,7 @@ const _sfc_main = {
|
||||
this.items = [];
|
||||
this.trxAmount = 0;
|
||||
this.order.remark = "";
|
||||
this.payments = { cash: 0, bank: 0, wechat: 0 };
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -158,13 +176,42 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
F: common_vendor.o((...args) => $options.chooseSupplier && $options.chooseSupplier(...args))
|
||||
} : {}, {
|
||||
D: $data.biz === "purchase",
|
||||
G: $data.biz === "sale" || $data.biz === "purchase"
|
||||
}, $data.biz === "sale" || $data.biz === "purchase" ? {
|
||||
H: common_vendor.t($options.totalQuantity),
|
||||
I: common_vendor.t($options.totalAmount.toFixed(2)),
|
||||
J: common_vendor.o((...args) => $options.chooseProduct && $options.chooseProduct(...args))
|
||||
G: $data.biz === "sale" && $data.saleType === "collect" || $data.biz === "purchase" && $data.purchaseType === "pay"
|
||||
}, $data.biz === "sale" && $data.saleType === "collect" || $data.biz === "purchase" && $data.purchaseType === "pay" ? common_vendor.e({
|
||||
H: $data.biz === "sale"
|
||||
}, $data.biz === "sale" ? {
|
||||
I: common_vendor.t($options.customerLabel),
|
||||
J: common_vendor.o((...args) => $options.chooseCustomer && $options.chooseCustomer(...args))
|
||||
} : {
|
||||
K: common_vendor.f($data.biz === "income" ? $options.incomeCategories : $options.expenseCategories, (c, k0, i0) => {
|
||||
K: common_vendor.t($options.supplierLabel),
|
||||
L: common_vendor.o((...args) => $options.chooseSupplier && $options.chooseSupplier(...args))
|
||||
}, {
|
||||
M: common_vendor.o([common_vendor.m(($event) => $data.payments.cash = $event.detail.value, {
|
||||
number: true
|
||||
}), ($event) => $options.recalcPay()]),
|
||||
N: $data.payments.cash,
|
||||
O: common_vendor.o([common_vendor.m(($event) => $data.payments.bank = $event.detail.value, {
|
||||
number: true
|
||||
}), ($event) => $options.recalcPay()]),
|
||||
P: $data.payments.bank,
|
||||
Q: common_vendor.o([common_vendor.m(($event) => $data.payments.wechat = $event.detail.value, {
|
||||
number: true
|
||||
}), ($event) => $options.recalcPay()]),
|
||||
R: $data.payments.wechat,
|
||||
S: common_vendor.t($data.showMore ? "收起" : ""),
|
||||
T: common_vendor.o(($event) => $data.showMore = !$data.showMore),
|
||||
U: common_vendor.t($options.payTotal.toFixed(2)),
|
||||
V: $data.order.remark,
|
||||
W: common_vendor.o(($event) => $data.order.remark = $event.detail.value),
|
||||
X: common_vendor.t($data.order.orderTime),
|
||||
Y: $data.order.orderTime,
|
||||
Z: common_vendor.o((...args) => $options.onDateChange && $options.onDateChange(...args))
|
||||
}) : $data.biz === "sale" || $data.biz === "purchase" ? {
|
||||
ab: common_vendor.t($options.totalQuantity),
|
||||
ac: common_vendor.t($options.totalAmount.toFixed(2)),
|
||||
ad: common_vendor.o((...args) => $options.chooseProduct && $options.chooseProduct(...args))
|
||||
} : {
|
||||
ae: common_vendor.f($data.biz === "income" ? $options.incomeCategories : $options.expenseCategories, (c, k0, i0) => {
|
||||
return {
|
||||
a: common_vendor.t(c.label),
|
||||
b: c.key,
|
||||
@@ -172,22 +219,23 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
d: common_vendor.o(($event) => $data.activeCategory = c.key, c.key)
|
||||
};
|
||||
}),
|
||||
L: common_vendor.t($options.counterpartyLabel),
|
||||
M: common_vendor.o((...args) => $options.chooseCounterparty && $options.chooseCounterparty(...args)),
|
||||
N: common_vendor.t($options.accountLabel),
|
||||
O: common_vendor.o((...args) => $options.chooseAccount && $options.chooseAccount(...args)),
|
||||
P: $data.trxAmount,
|
||||
Q: common_vendor.o(common_vendor.m(($event) => $data.trxAmount = $event.detail.value, {
|
||||
af: common_vendor.t($options.counterpartyLabel),
|
||||
ag: common_vendor.o((...args) => $options.chooseCounterparty && $options.chooseCounterparty(...args)),
|
||||
ah: common_vendor.t($options.accountLabel),
|
||||
ai: common_vendor.o((...args) => $options.chooseAccount && $options.chooseAccount(...args)),
|
||||
aj: $data.trxAmount,
|
||||
ak: common_vendor.o(common_vendor.m(($event) => $data.trxAmount = $event.detail.value, {
|
||||
number: true
|
||||
})),
|
||||
R: $data.order.remark,
|
||||
S: common_vendor.o(($event) => $data.order.remark = $event.detail.value)
|
||||
al: $data.order.remark,
|
||||
am: common_vendor.o(($event) => $data.order.remark = $event.detail.value)
|
||||
}, {
|
||||
T: !$data.items.length
|
||||
aa: $data.biz === "sale" || $data.biz === "purchase",
|
||||
an: !$data.items.length
|
||||
}, !$data.items.length ? {
|
||||
U: common_assets._imports_0$1
|
||||
ao: common_assets._imports_0$1
|
||||
} : {
|
||||
V: common_vendor.f($data.items, (it, idx, i0) => {
|
||||
ap: common_vendor.f($data.items, (it, idx, i0) => {
|
||||
return {
|
||||
a: common_vendor.t(it.productName),
|
||||
b: common_vendor.o([common_vendor.m(($event) => it.quantity = $event.detail.value, {
|
||||
@@ -203,8 +251,8 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
};
|
||||
})
|
||||
}, {
|
||||
W: common_vendor.o((...args) => $options.saveAndReset && $options.saveAndReset(...args)),
|
||||
X: common_vendor.o((...args) => $options.submit && $options.submit(...args))
|
||||
aq: common_vendor.o((...args) => $options.saveAndReset && $options.saveAndReset(...args)),
|
||||
ar: common_vendor.o((...args) => $options.submit && $options.submit(...args))
|
||||
});
|
||||
}
|
||||
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
|
||||
|
||||
Reference in New Issue
Block a user