Commit f6a3fe54 by cwq0219

用户详情组件复用

1 parent c6e49daa
import { roleCreateStructure, userRoleDetailColumn, userRoleDetailConsole } from './roleCommon'
import { userDetailColumn } from './userCommon'
export {
roleCreateStructure,
userRoleDetailColumn,
userRoleDetailConsole,
userDetailColumn
}
......@@ -29,7 +29,8 @@ const userRoleDetailConsole = {
label: '删除',
type: 'text',
callback: (index, rows) => {
this.$alert(rows[index])
rows.splice(index, 1)
// this.$alert(rows[index])
}
}]
}
......
const userDetailColumn = [{
label: '用户名',
prop: 'username'
}, {
label: '真实姓名',
prop: 'realname'
}, {
label: '管理员',
prop: 'isadmin'
}, {
label: '手机号码',
prop: 'mobile'
}, {
label: '邮箱',
prop: 'email'
}, {
label: '角色选项',
prop: 'roles'
}, {
label: '状态',
prop: 'state'
}]
export { userDetailColumn }
<!-- -->
<template>
<div>
<gl-dialog :title="userDetailTitle" :visible.sync="userDetailVisible" :before-close="handleClose">
<gl-table :table="tableParam"></gl-table>
</gl-dialog>
<gl-dialog :title="userDetailTitle" :visible.sync="userDetailVisible" :before-close="handleClose">
<gl-table :table="tableParam"></gl-table>
</gl-dialog>
</div>
</template>
......@@ -13,27 +13,37 @@ export default {
props: {
userDetailTitle: String,
userDetailVisible: Boolean,
// dataParam: Object,
// dataParam: Array,
columnParam: Array,
consoleParam: [Array, Object]
},
watch: {
columnParam(val) {
this.tableParam.column = this.$deep_clone(val)
this.tableParam.column = val
},
consoleParam(val) {
this.tableParam.console = this.$deep_clone(val)
this.tableParam.console = val
}
},
data() {
return {
tableParam: {
border: true,
// role-data
// data: [{
// id: '1006',
// username: 'text11',
// realname: '陈婉清',
// state: '启动'
// }],
data: [{
id: '1006',
username: 'text11',
username: 'abc',
realname: '陈婉清',
state: '启动'
isadmin: '否',
mobile: '13033333333',
email: 'abc@didihu.com',
roles: '好车主',
state: '开启'
}],
column: [],
console: []
......
......@@ -9,10 +9,10 @@
<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>
<role-detail :detailVisible="detailVisible" :roleParam="roleParam" @detailClose="handleDetailClose"></role-detail>
<user-detail :userDetailVisible="userDetailVisible" :userDetailTitle="userDetailTitle" @userDetailClose="handleUserDetailClose" :dataParam="[]" :columnParam="columnParam" :consoleParam="consoleParam"></user-detail>
<div class="m-b8">
<gl-table :table="roleData" :pagination="pagination"></gl-table>
<role-detail :detailVisible="detailVisible" :roleParam="roleParam" @detailClose="handleDetailClose"></role-detail>
<user-detail :userDetailVisible="userDetailVisible" :userDetailTitle="userDetailTitle" @userDetailClose="handleUserDetailClose" :dataParam="[]" :columnParam="columnParam" :consoleParam="consoleParam"></user-detail>
</div>
</div>
</div>
......@@ -21,7 +21,7 @@
<script>
import { RoleCreate, RoleDetail, UserDetail } from '@/components/index'
import { roleTest } from '@/api/roleApi'
import { roleCreateStructure, userRoleDetailColumn, userRoleDetailConsole } from '@/common/roleCommon'
import { roleCreateStructure, userRoleDetailColumn, userRoleDetailConsole } from '@/common/common'
export default {
name: 'role',
components: {
......@@ -139,7 +139,7 @@ export default {
createDialogVisible() {
this.createVisible = !this.createVisible
},
detaleDialogVisible() {
deleteDialogVisible() {
this.detailVisible = !this.detailVisible
},
userDetailDialogVisible() {
......@@ -150,21 +150,19 @@ export default {
},
handleGetRoleDetail(params) {
this.roleParam = params
this.detaleDialogVisible()
this.deleteDialogVisible()
},
handleDetailClose() {
this.detaleDialogVisible()
this.deleteDialogVisible()
this.roleParam = roleCreateStructure
},
handleGetUserDetail() {
this.columnParam = this.$deep_clone(userRoleDetailColumn)
this.consoleParam = this.$deep_clone(userRoleDetailConsole)
this.columnParam = userRoleDetailColumn
this.consoleParam = userRoleDetailConsole
this.userDetailDialogVisible()
},
handleUserDetailClose() {
this.userDetailDialogVisible()
this.columnParam = []
this.consoleParam = []
},
handleCreateOrEdit(params, title) {
this.createDialogVisible()
......
......@@ -14,23 +14,30 @@
</div>
<div class="m-b8">
<gl-table :table="userData" ref="multipleTable" :pagination="pagination"></gl-table>
<user-detail :userDetailVisible="userDetailVisible" :userDetailTitle="userDetailTitle" @userDetailClose="handleUserDetailClose" :dataParam="[]" :columnParam="columnParam" :consoleParam="consoleParam"></user-detail>
</div>
</div>
</div>
</template>
<script>
import UserForm from '@/components/UserCreate'
import { UserForm, UserDetail } from '@/components/index'
import { getUserInfo } from '@/api/userApi'
import { userDetailColumn } from '@/common/common'
export default {
name: 'user',
components: {
UserForm
UserForm,
UserDetail
},
data() {
return {
userName: '',
dialogFormVisible: false,
userDetailVisible: false,
userDetailTitle: '用户详情',
columnParam: [],
consoleParam: [],
userData: {
border: true,
align: 'center',
......@@ -90,7 +97,8 @@ export default {
label: '用户',
type: 'text',
callback: (index, rows) => {
this.$alert(rows[index])
this.handleGetUserDetail()
// this.$alert(rows[index])
}
}]
},
......@@ -157,6 +165,17 @@ export default {
},
changeShowNumber(command) {
this.showNumber = command
},
userDetailDialogVisible() {
this.userDetailVisible = !this.userDetailVisible
},
handleGetUserDetail() {
this.columnParam = userDetailColumn
this.consoleParam = []
this.userDetailDialogVisible()
},
handleUserDetailClose() {
this.userDetailDialogVisible()
}
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!