set.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <template>
  2. <div class="setting">
  3. <el-row class="order_tab">
  4. <el-col :span="15">
  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>{{item.name}}</span>
  8. <div class="tab_line"></div>
  9. </div>
  10. </div>
  11. </el-col>
  12. </el-row>
  13. <el-row class="content">
  14. <el-col :span="24">
  15. <component v-if="renderComponent" :is="activeName"></component>
  16. </el-col>
  17. </el-row>
  18. </div>
  19. </template>
  20. <script>
  21. import voiceSetting from "./settingComponents/voiceSetting.vue";
  22. import deliverySetting from "./settingComponents/deliverySetting.vue";
  23. export default {
  24. name: "HelloWorld",
  25. data() {
  26. return {
  27. tabList: [
  28. { name: "自动接单/语音设置", index: 0,activeName: 'voiceSetting' },
  29. { name: "推荐/屏蔽运力", index: 1,activeName: 'deliverySetting' },
  30. ],
  31. tabNum: 0,
  32. activeName: "voiceSetting",
  33. renderComponent: true,
  34. };
  35. },
  36. components: {
  37. voiceSetting,
  38. deliverySetting,
  39. },
  40. methods: {
  41. forceRerender() {
  42. // 从 DOM 中删除 my-component 组件
  43. this.renderComponent = false;
  44. this.$nextTick(() => {
  45. // 在 DOM 中添加 my-component 组件
  46. this.renderComponent = true;
  47. });
  48. },
  49. changeTabs(i) {
  50. if (i === this.tabNum) {
  51. this.forceRerender();
  52. return;
  53. }
  54. this.tabNum = i;
  55. this.activeName = this.tabList[i].activeName;
  56. },
  57. },
  58. };
  59. </script>
  60. <!-- Add "scoped" attribute to limit CSS to this component only -->
  61. <style lang="scss" scoped>
  62. .setting {
  63. .order_tab {
  64. width: 100%;
  65. height: 74px;
  66. background: #fff;
  67. .tabList {
  68. width: 100%;
  69. height: 74px;
  70. padding-top: 20px;
  71. padding-left: 36px;
  72. box-sizing: border-box;
  73. display: flex;
  74. .tab_item {
  75. min-width: 58px;
  76. margin-right: 56px;
  77. font-size: 16px;
  78. font-weight: 500;
  79. color: #b1b1b1;
  80. position: relative;
  81. text-align: center;
  82. cursor: pointer;
  83. .tab_line {
  84. width: 58px;
  85. height: 6px;
  86. background: #fff;
  87. border-radius: 3px;
  88. margin: 15px auto 0;
  89. }
  90. }
  91. .tab_item_ac {
  92. color: #fc7200;
  93. .tab_line {
  94. background: #fc7200;
  95. }
  96. }
  97. }
  98. }
  99. .content {
  100. width: 100%;
  101. margin-top: 10px;
  102. }
  103. }
  104. </style>