|
@@ -1,95 +1,182 @@
|
|
|
<template>
|
|
|
- <div>
|
|
|
+ <div class="bind-printer" v-loading="loading" element-loading-text="数据加载中">
|
|
|
<div class="store-list">
|
|
|
- <div class="store-list-item" :class=" index == 0 ? 'active' : '' " v-for="(item, index) in storeList" :key="index">{{ item.name }}</div>
|
|
|
+ <div class="store-list-item" :class=" index == 0 ? 'active' : '' " v-for="(item, index) in shopList" :key="index">{{ item.name }}</div>
|
|
|
</div>
|
|
|
- <div class="take-out-list">
|
|
|
- <div class="item">
|
|
|
- <div class="item-top">
|
|
|
- <div class="name">美团外卖</div>
|
|
|
- <div class="top-right">
|
|
|
- <span>开启后自动接单</span>
|
|
|
- <el-switch />
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div class="item-bottom">
|
|
|
- <div class="left">
|
|
|
- <div class="l-l">
|
|
|
- <img src="../../../static/image/alipay.png" class="l-l-img" />
|
|
|
- </div>
|
|
|
- <div class="take-out-name">
|
|
|
- <div class="take-out-name-bot">
|
|
|
- <span class="status1">· 打印机离线</span>
|
|
|
- <span class="status2">· 打印机离线</span>
|
|
|
- <span class="status3">· 打印机离线</span>
|
|
|
- </div>
|
|
|
- <div>打印机名称:飞鹅打印机</div>
|
|
|
- <div>打印机编号:VXN2020080765184</div>
|
|
|
- <div class="take-out-name-bot">打印机KEY:1234</div>
|
|
|
- <div>客户联:X1</div>
|
|
|
- <div>商家联:X1</div>
|
|
|
- <div>厨房联:X1</div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div class="right">
|
|
|
- <el-button size="small">编 辑</el-button>
|
|
|
- </div>
|
|
|
+ <div class="header">
|
|
|
+ <div class="left">
|
|
|
+ <div class="line">
|
|
|
+ <div class="b_line"></div>
|
|
|
+ <div class="triangle"></div>
|
|
|
</div>
|
|
|
+ <div class="label">打印机管理</div>
|
|
|
+ </div>
|
|
|
+ <div class="right">
|
|
|
+ <el-button class="btn" @click.stop="addPrinter(1)">添加打印机</el-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
-
|
|
|
- <div class="take-out-list">
|
|
|
+ <div class="take-out-list" v-for="(v,i) in printerList" :key="i">
|
|
|
<div class="item">
|
|
|
<div class="item-top">
|
|
|
- <div class="name">添加打印机</div>
|
|
|
+ <div class="name">{{v.name}}</div>
|
|
|
</div>
|
|
|
<div class="item-bottom">
|
|
|
<div class="left">
|
|
|
<div class="l-l">
|
|
|
- <img src="../../../static/image/printer.png" class="l-l-img" />
|
|
|
+ <img src="../../../static/image/alipay.png" class="l-l-img" />
|
|
|
</div>
|
|
|
<div class="take-out-name">
|
|
|
<div class="take-out-name-bot">
|
|
|
- <span class="status1">请添加打印机</span>
|
|
|
+ <span :class="['status'+v.onlineStatus,'status']"> 打印机{{v.onlineStatus === 1 ? '在线' : v.onlineStatus === 2 ? '异常' : '离线'}}</span>
|
|
|
</div>
|
|
|
- <div>打印机名称:-</div>
|
|
|
- <div>打印机编号:-</div>
|
|
|
- <div class="take-out-name-bot">打印机KEY:-</div>
|
|
|
- <div>客户联:-</div>
|
|
|
- <div>商家联:-</div>
|
|
|
- <div>厨房联:-</div>
|
|
|
+ <div>打印机名称:{{v.deviceName}}</div>
|
|
|
+ <div>打印机编号:{{v.deviceSn}}</div>
|
|
|
+ <div class="take-out-name-bot">打印机KEY:{{v.deviceSecret}}</div>
|
|
|
+ <div>客户联:X{{v.printCustomerCount}}</div>
|
|
|
+ <div>商家联:X{{v.printMerchantCount}}</div>
|
|
|
+ <div>厨房联:X{{v.printKitchenCount}}</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="right">
|
|
|
- <el-button type="primary" size="small" class="right-btn">添加打印机</el-button>
|
|
|
+ <el-button @click="addPrinter(2,v)" size="small">编 辑</el-button>
|
|
|
+ <el-button type="danger" @click="deletePrinter(v)" size="small">删 除</el-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
-
|
|
|
-
|
|
|
+ <printer-add @shopDeviceList="shopDeviceList(curIdx)" ref="printerAdd" :devices="deviceList"></printer-add>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
- export default {
|
|
|
- data() {
|
|
|
- return {
|
|
|
- storeList: [
|
|
|
- { id: 1, name: '门店名称-1' },
|
|
|
- { id: 2, name: '门店名称-2' },
|
|
|
- { id: 3, name: '门店名称-3' },
|
|
|
- { id: 4, name: '门店名称-4' },
|
|
|
- { id: 5, name: '门店名称-5' },
|
|
|
- { id: 6, name: '门店名称-6' },
|
|
|
- { id: 7, name: '门店名称-7' }
|
|
|
- ]
|
|
|
+import printerAdd from "./printerAdd";
|
|
|
+import {
|
|
|
+ getShopList,
|
|
|
+ shopDeviceList,
|
|
|
+ deviceDetail,
|
|
|
+ deviceList,
|
|
|
+ deviceAdd,
|
|
|
+ deviceDelete,
|
|
|
+ deviceStatus,
|
|
|
+} from "../../api/shop";
|
|
|
+export default {
|
|
|
+ components: {
|
|
|
+ printerAdd,
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ shopList: [
|
|
|
+ { id: 1, name: "门店名称-1" },
|
|
|
+ { id: 2, name: "门店名称-2" },
|
|
|
+ { id: 3, name: "门店名称-3" },
|
|
|
+ { id: 4, name: "门店名称-4" },
|
|
|
+ { id: 5, name: "门店名称-5" },
|
|
|
+ { id: 6, name: "门店名称-6" },
|
|
|
+ { id: 7, name: "门店名称-7" },
|
|
|
+ ],
|
|
|
+ curIdx: -1,
|
|
|
+ loading: true,
|
|
|
+ printerList: [],
|
|
|
+ showVisible: false,
|
|
|
+ title: "添加打印机",
|
|
|
+ deviceList: [],
|
|
|
+ };
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ curIdx(newVal, oldVal) {
|
|
|
+ this.shopDeviceList(newVal);
|
|
|
+ },
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.getShopList();
|
|
|
+ this.getDeviceList();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ deletePrinter(v) {
|
|
|
+ this.$confirm("此操作将删除打印机, 是否继续?", "提示", {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning",
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ deviceDelete({ id: v.id }).then((res) => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.$message({
|
|
|
+ type: "error",
|
|
|
+ message: "删除成功!",
|
|
|
+ });
|
|
|
+ this.shopDeviceList(this.curIdx);
|
|
|
+ } else {
|
|
|
+ this.$message({
|
|
|
+ type: "error",
|
|
|
+ message: res.msg,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ this.$message({
|
|
|
+ type: "info",
|
|
|
+ message: "已取消删除",
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ getDeviceList() {
|
|
|
+ deviceList({ type: 2 }).then((res) => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.deviceList = res.data;
|
|
|
+ } else {
|
|
|
+ this.$message({
|
|
|
+ type: "error",
|
|
|
+ message: res.msg,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ getShopList() {
|
|
|
+ getShopList().then((res) => {
|
|
|
+ this.loading = true;
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.shopList = res.data;
|
|
|
+ this.curIdx = 0;
|
|
|
+ } else {
|
|
|
+ this.$message({
|
|
|
+ type: "error",
|
|
|
+ message: res.msg,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ this.loading = false;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ addPrinter(val, e) {
|
|
|
+ if (val === 1) {
|
|
|
+ let shopId = this.shopList[this.curIdx].id;
|
|
|
+ this.$refs.printerAdd.init("", shopId);
|
|
|
+ } else {
|
|
|
+ this.$refs.printerAdd.init(JSON.parse(JSON.stringify(e)));
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
+ },
|
|
|
+ shopDeviceList(index) {
|
|
|
+ shopDeviceList({ deviceType: 2, shopId: this.shopList[index].id }).then(
|
|
|
+ (res) => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.printerList = res.data;
|
|
|
+ } else {
|
|
|
+ this.$message({
|
|
|
+ type: "error",
|
|
|
+ message: res.msg,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ );
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
+.bind-printer {
|
|
|
+ min-height: 200px;
|
|
|
.store-list {
|
|
|
display: flex;
|
|
|
flex-wrap: nowrap;
|
|
@@ -103,14 +190,14 @@
|
|
|
font-size: 14px;
|
|
|
font-family: PingFang SC;
|
|
|
font-weight: 400;
|
|
|
- color: #B1B1B1;
|
|
|
+ color: #b1b1b1;
|
|
|
box-sizing: border-box;
|
|
|
border: 1px solid #eee;
|
|
|
border-radius: 17px;
|
|
|
cursor: pointer;
|
|
|
margin-right: 10px;
|
|
|
&.active {
|
|
|
- color: #017E61;
|
|
|
+ color: #fc7200;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -153,7 +240,7 @@
|
|
|
font-size: 14px;
|
|
|
font-family: PingFang SC;
|
|
|
font-weight: 400;
|
|
|
- color: #B1B1B1;
|
|
|
+ color: #b1b1b1;
|
|
|
margin-right: 12px;
|
|
|
}
|
|
|
}
|
|
@@ -183,27 +270,120 @@
|
|
|
color: #333333;
|
|
|
line-height: 26px;
|
|
|
margin-left: 30px;
|
|
|
- .take-out-name-bot{
|
|
|
+ .take-out-name-bot {
|
|
|
margin-bottom: 10px;
|
|
|
- .status1{
|
|
|
- color: #B1B1B1;
|
|
|
+ .status {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ &:before {
|
|
|
+ content: "";
|
|
|
+ display: block;
|
|
|
+ width: 8px;
|
|
|
+ height: 8px;
|
|
|
+ border-radius: 50%;
|
|
|
+ margin-right: 5px;
|
|
|
+ }
|
|
|
}
|
|
|
- .status2{
|
|
|
- color: #F74141;
|
|
|
+ .status0 {
|
|
|
+ color: #b1b1b1;
|
|
|
+ &:before {
|
|
|
+ background: #b1b1b1;
|
|
|
+ }
|
|
|
}
|
|
|
- .status3{
|
|
|
- color: #18B71C;
|
|
|
+ .status2 {
|
|
|
+ color: #f74141;
|
|
|
+ &:before {
|
|
|
+ background: #f74141;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .status1 {
|
|
|
+ color: #18b71c;
|
|
|
+ &:before {
|
|
|
+ background: #18b71c;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
.right {
|
|
|
.right-btn {
|
|
|
- background-color: #FC7200;
|
|
|
+ background-color: #fc7200;
|
|
|
border: none;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ .category_box {
|
|
|
+ display: flex;
|
|
|
+ flex-wrap: wrap;
|
|
|
+ width: 100%;
|
|
|
+ margin-top: -10px;
|
|
|
+
|
|
|
+ .item {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ width: 92px;
|
|
|
+ height: 38px;
|
|
|
+ margin: 10px 10px 0 0;
|
|
|
+ background: #f4f4f4;
|
|
|
+ border-radius: 2px;
|
|
|
+ cursor: pointer;
|
|
|
+
|
|
|
+ &.active {
|
|
|
+ color: #ffffff;
|
|
|
+ background: #fc7200;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .header {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: space-between;
|
|
|
+ margin: 10px;
|
|
|
+ .left {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+
|
|
|
+ .line {
|
|
|
+ position: relative;
|
|
|
+ width: 4px;
|
|
|
+ height: 15px;
|
|
|
+ background: #fc7200;
|
|
|
+ border-radius: 4px;
|
|
|
+ overflow: hidden;
|
|
|
+ margin-right: 10px;
|
|
|
+
|
|
|
+ .b_line {
|
|
|
+ width: 100px;
|
|
|
+ height: 6px;
|
|
|
+ background: #462bf7;
|
|
|
+ }
|
|
|
+
|
|
|
+ .triangle {
|
|
|
+ width: 0;
|
|
|
+ height: 0;
|
|
|
+ border-top: 100px solid #462bf7;
|
|
|
+ border-left: 100px solid transparent;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .label {
|
|
|
+ font-size: 16px;
|
|
|
+ font-weight: 500;
|
|
|
+ color: #0d1e40;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .btn {
|
|
|
+ background: #fc7200;
|
|
|
+ border-color: #fc7200;
|
|
|
+ color: #fff;
|
|
|
+ &.black {
|
|
|
+ background: #0d1e40;
|
|
|
+ border-color: #0d1e40;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
</style>
|