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
<template>
<div class="app-content">
<a-form :form="form" :model="searchForm" layout="inline" class="search_form">
<a-form-item>
<a-input v-model="searchForm.personName" placeholder="请输入姓名" :maxLength="100" style="width: 160px" />
</a-form-item>
<a-form-item>
<a-input v-model="searchForm.certId" placeholder="请输入证件号" :maxLength="100" style="width: 160px" />
</a-form-item>
<a-form-item>
<a-select v-model="searchForm.sex" style="width: 160px">
<a-select-option value="">请选择性别</a-select-option>
<a-select-option value="男">男</a-select-option>
<a-select-option value="女">女</a-select-option>
</a-select>
</a-form-item>
<a-form-item>
<a-input v-model="searchForm.username" placeholder="请输入用户名" :maxLength="100" style="width: 160px" />
</a-form-item>
<a-form-item>
<a-input v-model="searchForm.mobile" placeholder="请输入手机号" :maxLength="100" style="width: 160px" />
</a-form-item>
<a-form-item>
<a-button type="primary" icon="search" @click="search">搜索</a-button>
<a-button icon="reload" style="margin-left: 10px" @click="reset" class="bt-normal">重置</a-button>
</a-form-item>
</a-form>
<a-divider style="height: 1px; background-color: #e8e8e8;" />
<div class="submit-btn">
<a-button type="primary" @click="importExcel">用户导入</a-button>
<a-button type="primary" @click="exportData" icon="download">Excel</a-button>
</div>
<a-table :dataSource="tableData" :columns="columns" rowKey="id" :pagination="false" :loading="loading">
<template slot="stateSwitch" slot-scope="record">
<a-switch checked-children="正常" un-checked-children="注销" :checked="checkedState(record)" @change="switchChange($event,record)" />
</template>
<template slot="option" slot-scope="record">
<a-button type="link" size="small" @click="recordClick(record,'edit')">修改</a-button>
<a-button type="link" size="small" @click="recordClick(record,'reset')">重置密码</a-button>
</template>
</a-table>
<a-pagination v-if="pagination.total > 0" :total="pagination.total" show-size-changer show-quick-jumper v-model="pagination.pageIndex" :page-size="pagination.pageSize" :page-size-options="pagination.pageSizeOptions" @showSizeChange="showSizeChange" @change="change" :showTotal="() => `共 ${pagination.total} 条`" />
<a-modal v-model="visibleView" title="查看" width="60%" :dialog-style="{ top: '12%' }" :footer="null" destroyOnClose>
<user-view v-model="id"></user-view>
</a-modal>
<a-modal v-model="visibleEdit" title="修改" width="60%" :dialog-style="{ top: '12%' }" :footer="null" destroyOnClose>
<!-- <person-edit v-model="id" @close="closeWindow"></person-edit> -->
<user-edit v-model="id" @close="closeWindow"></user-edit>
</a-modal>
<a-modal v-model="visibleImport" title="导入" width="60%" :dialog-style="{ top: '12%' }" :footer="null" destroyOnClose>
<user-import />
</a-modal>
</div>
</template>
<script>
import { isEmptyParams, hideIdCard, hidePhone } from "@/views/utils/common";
import moment from 'moment';
import userView from '@/views/manager/user/components/userView'
import userEdit from '@/views/manager/user/components/userEdit'
import userImport from '@/views/manager/user/components/userImport';
export default {
name: 'userManager',
components: {
userView, userEdit, userImport
},
data () {
return {
form: this.$form.createForm(this, { name: 'advanced_search' }),
searchForm: { unitName: null, treeCode: null, username: null, personName: null, certId: null, sex: "", mobile: null },
tableData: [],
columns: [
{ title: '用户名', dataIndex: 'username', align: 'center' },
// { title: '密码', dataIndex: 'password', align: 'center' },
{ title: '姓名', dataIndex: 'personName', align: 'center' },
{ title: '性别', dataIndex: 'sex', align: 'center' },
{ title: '证件号', dataIndex: 'certId', align: 'center' },
{ title: '单位', dataIndex: 'unitName', align: 'center' },
// { title: '专业', dataIndex: 'specName', align: 'center' },
{ title: '职称', dataIndex: 'titleName', align: 'center' },
// { title: '学历', dataIndex: 'educationName', align: 'center' },
{ title: '手机号', dataIndex: 'mobile', align: 'center' },
{ title: '邮箱', dataIndex: 'email', align: 'center' },
{ title: '状态', scopedSlots: { customRender: 'stateSwitch' }, align: 'center', width: '100px' },
{ title: '操作', scopedSlots: { customRender: 'option' }, align: 'center', fixed: 'right', width: 120, },
],
pagination: {
pageIndex: 1, pageSize: this.$defaultPageSize, total: 0, pageSizeOptions: this.$defaultPageSizeOptions,
},
// 弹窗
visibleView: false,
visibleEdit: false,
id: null,
loading: false,
visibleImport: false,
}
},
created () {
this.getListByPage()
},
methods: {
moment,
search () {
this.pagination.pageIndex = 1
this.getListByPage()
},
reset () {
this.searchForm = { unitName: null, treeCode: null, username: null, personName: null, certId: null, sex: "", mobile: null }
this.pagination.pageIndex = 1
this.getListByPage()
},
getListByPage () {
this.loading = true
let pars = isEmptyParams(this.searchForm)
let par = { ...pars, pageIndex: this.pagination.pageIndex, pageSize: this.pagination.pageSize }
this.$api.systemUser.getListByPage(par).then(({ data = {} }) => {
if (data) {
const { dataList = [], total = 0 } = data
this.tableData = dataList
this.pagination.total = total
this.loading = false
}
}).catch(() => {
this.loading = false
})
},
change () {
this.getListByPage()
},
showSizeChange (current, pageSize) {
this.pagination.pageSize = pageSize
this.getListByPage()
},
exportData () {
this.$api.person.exportPersonInfo();
},
recordClick (record, type) {
if (type === 'view') {
this.id = record.id
this.visibleView = true
} else if (type === 'edit') {
this.id = record.id
this.visibleEdit = true
}
else if (type === 'reset') {
this.resetPwd(record)
}
},
resetPwd (record) {
let self = this
this.$confirm({
title: '重置密码',
content: '重置后密码为"ky123456"确定要重置密码?',
okText: '确定',
okType: 'danger',
cancelText: '取消',
onOk () {
let par = { id: record.id }
self.$api.systemUser.resetUserPwd(par).then(({ data = {} }) => {
if (data) {
self.$message.success('重置成功!')
self.getListByPage()
}
}).catch(() => { })
},
onCancel () {
},
})
},
checkedState (record) {
return record.stateName === "正常" ? true : false
},
switchChange (checked, record) {
if (checked) {
record.stateName = "正常";
record.noteState = 1;
} else {
record.stateName = "注销";
record.noteState = 2;
}
let par = { id: record.id, noteState: record.noteState }
this.$api.systemUser.updateState(par).then(({ data = {} }) => {
if (data) {
this.$message.success('修改成功!')
}
}).catch(() => { })
},
closeWindow (value) {
if (value === 'edit') {
this.visibleEdit = false
this.getListByPage()
}
else
this.visibleView = false
},
importExcel () {
this.visibleImport = true;
},
}
}
</script>