This commit is contained in:
2025-09-18 15:29:52 +08:00
parent 335e21347b
commit e560e90970
26 changed files with 566 additions and 30 deletions

View File

@@ -0,0 +1,68 @@
"use strict";
const common_vendor = require("../../common/vendor.js");
const common_http = require("../../common/http.js");
const _sfc_main = {
data() {
return {
id: null,
form: { name: "", level: "", priceLevel: "retail", contactName: "", mobile: "", phone: "", address: "", arOpening: 0, remark: "" },
priceLevels: ["retail", "distribution", "wholesale", "big_client"],
priceIdx: 0
};
},
onLoad(query) {
if (query && query.id) {
this.id = Number(query.id);
}
},
methods: {
onPriceChange(e) {
this.priceIdx = Number(e.detail.value);
this.form.priceLevel = this.priceLevels[this.priceIdx];
},
async save() {
if (!this.form.name)
return common_vendor.index.showToast({ title: "请填写客户名称", icon: "none" });
try {
if (this.id)
await common_http.put(`/api/customers/${this.id}`, this.form);
else
await common_http.post("/api/customers", this.form);
common_vendor.index.showToast({ title: "保存成功", icon: "success" });
setTimeout(() => common_vendor.index.navigateBack(), 500);
} catch (e) {
common_vendor.index.showToast({ title: (e == null ? void 0 : e.message) || "保存失败", icon: "none" });
}
}
}
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return {
a: $data.form.name,
b: common_vendor.o(($event) => $data.form.name = $event.detail.value),
c: $data.form.level,
d: common_vendor.o(($event) => $data.form.level = $event.detail.value),
e: common_vendor.t($data.priceLevels[$data.priceIdx]),
f: $data.priceLevels,
g: $data.priceIdx,
h: common_vendor.o((...args) => $options.onPriceChange && $options.onPriceChange(...args)),
i: $data.form.contactName,
j: common_vendor.o(($event) => $data.form.contactName = $event.detail.value),
k: $data.form.mobile,
l: common_vendor.o(($event) => $data.form.mobile = $event.detail.value),
m: $data.form.phone,
n: common_vendor.o(($event) => $data.form.phone = $event.detail.value),
o: $data.form.address,
p: common_vendor.o(($event) => $data.form.address = $event.detail.value),
q: $data.form.arOpening,
r: common_vendor.o(common_vendor.m(($event) => $data.form.arOpening = $event.detail.value, {
number: true
})),
s: $data.form.remark,
t: common_vendor.o(($event) => $data.form.remark = $event.detail.value),
v: common_vendor.o((...args) => $options.save && $options.save(...args))
};
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/customer/form.js.map