diff --git a/src/api/app.js b/src/api/app.js index 16c17d7..ea20bfd 100644 --- a/src/api/app.js +++ b/src/api/app.js @@ -412,6 +412,11 @@ export const editShopTakeway = (params) => { export const editShop = (params) => { return putRequest('/app/shop/edit', params) } + +export const findShopWorkerByMobile = (params) => { + return getRequest('/app/shop/findWorkerByMobile', params) +} + //删除评论 export const deleteComment = (params) => { return postRequest('/app/comment/deleteByOrderId', params) diff --git a/src/views/app/shop/addEdit.vue b/src/views/app/shop/addEdit.vue index 37164da..ee0a502 100644 --- a/src/views/app/shop/addEdit.vue +++ b/src/views/app/shop/addEdit.vue @@ -69,6 +69,52 @@ + 商家自配送 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -108,6 +154,7 @@ import { addShop, editShop, + findShopWorkerByMobile, initShopArea, loadShopArea, } from "@/api/app"; @@ -142,9 +189,13 @@ title: "", passColor: "", submitLoading: false, + workerLoading: false, + workerMobile: "", maxHeight: 510, form: { address: [], + supportShopDelivery: 0, + orderBkge: 0, }, formValidate: { // 表单验证规则 @@ -192,9 +243,45 @@ message: "邮箱格式不正确" }, ], + workerId: [{ + validator: (rule, value, callback) => { + if (this.form.supportShopDelivery == 1 && !this.form.workerId) { + callback(new Error("请查询并绑定配送员")); + } else { + callback(); + } + }, + trigger: "change" + }], + shopDeliveryLocation: [{ + validator: (rule, value, callback) => { + if (this.form.supportShopDelivery == 1 && !value) { + callback(new Error("请选择送达位置")); + } else { + callback(); + } + }, + trigger: "change" + }], + shopDeliveryDuration: [{ + validator: (rule, value, callback) => { + if (this.form.supportShopDelivery == 1 && (!value || value <= 0)) { + callback(new Error("请输入配送时长")); + } else { + callback(); + } + }, + trigger: "change" + }], }, }; }, + computed: { + boundWorkerText() { + if (!this.form.workerId) return ""; + return `${this.form.workerName || ""} ${this.form.workerPhone || ""}`; + }, + }, methods: { init(v) { this.getRoleList(v); @@ -237,10 +324,52 @@ handleSelectShopAreaTree(v) { this.form.shopArea = v; }, + handleOrderBkgeChange(value) { + const numberValue = Number(value || 0); + this.$set(this.form, "orderBkge", Number(numberValue.toFixed(1))); + }, + findWorker() { + if (!this.workerMobile) { + this.$Message.warning("请输入配送员手机号"); + return; + } + this.workerLoading = true; + findShopWorkerByMobile({ + mobile: this.workerMobile + }).then((res) => { + this.workerLoading = false; + if (res.success) { + this.$set(this.form, "workerId", res.result.workerId); + this.$set(this.form, "workerName", res.result.workerName); + this.$set(this.form, "workerPhone", res.result.workerPhone || res.result.mobile); + this.$Message.success("配送员绑定成功"); + } else { + this.$Message.error(res.message || "未查询到配送员"); + } + }).catch(() => { + this.workerLoading = false; + }); + }, + normalizeSelfDeliveryForm() { + if (this.form.supportShopDelivery == null) { + this.$set(this.form, "supportShopDelivery", 0); + } + this.form.supportShopDelivery = Number(this.form.supportShopDelivery); + this.form.orderBkge = Number(Number(this.form.orderBkge || 0).toFixed(1)); + if (this.form.supportShopDelivery != 1) { + this.form.orderBkge = 0; + this.form.shopDeliveryLocation = null; + this.form.shopDeliveryDuration = null; + this.form.workerId = ""; + this.form.workerName = ""; + this.form.workerPhone = ""; + } + }, changePass(v, grade, strength) { this.form.passStrength = strength; }, submit() { + this.normalizeSelfDeliveryForm(); this.$refs.form.validate((valid) => { if (valid) { if (typeof this.form.chargeTime == "object") { @@ -330,6 +459,9 @@ this.$refs.shopAreaTree.setData(data.shopArea, data.shopAreaTitle); // 回显 this.form = data; + this.form.supportShopDelivery = data.supportShopDelivery == null ? 0 : Number(data.supportShopDelivery); + this.form.orderBkge = data.orderBkge == null ? 0 : Number(data.orderBkge); + this.workerMobile = data.workerPhone || ""; } else { // 添加 //this.$refs.shopAreaTree.setData("", ""); @@ -337,7 +469,10 @@ /*type: 0, sex: "", address: [],*/ + supportShopDelivery: 0, + orderBkge: 0, }; + this.workerMobile = ""; } this.visible = value; }, diff --git a/vue.config.js b/vue.config.js index 4fbad80..2e93c3b 100644 --- a/vue.config.js +++ b/vue.config.js @@ -7,8 +7,8 @@ module.exports = { port: 8889, proxy: { '/hiver': { - //target: 'https://hbkuaishi.com', // 正式1 - target: 'http://192.168.100.30:8888', // 本地 + target: 'https://hbkuaishi.com', // 正式1 + //target: 'http://192.168.100.30:8888', // 本地 ws: false }, '/foo': {