index.vue
6.05 KB
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
220
221
222
223
224
225
226
227
228
229
230
<!-- 用户管理 -->
<template>
<d2-container class="user">
<el-form :inline="true" :model="searchForm" label-width="85px" slot="header">
<el-form-item label="用户:">
<el-input v-model="searchForm.userName" placeholder="请输入用户名/姓名/联系电话" clearable></el-input>
</el-form-item>
<!-- <el-form-item label="角色:">
<el-select v-model="searchForm.roleId" clearable placeholder="请选择">
<el-option
v-for="(role,index) in baseData.roles"
:label="role.roleName"
:value="role.roleId"
:key="index"
></el-option>
</el-select>
</el-form-item> -->
<el-form-item label="注册时间:">
<el-date-picker
v-model="searchTimes"
type="daterange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
value-format="yyyy-MM-dd"
></el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" :id="tableParams.btnId">查询</el-button>
</el-form-item>
</el-form>
<d2-table-header title="用户列表"><auth-button category="action" label="创建用户"></auth-button></d2-table-header>
<d2-table
ref="userTable"
:searchForm="searchForm"
:tableParams="tableParams"
:getListApi="getListApi"
>
<auth-button
slot="auth-button"
slot-scope="scope"
:data="scope.scope"
:mapping="mapping"
></auth-button>
</d2-table>
<dialog-reg :isVisible="registerDialogVisible" :editData="editData" :key="key"/>
</d2-container>
</template>
<script>
import {
UserList,
PassWordReset,
AccountModify,
AccountIncrease,
AccountForbidden,
AccountValidate,
AccountActived,
Reg
} from '@/api/sys.account'
import notice from '@/common/notice'
import { mapActions } from 'vuex'
import util from '@/libs/util'
export default {
name: 'FimsUsers',
components: {
DialogReg: () => import('./dialogReg')
},
data() {
return {
getListApi: UserList,
key: new Date(),
mapping: Object.freeze({
field: 'status',
'1': ['重置密码', '编辑', '延期', '禁用'],
'2': ['重置密码', '编辑', '激活'],
'3': ['重置密码', '编辑', '激活'],
'4': ['审核']
}),
apiMapping: Object.freeze({
'重置密码': PassWordReset,
'延期': AccountIncrease,
'禁用': AccountForbidden,
'激活': AccountActived
}),
// 新增/编辑弹窗
registerDialogVisible: false,
editData: {},
// 搜索
searchForm: {
userName: '',
status: '',
stationCode: '',
postCode: '',
startTime: '',
endTime: ''
},
searchTimes: [],
// 表格
// 表格参数
tableParams: {
btnId: new Date().getTime() + parseInt(Math.random() * 1000),
listName: 'userList',
tag: Object.freeze({
type: ['', 'success', 'info', 'danger', 'warning'],
label: ['未知', '正常', '已过期', '禁用', '待审核']
}),
tableOption: true,
tableColumns: [{
label: '用户名',
prop: 'loginName',
width: '200'
}, {
label: '角色',
prop: 'roleName',
width: '140'
}, {
label: '注册时间',
prop: 'registerTime',
minWidth: '200'
}, {
label: '有效期',
prop: 'validTime',
minWidth: '200'
}, {
label: '状态',
prop: 'status',
width: '120',
tagLabel: true
}, {
label: '姓名',
prop: 'userName',
width: '120'
}]
}
/* -----------------------基础数据---------------------- */
// baseData: {
// // 所属站点
// stations: [],
// // 职务
// posts: [],
// // 角色
// roles: []
// }
}
},
watch: {
'searchTimes'(value) {
Object.assign(this.searchForm, util.formatTime(this.searchTimes))
}
// '$store.state.d2admin.base.role'(value) {
// this.baseData.roles = value
// this.key = new Date()
// }
},
mounted() {
// this.fetchData()
this.$event.$on('e-reg-dialog-close', isReload => {
isReload && this.$refs.userTable.refreshTable()
this.registerDialogVisible = false
})
},
methods: {
...mapActions('d2admin/base', ['load']),
// 加载业务所需所有数据
// fetchData() {
// this.loadBaseData()
// },
// async loadBaseData() {
// const { role, station, post } = await this.load()
// this.baseData.posts = post
// this.baseData.stations = station
// this.baseData.roles = role.roles
// Object.freeze(this.baseData)
// },
/* 接口请求-start */
filterTag(value, row) {
return row.status === value
},
handleRegister() {
const row = {
data: {
title: '用户创建',
submit: Reg
}
}
this.openDialog(row)
},
handleEdit(row) {
row = util.deepClone(row)
row.data = {
title: '用户编辑',
submit: AccountModify
}
this.openDialog(row)
},
openDialog(row) {
this.registerDialogVisible = true
this.editData = row
},
handleVerify(row) {
row = util.deepClone(row)
row.data = {
title: '用户审核',
submit: AccountValidate
}
this.openDialog(row)
},
// ------------
// 列表各种操作
async handleOperation(row, e) {
const _actionText = e.target.innerText
const res = await this.apiMapping[_actionText]({ userId: row.userId })
const { operateStatus } = res
if (operateStatus) {
notice.okTips(`${_actionText}成功!`)
this.$refs.userTable.refreshTable()
} else {
notice.errorTips(`${_actionText}失败!`)
}
}
}
}
</script>
<style scoped>
</style>