From 140e83402814ffd2e92dfe313f5681feedd39f86 Mon Sep 17 00:00:00 2001
From: 马宇豪 <978517621@qq.com>
Date: 星期二, 06 二月 2024 16:49:12 +0800
Subject: [PATCH] 修复弹窗bug

---
 src/views/Admin/sameLevel.vue |   68 +++++++++++++++++++++++++++++-----
 1 files changed, 58 insertions(+), 10 deletions(-)

diff --git a/src/views/Admin/sameLevel.vue b/src/views/Admin/sameLevel.vue
index 23317e6..be1f3b5 100644
--- a/src/views/Admin/sameLevel.vue
+++ b/src/views/Admin/sameLevel.vue
@@ -4,20 +4,23 @@
       <a-col :span="4">
         <a-button v-if="unittype && unittype !== null" type="primary" @click="editData('add',{})">新增用户</a-button>
       </a-col>
-      <a-col :span="20" v-if="unittype == null || !unittype">
-        <a-row type="flex" justify="end" :gutter="12">
-          <a-col :span="4">
-            <a-cascader :options="areaData" v-model="areaVal" placeholder="行政规划" expandTrigger="hover" :fieldNames="fieldNames" changeOnSelect @change="onChange" style="width: 100%"/>
+      <a-col :span="20">
+        <a-row type="flex" justify="end" :gutter="14">
+          <a-col :span="6">
+            <a-input v-model="search.searchParams.company" placeholder="单位名称" style="width: 100%"/>
           </a-col>
-          <a-col :span="4">
-            <a-button type="primary" @click="getUserList">查询</a-button>
+          <a-col :span="6" v-if="unittype == null || !unittype">
+            <a-cascader :options="areaData" v-model="areaVal" placeholder="所属区域" expandTrigger="hover" :fieldNames="fieldNames" changeOnSelect @change="onChange" style="width: 100%"/>
+          </a-col>
+          <a-col :span="6">
+            <a-button type="primary" @click="getUserList" v-preventReClick="1500">查询</a-button>
             <a-button style="margin-left: 12px" @click="resetSearch">重置</a-button>
           </a-col>
         </a-row>
       </a-col>
     </a-row>
     <div class="table-cont">
-      <a-table :columns="columns" :data-source="tableData" :pagination="pagination" :rowKey="record=>record.name" bordered>
+      <a-table :columns="columns" :data-source="tableData" :pagination="pagination" :rowKey="record=>record.id" bordered>
         <template #unittype="unittype">
           <a-tag
               :color="unittype === 1 ? 'purple' : unittype === 2 ? 'blue' : unittype === 3 ? 'cyan' : 'green'"
@@ -42,7 +45,7 @@
 </template>
 
 <script>
-import {delRecipient, delUser, getRecipient, getUser} from '@/api/user'
+import {delRecipient, delUser, getRecipient, getSameLevelGroupList, getUser} from '@/api/user'
 import sameLevelMod from "@/views/Admin/components/sameLevelMod"
 import {getUserInfo} from "@/util/storage";
 import {getDistrictInfo} from "@/api/login";
@@ -60,6 +63,7 @@
         pageIndex: 1,
         pageSize: 10,
         searchParams:{
+          company: '',
           province: '',
           city: '',
           area: '',
@@ -76,6 +80,11 @@
           title: '接收人姓名',
           dataIndex: 'recipientName',
           key: 'recipientName'
+        },
+        {
+          title: '所属分组',
+          dataIndex: 'peerRecipientGroupName',
+          key: 'peerRecipientGroupName'
         },
         {
           title: '手机号码',
@@ -96,11 +105,13 @@
         },
         {
           title: '操作',
+          width: '12%',
           key: 'action',
           scopedSlots: { customRender: 'action' }
         },
       ],
       tableData: [],
+      groupData: [],
       pagination: {
         current: 1,
         defaultCurrent: 1,
@@ -119,23 +130,41 @@
   },
   created() {
     const t = this
+    t.groupData = []
     t.unittype = getUserInfo().unittype
     t.districtId = getUserInfo().districtId
+    t.getGroupList()
     t.getUserList()
     t.getDistrictInfo()
   },
   methods:{
     async getUserList(){
       const t = this
-      if(t.search.searchParams.province == '' && t.search.searchParams.city == '' && t.search.searchParams.area == '' ){
+      if(t.search.searchParams.province == '' && t.search.searchParams.city == '' && t.search.searchParams.area == '' && t.search.searchParams.company == ''){
         const {searchParams,...data} = t.search
         const res = await getRecipient(data)
         if(res.data.code == 100){
           t.tableData = res.data.data
           t.pagination.total = res.data.total
+          // for(let i of t.tableData){
+          //   if(i.peerRecipientGroupId == null){
+          //     i['peerRecipientGroup'] = '未分类'
+          //   }else{
+          //     getSameLevelGroupList().then((re)=>{
+          //       if(re.data.data && re.data.data.length>0){
+          //         for(let j of re.data.data){
+          //           if(j.id == i.peerRecipientGroupId){
+          //             i['peerRecipientGroup'] = j.name
+          //           }
+          //         }
+          //       }
+          //     })
+          //   }
+          // }
         }else{
           t.$message.warning(res.data.msg);
         }
+        console.log(t.tableData,'table')
       }else{
         const res = await getRecipient(t.search)
         if(res.data.code == 100){
@@ -156,6 +185,23 @@
       }
     },
 
+    async getGroupList() {
+      const t = this
+      const res = await getSameLevelGroupList();
+      if(res.data.code == 100){
+        if(res.data.data){
+          let arr = res.data.data
+          t.groupData = arr.concat([{id: null, name: '未分类'}])
+        }else{
+          t.groupData = [{
+            id: null,
+            name: '未分类'
+          }]
+        }
+      }else{
+        this.$message.error(res.data.msg)
+      }
+    },
     resetSearch(){
       const t = this
       t.areaVal = []
@@ -163,6 +209,7 @@
         pageIndex: 1,
         pageSize: 10,
         searchParams:{
+          company: '',
           province: '',
           city: '',
           area: '',
@@ -174,7 +221,7 @@
 
     editData(type,data){
       const t = this
-      t.$refs.sameLevelMod.openDialog(type,data)
+      t.$refs.sameLevelMod.openDialog(type,data,t.groupData)
       t.$refs.sameLevelMod.areaData = t.areaData
       t.$refs.sameLevelMod.form.unittype = t.unittype
       t.$refs.sameLevelMod.form.districtId = t.districtId
@@ -229,6 +276,7 @@
     onChange(value) {
       const t = this
       t.search.searchParams = {
+        company: '',
         province: '',
         city: '',
         area: '',

--
Gitblit v1.9.2