Commit 3e574839 by cwq0219

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

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