Commit aea095d8 by cwq0219

优化

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