9.18/3
This commit is contained in:
2
frontend/unpackage/dist/dev/mp-weixin/app.js
vendored
2
frontend/unpackage/dist/dev/mp-weixin/app.js
vendored
@@ -12,7 +12,9 @@ if (!Math) {
|
||||
"./pages/product/settings.js";
|
||||
"./pages/customer/select.js";
|
||||
"./pages/customer/form.js";
|
||||
"./pages/customer/detail.js";
|
||||
"./pages/supplier/select.js";
|
||||
"./pages/supplier/form.js";
|
||||
"./pages/account/select.js";
|
||||
"./pages/detail/index.js";
|
||||
}
|
||||
|
||||
@@ -10,7 +10,9 @@
|
||||
"pages/product/settings",
|
||||
"pages/customer/select",
|
||||
"pages/customer/form",
|
||||
"pages/customer/detail",
|
||||
"pages/supplier/select",
|
||||
"pages/supplier/form",
|
||||
"pages/account/select",
|
||||
"pages/detail/index"
|
||||
],
|
||||
|
||||
@@ -15,9 +15,11 @@ function requestWithFallback(options, candidates, idx, resolve, reject) {
|
||||
const { statusCode, data } = res;
|
||||
if (statusCode >= 200 && statusCode < 300)
|
||||
return resolve(data);
|
||||
const msg = data && (data.message || data.error || data.msg) || "HTTP " + statusCode;
|
||||
common_vendor.index.showToast({ title: msg, icon: "none" });
|
||||
if (idx + 1 < candidates.length)
|
||||
return requestWithFallback(options, candidates, idx + 1, resolve, reject);
|
||||
reject(new Error("HTTP " + statusCode));
|
||||
reject(new Error(msg));
|
||||
}, fail: (err) => {
|
||||
if (idx + 1 < candidates.length)
|
||||
return requestWithFallback(options, candidates, idx + 1, resolve, reject);
|
||||
|
||||
156
frontend/unpackage/dist/dev/mp-weixin/pages/customer/detail.js
vendored
Normal file
156
frontend/unpackage/dist/dev/mp-weixin/pages/customer/detail.js
vendored
Normal file
@@ -0,0 +1,156 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../common/vendor.js");
|
||||
const common_http = require("../../common/http.js");
|
||||
const _sfc_main = {
|
||||
data() {
|
||||
return { id: null, d: {}, editing: false, form: { name: "", contactName: "", mobile: "", phone: "", address: "", level: "", priceLevel: "零售价", arOpening: 0, remark: "" }, priceLevels: ["零售价", "批发价", "大单报价"], priceLabels: ["零售价", "批发价", "大单报价"], priceIdx: 0 };
|
||||
},
|
||||
onLoad(q) {
|
||||
if (q && q.id) {
|
||||
this.id = Number(q.id);
|
||||
this.fetch();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async fetch() {
|
||||
try {
|
||||
this.d = await common_http.get(`/api/customers/${this.id}`);
|
||||
this.form = {
|
||||
name: this.d.name || "",
|
||||
contactName: this.d.contactName || "",
|
||||
mobile: this.d.mobile || "",
|
||||
phone: this.d.phone || "",
|
||||
address: this.d.address || "",
|
||||
level: this.d.level || "",
|
||||
priceLevel: this.d.priceLevel || "retail",
|
||||
arOpening: Number(this.d.arOpening || 0),
|
||||
remark: this.d.remark || ""
|
||||
};
|
||||
const idx = this.priceLevels.indexOf(this.form.priceLevel);
|
||||
this.priceIdx = idx >= 0 ? idx : 0;
|
||||
} catch (e) {
|
||||
common_vendor.index.showToast({ title: "加载失败", icon: "none" });
|
||||
}
|
||||
},
|
||||
toggleEdit() {
|
||||
this.editing = !this.editing;
|
||||
},
|
||||
onPriceChange(e) {
|
||||
this.priceIdx = Number(e.detail.value);
|
||||
this.form.priceLevel = this.priceLevels[this.priceIdx];
|
||||
},
|
||||
choose() {
|
||||
const pages = getCurrentPages();
|
||||
let targetIdx = -1;
|
||||
for (let i = pages.length - 2; i >= 0; i--) {
|
||||
const vm = pages[i] && pages[i].$vm ? pages[i].$vm : null;
|
||||
if (vm && vm.order) {
|
||||
vm.order.customerId = this.d.id;
|
||||
vm.customerName = this.d.name;
|
||||
targetIdx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (targetIdx >= 0) {
|
||||
const delta = pages.length - 1 - targetIdx;
|
||||
common_vendor.index.navigateBack({ delta });
|
||||
} else {
|
||||
common_vendor.index.navigateBack();
|
||||
}
|
||||
},
|
||||
async save() {
|
||||
if (!this.form.name)
|
||||
return common_vendor.index.showToast({ title: "请填写客户名称", icon: "none" });
|
||||
try {
|
||||
await common_http.put(`/api/customers/${this.id}`, this.form);
|
||||
common_vendor.index.showToast({ title: "已保存", icon: "success" });
|
||||
this.editing = false;
|
||||
await this.fetch();
|
||||
} 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 common_vendor.e({
|
||||
a: !$data.editing
|
||||
}, !$data.editing ? {
|
||||
b: common_vendor.t($data.d.name)
|
||||
} : {
|
||||
c: $data.form.name,
|
||||
d: common_vendor.o(($event) => $data.form.name = $event.detail.value)
|
||||
}, {
|
||||
e: !$data.editing
|
||||
}, !$data.editing ? {
|
||||
f: common_vendor.t($data.d.contactName || "—")
|
||||
} : {
|
||||
g: $data.form.contactName,
|
||||
h: common_vendor.o(($event) => $data.form.contactName = $event.detail.value)
|
||||
}, {
|
||||
i: !$data.editing
|
||||
}, !$data.editing ? {
|
||||
j: common_vendor.t($data.d.mobile || "—")
|
||||
} : {
|
||||
k: $data.form.mobile,
|
||||
l: common_vendor.o(($event) => $data.form.mobile = $event.detail.value)
|
||||
}, {
|
||||
m: !$data.editing
|
||||
}, !$data.editing ? {
|
||||
n: common_vendor.t($data.d.phone || "—")
|
||||
} : {
|
||||
o: $data.form.phone,
|
||||
p: common_vendor.o(($event) => $data.form.phone = $event.detail.value)
|
||||
}, {
|
||||
q: !$data.editing
|
||||
}, !$data.editing ? {
|
||||
r: common_vendor.t($data.d.address || "—")
|
||||
} : {
|
||||
s: $data.form.address,
|
||||
t: common_vendor.o(($event) => $data.form.address = $event.detail.value)
|
||||
}, {
|
||||
v: !$data.editing
|
||||
}, !$data.editing ? {
|
||||
w: common_vendor.t($data.d.level || "—")
|
||||
} : {
|
||||
x: $data.form.level,
|
||||
y: common_vendor.o(($event) => $data.form.level = $event.detail.value)
|
||||
}, {
|
||||
z: !$data.editing
|
||||
}, !$data.editing ? {
|
||||
A: common_vendor.t($data.d.priceLevel)
|
||||
} : {
|
||||
B: common_vendor.t($data.priceLabels[$data.priceIdx]),
|
||||
C: $data.priceLabels,
|
||||
D: $data.priceIdx,
|
||||
E: common_vendor.o((...args) => $options.onPriceChange && $options.onPriceChange(...args))
|
||||
}, {
|
||||
F: !$data.editing
|
||||
}, !$data.editing ? {
|
||||
G: common_vendor.t(Number($data.d.arOpening || 0).toFixed(2))
|
||||
} : {
|
||||
H: $data.form.arOpening,
|
||||
I: common_vendor.o(common_vendor.m(($event) => $data.form.arOpening = $event.detail.value, {
|
||||
number: true
|
||||
}))
|
||||
}, {
|
||||
J: common_vendor.t(Number($data.d.receivable || 0).toFixed(2)),
|
||||
K: !$data.editing
|
||||
}, !$data.editing ? {
|
||||
L: common_vendor.t($data.d.remark || "—")
|
||||
} : {
|
||||
M: $data.form.remark,
|
||||
N: common_vendor.o(($event) => $data.form.remark = $event.detail.value)
|
||||
}, {
|
||||
O: common_vendor.t($data.editing ? "取消" : "编辑"),
|
||||
P: common_vendor.o((...args) => $options.toggleEdit && $options.toggleEdit(...args)),
|
||||
Q: $data.editing
|
||||
}, $data.editing ? {
|
||||
R: common_vendor.o((...args) => $options.save && $options.save(...args))
|
||||
} : {
|
||||
S: common_vendor.o((...args) => $options.choose && $options.choose(...args))
|
||||
});
|
||||
}
|
||||
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
|
||||
wx.createPage(MiniProgramPage);
|
||||
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/customer/detail.js.map
|
||||
4
frontend/unpackage/dist/dev/mp-weixin/pages/customer/detail.json
vendored
Normal file
4
frontend/unpackage/dist/dev/mp-weixin/pages/customer/detail.json
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"navigationBarTitleText": "客户详情",
|
||||
"usingComponents": {}
|
||||
}
|
||||
1
frontend/unpackage/dist/dev/mp-weixin/pages/customer/detail.wxml
vendored
Normal file
1
frontend/unpackage/dist/dev/mp-weixin/pages/customer/detail.wxml
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<view class="page"><view class="card"><view class="row"><text class="label">名称</text><text wx:if="{{a}}" class="value">{{b}}</text><input wx:else class="value-input" placeholder="必填" value="{{c}}" bindinput="{{d}}"/></view><view class="row"><text class="label">联系人</text><text wx:if="{{e}}" class="value">{{f}}</text><input wx:else class="value-input" placeholder="可选" value="{{g}}" bindinput="{{h}}"/></view><view class="row"><text class="label">手机</text><text wx:if="{{i}}" class="value">{{j}}</text><input wx:else class="value-input" placeholder="可选" value="{{k}}" bindinput="{{l}}"/></view><view class="row"><text class="label">电话</text><text wx:if="{{m}}" class="value">{{n}}</text><input wx:else class="value-input" placeholder="可选(座机)" value="{{o}}" bindinput="{{p}}"/></view><view class="row"><text class="label">地址</text><text wx:if="{{q}}" class="value">{{r}}</text><input wx:else class="value-input" placeholder="可选" value="{{s}}" bindinput="{{t}}"/></view><view class="row"><text class="label">等级</text><text wx:if="{{v}}" class="value">{{w}}</text><input wx:else class="value-input" placeholder="可选,如 VIP/A/B" value="{{x}}" bindinput="{{y}}"/></view><view class="row"><text class="label">售价档位</text><text wx:if="{{z}}" class="value">{{A}}</text><picker wx:else range="{{C}}" value="{{D}}" bindchange="{{E}}"><view class="value">{{B}}</view></picker></view><view class="row"><text class="label">初始应收</text><text wx:if="{{F}}" class="value">¥ {{G}}</text><input wx:else class="value-input" type="digit" placeholder="0.00" value="{{H}}" bindinput="{{I}}"/></view><view class="row"><text class="label">当前应收</text><text class="value emp">¥ {{J}}</text></view><view class="row"><text class="label">备注</text><text wx:if="{{K}}" class="value">{{L}}</text><input wx:else class="value-input" placeholder="—" value="{{M}}" bindinput="{{N}}"/></view></view><view class="bottom"><button class="ghost" bindtap="{{P}}">{{O}}</button><button wx:if="{{Q}}" class="primary" bindtap="{{R}}">保存</button><button wx:else class="primary" bindtap="{{S}}">选择此客户</button></view></view>
|
||||
23
frontend/unpackage/dist/dev/mp-weixin/pages/customer/detail.wxss
vendored
Normal file
23
frontend/unpackage/dist/dev/mp-weixin/pages/customer/detail.wxss
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
|
||||
.page { padding-bottom: 140rpx;
|
||||
}
|
||||
.card { background:#fff; margin: 16rpx; padding: 12rpx 16rpx; border-radius: 16rpx;
|
||||
}
|
||||
.row { display:flex; justify-content: space-between; padding: 18rpx 8rpx; border-bottom: 1rpx solid #f3f3f3;
|
||||
}
|
||||
.row:last-child { border-bottom: 0;
|
||||
}
|
||||
.label { color:#666;
|
||||
}
|
||||
.value { color:#333; max-width: 60%; text-align: right;
|
||||
}
|
||||
.value-input { color:#333; text-align: right; flex: 1;
|
||||
}
|
||||
.emp { color:#107e9b; font-weight: 700;
|
||||
}
|
||||
.bottom { position: fixed; left:0; right:0; bottom:0; background:#fff; padding: 16rpx 24rpx calc(env(safe-area-inset-bottom) + 16rpx); box-shadow: 0 -4rpx 12rpx rgba(0,0,0,0.06); display:flex; gap: 12rpx;
|
||||
}
|
||||
.primary { flex:1; background: linear-gradient(135deg, #A0E4FF 0%, #17A2C4 100%); color:#fff; border-radius: 999rpx; padding: 20rpx 0;
|
||||
}
|
||||
.ghost { flex:1; background:#fff; color:#107e9b; border: 2rpx solid #A0E4FF; border-radius: 999rpx; padding: 18rpx 0;
|
||||
}
|
||||
@@ -6,7 +6,8 @@ const _sfc_main = {
|
||||
return {
|
||||
id: null,
|
||||
form: { name: "", level: "", priceLevel: "retail", contactName: "", mobile: "", phone: "", address: "", arOpening: 0, remark: "" },
|
||||
priceLevels: ["retail", "distribution", "wholesale", "big_client"],
|
||||
priceLevels: ["零售价", "批发价", "大单报价"],
|
||||
priceLabels: ["零售价", "批发价", "大单报价"],
|
||||
priceIdx: 0
|
||||
};
|
||||
},
|
||||
@@ -42,8 +43,8 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
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,
|
||||
e: common_vendor.t($data.priceLabels[$data.priceIdx]),
|
||||
f: $data.priceLabels,
|
||||
g: $data.priceIdx,
|
||||
h: common_vendor.o((...args) => $options.onPriceChange && $options.onPriceChange(...args)),
|
||||
i: $data.form.contactName,
|
||||
|
||||
@@ -8,6 +8,9 @@ const _sfc_main = {
|
||||
onLoad() {
|
||||
this.search();
|
||||
},
|
||||
onShow() {
|
||||
this.search();
|
||||
},
|
||||
methods: {
|
||||
toggleDebtOnly() {
|
||||
this.debtOnly = !this.debtOnly;
|
||||
@@ -25,12 +28,17 @@ const _sfc_main = {
|
||||
common_vendor.index.navigateTo({ url: "/pages/customer/form" });
|
||||
},
|
||||
select(c) {
|
||||
const opener = getCurrentPages()[getCurrentPages().length - 2];
|
||||
if (opener && opener.$vm) {
|
||||
opener.$vm.order.customerId = c.id;
|
||||
opener.$vm.customerName = c.name;
|
||||
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 });
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -51,7 +59,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
d: common_vendor.t(Number(c.receivable).toFixed(2))
|
||||
} : {}, {
|
||||
e: c.id,
|
||||
f: common_vendor.o(($event) => $options.select(c), c.id)
|
||||
f: common_vendor.o(($event) => $options.openDetail(c), c.id)
|
||||
});
|
||||
}),
|
||||
h: common_vendor.o((...args) => $options.createCustomer && $options.createCustomer(...args))
|
||||
|
||||
@@ -67,6 +67,10 @@ const _sfc_main = {
|
||||
common_vendor.index.navigateTo({ url: "/pages/customer/select" });
|
||||
return;
|
||||
}
|
||||
if (item.key === "supplier") {
|
||||
common_vendor.index.navigateTo({ url: "/pages/supplier/select" });
|
||||
return;
|
||||
}
|
||||
common_vendor.index.showToast({ title: item.title + "(开发中)", icon: "none" });
|
||||
},
|
||||
goProduct() {
|
||||
@@ -79,7 +83,7 @@ const _sfc_main = {
|
||||
goDetail() {
|
||||
this.activeTab = "detail";
|
||||
try {
|
||||
common_vendor.index.__f__("log", "at pages/index/index.vue:170", "[index] goDetail → /pages/detail/index");
|
||||
common_vendor.index.__f__("log", "at pages/index/index.vue:174", "[index] goDetail → /pages/detail/index");
|
||||
} catch (e) {
|
||||
}
|
||||
common_vendor.index.navigateTo({ url: "/pages/detail/index" });
|
||||
|
||||
@@ -22,6 +22,9 @@ const _sfc_main = {
|
||||
remark: ""
|
||||
},
|
||||
customerName: "",
|
||||
customerPriceLevel: "零售价",
|
||||
_lastCustomerId: null,
|
||||
_priceCache: {},
|
||||
supplierName: "",
|
||||
items: [],
|
||||
activeCategory: "sale_income",
|
||||
@@ -64,7 +67,70 @@ const _sfc_main = {
|
||||
return Number(p.cash || 0) + Number(p.bank || 0) + Number(p.wechat || 0);
|
||||
}
|
||||
},
|
||||
onShow() {
|
||||
if (this.biz === "sale") {
|
||||
if (this.order.customerId && this.order.customerId !== this._lastCustomerId) {
|
||||
this.loadCustomerLevel(this.order.customerId).then(() => {
|
||||
this._lastCustomerId = this.order.customerId;
|
||||
for (const it of this.items) {
|
||||
if (it && (it._autoPrice || !it.unitPrice))
|
||||
this.autoPriceItem(it);
|
||||
}
|
||||
});
|
||||
}
|
||||
for (const it of this.items) {
|
||||
if (it && !it.unitPrice)
|
||||
this.autoPriceItem(it);
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async loadCustomerLevel(customerId) {
|
||||
try {
|
||||
const d = await common_http.get(`/api/customers/${customerId}`);
|
||||
this.customerPriceLevel = d && d.priceLevel ? d.priceLevel : "零售价";
|
||||
} catch (e) {
|
||||
this.customerPriceLevel = "零售价";
|
||||
}
|
||||
},
|
||||
priceFieldForLevel() {
|
||||
const lvl = this.customerPriceLevel || "零售价";
|
||||
if (lvl === "批发价")
|
||||
return "wholesalePrice";
|
||||
if (lvl === "大单报价")
|
||||
return "bigClientPrice";
|
||||
return "retailPrice";
|
||||
},
|
||||
async autoPriceItem(it) {
|
||||
if (this.biz !== "sale")
|
||||
return;
|
||||
if (!it || !it.productId)
|
||||
return;
|
||||
const pid = it.productId;
|
||||
let detail = this._priceCache[pid];
|
||||
if (!detail) {
|
||||
try {
|
||||
detail = await common_http.get(`/api/products/${pid}`);
|
||||
this._priceCache[pid] = detail;
|
||||
} catch (e) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
const field = this.priceFieldForLevel();
|
||||
let price = Number(detail && detail[field] != null ? detail[field] : 0);
|
||||
if (!price && field !== "retailPrice") {
|
||||
price = Number(detail && detail.retailPrice != null ? detail.retailPrice : 0);
|
||||
}
|
||||
it.unitPrice = price;
|
||||
it._autoPrice = true;
|
||||
this.recalc();
|
||||
},
|
||||
onPriceInput(it) {
|
||||
if (it) {
|
||||
it._autoPrice = false;
|
||||
this.recalc();
|
||||
}
|
||||
},
|
||||
switchBiz(type) {
|
||||
this.biz = type;
|
||||
},
|
||||
@@ -98,6 +164,17 @@ const _sfc_main = {
|
||||
const isSaleOrPurchase = this.biz === "sale" || this.biz === "purchase";
|
||||
const isCollectOrPay = this.biz === "sale" && this.saleType === "collect" || this.biz === "purchase" && this.purchaseType === "pay";
|
||||
const saleTypeValue = this.biz === "sale" ? "sale." + this.saleType : "purchase." + this.purchaseType;
|
||||
if (isSaleOrPurchase && !isCollectOrPay) {
|
||||
if (!this.items.length) {
|
||||
common_vendor.index.showToast({ title: "请先选择商品", icon: "none" });
|
||||
return;
|
||||
}
|
||||
const invalid = this.items.find((it) => !it.productId || Number(it.quantity || 0) <= 0);
|
||||
if (invalid) {
|
||||
common_vendor.index.showToast({ title: "数量需大于0", icon: "none" });
|
||||
return;
|
||||
}
|
||||
}
|
||||
const payload = isSaleOrPurchase ? isCollectOrPay ? [
|
||||
{ method: "cash", amount: Number(this.payments.cash || 0) },
|
||||
{ method: "bank", amount: Number(this.payments.bank || 0) },
|
||||
@@ -244,7 +321,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
c: it.quantity,
|
||||
d: common_vendor.o([common_vendor.m(($event) => it.unitPrice = $event.detail.value, {
|
||||
number: true
|
||||
}), ($event) => $options.recalc()], idx),
|
||||
}), ($event) => $options.onPriceInput(it)], idx),
|
||||
e: it.unitPrice,
|
||||
f: common_vendor.t((Number(it.quantity) * Number(it.unitPrice)).toFixed(2)),
|
||||
g: idx
|
||||
|
||||
@@ -20,7 +20,8 @@ const _sfc_main = {
|
||||
select(p) {
|
||||
const opener = getCurrentPages()[getCurrentPages().length - 2];
|
||||
if (opener && opener.$vm && opener.$vm.items) {
|
||||
opener.$vm.items.push({ productId: p.id, productName: p.name, quantity: 1, unitPrice: Number(p.price || 0) });
|
||||
const initPrice = Number(p.retailPrice != null ? p.retailPrice : p.price || 0);
|
||||
opener.$vm.items.push({ productId: p.id, productName: p.name, quantity: 1, unitPrice: initPrice, _autoPrice: true });
|
||||
}
|
||||
common_vendor.index.navigateBack();
|
||||
}
|
||||
|
||||
60
frontend/unpackage/dist/dev/mp-weixin/pages/supplier/form.js
vendored
Normal file
60
frontend/unpackage/dist/dev/mp-weixin/pages/supplier/form.js
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
"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);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
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
|
||||
4
frontend/unpackage/dist/dev/mp-weixin/pages/supplier/form.json
vendored
Normal file
4
frontend/unpackage/dist/dev/mp-weixin/pages/supplier/form.json
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"navigationBarTitleText": "新增/编辑供应商",
|
||||
"usingComponents": {}
|
||||
}
|
||||
1
frontend/unpackage/dist/dev/mp-weixin/pages/supplier/form.wxml
vendored
Normal file
1
frontend/unpackage/dist/dev/mp-weixin/pages/supplier/form.wxml
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<view class="page"><view class="field"><text class="label">供应商名称</text><input class="value" placeholder="必填" value="{{a}}" bindinput="{{b}}"/></view><view class="field"><text class="label">联系人</text><input class="value" placeholder="可选" value="{{c}}" bindinput="{{d}}"/></view><view class="field"><text class="label">手机</text><input class="value" placeholder="可选" value="{{e}}" bindinput="{{f}}"/></view><view class="field"><text class="label">电话</text><input class="value" placeholder="可选(座机)" value="{{g}}" bindinput="{{h}}"/></view><view class="field"><text class="label">经营地址</text><input class="value" placeholder="可选" value="{{i}}" bindinput="{{j}}"/></view><view class="field"><text class="label">初始应付款</text><input class="value" type="digit" placeholder="默认 0.00" value="{{k}}" bindinput="{{l}}"/></view><view class="field"><text class="label">应付款</text><input class="value" type="digit" placeholder="默认 0.00" value="{{m}}" bindinput="{{n}}"/></view><view class="textarea"><block wx:if="{{r0}}"><textarea maxlength="200" placeholder="备注(最多200字)" value="{{o}}" bindinput="{{p}}"></textarea></block></view><view class="bottom"><button class="primary" bindtap="{{q}}">保存</button></view></view>
|
||||
15
frontend/unpackage/dist/dev/mp-weixin/pages/supplier/form.wxss
vendored
Normal file
15
frontend/unpackage/dist/dev/mp-weixin/pages/supplier/form.wxss
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
.page { padding-bottom: 140rpx;
|
||||
}
|
||||
.field { display:flex; justify-content: space-between; padding: 22rpx 24rpx; background:#fff; border-bottom:1rpx solid #eee;
|
||||
}
|
||||
.label { color:#666;
|
||||
}
|
||||
.value { color:#333; text-align: right; flex: 1;
|
||||
}
|
||||
.textarea { padding: 16rpx 24rpx; background:#fff; margin-top: 12rpx;
|
||||
}
|
||||
.bottom { position: fixed; left:0; right:0; bottom:0; background:#fff; padding: 16rpx 24rpx calc(env(safe-area-inset-bottom) + 16rpx); box-shadow: 0 -4rpx 12rpx rgba(0,0,0,0.06);
|
||||
}
|
||||
.primary { width: 100%; background: linear-gradient(135deg, #A0E4FF 0%, #17A2C4 100%); color:#fff; border-radius: 999rpx; padding: 20rpx 0;
|
||||
}
|
||||
@@ -3,20 +3,27 @@ const common_vendor = require("../../common/vendor.js");
|
||||
const common_http = require("../../common/http.js");
|
||||
const _sfc_main = {
|
||||
data() {
|
||||
return { kw: "", suppliers: [] };
|
||||
return { kw: "", debtOnly: false, suppliers: [] };
|
||||
},
|
||||
onLoad() {
|
||||
this.search();
|
||||
},
|
||||
methods: {
|
||||
toggleDebtOnly() {
|
||||
this.debtOnly = !this.debtOnly;
|
||||
this.search();
|
||||
},
|
||||
async search() {
|
||||
try {
|
||||
const res = await common_http.get("/api/suppliers", { kw: this.kw, page: 1, size: 50 });
|
||||
const res = await common_http.get("/api/suppliers", { kw: this.kw, debtOnly: this.debtOnly, page: 1, size: 50 });
|
||||
this.suppliers = Array.isArray(res == null ? void 0 : res.list) ? res.list : Array.isArray(res) ? res : [];
|
||||
} catch (e) {
|
||||
common_vendor.index.showToast({ title: "加载失败", icon: "none" });
|
||||
}
|
||||
},
|
||||
createSupplier() {
|
||||
common_vendor.index.navigateTo({ url: "/pages/supplier/form" });
|
||||
},
|
||||
select(s) {
|
||||
const opener = getCurrentPages()[getCurrentPages().length - 2];
|
||||
if (opener && opener.$vm) {
|
||||
@@ -33,14 +40,21 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
b: $data.kw,
|
||||
c: common_vendor.o(($event) => $data.kw = $event.detail.value),
|
||||
d: common_vendor.o((...args) => $options.search && $options.search(...args)),
|
||||
e: common_vendor.f($data.suppliers, (s, k0, i0) => {
|
||||
return {
|
||||
e: $data.debtOnly ? "primary" : "default",
|
||||
f: common_vendor.o((...args) => $options.toggleDebtOnly && $options.toggleDebtOnly(...args)),
|
||||
g: common_vendor.f($data.suppliers, (s, k0, i0) => {
|
||||
return common_vendor.e({
|
||||
a: common_vendor.t(s.name),
|
||||
b: common_vendor.t(s.mobile || "—"),
|
||||
c: s.id,
|
||||
d: common_vendor.o(($event) => $options.select(s), s.id)
|
||||
};
|
||||
})
|
||||
c: typeof s.apPayable === "number"
|
||||
}, typeof s.apPayable === "number" ? {
|
||||
d: common_vendor.t(Number(s.apPayable).toFixed(2))
|
||||
} : {}, {
|
||||
e: s.id,
|
||||
f: common_vendor.o(($event) => $options.select(s), s.id)
|
||||
});
|
||||
}),
|
||||
h: common_vendor.o((...args) => $options.createSupplier && $options.createSupplier(...args))
|
||||
};
|
||||
}
|
||||
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
|
||||
|
||||
@@ -1 +1 @@
|
||||
<view class="page"><view class="search"><input placeholder="搜索供应商名称/电话" bindconfirm="{{a}}" value="{{b}}" bindinput="{{c}}"/><button size="mini" bindtap="{{d}}">搜索</button></view><scroll-view scroll-y class="list"><view wx:for="{{e}}" wx:for-item="s" wx:key="c" class="item" bindtap="{{s.d}}"><view class="name">{{s.a}}</view><view class="meta">{{s.b}}</view></view></scroll-view></view>
|
||||
<view class="page"><view class="search"><input placeholder="搜索供应商名称/电话" bindconfirm="{{a}}" value="{{b}}" bindinput="{{c}}"/><button size="mini" bindtap="{{d}}">搜索</button><button size="mini" type="{{e}}" bindtap="{{f}}">只看欠款</button></view><scroll-view scroll-y class="list"><view wx:for="{{g}}" wx:for-item="s" wx:key="e" class="item" bindtap="{{s.f}}"><view class="name">{{s.a}}</view><view class="meta">{{s.b}} <text wx:if="{{s.c}}">|应付:¥ {{s.d}}</text></view></view></scroll-view><view class="bottom"><button class="primary" bindtap="{{h}}">新增供应商</button></view></view>
|
||||
Reference in New Issue
Block a user