From 0d32ef0479cb7d7d0f24b4e866994d43dfaf82e6 Mon Sep 17 00:00:00 2001
From: 马宇豪 <978517621@qq.com>
Date: Tue, 04 Jun 2024 13:12:41 +0800
Subject: [PATCH] 添加通讯录
---
src/views/Admin/sameLevel.vue | 128 ++++++++++++++++++++++++++++++++++--------
1 files changed, 104 insertions(+), 24 deletions(-)
diff --git a/src/views/Admin/sameLevel.vue b/src/views/Admin/sameLevel.vue
index 09231d2..d407693 100644
--- a/src/views/Admin/sameLevel.vue
+++ b/src/views/Admin/sameLevel.vue
@@ -1,23 +1,32 @@
<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" 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" :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="4">
- <a-button type="primary" @click="getUserList">查询</a-button>
+ <a-col :span="6">
+ <a-input v-model="search.searchParams.company" placeholder="单位名称" style="width: 100%"/>
+ </a-col>
+ <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-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.name" 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'"
@@ -42,7 +51,7 @@
</template>
<script>
-import {delRecipient, delUser, getRecipient, 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";
@@ -60,12 +69,15 @@
pageIndex: 1,
pageSize: 10,
searchParams:{
+ company: '',
province: '',
city: '',
area: '',
- town: ''
+ town: '',
+ peerRecipientGroupId: undefined
}
},
+ selectedRowKeys: [],
columns:[
{
title: '单位名称',
@@ -76,6 +88,11 @@
title: '接收人姓名',
dataIndex: 'recipientName',
key: 'recipientName'
+ },
+ {
+ title: '所属分组',
+ dataIndex: 'peerRecipientGroupName',
+ key: 'peerRecipientGroupName'
},
{
title: '手机号码',
@@ -96,11 +113,13 @@
},
{
title: '操作',
+ width: '12%',
key: 'action',
scopedSlots: { customRender: 'action' }
},
],
tableData: [],
+ groupData: [],
pagination: {
current: 1,
defaultCurrent: 1,
@@ -119,16 +138,17 @@
},
created() {
const t = this
- console.log(getUserInfo(),'id')
+ 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 == '' && t.search.searchParams.peerRecipientGroupId == undefined){
const {searchParams,...data} = t.search
const res = await getRecipient(data)
if(res.data.code == 100){
@@ -157,6 +177,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: -1, name: '未分类'}])
+ }else{
+ t.groupData = [{
+ id: -1,
+ name: '未分类'
+ }]
+ }
+ }else{
+ this.$message.error(res.data.msg)
+ }
+ },
resetSearch(){
const t = this
t.areaVal = []
@@ -164,10 +201,12 @@
pageIndex: 1,
pageSize: 10,
searchParams:{
+ company: '',
province: '',
city: '',
area: '',
- town: ''
+ town: '',
+ peerRecipientGroupId: undefined
}
}
t.getUserList()
@@ -175,10 +214,16 @@
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
+ },
+
+ filterOption(input, option) {
+ return (
+ option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
+ );
},
async delData(row){
@@ -189,14 +234,15 @@
cancelText: '取消',
okText: '确认',
centered: true,
- async onOk() {
- let res = await delRecipient(row.id)
- if(res.data.code == 100){
- t.$message.success('删除用户信息成功');
- t.getUserList()
- }else{
- t.$message.warning(res.data.msg);
- }
+ onOk() {
+ delRecipient(row.id).then(res=>{
+ if(res.data.code == 100){
+ t.$message.success('删除用户信息成功');
+ t.getUserList()
+ }else{
+ t.$message.warning(res.data.msg);
+ }
+ })
},
onCancel() {
console.log('Cancel');
@@ -220,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
@@ -229,10 +300,12 @@
onChange(value) {
const t = this
t.search.searchParams = {
+ company: '',
province: '',
city: '',
area: '',
- town: ''
+ town: '',
+ peerRecipientGroupId: undefined
}
if(value[0]){
t.search.searchParams.province = t.findCodeById(t.areaData,value[0]).name
@@ -247,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>
--
Gitblit v1.9.2