Commit 3e574839 by cwq0219

role-数据深拷贝;userdetail-角色列表

1 parent 5614627c
......@@ -32,24 +32,21 @@
</template>
<script>
// import { roleCreateStructure } from '@/common/commonConst'
export default {
name: 'RoleCreate',
props: {
createVisible: Boolean,
createRuleForm: Object,
flagCOrE: [Boolean, Array, Function]
// roleMenuTree: Array
},
watch: {
createVisible(val) {
!val && this.$refs['createRuleForm'].resetFields()
val && (this.key = Date.now())
// 考虑一下放这里还是放下面
// this.createRuleForm.rights = this.roleMenuTree
},
flagCOrE(val) {
this.title = val ? '新建角色' : '角色列表'
// this.createRuleForm.rights = this.roleMenuTree
},
'createRuleForm.description.length'(val) {
this.numberErr = val > 200 ? 1 : 0
......
......@@ -59,7 +59,7 @@ export default {
// console.log(this.data)
},
getData() {
console.log(this.defaultCheckedKeys)
// console.log(this.defaultCheckedKeys)
!this.isDepart
? findMenuTree.req().then(res => {
// console.log(res)
......
......@@ -43,7 +43,7 @@ export default {
createVisible: false,
detailVisible: false,
userDetailVisible: false,
roleParam: roleCreateStructure,
roleParam: this.$deep_clone(roleCreateStructure),
columnParam: [],
consoleParam: [],
apiParam: Number,
......@@ -223,7 +223,7 @@ export default {
},
handleDetailClose() {
this.deleteDialogVisible()
this.roleParam = roleCreateStructure
this.roleParam = this.$deep_clone(roleCreateStructure)
this.roleMenuTree = []
},
handleGetUserDetail(index, rows) {
......@@ -239,14 +239,14 @@ export default {
this.apiParam = Number
},
handleCreateOrEdit() {
this.roleParam = this.flagCOrE ? roleCreateStructure : this.roleParam
this.roleParam = this.flagCOrE ? this.$deep_clone(roleCreateStructure) : this.roleParam
this.createDialogVisible()
// this.flagCOrE && this.createDialogVisible()
// !this.flagCOrE && this.getMenuTree(this.roleParam.id, this.editOrDetail = true)
},
// 关闭新增用户组件
handleCreateClose(data) {
this.roleParam = roleCreateStructure
this.roleParam = this.$deep_clone(roleCreateStructure)
if (!data) {
this.createDialogVisible()
this.message(this.flagCOrE ? '取消创建角色' : '取消编辑角色', 'info')
......
......@@ -52,7 +52,7 @@ export default {
// 分页所需参数-end
columnParam: [],
consoleParam: [],
apiParam: Number,
apiParam: Object,
flagRoleOrUser: Boolean,
userData: {
select: this.handleSelectionChange,
......@@ -190,6 +190,7 @@ export default {
getRoleOptions() {
getRoleList.req().then(res => {
userForm.roleList = res.list
// return res.list
})
},
// 新增更新用户接口请求
......@@ -228,9 +229,9 @@ export default {
},
// 接受子组件传递的值
handleUserFormData(isEdit, params) {
console.log(isEdit)
this.userManageForm = {}
!params && this.message('取消操作', 'warning')
console.log(this.userManageForm.roles)
params && this.updateUser_Post(params)
this.dialogFormVisible = !this.dialogFormVisible
},
......@@ -252,9 +253,11 @@ export default {
}
})
Promise.all([findAll, getRoleList]).then((result) => {
console.log(row.roles)
if (row.roles && typeof (row.roles) === 'string') {
row.roles = (row.roles + '').split(',').map(role => +role)
} else {
console.log(12312)
row.roles = []
}
this.userManageForm = this.$deep_clone(row)
......@@ -319,12 +322,27 @@ export default {
this.message('取消删除', 'info')
})
},
findRolesName(params) {
// console.log(userForm.roleList)
var nameArray = []
const userRoles = params.split(',')
userRoles.forEach(userItem => {
userForm.roleList.forEach(item => {
if (+userItem === item.id) {
nameArray.push(item.roleName)
}
})
})
return nameArray.join(',')
},
// 详细操作
handleGetUserDetail(index, rows) {
this.columnParam = userDetailColumn
this.consoleParam = []
this.flagRoleOrUser = false
this.apiParam = rows[index]
this.apiParam = this.$deep_clone(rows[index])
console.log(rows[index])
this.apiParam.roles = this.findRolesName(this.apiParam.roles)
console.log(this.apiParam)
this.userDetailVisible = !this.userDetailVisible
},
......@@ -347,9 +365,9 @@ export default {
</script>
<style scoped>
.search-w250 {
width: 250px;
width: 250px;
}
.m-b8 {
margin-bottom: 8px;
margin-bottom: 8px;
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!