wangfukang 3 weeks ago
parent
commit
6a7b11b9ec
  1. 4
      src/api/app.js
  2. 79
      src/views/app/shop/addEdit.vue

4
src/api/app.js

@ -487,6 +487,10 @@ export const getShopPrintConfig = (params) => {
return getRequest('/app/shop/printConfig', params)
}
export const testShopPrinter = (params) => {
return postRequest('/app/shop/printTest', params)
}
export const findShopWorkerByMobile = (params) => {
return getRequest('/app/shop/findWorkerByMobile', params)
}

79
src/views/app/shop/addEdit.vue

@ -136,17 +136,24 @@
</Row>
<Divider v-if="type == '1'">云打印机</Divider>
<Alert v-if="type == '1' && form.printerSn" type="success" show-icon>
已绑定:{{ form.printerName || form.shopName || "云打印机" }}({{ form.printerSn }})
已绑定:{{ currentPrinterBrandName }} - {{ form.printerName || form.shopName || "云打印机" }}({{ form.printerSn }})
</Alert>
<Row :gutter="32" v-if="type == '1'">
<Col span="12">
<FormItem label="打印机SN">
<Input v-model="printerForm.sn" autocomplete="off" :maxlength="50" placeholder="请输入打印机编号" />
<Col span="8">
<FormItem label="云打印品牌">
<Select v-model="printerForm.brand" transfer>
<Option v-for="item in printerBrandOptions" :key="item.value" :value="item.value">{{ item.label }}</Option>
</Select>
</FormItem>
</Col>
<Col span="12">
<FormItem label="设备绑定码">
<Input type="password" v-model="printerForm.key" autocomplete="off" :maxlength="255" placeholder="请输入设备绑定码" />
<Col span="8">
<FormItem :label="printerForm.brand == 'yilianyun' ? '终端号' : '打印机SN'">
<Input v-model="printerForm.sn" autocomplete="off" :maxlength="50" :placeholder="printerForm.brand == 'yilianyun' ? '请输入易联云终端号' : '请输入打印机编号'" />
</FormItem>
</Col>
<Col span="8">
<FormItem :label="printerForm.brand == 'yilianyun' ? 'mSign' : (printerForm.brand == 'feieyun' ? '设备KEY' : '设备绑定码')">
<Input type="password" v-model="printerForm.key" autocomplete="off" :maxlength="255" :placeholder="printerForm.brand == 'yilianyun' ? '请输入易联云mSign' : (printerForm.brand == 'feieyun' ? '请输入飞鹅云KEY' : '请输入设备绑定码')" />
</FormItem>
</Col>
</Row>
@ -159,6 +166,7 @@
<Col span="12">
<FormItem label="操作">
<Button type="primary" :loading="printerBindLoading" @click="bindPrinter">绑定打印机</Button>
<Button style="margin-left: 8px;" :loading="printerTestLoading" :disabled="!form.printerSn" @click="testPrinter">打印测试</Button>
</FormItem>
</Col>
</Row>
@ -319,6 +327,7 @@
editShop,
bindShopPrinter,
getShopPrintConfig,
testShopPrinter,
findShopWorkerByMobile,
} from "@/api/app";
export default {
@ -357,12 +366,27 @@
submitLoading: false,
workerLoading: false,
printerBindLoading: false,
printerTestLoading: false,
workerMobile: "",
printerForm: {
brand: "daqu",
sn: "",
key: "",
name: "",
},
printerBrandOptions: [{
value: "daqu",
label: "大趋智能"
},
{
value: "yilianyun",
label: "易联云"
},
{
value: "feieyun",
label: "飞鹅云"
}
],
maxHeight: 510,
form: {
address: [],
@ -499,6 +523,11 @@
if (!this.form.workerId) return "";
return `${this.form.workerName || ""} ${this.form.workerPhone || ""}`;
},
currentPrinterBrandName() {
const brand = this.form.printerBrand || this.printerForm.brand || "daqu";
const item = this.printerBrandOptions.find(option => option.value == brand);
return item ? item.label : "大趋智能";
},
},
methods: {
init(v) {
@ -534,17 +563,19 @@
const sn = (this.printerForm.sn || "").trim();
const key = (this.printerForm.key || "").trim();
const name = (this.printerForm.name || this.form.shopName || "").trim();
const brand = this.printerForm.brand || "daqu";
if (!sn) {
this.$Message.warning("请输入打印机SN");
this.$Message.warning(brand == "yilianyun" ? "请输入终端号" : "请输入打印机SN");
return;
}
if (!key) {
this.$Message.warning("请输入设备绑定码");
this.$Message.warning(brand == "yilianyun" ? "请输入mSign" : (brand == "feieyun" ? "请输入设备KEY" : "请输入设备绑定码"));
return;
}
this.printerBindLoading = true;
bindShopPrinter({
shopId: this.form.id,
brand,
sn,
key,
name,
@ -553,8 +584,10 @@
this.printerBindLoading = false;
if (res.success) {
if (res.result) {
this.$set(this.form, "printerBrand", res.result.printerBrand || brand);
this.$set(this.form, "printerSn", res.result.printerSn || sn);
this.$set(this.form, "printerName", res.result.printerName || name);
this.$set(this.printerForm, "brand", res.result.printerBrand || brand);
this.$set(this.printerForm, "name", res.result.printerName || name);
}
this.$Message.success(res.message || "打印机绑定成功");
@ -565,6 +598,29 @@
this.printerBindLoading = false;
});
},
testPrinter() {
if (!this.form.id) {
this.$Message.warning("请先保存店铺后再测试打印");
return;
}
if (!this.form.printerSn) {
this.$Message.warning("请先绑定云打印机");
return;
}
this.printerTestLoading = true;
testShopPrinter({
shopId: this.form.id
}).then((res) => {
this.printerTestLoading = false;
if (res.success) {
this.$Message.success(res.message || "测试打印已发送");
} else {
this.$Message.error(res.message || "测试打印失败");
}
}).catch(() => {
this.printerTestLoading = false;
});
},
loadPrintConfig() {
if (!this.form.id) return;
getShopPrintConfig({
@ -573,10 +629,13 @@
if (res.success && res.result) {
const printerSn = res.result.printerSn || "";
const printerName = res.result.printerName || this.form.shopName || "";
const printerBrand = res.result.printerBrand || "daqu";
this.$set(this.form, "printerBrand", printerBrand);
this.$set(this.form, "printerSn", printerSn);
this.$set(this.form, "printerName", printerName);
this.$set(this.form, "printingMethod", res.result.printingMethod || "bluetooth");
this.printerForm = {
brand: printerBrand,
sn: printerSn,
key: "",
name: printerName,
@ -933,6 +992,7 @@
transferAddressName: data.transferAddressName || "",
});
this.printerForm = {
brand: this.form.printerBrand || "daqu",
sn: this.form.printerSn || "",
key: "",
name: this.form.printerName || this.form.shopName || "",
@ -962,6 +1022,7 @@
supportTransferDelivery: 0,
};
this.printerForm = {
brand: "daqu",
sn: "",
key: "",
name: "",

Loading…
Cancel
Save