|
@@ -1,6 +1,9 @@
|
1
|
1
|
<template>
|
2
|
2
|
<div>
|
3
|
3
|
<el-form class="user-form" :rules="rules" :model="detail" ref="ruleForm" label-width="160px">
|
|
4
|
+ <el-form-item label="登录名" prop="loginname" required>
|
|
5
|
+ <el-input v-model="detail.loginname"></el-input>
|
|
6
|
+ </el-form-item>
|
4
|
7
|
<el-form-item label="用户名" prop="username" required>
|
5
|
8
|
<el-input v-model="detail.username"></el-input>
|
6
|
9
|
</el-form-item>
|
|
@@ -57,9 +60,22 @@ export default {
|
57
|
60
|
menuArray: []
|
58
|
61
|
|
59
|
62
|
},
|
|
63
|
+ pageNavi: {
|
|
64
|
+ page: 1,
|
|
65
|
+ size: 10,
|
|
66
|
+ total: 0,
|
|
67
|
+ },
|
|
68
|
+ listQuery: {
|
|
69
|
+ name: '',
|
|
70
|
+ phone: '',
|
|
71
|
+ identity: undefined,
|
|
72
|
+ },
|
60
|
73
|
roleId: [],
|
61
|
74
|
sysRole:[],
|
62
|
75
|
rules: {
|
|
76
|
+ loginname: [
|
|
77
|
+ { required: true, message: '请输入登录名', trigger: 'blur' }
|
|
78
|
+ ],
|
63
|
79
|
nickname: [
|
64
|
80
|
{ required: true, message: '请输入用户名', trigger: 'blur' }
|
65
|
81
|
],
|
|
@@ -77,6 +93,7 @@ export default {
|
77
|
93
|
},
|
78
|
94
|
methods: {
|
79
|
95
|
...mapUserActions([
|
|
96
|
+ 'getSysUserList',
|
80
|
97
|
'getDetail',
|
81
|
98
|
'addSysUser',
|
82
|
99
|
'editSysUser',
|
|
@@ -90,6 +107,17 @@ export default {
|
90
|
107
|
onCancel () {
|
91
|
108
|
this.$router.back()
|
92
|
109
|
},
|
|
110
|
+ getList () {
|
|
111
|
+ this.getSysUserList({
|
|
112
|
+ pageNum: this.pageNavi.page || 1,
|
|
113
|
+ pageSize: this.pageNavi.size,
|
|
114
|
+ identity: this.listQuery.identity === '%' ? undefined : this.listQuery.identity,
|
|
115
|
+ ...this.listQuery,
|
|
116
|
+ }).then((data) => {
|
|
117
|
+ const { current: page, size, total } = data
|
|
118
|
+ this.pageNavi = { page, size, total }
|
|
119
|
+ })
|
|
120
|
+ },
|
93
|
121
|
onSubmit () {
|
94
|
122
|
this.$refs.ruleForm.validate((valid) => {
|
95
|
123
|
if (!valid) {
|
|
@@ -99,19 +127,36 @@ export default {
|
99
|
127
|
|
100
|
128
|
if (!this.detail.userId) {
|
101
|
129
|
// 新增
|
102
|
|
- this.addSysUser({...this.detail, isSales: 1}).then(() => {
|
|
130
|
+ this.addSysUser({...this.detail, isSales: 1}).then((res) => {
|
103
|
131
|
this.$notify.success('添加信息成功')
|
|
132
|
+
|
|
133
|
+ this.formInline.userId = res.userId
|
|
134
|
+ this.getUserRoledetails()
|
|
135
|
+ this.init()
|
|
136
|
+
|
|
137
|
+ // 保存角色
|
|
138
|
+ this.formInline.menuArray = this.roleId
|
|
139
|
+ this.updateUserRolede(this.formInline)
|
|
140
|
+ this.getList()
|
|
141
|
+ this.$router.go(-1)
|
104
|
142
|
})
|
105
|
143
|
} else {
|
106
|
144
|
// 修改
|
107
|
145
|
this.editSysUser({...this.detail, isSales: 1}).then(() => {
|
108
|
146
|
this.$notify.success('编辑信息成功')
|
|
147
|
+ // 保存角色
|
|
148
|
+ this.formInline.menuArray = this.roleId
|
|
149
|
+ this.updateUserRolede(this.formInline)
|
|
150
|
+ this.getList()
|
|
151
|
+ this.$router.go(-1)
|
109
|
152
|
})
|
110
|
|
- // 保存角色
|
111
|
|
- this.formInline.menuArray = this.roleId
|
112
|
|
- this.updateUserRolede(this.formInline)
|
113
|
153
|
}
|
114
|
|
-
|
|
154
|
+ })
|
|
155
|
+ },
|
|
156
|
+ getUserRoledetails() {
|
|
157
|
+ this.userRoledetails(this.formInline).then((data)=>{
|
|
158
|
+ this.sysRole = data.sysRole
|
|
159
|
+ this.roleId = data.arrayList
|
115
|
160
|
})
|
116
|
161
|
},
|
117
|
162
|
init () {
|
|
@@ -132,10 +177,7 @@ export default {
|
132
|
177
|
},
|
133
|
178
|
created () {
|
134
|
179
|
this.formInline.userId = this.$route.query.id
|
135
|
|
- this.userRoledetails(this.formInline).then((data)=>{
|
136
|
|
- this.sysRole = data.sysRole
|
137
|
|
- this.roleId = data.arrayList
|
138
|
|
- })
|
|
180
|
+ this.getUserRoledetails()
|
139
|
181
|
this.init()
|
140
|
182
|
},
|
141
|
183
|
}
|