"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: "", contactName: "", mobile: "", phone: "", address: "", apOpening: 0, apPayable: 0, remark: "" } }; }, onLoad(query) { if (query && query.id) { this.id = Number(query.id); this.load(); } }, methods: { async load() { if (!this.id) return; try { const d = await common_http.get(`/api/suppliers/${this.id}`); this.form = { name: (d == null ? void 0 : d.name) || "", contactName: (d == null ? void 0 : d.contactName) || "", mobile: (d == null ? void 0 : d.mobile) || "", phone: (d == null ? void 0 : d.phone) || "", address: (d == null ? void 0 : d.address) || "", apOpening: Number((d == null ? void 0 : d.apOpening) || 0), apPayable: Number((d == null ? void 0 : d.apPayable) || 0), remark: (d == null ? void 0 : d.remark) || "" }; } catch (e) { common_vendor.index.showToast({ title: (e == null ? void 0 : e.message) || "加载失败", icon: "none" }); } }, async save() { if (!this.form.name) return common_vendor.index.showToast({ title: "请填写供应商名称", icon: "none" }); try { if (this.id) await common_http.put(`/api/suppliers/${this.id}`, this.form); else await common_http.post("/api/suppliers", 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.contactName, d: common_vendor.o(($event) => $data.form.contactName = $event.detail.value), e: $data.form.mobile, f: common_vendor.o(($event) => $data.form.mobile = $event.detail.value), g: $data.form.phone, h: common_vendor.o(($event) => $data.form.phone = $event.detail.value), i: $data.form.address, j: common_vendor.o(($event) => $data.form.address = $event.detail.value), k: $data.form.apOpening, l: common_vendor.o(common_vendor.m(($event) => $data.form.apOpening = $event.detail.value, { number: true })), m: $data.form.apPayable, n: common_vendor.o(common_vendor.m(($event) => $data.form.apPayable = $event.detail.value, { number: true })), o: $data.form.remark, p: common_vendor.o(($event) => $data.form.remark = $event.detail.value), q: 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/supplier/form.js.map