马宇豪
2024-04-08 743a085df156140f4a3f4ae2d03e910790181945
新增查询条件
已修改7个文件
229 ■■■■■ 文件已修改
src/api/user.js 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/layout/menuSider.vue 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/Admin/addressBook.vue 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/Admin/components/pwdMod.vue 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/Admin/sameLevel.vue 86 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/Home.vue 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/Login.vue 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/user.js
@@ -94,6 +94,13 @@
    })
}
export function delRecipientBatch(ids){
    return request({
        url:'/mesmanager/recipient/deletebatch/' + ids,
        method: 'delete'
    })
}
// 获取同级领导
export function getLeaders(){
    return request({
src/layout/menuSider.vue
@@ -29,7 +29,7 @@
    return {
      userInfo: {},
      navData: [],
      openKeys: ['1','2','3','4']
      openKeys: ['1']
    };
  },
  created() {
@@ -60,10 +60,17 @@
  },
  methods: {
    onOpenChange(openKeys) {
      if (openKeys.length !== 0) {
        this.openKeys = [openKeys[1]]
      // if (openKeys.length !== 0) {
      //   this.openKeys = [openKeys[1]]
      // } else {
      //   this.openKeys = ['']
      // }
      const rootSubmenuKeys = this.navData.map(i=>i.MenuID)
      const latestOpenKey = openKeys.find(key => this.openKeys.indexOf(key) === -1);
      if (rootSubmenuKeys.indexOf(latestOpenKey) === -1) {
        this.openKeys = openKeys;
      } else {
        this.openKeys = ['']
        this.openKeys = latestOpenKey ? [latestOpenKey] : [];
      }
    },
  }
src/views/Admin/addressBook.vue
@@ -1,13 +1,13 @@
<template>
  <div class="inner">
    <a-row type="flex" justify="space-between" style="margin-bottom: 20px">
      <a-col :span="6">
        <a-button v-if="unittype && unittype !== null" type="primary" @click="editData('add',{})">新增</a-button>
        <a-button v-if="unittype && unittype !== null" type="primary" @click="visible = true" style="margin: 0 12px">导入通讯录表</a-button>
        <a-button v-if="unittype && unittype !== null" type="primary" @click="openGroup()">分组管理</a-button>
      <a-col :span="6" v-if="unittype && unittype !== null">
        <a-button type="primary" @click="editData('add',{})">新增</a-button>
        <a-button type="primary" @click="visible = true" style="margin: 0 12px">导入通讯录表</a-button>
        <a-button type="primary" @click="openGroup()">分组管理</a-button>
      </a-col>
      <a-col :span="18">
        <a-row type="flex" justify="end" :gutter="14">
        <a-row type="flex" :gutter="14">
          <a-col :span="6">
            <a-input v-model="search.searchParams.company" placeholder="单位名称" style="width: 100%"/>
          </a-col>
src/views/Admin/components/pwdMod.vue
@@ -80,7 +80,6 @@
  },
  created() {
    const t = this
    console.log(t.id,t.form.uid,'id')
  },
  methods:{
    clearMod(){
src/views/Admin/sameLevel.vue
@@ -1,11 +1,16 @@
<template>
  <div class="inner">
    <a-row type="flex" justify="space-between" style="margin-bottom: 20px">
      <a-col :span="4">
        <a-button v-if="unittype && unittype !== null" type="primary" @click="editData('add',{})">新增用户</a-button>
      <a-col :span="4" v-if="unittype && unittype !== null">
        <a-button type="primary" @click="editData('add',{})">新增用户</a-button>
      </a-col>
      <a-col :span="20">
        <a-row type="flex" justify="end" :gutter="14">
        <a-row type="flex" :gutter="14">
          <a-col :span="6">
            <a-select v-model="search.searchParams.peerRecipientGroupId" placeholder="选择分组" style="width: 100%" @change="handleChange" allowClear show-search :filter-option="filterOption">
              <a-select-option v-for="item in groupData" :value="item.id" :key="item.id">{{item.name}}</a-select-option>
            </a-select>
          </a-col>
          <a-col :span="6">
            <a-input v-model="search.searchParams.company" placeholder="单位名称" style="width: 100%"/>
          </a-col>
@@ -15,12 +20,13 @@
          <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-button type="danger" style="margin-left: 12px" @click="delBySet">批量删除</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.id" bordered>
      <a-table :columns="columns" :data-source="tableData" :pagination="pagination" :rowKey="record=>record.id" bordered :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }">
        <template #unittype="unittype">
          <a-tag
              :color="unittype === 1 ? 'purple' : unittype === 2 ? 'blue' : unittype === 3 ? 'cyan' : 'green'"
@@ -45,7 +51,7 @@
</template>
<script>
import {delRecipient, delUser, getRecipient, getSameLevelGroupList, getUser} from '@/api/user'
import {delRecipient, delRecipientBatch, delUser, getRecipient, getSameLevelGroupList, getUser} from '@/api/user'
import sameLevelMod from "@/views/Admin/components/sameLevelMod"
import {getUserInfo} from "@/util/storage";
import {getDistrictInfo} from "@/api/login";
@@ -67,9 +73,11 @@
          province: '',
          city: '',
          area: '',
          town: ''
          town: '',
          peerRecipientGroupId: undefined
        }
      },
      selectedRowKeys: [],
      columns:[
        {
          title: '单位名称',
@@ -140,31 +148,15 @@
  methods:{
    async getUserList(){
      const t = this
      if(t.search.searchParams.province == '' && t.search.searchParams.city == '' && t.search.searchParams.area == '' && t.search.searchParams.company == ''){
      if(t.search.searchParams.province == '' && t.search.searchParams.city == '' && t.search.searchParams.area == '' && t.search.searchParams.company == '' && t.search.searchParams.peerRecipientGroupId == undefined){
        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){
@@ -191,10 +183,10 @@
      if(res.data.code == 100){
        if(res.data.data){
          let arr = res.data.data
          t.groupData = arr.concat([{id: null, name: '未分类'}])
          t.groupData = arr.concat([{id: -1, name: '未分类'}])
        }else{
          t.groupData = [{
            id: null,
            id: -1,
            name: '未分类'
          }]
        }
@@ -213,7 +205,8 @@
          province: '',
          city: '',
          area: '',
          town: ''
          town: '',
          peerRecipientGroupId: undefined
        }
      }
      t.getUserList()
@@ -225,6 +218,12 @@
      t.$refs.sameLevelMod.areaData = t.areaData
      t.$refs.sameLevelMod.form.unittype = t.unittype
      t.$refs.sameLevelMod.form.districtId = t.districtId
    },
    filterOption(input, option) {
      return (
          option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
      );
    },
    async delData(row){
@@ -267,6 +266,31 @@
      return null;
    },
    async delBySet(){
      const t = this
      this.$confirm({
        title: '提示',
        content: h => <div>是否删除所选用户信息?</div>,
        cancelText: '取消',
        okText: '确认',
        centered: true,
        onOk() {
          delRecipientBatch(t.selectedRowKeys.join(',')).then(res=>{
            if(res.data.code == 100){
              t.$message.success('删除用户信息成功');
              t.getUserList()
              t.selectedRowKeys = []
            }else{
              t.$message.warning(res.data.msg);
            }
          })
        },
        onCancel() {
          console.log('Cancel');
        },
      });
    },
    onPageChange(page, pageSize) {
      const t= this
      t.pagination.current = page
@@ -280,7 +304,8 @@
        province: '',
        city: '',
        area: '',
        town: ''
        town: '',
        peerRecipientGroupId: undefined
      }
      if(value[0]){
        t.search.searchParams.province = t.findCodeById(t.areaData,value[0]).name
@@ -295,6 +320,13 @@
        t.search.searchParams.town = t.findCodeById(t.areaData,value[3]).name
      }
    },
    handleChange(value) {
      console.log(`selected ${value}`);
      this.getUserList()
    },
    onSelectChange(selectedRowKeys) {
      this.selectedRowKeys = selectedRowKeys;
    },
  }
}
</script>
src/views/Home.vue
@@ -56,6 +56,7 @@
  import { loginOut, getDistrictInfo } from "@/api/login";
  import { Session, getUserInfo} from '@/util/storage';
  import Cookies from "js-cookie";
  import {getAreaWithUserIfo} from "@/api/user";
    export default {
        name: "Home",
        data() {
@@ -84,6 +85,7 @@
                })
                this.addListener()
            }
      this.getAreaUsers(getUserInfo().districtId)
        },
        watch: {
            '$route': function(newRoute) {
@@ -217,6 +219,59 @@
                const path = closePath && closePath.split('?')[0]
                this.remove(path, nextRoute)
            },
      async getAreaUsers(districtId) {
        let t = this
        let res = await getAreaWithUserIfo()
        if (res.data.code == 100) {
          if (res.data.data) {
            t.userTitTree(res.data.data)
            const areaUsers = t.findNodeById(res.data.data, districtId).children
            localStorage.removeItem('areaUsers')
            localStorage.setItem('areaUsers',JSON.stringify(areaUsers))
          } else {
            console.log('暂无数据')
          }
        } else {
          this.$message.warning(res.data.msg);
        }
      },
      // 根据id查对象
      findNodeById(data, value) {
        for (const node of data) {
          if (node.id === value) {
            return node;
          }
          if (node.children) {
            const foundNode = this.findNodeById(node.children, value);
            if (foundNode) {
              return foundNode;
            }
          }
        }
        return null;
      },
      // 将树状数据name字段放入users的姓名电话
      userTitTree(treeData) {
        for (const node of treeData) {
          if (node.users) {
            node.users = node.users.filter(i => i.roleId == 3)
            node.users = node.users.map((i) => {
              return {
                ...i,
                unittype: node.type,
                districtId: node.id
              }
            })
            node.name = node.name + '(' + node.users.map(i => i.realName + ' ' + i.phone).join(',') + ')'
          }
          if (node.children) {
            this.userTitTree(node.children)
          }
        }
        return treeData
      }
        }
    };
</script>
src/views/Login.vue
@@ -107,7 +107,6 @@
import { login, getMenuAdmin } from "@/api/login";
import Cookies from 'js-cookie';
import {Base64} from "js-base64";
import {getAreaWithUserIfo} from "@/api/user";
export default {
@@ -158,7 +157,6 @@
            Cookies.set('resTk', res.data.data.tk);
            Cookies.set('resUid', res.data.data.uid);
            Cookies.set('userInfo',JSON.stringify(res.data.data),{expires: 7})
            await this.getAreaUsers(res.data.data.districtId)
            if (this.saveAccount) {
              localStorage.setItem('userName', this.form.name)
              localStorage.setItem('userPassword', Base64.encode(this.form.pwd))
@@ -178,59 +176,6 @@
      });
    },
    async getAreaUsers(districtId) {
      let t = this
      let res = await getAreaWithUserIfo()
      if (res.data.code == 100) {
        if (res.data.data) {
          t.userTitTree(res.data.data)
          const areaUsers = t.findNodeById(res.data.data, districtId).children
          localStorage.removeItem('areaUsers')
          localStorage.setItem('areaUsers',JSON.stringify(areaUsers))
        } else {
          console.log('暂无数据')
        }
      } else {
        this.$message.warning(res.data.msg);
      }
    },
    // 根据id查对象
    findNodeById(data, value) {
      for (const node of data) {
        if (node.id === value) {
          return node;
        }
        if (node.children) {
          const foundNode = this.findNodeById(node.children, value);
          if (foundNode) {
            return foundNode;
          }
        }
      }
      return null;
    },
    // 将树状数据name字段放入users的姓名电话
    userTitTree(treeData) {
      for (const node of treeData) {
        if (node.users) {
          node.users = node.users.filter(i => i.roleId == 3)
          node.users = node.users.map((i) => {
            return {
              ...i,
              unittype: node.type,
              districtId: node.id
            }
          })
          node.name = node.name + '(' + node.users.map(i => i.realName + ' ' + i.phone).join(',') + ')'
        }
        if (node.children) {
          this.userTitTree(node.children)
        }
      }
      return treeData
    }
  },
};
</script>