Browse Source

add 外卖设置-打印机管理(云打印机)

Funny 3 năm trước cách đây
mục cha
commit
59ad89ded5

+ 7 - 0
src/api/shop.js

@@ -4,9 +4,16 @@ export const getShopList = (params) => {
   return get('app/shop/list', params)
 }
 
+export const shopListNew = (params) => {
+  return get('app/shop/listSelect', params)
+}
+
 export const getShopDetail = (params) => {
   return get('app/shop/detail', params)
 }
+export const printTest = (params) => {
+  return get('app/order/print/test/waimai', params)
+}
 
 export const shopAdd = (params) => {
   return post('app/shop/add', params)

+ 1 - 1
src/components/shopCompoents/bindUsbPrint.vue

@@ -19,7 +19,7 @@
       <el-empty style="width:100%;" v-if="!printerList.length" description="无法获取系统打印机列表,请先安装下载中心USB打印相关插件!"></el-empty>
     </div>
     <!-- 打印机新增、编辑 -->
-    <el-dialog width="40%" :title="title" destroy-on-close center :visible.sync="showVisible">
+    <el-dialog width="600px" :title="title" destroy-on-close center :visible.sync="showVisible">
       <el-form :model="form" ref="form" label-width="130px">
         <el-form-item label="打印机系统名称" prop="deviceName">
           <span>{{form.deviceName}}</span>

+ 2 - 2
src/components/waimai.vue

@@ -25,7 +25,7 @@
 </template>
 
 <script>
-import printerList from "./shopCompoents/bindPrinter.vue";
+import printerList from "./waimaiComponents/printerList.vue";
 import usbPrinter from "./shopCompoents/bindUsbPrint.vue";
 import pictureManagement from "./waimaiComponents/pictureManagement.vue";
 import addressManagement from "./waimaiComponents/addressManagement.vue";
@@ -142,7 +142,7 @@ export default {
     margin-top: 10px;
     // padding: 20px;
     box-sizing: border-box;
-    background: #f5f5f5;
+    // background: #f5f5f5;
   }
 }
 </style>

+ 34 - 14
src/components/shopCompoents/printerAdd.vue

@@ -1,7 +1,7 @@
 <template>
   <div class="shopAdd">
     <!-- 打印机新增、编辑 -->
-    <el-dialog width="40%" :title="title" destroy-on-close center :visible.sync="showVisible">
+    <el-dialog width="600px" :title="title" :destroy-on-close="true" center :visible.sync="showVisible">
       <el-form :model="form" ref="form" label-width="120px">
         <el-form-item label="选择打印机" prop="deviceType">
           <div class="category_box">
@@ -10,16 +10,21 @@
             </div>
           </div>
         </el-form-item>
+        <el-form-item label="关联门店">
+          <el-select v-model="form.shopId" placeholder="请选择关联门店">
+            <el-option v-for="v in shopList" :key="v.id" :label="v.name" :value="v.id"></el-option>
+          </el-select>
+        </el-form-item>
         <el-form-item label="打印机名称" prop="name">
-          <el-input v-model="form.name" placeholder="给这台打印机取个名字吧" autocomplete="off" style="width: 100%">
+          <el-input clearable v-model="form.name" placeholder="给这台打印机取个名字吧" autocomplete="off" style="width: 100%">
           </el-input>
         </el-form-item>
         <el-form-item label="打印机编号" prop="deviceSn">
-          <el-input v-model="form.deviceSn" placeholder="查看打印机底部标签" autocomplete="off" style="width: 100%">
+          <el-input clearable v-model="form.deviceSn" placeholder="查看打印机底部标签" autocomplete="off" style="width: 100%">
           </el-input>
         </el-form-item>
-        <el-form-item label="打印机KEY" prop="deviceSecret">
-          <el-input v-model="form.deviceSecret" placeholder="查看打印机底部标签" autocomplete="off" style="width: 100%">
+        <el-form-item label="打印机KEY" prop="deviceSecret" v-if="form.deviceType!==25">
+          <el-input clearable v-model="form.deviceSecret" placeholder="查看打印机底部标签" autocomplete="off" style="width: 100%">
           </el-input>
         </el-form-item>
         <el-form-item label="自动打印接单" prop="deviceSecret">
@@ -66,12 +71,24 @@ export default {
         return [];
       },
     },
+    shopList: {
+      type: Array,
+      default: function () {
+        return [];
+      },
+    },
   },
   data() {
     return {
       title: "添加打印机",
       showVisible: false,
-      form: {},
+      form: {
+        openOrderPrint: 1,
+        openOrderCancelPrint: 1,
+        printCustomerCount: 1,
+        printMerchantCount: 1,
+        printKitchenCount: 1,
+      },
       revieweds: [],
       loading: false,
       isEdit: false,
@@ -84,9 +101,10 @@ export default {
         return;
       }
       this.$set(this.form, "deviceType", v.type);
+      this.$set(this.form, "name", v.name);
       this.form.deviceId = v.id;
     },
-    init(e, shopId) {
+    init(e) {
       if (e) {
         this.isEdit = true;
         this.title = "编辑打印机";
@@ -95,14 +113,16 @@ export default {
         this.isEdit = false;
         this.title = "添加打印机";
         this.form = {
+          openOrderPrint: 1,
+          openOrderCancelPrint: 1,
+          printCustomerCount: 1,
+          printMerchantCount: 1,
+          printKitchenCount: 1,
+          deviceType: "",
           name: "",
-          deviceSn: "",
-          deviceSecret: "",
           deviceId: "",
-          printCustomerCount: 0,
-          printMerchantCount: 0,
-          printKitchenCount: 0,
-          shopId,
+          shopId: "",
+          deviceSn: "",
         };
       }
       this.showVisible = true;
@@ -126,7 +146,7 @@ export default {
           message: "请填写打印机编号!",
         });
       }
-      if (!this.form.deviceSecret.trim()) {
+      if (this.form.deviceType !== 25 && !this.form.deviceSecret.trim()) {
         return this.$message({
           type: "error",
           message: "请填写打印机Key!",

+ 302 - 0
src/components/waimaiComponents/printerList.vue

@@ -0,0 +1,302 @@
+<template>
+  <div class="printer-list">
+    <div class="model">
+      <div class="title">
+        <div class="name">云打印</div>
+        <div class="status-list">
+          <div class="status">
+            <div class="bg1"></div>
+            <div class="con">在线{{pinter.onlineNum}}</div>
+          </div>
+          <div class="status">
+            <div class="bg1 bg2"></div>
+            <div class="con">离线{{pinter.offlineNum}}</div>
+          </div>
+          <div class="status">
+            <div class="bg1 bg3"></div>
+            <div class="con">异常{{pinter.abnormalNum}}</div>
+          </div>
+        </div>
+      </div>
+      <div class="printer-list">
+        <div class="item" v-for="(v,i) in printerList" :key=i @click.stop="addPrinter(v)">
+          <img class="img" :src="require(`../../../static/image/printer-online-${v.onlineStatus}.png`)" alt="">
+          <div class="name">{{v.name}}</div>
+          <div class="shop-name">{{v.shopName}}</div>
+          <div class="btns">
+            <img @click.stop="printTest(v)" src="../../../static/image/print-icon.png" alt="">
+            <img @click.stop="deletePrinter(v)" src="../../../static/image/delete-icon.png" alt="">
+          </div>
+        </div>
+        <div class="item" @click.stop="addPrinter('')">
+          <img class="img" src="../../../static/image/icon-add.png" alt="">
+          <div class="name">添加打印机</div>
+          <div class="shop-name"> </div>
+        </div>
+      </div>
+    </div>
+    <printer-add :shopList="shopList" @shopDeviceList="refreshData" ref="printerAdd" :devices="deviceList"></printer-add>
+  </div>
+</template>
+
+<script>
+import printerAdd from "./printerAdd";
+import {
+  getShopList,
+  shopListNew,
+  shopDeviceList,
+  deviceDetail,
+  deviceList,
+  deviceAdd,
+  deviceDelete,
+  deviceStatus,
+  printTest,
+} from "../../api/shop";
+export default {
+  name: "printerList",
+  components: {
+    printerAdd,
+  },
+  data() {
+    return {
+      pinter: {},
+      printerList: [],
+      deviceList: [],
+      shopList: [],
+    };
+  },
+  // 监听属性 类似于data概念
+  computed: {},
+  // 监控data中的数据变化
+  watch: {},
+  // 方法集合
+  methods: {
+    printTest(v) {
+      printTest({ deviceSn: v.deviceSn }).then((res) => {
+        if (res.code === 200) {
+          this.$message({
+            type: "success",
+            message: "操作成功!",
+          });
+          this.refreshData();
+        } else {
+          this.$message({
+            type: "error",
+            message: res.msg,
+          });
+        }
+      });
+    },
+    deletePrinter(v) {
+      this.$confirm("此操作将删除打印机, 是否继续?", "提示", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning",
+        center: true,
+      })
+        .then(() => {
+          deviceDelete({ id: v.id }).then((res) => {
+            if (res.code === 200) {
+              this.$message({
+                type: "error",
+                message: "删除成功!",
+              });
+              this.refreshData();
+            } else {
+              this.$message({
+                type: "error",
+                message: res.msg,
+              });
+            }
+          });
+        })
+        .catch(() => {
+          this.$message({
+            type: "info",
+            message: "已取消删除",
+          });
+        });
+    },
+    refreshData() {
+      this.getPrinterNum();
+      this.getPrinterList();
+    },
+    addPrinter(e) {
+      console.log(e);
+      if (!e) {
+        this.$refs.printerAdd.init();
+      } else {
+        this.$refs.printerAdd.init(JSON.parse(JSON.stringify(e)));
+      }
+    },
+    getPrinterList() {
+      shopDeviceList({ deviceType: 2 }).then((res) => {
+        if (res.code === 200) {
+          this.printerList = res.data;
+        } else {
+          this.$message({
+            type: "error",
+            message: res.msg,
+          });
+        }
+      });
+    },
+    getPrinterNum() {
+      deviceStatus().then((res) => {
+        if (res.code === 200) {
+          this.pinter = res.data;
+        } else {
+          this.$message({
+            type: "error",
+            message: res.msg,
+          });
+        }
+      });
+    },
+    getDeviceList() {
+      deviceList({ type: 2 }).then((res) => {
+        if (res.code === 200) {
+          this.deviceList = res.data;
+        } else {
+          this.$message({
+            type: "error",
+            message: res.msg,
+          });
+        }
+      });
+    },
+    getShopList() {
+      shopListNew().then((res) => {
+        if (res.code === 200) {
+          this.shopList = res.data;
+        } else {
+          this.$message({
+            type: "error",
+            message: res.msg,
+          });
+        }
+      });
+    },
+  },
+  // 生命周期 - 创建完成(可以访问当前this实例)
+  created() {
+    this.getPrinterNum();
+    this.getPrinterList();
+    this.getDeviceList();
+    this.getShopList();
+  },
+  // 生命周期 - 挂载完成(可以访问DOM元素)
+  mounted() {},
+  // 生命周期 - 创建之前
+  beforeCreate() {},
+  // 生命周期 - 挂载之前
+  beforeMount() {},
+  // 生命周期 - 更新之前
+  beforeUpdate() {},
+  // 生命周期 - 更新之后
+  updated() {},
+  // 生命周期 - 销毁之前
+  beforeDestroy() {},
+  // 生命周期 - 销毁完成
+  destroyed() {},
+  // 如果页面有keep-alive缓存功能,这个函数会触发
+  activated() {},
+};
+</script>
+
+<style lang="scss" scoped  type="text/css">
+.model {
+  .title {
+    position: relative;
+    display: flex;
+    align-items: center;
+    font-size: 16px;
+    font-weight: bold;
+    line-height: 22px;
+    color: #333333;
+    padding-left: 10px;
+    margin-top: 24px;
+    .status-list {
+      display: flex;
+      align-items: center;
+      font-size: 14px;
+      font-weight: 400;
+      line-height: 22px;
+      color: #999999;
+      .status {
+        display: flex;
+        align-items: center;
+        margin-left: 30px;
+        .con {
+          margin-left: 5px;
+        }
+        .bg1 {
+          width: 40px;
+          height: 10px;
+          border-radius: 2px;
+          background: linear-gradient(180deg, #64c47c 0%, #1aaa3d 100%);
+        }
+        .bg2 {
+          background: rgba(204, 204, 204, 0.39);
+        }
+        .bg3 {
+          background: linear-gradient(180deg, #ff8a8a 0%, #e60000 100%);
+        }
+      }
+    }
+  }
+  .title::before {
+    width: 3px;
+    height: 16px;
+    background: rgba(252, 114, 0, 0.39);
+    border-radius: 2px;
+    content: "";
+    position: absolute;
+    top: 2px;
+    left: 0;
+  }
+  .printer-list {
+    display: flex;
+    flex-wrap: wrap;
+    .item {
+      position: relative;
+      display: flex;
+      flex-direction: column;
+      align-items: center;
+      justify-content: center;
+      width: 320px;
+      height: 182px;
+      background: #ffffff;
+      border-radius: 8px;
+      margin: 10px 20px 0 0;
+      cursor: pointer;
+      .img {
+        width: 80px;
+        height: 80px;
+      }
+      .name {
+        font-size: 14px;
+        font-weight: 500;
+        line-height: 20px;
+        color: #333333;
+      }
+      .shop-name {
+        font-size: 12px;
+        font-weight: 400;
+        line-height: 20px;
+        color: #999999;
+      }
+      .btns {
+        position: absolute;
+        top: 10px;
+        right: 0;
+        img {
+          width: 20px;
+          height: 20px;
+          margin-right: 10px;
+        }
+      }
+    }
+  }
+}
+</style>

BIN
static/image/delete-icon.png


BIN
static/image/edit-icon.png


BIN
static/image/print-icon.png


BIN
static/image/printer-online-0.png


BIN
static/image/printer-online-1.png


BIN
static/image/printer-online-2.png