waimai.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template>
  2. <div class="shopInfo">
  3. <el-row class="order_tab">
  4. <el-col :span="24">
  5. <div class="tabList">
  6. <div class="tab_item" @click="changeTabs(i)" :class="{'tab_item_ac':tabNum==i?true:false}" v-for="(item,i) in tabList" :key="i">
  7. <span class="item" v-if="!item.children">{{item.name}}</span>
  8. <el-dropdown v-else @command="chooseCoupon">
  9. <span class="el-dropdown-link item">
  10. {{item.name}}<i class="el-icon-arrow-down el-icon--right"></i>
  11. </span>
  12. <el-dropdown-menu slot="dropdown">
  13. <el-dropdown-item :command="v.command" v-for="(v,index) in item.children" :key="index">{{v.name}}</el-dropdown-item>
  14. </el-dropdown-menu>
  15. </el-dropdown>
  16. <div class="tab_line"></div>
  17. </div>
  18. </div>
  19. </el-col>
  20. </el-row>
  21. <el-row class="content">
  22. <component v-if="renderComponent" :is="activeName"></component>
  23. </el-row>
  24. </div>
  25. </template>
  26. <script>
  27. import printerList from "./shopCompoents/bindPrinter.vue";
  28. import usbPrinter from "./shopCompoents/bindUsbPrint.vue";
  29. import pictureManagement from "./waimaiComponents/pictureManagement.vue";
  30. import addressManagement from "./waimaiComponents/addressManagement.vue";
  31. import deliverySetting from "./waimaiComponents/deliverySetting.vue";
  32. import voiceSetting from "./waimaiComponents/voiceSetting.vue";
  33. export default {
  34. name: "waimai",
  35. components: {
  36. printerList,
  37. usbPrinter,
  38. pictureManagement,
  39. addressManagement,
  40. deliverySetting,
  41. voiceSetting,
  42. },
  43. data() {
  44. return {
  45. activeName: "deliverySetting",
  46. tabList: [
  47. { name: "配送设置", index: 0, activeName: "deliverySetting" },
  48. { name: "语音设置", index: 1, activeName: "voiceSetting" },
  49. {
  50. name: "打印机管理",
  51. index: 2,
  52. activeName: "printerList",
  53. children: [
  54. { name: "云打印机", command: "printerList" },
  55. { name: "USB打印机", command: "usbPrinter" },
  56. ],
  57. },
  58. { name: "商品管理", index: 3, activeName: "pictureManagement" },
  59. { name: "常用地址", index: 4, activeName: "addressManagement" },
  60. ],
  61. tabNum: 0,
  62. renderComponent: true,
  63. };
  64. },
  65. created() {
  66. this.changeTabs(0);
  67. },
  68. methods: {
  69. chooseCoupon(e) {
  70. this.tabNum = 2;
  71. this.activeName = e;
  72. },
  73. forceRerender() {
  74. // 从 DOM 中删除 my-component 组件
  75. this.renderComponent = false;
  76. this.$nextTick(() => {
  77. // 在 DOM 中添加 my-component 组件
  78. this.renderComponent = true;
  79. });
  80. },
  81. changeTabs(i) {
  82. if (i === this.tabNum) {
  83. this.forceRerender();
  84. return;
  85. }
  86. this.tabNum = i;
  87. this.activeName = this.tabList[i].activeName;
  88. },
  89. },
  90. };
  91. </script>
  92. <!-- Add "scoped" attribute to limit CSS to this component only -->
  93. <style scoped lang="scss">
  94. .shopInfo {
  95. .order_tab {
  96. width: 100%;
  97. height: 74px;
  98. background: #fff;
  99. .tabList {
  100. width: 100%;
  101. height: 74px;
  102. padding-top: 20px;
  103. padding-left: 36px;
  104. box-sizing: border-box;
  105. display: flex;
  106. .tab_item {
  107. min-width: 58px;
  108. margin-right: 56px;
  109. .item {
  110. font-size: 16px;
  111. font-weight: 500;
  112. color: #b1b1b1;
  113. position: relative;
  114. text-align: center;
  115. cursor: pointer;
  116. }
  117. .tab_line {
  118. width: 58px;
  119. height: 6px;
  120. background: #fff;
  121. border-radius: 3px;
  122. margin: 15px auto 0;
  123. }
  124. }
  125. .tab_item_ac {
  126. color: #fc7200;
  127. .tab_line {
  128. background: #fc7200;
  129. }
  130. }
  131. }
  132. }
  133. .content {
  134. width: 100%;
  135. margin-top: 10px;
  136. // padding: 20px;
  137. box-sizing: border-box;
  138. background: #f5f5f5;
  139. }
  140. }
  141. </style>