9.18/3
This commit is contained in:
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))
|
||||
|
||||
Reference in New Issue
Block a user