9.20/1
This commit is contained in:
@@ -28,6 +28,7 @@ const _sfc_main = {
|
||||
supplierName: "",
|
||||
items: [],
|
||||
activeCategory: "sale_income",
|
||||
counterpartyType: "customer",
|
||||
trxAmount: 0,
|
||||
selectedAccountId: null,
|
||||
selectedAccountName: "",
|
||||
@@ -50,16 +51,16 @@ const _sfc_main = {
|
||||
return this.supplierName || "零散供应商";
|
||||
},
|
||||
incomeCategories() {
|
||||
return common_constants.INCOME_CATEGORIES;
|
||||
return this._incomeCategories || common_constants.INCOME_CATEGORIES;
|
||||
},
|
||||
expenseCategories() {
|
||||
return common_constants.EXPENSE_CATEGORIES;
|
||||
return this._expenseCategories || common_constants.EXPENSE_CATEGORIES;
|
||||
},
|
||||
accountLabel() {
|
||||
return this.selectedAccountName || "现金";
|
||||
},
|
||||
counterpartyLabel() {
|
||||
return this.customerName || this.supplierName || "—";
|
||||
return this.counterpartyType === "customer" ? this.customerName || "—" : this.supplierName || "—";
|
||||
},
|
||||
// 收款/付款合计
|
||||
payTotal() {
|
||||
@@ -67,6 +68,9 @@ const _sfc_main = {
|
||||
return Number(p.cash || 0) + Number(p.bank || 0) + Number(p.wechat || 0);
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.fetchCategories();
|
||||
},
|
||||
onShow() {
|
||||
if (this.biz === "sale") {
|
||||
if (this.order.customerId && this.order.customerId !== this._lastCustomerId) {
|
||||
@@ -85,6 +89,26 @@ const _sfc_main = {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async fetchCategories() {
|
||||
try {
|
||||
const res = await common_http.get("/api/finance/categories");
|
||||
if (res && Array.isArray(res.incomeCategories))
|
||||
this._incomeCategories = res.incomeCategories;
|
||||
if (res && Array.isArray(res.expenseCategories))
|
||||
this._expenseCategories = res.expenseCategories;
|
||||
this.ensureActiveCategory();
|
||||
} catch (_) {
|
||||
this.ensureActiveCategory();
|
||||
}
|
||||
},
|
||||
ensureActiveCategory() {
|
||||
const list = this.biz === "income" ? this.incomeCategories || [] : this.expenseCategories || [];
|
||||
if (!list.length)
|
||||
return;
|
||||
const exists = list.some((it) => it && it.key === this.activeCategory);
|
||||
if (!exists)
|
||||
this.activeCategory = list[0].key;
|
||||
},
|
||||
async loadCustomerLevel(customerId) {
|
||||
try {
|
||||
const d = await common_http.get(`/api/customers/${customerId}`);
|
||||
@@ -133,6 +157,7 @@ const _sfc_main = {
|
||||
},
|
||||
switchBiz(type) {
|
||||
this.biz = type;
|
||||
this.ensureActiveCategory();
|
||||
},
|
||||
onDateChange(e) {
|
||||
this.order.orderTime = e.detail.value;
|
||||
@@ -147,13 +172,21 @@ const _sfc_main = {
|
||||
common_vendor.index.navigateTo({ url: "/pages/product/select" });
|
||||
},
|
||||
chooseAccount() {
|
||||
common_vendor.index.navigateTo({ url: "/pages/account/select" });
|
||||
common_vendor.index.navigateTo({ url: "/pages/account/select?mode=pick" });
|
||||
},
|
||||
chooseCounterparty() {
|
||||
if (this.biz === "income" || this.biz === "expense") {
|
||||
if (!(this.biz === "income" || this.biz === "expense"))
|
||||
return;
|
||||
if (this.counterpartyType === "customer") {
|
||||
common_vendor.index.navigateTo({ url: "/pages/customer/select" });
|
||||
} else {
|
||||
common_vendor.index.navigateTo({ url: "/pages/supplier/select" });
|
||||
}
|
||||
},
|
||||
setCounterparty(t) {
|
||||
this.counterpartyType = t;
|
||||
this.ensureActiveCategory();
|
||||
},
|
||||
recalc() {
|
||||
this.$forceUpdate();
|
||||
},
|
||||
@@ -189,7 +222,8 @@ const _sfc_main = {
|
||||
} : {
|
||||
type: this.biz,
|
||||
category: this.activeCategory,
|
||||
counterpartyId: this.order.customerId || null,
|
||||
counterpartyType: this.counterpartyType,
|
||||
counterpartyId: this.counterpartyType === "customer" ? this.order.customerId || null : this.order.supplierId || null,
|
||||
accountId: this.selectedAccountId || null,
|
||||
amount: Number(this.trxAmount || 0),
|
||||
txTime: this.order.orderTime,
|
||||
@@ -288,7 +322,11 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
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) => {
|
||||
ae: $data.counterpartyType === "customer" ? 1 : "",
|
||||
af: common_vendor.o(($event) => $options.setCounterparty("customer")),
|
||||
ag: $data.counterpartyType === "supplier" ? 1 : "",
|
||||
ah: common_vendor.o(($event) => $options.setCounterparty("supplier")),
|
||||
ai: common_vendor.f($data.biz === "income" ? $options.incomeCategories : $options.expenseCategories, (c, k0, i0) => {
|
||||
return {
|
||||
a: common_vendor.t(c.label),
|
||||
b: c.key,
|
||||
@@ -296,23 +334,23 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
d: common_vendor.o(($event) => $data.activeCategory = c.key, c.key)
|
||||
};
|
||||
}),
|
||||
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, {
|
||||
aj: common_vendor.t($options.counterpartyLabel),
|
||||
ak: common_vendor.o((...args) => $options.chooseCounterparty && $options.chooseCounterparty(...args)),
|
||||
al: common_vendor.t($options.accountLabel),
|
||||
am: common_vendor.o((...args) => $options.chooseAccount && $options.chooseAccount(...args)),
|
||||
an: $data.trxAmount,
|
||||
ao: common_vendor.o(common_vendor.m(($event) => $data.trxAmount = $event.detail.value, {
|
||||
number: true
|
||||
})),
|
||||
al: $data.order.remark,
|
||||
am: common_vendor.o(($event) => $data.order.remark = $event.detail.value)
|
||||
ap: $data.order.remark,
|
||||
aq: common_vendor.o(($event) => $data.order.remark = $event.detail.value)
|
||||
}, {
|
||||
aa: $data.biz === "sale" || $data.biz === "purchase",
|
||||
an: !$data.items.length
|
||||
ar: !$data.items.length
|
||||
}, !$data.items.length ? {
|
||||
ao: common_assets._imports_0$1
|
||||
as: common_assets._imports_0$1
|
||||
} : {
|
||||
ap: common_vendor.f($data.items, (it, idx, i0) => {
|
||||
at: 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, {
|
||||
@@ -328,8 +366,8 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
};
|
||||
})
|
||||
}, {
|
||||
aq: common_vendor.o((...args) => $options.saveAndReset && $options.saveAndReset(...args)),
|
||||
ar: common_vendor.o((...args) => $options.submit && $options.submit(...args))
|
||||
av: common_vendor.o((...args) => $options.saveAndReset && $options.saveAndReset(...args)),
|
||||
aw: common_vendor.o((...args) => $options.submit && $options.submit(...args))
|
||||
});
|
||||
}
|
||||
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
|
||||
|
||||
@@ -1 +1 @@
|
||||
<view class="order"><view class="tabs"><text class="{{[a && 'active']}}" bindtap="{{b}}">销售</text><text class="{{[c && 'active']}}" bindtap="{{d}}">进货</text><text class="{{[e && 'active']}}" bindtap="{{f}}">其他收入</text><text class="{{[g && 'active']}}" bindtap="{{h}}">其他支出</text></view><view wx:if="{{i}}" class="subtabs"><button class="{{['subbtn', j && 'active']}}" bindtap="{{k}}">出货</button><button class="{{['subbtn', l && 'active']}}" bindtap="{{m}}">退货</button><button class="{{['subbtn', n && 'active']}}" bindtap="{{o}}">收款</button></view><view wx:elif="{{p}}" class="subtabs"><button class="{{['subbtn', q && 'active']}}" bindtap="{{r}}">进货</button><button class="{{['subbtn', s && 'active']}}" bindtap="{{t}}">退货</button><button class="{{['subbtn', v && 'active']}}" bindtap="{{w}}">付款</button></view><picker mode="date" value="{{y}}" bindchange="{{z}}"><view class="field"><text class="label">时间</text><text class="value">{{x}}</text></view></picker><view wx:if="{{A}}" class="field" bindtap="{{C}}"><text class="label">客户</text><text class="value">{{B}}</text></view><view wx:elif="{{D}}" class="field" bindtap="{{F}}"><text class="label">供应商</text><text class="value">{{E}}</text></view><view wx:if="{{G}}"><view wx:if="{{H}}" class="field" bindtap="{{J}}"><text class="label">客户</text><text class="value">{{I}}</text></view><view wx:else class="field" bindtap="{{L}}"><text class="label">供应商</text><text class="value">{{K}}</text></view><view class="field pay-row"><text class="label">现金</text><input class="pay-input" type="digit" placeholder="0.00" bindinput="{{M}}" value="{{N}}"/></view><view class="field pay-row"><text class="label">银行存款</text><input class="pay-input" type="digit" placeholder="0.00" bindinput="{{O}}" value="{{P}}"/></view><view class="field pay-row"><text class="label">微信</text><input class="pay-input" type="digit" placeholder="0.00" bindinput="{{Q}}" value="{{R}}"/></view><view class="collapse-trigger" bindtap="{{T}}">{{S}}</view><view class="textarea"><view class="amount-badge">总金额:{{U}}</view><block wx:if="{{r0}}"><textarea maxlength="200" placeholder="备注(最多输入200个字)" value="{{V}}" bindinput="{{W}}"></textarea></block><view class="date-mini"><picker mode="date" value="{{Y}}" bindchange="{{Z}}"><text>{{X}}</text></picker></view></view></view><view wx:elif="{{aa}}"><view class="summary"><text>选中货品({{ab}})</text><text>合计金额:¥ {{ac}}</text></view><view class="add" bindtap="{{ad}}">+</view></view><view wx:else><view class="chips"><view wx:for="{{ae}}" wx:for-item="c" wx:key="b" class="{{['chip', c.c && 'active']}}" bindtap="{{c.d}}">{{c.a}}</view></view><view class="field" bindtap="{{ag}}"><text class="label">往来单位</text><text class="value">{{af}}</text></view><view class="field" bindtap="{{ai}}"><text class="label">结算账户</text><text class="value">{{ah}}</text></view><view class="field"><text class="label">金额</text><input class="value" type="digit" placeholder="0.00" value="{{aj}}" bindinput="{{ak}}"/></view><view class="textarea"><block wx:if="{{r0}}"><textarea maxlength="200" placeholder="备注(最多输入200个字)" value="{{al}}" bindinput="{{am}}"></textarea></block></view></view><view wx:if="{{an}}" class="empty"><image src="{{ao}}" mode="widthFix" class="empty-img"></image><text class="empty-text">购物车里空空如也</text><text class="empty-sub">扫描或点击 “+” 选择商品吧</text></view><view wx:else class="list"><view wx:for="{{ap}}" wx:for-item="it" wx:key="g" class="row"><view class="col name">{{it.a}}</view><view class="col qty"><input type="number" bindinput="{{it.b}}" value="{{it.c}}"/></view><view class="col price"><input type="number" bindinput="{{it.d}}" value="{{it.e}}"/></view><view class="col amount">¥ {{it.f}}</view></view></view><view class="bottom"><button class="ghost" bindtap="{{aq}}">再记一笔</button><button class="primary" bindtap="{{ar}}">保存</button></view></view>
|
||||
<view class="order"><view class="tabs"><text class="{{[a && 'active']}}" bindtap="{{b}}">销售</text><text class="{{[c && 'active']}}" bindtap="{{d}}">进货</text><text class="{{[e && 'active']}}" bindtap="{{f}}">其他收入</text><text class="{{[g && 'active']}}" bindtap="{{h}}">其他支出</text></view><view wx:if="{{i}}" class="subtabs"><button class="{{['subbtn', j && 'active']}}" bindtap="{{k}}">出货</button><button class="{{['subbtn', l && 'active']}}" bindtap="{{m}}">退货</button><button class="{{['subbtn', n && 'active']}}" bindtap="{{o}}">收款</button></view><view wx:elif="{{p}}" class="subtabs"><button class="{{['subbtn', q && 'active']}}" bindtap="{{r}}">进货</button><button class="{{['subbtn', s && 'active']}}" bindtap="{{t}}">退货</button><button class="{{['subbtn', v && 'active']}}" bindtap="{{w}}">付款</button></view><picker mode="date" value="{{y}}" bindchange="{{z}}"><view class="field"><text class="label">时间</text><text class="value">{{x}}</text></view></picker><view wx:if="{{A}}" class="field" bindtap="{{C}}"><text class="label">客户</text><text class="value">{{B}}</text></view><view wx:elif="{{D}}" class="field" bindtap="{{F}}"><text class="label">供应商</text><text class="value">{{E}}</text></view><view wx:if="{{G}}"><view wx:if="{{H}}" class="field" bindtap="{{J}}"><text class="label">客户</text><text class="value">{{I}}</text></view><view wx:else class="field" bindtap="{{L}}"><text class="label">供应商</text><text class="value">{{K}}</text></view><view class="field pay-row"><text class="label">现金</text><input class="pay-input" type="digit" placeholder="0.00" bindinput="{{M}}" value="{{N}}"/></view><view class="field pay-row"><text class="label">银行存款</text><input class="pay-input" type="digit" placeholder="0.00" bindinput="{{O}}" value="{{P}}"/></view><view class="field pay-row"><text class="label">微信</text><input class="pay-input" type="digit" placeholder="0.00" bindinput="{{Q}}" value="{{R}}"/></view><view class="collapse-trigger" bindtap="{{T}}">{{S}}</view><view class="textarea"><view class="amount-badge">总金额:{{U}}</view><block wx:if="{{r0}}"><textarea maxlength="200" placeholder="备注(最多输入200个字)" value="{{V}}" bindinput="{{W}}"></textarea></block><view class="date-mini"><picker mode="date" value="{{Y}}" bindchange="{{Z}}"><text>{{X}}</text></picker></view></view></view><view wx:elif="{{aa}}"><view class="summary"><text>选中货品({{ab}})</text><text>合计金额:¥ {{ac}}</text></view><view class="add" bindtap="{{ad}}">+</view></view><view wx:else><view class="subtabs"><button class="{{['subbtn', ae && 'active']}}" bindtap="{{af}}">客户</button><button class="{{['subbtn', ag && 'active']}}" bindtap="{{ah}}">供应商</button></view><view class="chips"><view wx:for="{{ai}}" wx:for-item="c" wx:key="b" class="{{['chip', c.c && 'active']}}" bindtap="{{c.d}}">{{c.a}}</view></view><view class="field" bindtap="{{ak}}"><text class="label">往来单位</text><text class="value">{{aj}}</text></view><view class="field" bindtap="{{am}}"><text class="label">结算账户</text><text class="value">{{al}}</text></view><view class="field"><text class="label">金额</text><input class="value" type="digit" placeholder="0.00" value="{{an}}" bindinput="{{ao}}"/></view><view class="textarea"><block wx:if="{{r0}}"><textarea maxlength="200" placeholder="备注(最多输入200个字)" value="{{ap}}" bindinput="{{aq}}"></textarea></block></view></view><view wx:if="{{ar}}" class="empty"><image src="{{as}}" mode="widthFix" class="empty-img"></image><text class="empty-text">购物车里空空如也</text><text class="empty-sub">扫描或点击 “+” 选择商品吧</text></view><view wx:else class="list"><view wx:for="{{at}}" wx:for-item="it" wx:key="g" class="row"><view class="col name">{{it.a}}</view><view class="col qty"><input type="number" bindinput="{{it.b}}" value="{{it.c}}"/></view><view class="col price"><input type="number" bindinput="{{it.d}}" value="{{it.e}}"/></view><view class="col amount">¥ {{it.f}}</view></view></view><view class="bottom"><button class="ghost" bindtap="{{av}}">再记一笔</button><button class="primary" bindtap="{{aw}}">保存</button></view></view>
|
||||
@@ -49,4 +49,11 @@
|
||||
.amount-badge { position: absolute; right: 24rpx; top: -36rpx; background: #d1f0ff; color:#107e9b; padding: 8rpx 16rpx; border-radius: 12rpx; font-size: 24rpx;
|
||||
}
|
||||
.date-mini { position: absolute; right: 24rpx; bottom: 20rpx; color:#666; font-size: 24rpx;
|
||||
}
|
||||
/* 分类chips样式:选中后文字变红 */
|
||||
.chips { display:flex; flex-wrap: wrap; gap: 12rpx; padding: 12rpx 24rpx;
|
||||
}
|
||||
.chip { padding: 10rpx 20rpx; border-radius: 999rpx; background: #f4f4f4; color:#666;
|
||||
}
|
||||
.chip.active { color: #e54d42;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user