Commit aea095d8 by cwq0219

优化

1 parent b334f618
......@@ -35,28 +35,22 @@
</template>
<script>
import { roleCreateStructure } from '@/common/commonConst'
// import { roleCreateStructure } from '@/common/commonConst'
import { saveRoleList, updateRole } from '@/api/api'
export default {
name: 'RoleCreate',
props: {
createOrEditTitle: String,
createVisible: Boolean,
roleParam: Object
createRuleForm: Object
},
watch: {
createVisible(val) {
!val && this.$refs['createRuleForm'].resetFields()
},
roleParam(val) {
if (val !== this.createRuleForm) {
this.createRuleForm = this.$deep_clone(val)
}
}
},
data() {
return {
createRuleForm: roleCreateStructure,
show_checkbox: true,
defaultExpandAll: true,
createRules: {
......@@ -85,10 +79,10 @@ export default {
// 接口
addRole(flagEOrC, editData) {
// editData = { roleName: editData.roleName }
// const aa = JSON.stringify(editData)
const aa = JSON.stringify(editData)
// console.log(aa)
// console.log(editData)
saveRoleList.req(editData).then((data) => {
saveRoleList.req(aa).then((data) => {
console.log(data)
this.$emit('createClose', flagEOrC, editData)
}).catch(err => {
......
......@@ -10,13 +10,13 @@
</template>
<script>
import { selectUserRoleByRoleId, getWithRoles } from '@/api/api'
import { selectUserRoleByRoleId } from '@/api/api'
export default {
name: 'UserDetail',
props: {
userDetailTitle: String,
userDetailVisible: Boolean,
apiParam: [Number, Function],
apiParam: [Object, Function],
flagRoleOrUser: [Boolean, Function],
columnParam: Array,
consoleParam: [Array, Object]
......@@ -28,11 +28,8 @@ export default {
consoleParam(val) {
this.tableParam.console = val
},
flagRoleOrUser(val) {
this.flag = val
},
apiParam(val) {
this.id = val
this.id = val.id
this.id !== Number && this.callApi()
}
},
......@@ -42,7 +39,6 @@ export default {
pageSize: 5,
total: 10,
id: Number,
flag: Number,
tableParam: {
border: true,
align: 'center',
......@@ -60,13 +56,13 @@ export default {
roleId: this.id
}
},
getUserParams() {
return {
pageSize: this.pageSize,
pageNum: this.pageNum,
userId: this.id
}
},
// getUserParams() {
// return {
// pageSize: this.pageSize,
// pageNum: this.pageNum,
// userId: this.id
// }
// },
// 获取角色的相关用户详细信息
selectUser() {
const params = this.getRoleParams()
......@@ -78,21 +74,19 @@ export default {
})
},
// 获取用户详情,包括角色
getUserRoles() {
const params = this.getUserParams()
getWithRoles.req(params).then(res => {
this.total = 1
this.tableParam.data = [res]
}).catch(err => {
console.log(err)
})
},
objectToArray() {
},
// getUserRoles() {
// const params = this.getUserParams()
// getWithRoles.req(params).then(res => {
// this.total = 1
// this.tableParam.data = [res]
// }).catch(err => {
// console.log(err)
// })
// },
callApi() {
this.flag && this.selectUser()
!this.flag && this.getUserRoles()
this.flagRoleOrUser && this.selectUser()
// !this.flagRoleOrUser && this.getUserRoles()
!this.flagRoleOrUser && (this.tableParam.data = [this.apiParam])
},
handleClose() {
this.$emit('userDetailClose')
......
......@@ -7,8 +7,8 @@
</div>
<hr>
<div class="default p-t15">
<gl-button class="control-tabledata-button" size="small" @click="handleCreateOrEdit(roleParam, '新增角色')">创建</gl-button>
<role-create :createVisible="createVisible" :roleParam="roleParam" :createOrEditTitle="createOrEditTitle" @createClose="handleCreateClose"></role-create>
<gl-button class="control-tabledata-button" size="small" @click="handleCreateOrEdit('新增角色')">创建</gl-button>
<role-create :createVisible="createVisible" :createRuleForm="roleParam" :createOrEditTitle="createOrEditTitle" @createClose="handleCreateClose"></role-create>
<div class="m-b8">
<transition>
<gl-table :table="roleData"></gl-table>
......@@ -83,7 +83,8 @@ export default {
label: '编辑',
type: 'text',
callback: (index, rows) => {
this.handleCreateOrEdit(rows[index], '角色列表')
this.roleParam = this.$deep_clone(rows[index])
this.handleCreateOrEdit('角色列表')
}
}, {
label: '详细',
......@@ -214,17 +215,17 @@ export default {
this.columnParam = userRoleDetailColumn
this.consoleParam = userRoleDetailConsole
this.flagRoleOrUser = true
this.apiParam = rows[index].id
this.apiParam = rows[index]
this.userDetailDialogVisible()
},
handleUserDetailClose() {
this.userDetailDialogVisible()
this.apiParam = Number
},
handleCreateOrEdit(params, title) {
handleCreateOrEdit(title) {
this.createDialogVisible()
this.createOrEditTitle = title
this.roleParam = params
this.roleParam !== roleCreateStructure ? this.roleParam : roleCreateStructure
},
// 关闭新增用户组件
handleCreateClose(flagEOrC, data) {
......
......@@ -259,7 +259,7 @@ export default {
this.columnParam = userDetailColumn
this.consoleParam = []
this.flagRoleOrUser = false
this.apiParam = rows[index].id
this.apiParam = rows[index]
this.userDetailDialogVisible()
},
handleUserDetailClose() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!