马宇豪
2024-02-06 140e83402814ffd2e92dfe313f5681feedd39f86
src/views/Admin/sameLevel.vue
@@ -45,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";
@@ -82,6 +82,11 @@
          key: 'recipientName'
        },
        {
          title: '所属分组',
          dataIndex: 'peerRecipientGroupName',
          key: 'peerRecipientGroupName'
        },
        {
          title: '手机号码',
          dataIndex: 'phone',
          key: 'phone'
@@ -106,6 +111,7 @@
        },
      ],
      tableData: [],
      groupData: [],
      pagination: {
        current: 1,
        defaultCurrent: 1,
@@ -124,8 +130,10 @@
  },
  created() {
    const t = this
    t.groupData = []
    t.unittype = getUserInfo().unittype
    t.districtId = getUserInfo().districtId
    t.getGroupList()
    t.getUserList()
    t.getDistrictInfo()
  },
@@ -138,9 +146,25 @@
        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){
@@ -161,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 = []
@@ -180,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