linwenxin 1 rok temu
rodzic
commit
3b9c5f5bd3
1 zmienionych plików z 18 dodań i 12 usunięć
  1. 18 12
      src/views/setting/departmentManage/index.vue

+ 18 - 12
src/views/setting/departmentManage/index.vue

@@ -3,7 +3,7 @@
     <div class="mymain-container">
       <div>
         <el-select v-model="value1" multiple placeholder="显示层级">
-          <el-option v-for="item in levels" :key="item.value" :label="['平台', '商户', '网点'][item - 1]" :value="item">
+          <el-option v-for="item in types" :key="item.value" :label="item.label" :value="item.value">
           </el-option>
         </el-select>
         <span style="display: inline-block; width: 220px; margin-left: 10px"><el-input v-model="input"
@@ -12,11 +12,11 @@
 
       <div class="table">
         <el-table :data="showList" border>
-          <el-table-column prop="level" label="级别" width="70">
+          <el-table-column prop="type" label="级别" width="70">
             <template slot-scope="scope">
-              <el-tag v-if="scope.row.level == 1" type="success">平台</el-tag>
-              <el-tag v-if="scope.row.level == 2">商户</el-tag>
-              <el-tag v-if="scope.row.level == 3" type="warning">网点</el-tag>
+              <el-tag v-if="scope.row.type == 'A'" type="success">平台</el-tag>
+              <el-tag v-if="scope.row.type == 'B'">商户</el-tag>
+              <el-tag v-if="scope.row.type == 'C'" type="warning">网点</el-tag>
             </template>
           </el-table-column>
           <el-table-column prop="name" label="网点名称"> </el-table-column>
@@ -38,9 +38,13 @@
                 @click="openMainForm('edit', scope.row.websitId)">编辑</el-button>
               <el-button type="primary" size="mini" icon="el-icon-edit"
                 @click="handleDelete(scope.row.websitId)">删除</el-button>
-              <el-button v-if="scope.row.level == 2" :type="['primary', 'warning'][scope.row.level - 1]" plain size="mini"
-                icon="el-icon-plus" @click="openMainForm('add', scope.row.websitId)">添加{{ scope.row.level == 1 ? '商户' :
-                  scope.row.level == 2 ? '网点' : '网点' }}</el-button>
+              <el-button v-if="!!~['A', 'B'].indexOf(scope.row.type)"
+                :type="({ A: 'primary', B: 'warning' })[scope.row.type]" plain size="mini" icon="el-icon-plus"
+                @click="openMainForm('add', scope.row.websitId)">
+                添加{{ scope.row.type
+                  == 'A' ? '商户' :
+                  scope.row.type == 'B' ? '网点' : '网点' }}
+              </el-button>
             </template>
           </el-table-column>
         </el-table>
@@ -101,10 +105,11 @@ export default {
       input: '',
       value1: [],
       levels: [],
+      types: [{ label: '平台', value: 'A' }, { label: '商户', value: 'B' }, { label: '网点', value: 'C' }],
       mainForm: {
         parentId: '',
         name: '',
-        address:'',
+        address: '',
         status: true,
       },
       mainFormRules: {
@@ -122,7 +127,7 @@ export default {
       return [...this.dataList]
         .filter(item => {
           return (
-            (this.value1.length ? !!~this.value1.indexOf(item.level) : true) &&
+            (this.value1.length ? !!~this.value1.indexOf(item.type) : true) &&
             (this.input ? !!~item.name.indexOf(this.input) || !!~item.pname.indexOf(this.input) : true)
           )
         })
@@ -131,7 +136,7 @@ export default {
     listTotal() {
       return [...this.dataList].filter(item => {
         return (
-          (this.value1.length ? !!~this.value1.indexOf(item.level) : true) &&
+          (this.value1.length ? !!~this.value1.indexOf(item.type) : true) &&
           (this.input ? !!~item.name.indexOf(this.input) || !!~item.pname.indexOf(this.input) : true)
         )
       }).length
@@ -156,6 +161,7 @@ export default {
       var levels = []
       function dg(list, level = 1, pname = []) {
         for (let { children, name, ...item } of list) {
+          console.log(item)
           var n_ = ''
           for (var i = 1; i < level; i++) n_ += ` -> `
           list_.push({ ...item, name: n_ + name, level, pname: [...pname] })
@@ -214,7 +220,7 @@ export default {
           this.mainForm = {
             parentId: res.data.parentId,
             name: res.data.name,
-            address:res.data.address,
+            address: res.data.address,
             status: res.data.status,
           }
         })