1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
| <template>
| <div class="inner">
| <a-row type="flex" justify="space-between" style="margin-bottom: 20px">
| <a-col :span="4">
| <a-button type="primary" @click="editData('add',{})">新增用户</a-button>
| </a-col>
| <a-col :span="20">
| <a-row type="flex" justify="end" :gutter="12">
| <a-col :span="4">
| <a-cascader :options="areaData" v-model="areaVal" placeholder="行政规划" expandTrigger="hover" changeOnSelect @change="onChange" style="width: 100%"/>
| </a-col>
| <a-col :span="4">
| <a-button type="primary" @click="getUserList">查询</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>
| <template #levels="level">
| <a-tag
| :color="level === 1 ? 'pink' : level === 2 ? 'blue' : 'green'"
| >
| {{ level === 1 ? '省级' : level === 2 ? '地(市、州)级' : level === 3 ? '区县级' : '村(乡、镇)级' }}
| </a-tag>
| </template>
| <template #area="area">
| {{findAreaById(areaData,area)}}
| </template>
| <template #action="action,row">
| <a-button type="link" @click="editData('edit',row)">编辑</a-button>
| <a-button type="link" class="delBtn">删除</a-button>
| </template>
| </a-table>
| </div>
| <same-level-mod ref="sameLevelMod" @refrech="getUserList"></same-level-mod>
| </div>
| </template>
|
| <script>
| import {getUser} from '@/api/user'
| import sameLevelMod from "@/views/Admin/components/sameLevelMod"
| export default {
| name: 'sameLevel',
| components: {
| sameLevelMod
| },
| data () {
| return {
| areaVal: [],
| search:{
| pageIndex: 1,
| pageSize: 10,
| searchParams:{
| districtId: null
| }
| },
| columns:[
| {
| title: '单位名称',
| dataIndex: 'depName',
| key: 'depName'
| },
| {
| title: '接收人姓名',
| dataIndex: 'name',
| key: 'name'
| },
| {
| title: '手机号码',
| dataIndex: 'phone',
| key: 'phone'
| },
| {
| title: '级别',
| dataIndex: 'level',
| key: 'level',
| scopedSlots: { customRender: 'levels' }
| },
| {
| title: '行政区划',
| dataIndex: 'area',
| key: 'area',
| scopedSlots: { customRender: 'area' }
| },
| {
| title: '操作',
| key: 'action',
| scopedSlots: { customRender: 'action' }
| },
| ],
| tableData: [
| {
| depName: '阿勒泰地区自然资源局',
| name: 'John Brown',
| phone: '15261806177',
| level: 1,
| area: 111
| },
| {
| depName: '阿勒泰地区公安局',
| name: 'Jim Green',
| phone: '15261806178',
| level: 2,
| area: 211
| },
| {
| depName: '阿勒泰地区自然资源局',
| name: 'Joe Black',
| phone: '15261806176',
| level: 3,
| area: 11
| },
| ],
| pagination: {
| current: 1,
| defaultCurrent: 1,
| defaultPageSize: 10,
| total: 11,
| onChange: ( page, pageSize ) => this.onPageChange(page,pageSize)
| },
| areaData: [
| {
| value: 1,
| label: '江苏省',
| children: [
| {
| value: 11,
| label: '苏州市',
| children: [
| {
| value: 111,
| label: '工业园区',
| },
| ],
| },
| ],
| },
| {
| value: 2,
| label: '新疆维吾尔自治区',
| children: [
| {
| value: 21,
| label: '乌鲁木齐市',
| children: [
| {
| value: 211,
| label: '国泰新华',
| },
| ],
| },
| ],
| },
| ]
| }
| },
| created() {
| const t = this
| t.getUserList()
| },
| methods:{
| async getUserList(){
| const t = this
| const res = await getUser(t.search)
| },
|
| resetSearch(){
| const t = this
| t.areaVal = []
| t.search = {
| pageIndex: 1,
| pageSize: 10,
| searchParams:{
| districtId: null
| }
| }
| t.getUserList()
| },
|
| editData(type,data){
| const t = this
| t.$refs.sameLevelMod.openDialog(type,data)
| t.$refs.sameLevelMod.areaData = t.areaData
| },
|
| onPageChange(page, pageSize) {
| const t= this
| t.pagination.current = page
| },
| onChange(value) {
| const t = this
| t.search.searchParams.districtId = value[value.length - 1]
| },
|
| findAreaById(data,value) {
| for (const node of data) {
| if (node.value === value) {
| return node.label;
| }
| if (node.children) {
| const foundLabel = this.findAreaById(node.children, value);
| if (foundLabel) {
| return foundLabel;
| }
| }
| }
| return null;
| }
| }
| }
| </script>
|
| <style lang="less" scoped>
| .delBtn{
| color: @danger
| }
| </style>
|
|