|
@@ -1,10 +1,10 @@
|
1
|
1
|
<template>
|
2
|
2
|
<div id="root">
|
3
|
3
|
<el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="100px" class="demo-ruleForm">
|
4
|
|
- <el-form-item label="名称" prop="userName">
|
|
4
|
+ <el-form-item label="姓名" prop="userName">
|
5
|
5
|
<el-input v-model="ruleForm.userName"/>
|
6
|
6
|
</el-form-item>
|
7
|
|
- <el-form-item class="filter-item" label="手机号" prop="loginName" >
|
|
7
|
+ <el-form-item class="filter-item" label="手机号" prop="loginName" >
|
8
|
8
|
<el-input v-model.trim="ruleForm.loginName" onkeyup="this.value=this.value.replace(/\D/g,'')" placeholder="手机号" />
|
9
|
9
|
</el-form-item>
|
10
|
10
|
<el-form-item label="角色" prop="menuArray">
|
|
@@ -37,7 +37,7 @@ export default {
|
37
|
37
|
ruleForm: {
|
38
|
38
|
id: '',
|
39
|
39
|
userName: '',
|
40
|
|
- loginName:'',
|
|
40
|
+ loginName: '',
|
41
|
41
|
remark: '',
|
42
|
42
|
roleName: '',
|
43
|
43
|
createUser: '',
|
|
@@ -62,16 +62,15 @@ export default {
|
62
|
62
|
],
|
63
|
63
|
menuArray: [
|
64
|
64
|
{ required: true, message: '请选择角色', trigger: 'blur' }
|
65
|
|
- ],
|
|
65
|
+ ]
|
66
|
66
|
}
|
67
|
67
|
}
|
68
|
68
|
},
|
69
|
69
|
mounted() {
|
70
|
|
- this.getById()
|
|
70
|
+ this.getById()
|
71
|
71
|
},
|
72
|
72
|
methods: {
|
73
|
73
|
submitForm(formName) {
|
74
|
|
-
|
75
|
74
|
// 获取选中的树形节点 key
|
76
|
75
|
this.ruleForm.menuArray = this.$refs.tree.getCheckedKeys()
|
77
|
76
|
this.$refs[formName].validate((valid) => {
|
|
@@ -82,16 +81,16 @@ export default {
|
82
|
81
|
background: 'rgba(0, 0, 0, 0.7)'
|
83
|
82
|
})
|
84
|
83
|
if (valid) {
|
85
|
|
- console.log('this.roleName',this.roleName)
|
|
84
|
+ console.log('this.roleName', this.roleName)
|
86
|
85
|
this.$store.dispatch('AddUser', this.ruleForm).then((res) => {
|
87
|
|
- if(this.ruleForm.menuArray.length<=0){
|
88
|
|
- this.$message.error('请选择角色')
|
89
|
|
- loading.close()
|
90
|
|
- console.log('this.ruleForm.menuArray',this.ruleForm.menuArray)
|
91
|
|
- return
|
|
86
|
+ if (this.ruleForm.menuArray.length <= 0) {
|
|
87
|
+ this.$message.error('请选择角色')
|
|
88
|
+ loading.close()
|
|
89
|
+ console.log('this.ruleForm.menuArray', this.ruleForm.menuArray)
|
|
90
|
+ return
|
92
|
91
|
}
|
93
|
92
|
const resCode = res.code
|
94
|
|
- this.ruleForm.id=''
|
|
93
|
+ this.ruleForm.id = ''
|
95
|
94
|
if (resCode === '0') {
|
96
|
95
|
this.$message({
|
97
|
96
|
message: res.message,
|
|
@@ -99,7 +98,7 @@ export default {
|
99
|
98
|
})
|
100
|
99
|
loading.close()
|
101
|
100
|
this.$router.push({ name: 'user-index' })
|
102
|
|
- }else{
|
|
101
|
+ } else {
|
103
|
102
|
this.$message.error(res.message)
|
104
|
103
|
}
|
105
|
104
|
}).catch(() => {
|
|
@@ -126,16 +125,16 @@ export default {
|
126
|
125
|
console.log('error GetMenuList')
|
127
|
126
|
})
|
128
|
127
|
},
|
129
|
|
- getById(){
|
130
|
|
- this.$store.dispatch('UserRoleById', this.ruleForm).then((res) => {
|
131
|
|
- this.menuData = res.data.list
|
132
|
|
- console.log(this.menuData)
|
133
|
|
- }).catch(() => {
|
134
|
|
- console.log('error UserRoleById')
|
135
|
|
- })
|
136
|
|
-}
|
137
|
|
- }
|
|
128
|
+ getById() {
|
|
129
|
+ this.$store.dispatch('UserRoleById', this.ruleForm).then((res) => {
|
|
130
|
+ this.menuData = res.data.list
|
|
131
|
+ console.log(this.menuData)
|
|
132
|
+ }).catch(() => {
|
|
133
|
+ console.log('error UserRoleById')
|
|
134
|
+ })
|
|
135
|
+ }
|
138
|
136
|
}
|
|
137
|
+}
|
139
|
138
|
</script>
|
140
|
139
|
|
141
|
140
|
<style scoped>
|