2
This commit is contained in:
@@ -11,9 +11,29 @@ const _sfc_main = {
|
||||
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" });
|
||||
|
||||
@@ -25,12 +25,22 @@ const _sfc_main = {
|
||||
common_vendor.index.navigateTo({ url: "/pages/supplier/form" });
|
||||
},
|
||||
select(s) {
|
||||
const opener = getCurrentPages()[getCurrentPages().length - 2];
|
||||
if (opener && opener.$vm) {
|
||||
opener.$vm.order.supplierId = s.id;
|
||||
opener.$vm.supplierName = s.name;
|
||||
try {
|
||||
const pages = getCurrentPages();
|
||||
const opener = pages && pages.length >= 2 ? pages[pages.length - 2] : null;
|
||||
const vm = opener && opener.$vm ? opener.$vm : null;
|
||||
const canPick = !!(vm && vm.order);
|
||||
if (canPick) {
|
||||
vm.order.supplierId = s.id;
|
||||
if (Object.prototype.hasOwnProperty.call(vm, "supplierName"))
|
||||
vm.supplierName = s.name;
|
||||
common_vendor.index.navigateBack();
|
||||
} else {
|
||||
common_vendor.index.navigateTo({ url: `/pages/supplier/form?id=${s.id}` });
|
||||
}
|
||||
} catch (_) {
|
||||
common_vendor.index.navigateTo({ url: `/pages/supplier/form?id=${s.id}` });
|
||||
}
|
||||
common_vendor.index.navigateBack();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user