123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389 |
- <template>
- <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 shopList" :key="index">{{ item.name }}</div>
- </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" v-for="(v,i) in printerList" :key="i">
- <div class="item">
- <div class="item-top">
- <div class="name">{{v.name}}</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="['status'+v.onlineStatus,'status']"> 打印机{{v.onlineStatus === 1 ? '在线' : v.onlineStatus === 2 ? '异常' : '离线'}}</span>
- </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 @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>
- 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;
- width: 100%;
- white-space: nowrap;
- overflow-x: auto;
- padding-bottom: 10px;
- &-item {
- padding: 8px 27px;
- background-color: #fff;
- font-size: 14px;
- font-family: PingFang SC;
- font-weight: 400;
- color: #b1b1b1;
- box-sizing: border-box;
- border: 1px solid #eee;
- border-radius: 17px;
- cursor: pointer;
- margin-right: 10px;
- &.active {
- color: #fc7200;
- }
- }
- }
- .store-list::-webkit-scrollbar {
- height: 6px;
- }
- .store-list::-webkit-scrollbar-track {
- background-color: #eee;
- /*border-radius: 5px;
- -webkit-border-radius: 5px;
- -moz-border-radius: 5px;*/
- }
- .store-list::-webkit-scrollbar-thumb {
- background-color: #999;
- border-radius: 6px;
- -webkit-border-radius: 6px;
- -moz-border-radius: 6px;
- }
- .take-out-list {
- margin-bottom: 10px;
- .item {
- background-color: #fff;
- .item-top {
- display: flex;
- justify-content: space-between;
- box-sizing: border-box;
- padding: 20px 18px;
- align-items: center;
- border-bottom: 1px solid #eee;
- .name {
- font-size: 16px;
- font-family: PingFang SC;
- font-weight: bold;
- color: #333333;
- }
- .top-right {
- display: flex;
- align-items: center;
- span {
- font-size: 14px;
- font-family: PingFang SC;
- font-weight: 400;
- color: #b1b1b1;
- margin-right: 12px;
- }
- }
- }
- .item-bottom {
- display: flex;
- justify-content: space-between;
- box-sizing: border-box;
- padding: 25px 18px;
- align-items: center;
- .left {
- display: flex;
- align-items: center;
- .l-l {
- width: 220px;
- height: 220px;
- font-size: 0;
- .l-l-img {
- width: 100%;
- height: 100%;
- }
- }
- .take-out-name {
- font-size: 13px;
- font-family: PingFang SC;
- font-weight: 400;
- color: #333333;
- line-height: 26px;
- margin-left: 30px;
- .take-out-name-bot {
- margin-bottom: 10px;
- .status {
- display: flex;
- align-items: center;
- &:before {
- content: "";
- display: block;
- width: 8px;
- height: 8px;
- border-radius: 50%;
- margin-right: 5px;
- }
- }
- .status0 {
- color: #b1b1b1;
- &:before {
- background: #b1b1b1;
- }
- }
- .status2 {
- color: #f74141;
- &:before {
- background: #f74141;
- }
- }
- .status1 {
- color: #18b71c;
- &:before {
- background: #18b71c;
- }
- }
- }
- }
- }
- .right {
- .right-btn {
- 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>
|