9.20/1
This commit is contained in:
83
frontend/unpackage/dist/dev/mp-weixin/pages/account/ledger.js
vendored
Normal file
83
frontend/unpackage/dist/dev/mp-weixin/pages/account/ledger.js
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../common/vendor.js");
|
||||
const common_http = require("../../common/http.js");
|
||||
const _sfc_main = {
|
||||
data() {
|
||||
return { accountId: null, startDate: "", endDate: "", list: [], opening: 0, income: 0, expense: 0, ending: 0 };
|
||||
},
|
||||
onLoad(query) {
|
||||
this.accountId = Number(query && query.id);
|
||||
this.quickInit();
|
||||
this.load();
|
||||
},
|
||||
methods: {
|
||||
quickInit() {
|
||||
const now = /* @__PURE__ */ new Date();
|
||||
const y = now.getFullYear(), m = now.getMonth() + 1;
|
||||
this.startDate = `${y}-${String(m).padStart(2, "0")}-01`;
|
||||
const lastDay = new Date(y, m, 0).getDate();
|
||||
this.endDate = `${y}-${String(m).padStart(2, "0")}-${String(lastDay).padStart(2, "0")}`;
|
||||
},
|
||||
async load(page = 1, size = 50) {
|
||||
try {
|
||||
const res = await common_http.get(`/api/accounts/${this.accountId}/ledger`, { startDate: this.startDate, endDate: this.endDate, page, size });
|
||||
this.list = res && res.list || [];
|
||||
this.opening = Number(res && res.opening || 0);
|
||||
this.income = Number(res && res.income || 0);
|
||||
this.expense = Number(res && res.expense || 0);
|
||||
this.ending = Number(res && res.ending || 0);
|
||||
} catch (e) {
|
||||
common_vendor.index.showToast({ title: "加载失败", icon: "none" });
|
||||
}
|
||||
},
|
||||
fmt(v) {
|
||||
return (typeof v === "number" ? v : Number(v || 0)).toFixed(2);
|
||||
},
|
||||
formatDate(s) {
|
||||
if (!s)
|
||||
return "-";
|
||||
try {
|
||||
const d = new Date(s);
|
||||
const pad = (n) => String(n).padStart(2, "0");
|
||||
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}`;
|
||||
} catch (e) {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
return {
|
||||
a: common_vendor.t($data.startDate || "—"),
|
||||
b: $data.startDate,
|
||||
c: common_vendor.o((e) => {
|
||||
$data.startDate = e.detail.value;
|
||||
$options.load();
|
||||
}),
|
||||
d: common_vendor.t($data.endDate || "—"),
|
||||
e: $data.endDate,
|
||||
f: common_vendor.o((e) => {
|
||||
$data.endDate = e.detail.value;
|
||||
$options.load();
|
||||
}),
|
||||
g: common_vendor.t($options.fmt($data.income)),
|
||||
h: common_vendor.t($options.fmt($data.expense)),
|
||||
i: common_vendor.t($options.fmt($data.opening)),
|
||||
j: common_vendor.t($options.fmt($data.ending)),
|
||||
k: common_vendor.f($data.list, (it, k0, i0) => {
|
||||
return {
|
||||
a: common_vendor.t(it.src === "other" ? it.category || "其他" : it.remark || "收付款"),
|
||||
b: common_vendor.t(it.direction === "in" ? "+" : "-"),
|
||||
c: common_vendor.t($options.fmt(it.amount)),
|
||||
d: it.direction === "in" ? 1 : "",
|
||||
e: it.direction === "out" ? 1 : "",
|
||||
f: common_vendor.t($options.formatDate(it.tx_time || it.txTime)),
|
||||
g: common_vendor.t(it.remark || "-"),
|
||||
h: it.id
|
||||
};
|
||||
})
|
||||
};
|
||||
}
|
||||
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
|
||||
wx.createPage(MiniProgramPage);
|
||||
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/account/ledger.js.map
|
||||
Reference in New Issue
Block a user