guhongwei 4 gadi atpakaļ
vecāks
revīzija
df17891e86
1 mainītis faili ar 67 papildinājumiem un 31 dzēšanām
  1. 67 31
      src/views/superAdminCenter/user/index.vue

+ 67 - 31
src/views/superAdminCenter/user/index.vue

@@ -4,13 +4,13 @@
       <el-col :span="24" class="main">
         <el-tabs v-model="activeName" type="card" @tab-click="clickBtn">
           <el-tab-pane label="待审核" name="first">
-            <list :list="oneList" :total="onetotal" :type="type" @handleDelete="handleDelete" @handleEdit="handleEdit"></list>
+            <data-table :fields="fields" :opera="opera" :data="oneList" :total="onetotal" @edit="toEdit" @delete="toDelete" @query="search"></data-table>
           </el-tab-pane>
           <el-tab-pane label="审核完成" name="second">
-            <list :list="twoList" :total="twototal" :type="type" @handleDelete="handleDelete" @handleEdit="handleEdit"></list>
+            <data-table :fields="fields" :opera="opera" :data="twoList" :total="twototal" @edit="toEdit" @delete="toDelete" @query="search"></data-table>
           </el-tab-pane>
           <el-tab-pane label="审核失败" name="third">
-            <list :list="threeList" :total="threetotal" :type="type" @handleDelete="handleDelete" @handleEdit="handleEdit"></list>
+            <data-table :fields="fields" :opera="opera" :data="threeList" :total="threetotal" @edit="toEdit" @delete="toDelete" @query="search"></data-table>
           </el-tab-pane>
         </el-tabs>
       </el-col>
@@ -22,7 +22,7 @@
 </template>
 
 <script>
-import list from './parts/list.vue';
+import dataTable from '@/components/data-table.vue';
 import detailInfo from './parts/detailInfo.vue';
 import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions: authUser } = createNamespacedHelpers('authUser');
@@ -35,17 +35,47 @@ export default {
   name: 'index',
   props: {},
   components: {
-    list,
+    dataTable,
     detailInfo,
   },
   data: function() {
     return {
       activeName: 'first',
       type: '0',
-      // 待审核
+      opera: [
+        {
+          label: '修改',
+          icon: 'el-icon-edit',
+          method: 'edit',
+        },
+        {
+          label: '删除',
+          icon: 'el-icon-delete',
+          method: 'delete',
+        },
+      ],
+      fields: [
+        { label: '用户名', prop: 'name' },
+        { label: '用户ID', prop: 'phone' },
+        {
+          label: '用户类别',
+          prop: 'role',
+          format: item => {
+            return item === '4' ? '个人用户' : item === '5' ? '机构用户' : '专家用户';
+          },
+        },
+        {
+          label: '状态',
+          prop: 'status',
+          format: item => {
+            return item === '0' ? '审核中' : item === '1' ? '审核通过' : '审核拒绝';
+          },
+        },
+      ],
+      // // 待审核
       oneList: [],
       onetotal: 0,
-      // 审核成功
+      // // 审核成功
       twoList: [],
       twototal: 0,
       // 审核失败
@@ -67,30 +97,36 @@ export default {
     async search({ skip = 0, limit = 10, ...info } = {}) {
       let code = this.user.code;
       if (code == 'JLCJGLY') {
-        let res = await this.userquery({ skip, ...info });
-        let one = res.data.filter(i => i.status == '0');
-        let two = res.data.filter(i => i.status == '1');
-        let thr = res.data.filter(i => i.status == '2');
-        if (one || two || thr) {
-          this.$set(this, `oneList`, one);
-          this.$set(this, `onetotal`, one.length);
-          this.$set(this, `twoList`, two);
-          this.$set(this, `twototal`, two.length);
-          this.$set(this, `threeList`, thr);
-          this.$set(this, `threetotal`, thr.length);
+        let res = await this.userquery({ skip, limit, status: '0', ...info });
+        if (this.$checkRes(res)) {
+          this.$set(this, `oneList`, res.data);
+          this.$set(this, `onetotal`, res.total);
+        }
+        res = await this.userquery({ skip, limit, status: '1', ...info });
+        if (this.$checkRes(res)) {
+          this.$set(this, `twoList`, res.data);
+          this.$set(this, `twototal`, res.total);
+        }
+        res = await this.userquery({ skip, limit, status: '2', ...info });
+        if (this.$checkRes(res)) {
+          this.$set(this, `threeList`, res.data);
+          this.$set(this, `threetotal`, res.total);
         }
       } else {
-        let res = await this.userquery({ skip, code, ...info });
-        let one = res.data.filter(i => i.status == '0');
-        let two = res.data.filter(i => i.status == '1');
-        let thr = res.data.filter(i => i.status == '2');
-        if (one || two || thr) {
-          this.$set(this, `oneList`, one);
-          this.$set(this, `onetotal`, one.length);
-          this.$set(this, `twoList`, two);
-          this.$set(this, `twototal`, two.length);
-          this.$set(this, `threeList`, thr);
-          this.$set(this, `threetotal`, thr.length);
+        let res = await this.userquery({ skip, limit, code, status: '0', ...info });
+        if (this.$checkRes(res)) {
+          this.$set(this, `oneList`, res.data);
+          this.$set(this, `onetotal`, res.total);
+        }
+        res = await this.userquery({ skip, limit, code, status: '1', ...info });
+        if (this.$checkRes(res)) {
+          this.$set(this, `twoList`, res.data);
+          this.$set(this, `twototal`, res.total);
+        }
+        res = await this.userquery({ skip, limit, code, status: '2', ...info });
+        if (this.$checkRes(res)) {
+          this.$set(this, `threeList`, res.data);
+          this.$set(this, `threetotal`, res.total);
         }
       }
     },
@@ -99,7 +135,7 @@ export default {
       this.$set(this, `type`, tab.index);
     },
     // 审核。查看
-    async handleEdit(data) {
+    async toEdit({ data }) {
       if (data.role == '4' || data.role == '5') {
         let res = await this.fetch(data.uid);
         if (this.$checkRes(res)) {
@@ -139,7 +175,7 @@ export default {
       }
     },
     // 刪除
-    async handleDelete(data) {
+    async toDelete({ data }) {
       this.$confirm('您确定要删除此信息吗?', '提示', {
         confirmButtonText: '确定',
         cancelButtonText: '取消',