Files
2025-09-18 21:17:44 +08:00

71 lines
2.5 KiB
JavaScript

"use strict";
const common_vendor = require("../../common/vendor.js");
const common_http = require("../../common/http.js");
const _sfc_main = {
data() {
return { kw: "", debtOnly: false, customers: [] };
},
onLoad() {
this.search();
},
onShow() {
this.search();
},
methods: {
toggleDebtOnly() {
this.debtOnly = !this.debtOnly;
this.search();
},
async search() {
try {
const res = await common_http.get("/api/customers", { kw: this.kw, debtOnly: this.debtOnly, page: 1, size: 50 });
this.customers = Array.isArray(res == null ? void 0 : res.list) ? res.list : Array.isArray(res) ? res : [];
} catch (e) {
common_vendor.index.showToast({ title: "加载失败", icon: "none" });
}
},
createCustomer() {
common_vendor.index.navigateTo({ url: "/pages/customer/form" });
},
select(c) {
const pages = getCurrentPages();
const prev = pages.length >= 2 ? pages[pages.length - 2] : null;
const vm = prev && prev.$vm ? prev.$vm : null;
if (vm && vm.order) {
vm.order.customerId = c.id;
vm.customerName = c.name;
}
common_vendor.index.navigateBack();
},
openDetail(c) {
common_vendor.index.navigateTo({ url: "/pages/customer/detail?id=" + c.id });
}
}
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return {
a: common_vendor.o((...args) => $options.search && $options.search(...args)),
b: $data.kw,
c: common_vendor.o(($event) => $data.kw = $event.detail.value),
d: common_vendor.o((...args) => $options.search && $options.search(...args)),
e: $data.debtOnly ? "primary" : "default",
f: common_vendor.o((...args) => $options.toggleDebtOnly && $options.toggleDebtOnly(...args)),
g: common_vendor.f($data.customers, (c, k0, i0) => {
return common_vendor.e({
a: common_vendor.t(c.name),
b: common_vendor.t(c.mobile || "—"),
c: typeof c.receivable === "number"
}, typeof c.receivable === "number" ? {
d: common_vendor.t(Number(c.receivable).toFixed(2))
} : {}, {
e: c.id,
f: common_vendor.o(($event) => $options.openDetail(c), c.id)
});
}),
h: common_vendor.o((...args) => $options.createCustomer && $options.createCustomer(...args))
};
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/customer/select.js.map