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 = { ...@@ -29,7 +29,8 @@ const userRoleDetailConsole = {
label: '删除', label: '删除',
type: 'text', type: 'text',
callback: (index, rows) => { 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> <template>
<div> <div>
<gl-dialog :title="userDetailTitle" :visible.sync="userDetailVisible" :before-close="handleClose"> <gl-dialog :title="userDetailTitle" :visible.sync="userDetailVisible" :before-close="handleClose">
<gl-table :table="tableParam"></gl-table> <gl-table :table="tableParam"></gl-table>
</gl-dialog> </gl-dialog>
</div> </div>
</template> </template>
...@@ -13,27 +13,37 @@ export default { ...@@ -13,27 +13,37 @@ export default {
props: { props: {
userDetailTitle: String, userDetailTitle: String,
userDetailVisible: Boolean, userDetailVisible: Boolean,
// dataParam: Object, // dataParam: Array,
columnParam: Array, columnParam: Array,
consoleParam: [Array, Object] consoleParam: [Array, Object]
}, },
watch: { watch: {
columnParam(val) { columnParam(val) {
this.tableParam.column = this.$deep_clone(val) this.tableParam.column = val
}, },
consoleParam(val) { consoleParam(val) {
this.tableParam.console = this.$deep_clone(val) this.tableParam.console = val
} }
}, },
data() { data() {
return { return {
tableParam: { tableParam: {
border: true, border: true,
// role-data
// data: [{
// id: '1006',
// username: 'text11',
// realname: '陈婉清',
// state: '启动'
// }],
data: [{ data: [{
id: '1006', username: 'abc',
username: 'text11',
realname: '陈婉清', realname: '陈婉清',
state: '启动' isadmin: '否',
mobile: '13033333333',
email: 'abc@didihu.com',
roles: '好车主',
state: '开启'
}], }],
column: [], column: [],
console: [] console: []
......
...@@ -9,10 +9,10 @@ ...@@ -9,10 +9,10 @@
<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(roleParam, '新增角色')">创建</gl-button>
<role-create :createVisible="createVisible" :roleParam="roleParam" :createOrEditTitle="createOrEditTitle" @createClose="handleCreateClose"></role-create> <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"> <div class="m-b8">
<gl-table :table="roleData" :pagination="pagination"></gl-table> <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> </div>
</div> </div>
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
<script> <script>
import { RoleCreate, RoleDetail, UserDetail } from '@/components/index' import { RoleCreate, RoleDetail, UserDetail } from '@/components/index'
import { roleTest } from '@/api/roleApi' import { roleTest } from '@/api/roleApi'
import { roleCreateStructure, userRoleDetailColumn, userRoleDetailConsole } from '@/common/roleCommon' import { roleCreateStructure, userRoleDetailColumn, userRoleDetailConsole } from '@/common/common'
export default { export default {
name: 'role', name: 'role',
components: { components: {
...@@ -139,7 +139,7 @@ export default { ...@@ -139,7 +139,7 @@ export default {
createDialogVisible() { createDialogVisible() {
this.createVisible = !this.createVisible this.createVisible = !this.createVisible
}, },
detaleDialogVisible() { deleteDialogVisible() {
this.detailVisible = !this.detailVisible this.detailVisible = !this.detailVisible
}, },
userDetailDialogVisible() { userDetailDialogVisible() {
...@@ -150,21 +150,19 @@ export default { ...@@ -150,21 +150,19 @@ export default {
}, },
handleGetRoleDetail(params) { handleGetRoleDetail(params) {
this.roleParam = params this.roleParam = params
this.detaleDialogVisible() this.deleteDialogVisible()
}, },
handleDetailClose() { handleDetailClose() {
this.detaleDialogVisible() this.deleteDialogVisible()
this.roleParam = roleCreateStructure this.roleParam = roleCreateStructure
}, },
handleGetUserDetail() { handleGetUserDetail() {
this.columnParam = this.$deep_clone(userRoleDetailColumn) this.columnParam = userRoleDetailColumn
this.consoleParam = this.$deep_clone(userRoleDetailConsole) this.consoleParam = userRoleDetailConsole
this.userDetailDialogVisible() this.userDetailDialogVisible()
}, },
handleUserDetailClose() { handleUserDetailClose() {
this.userDetailDialogVisible() this.userDetailDialogVisible()
this.columnParam = []
this.consoleParam = []
}, },
handleCreateOrEdit(params, title) { handleCreateOrEdit(params, title) {
this.createDialogVisible() this.createDialogVisible()
......
...@@ -14,23 +14,30 @@ ...@@ -14,23 +14,30 @@
</div> </div>
<div class="m-b8"> <div class="m-b8">
<gl-table :table="userData" ref="multipleTable" :pagination="pagination"></gl-table> <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> </div>
</div> </div>
</template> </template>
<script> <script>
import UserForm from '@/components/UserCreate' import { UserForm, UserDetail } from '@/components/index'
import { getUserInfo } from '@/api/userApi' import { getUserInfo } from '@/api/userApi'
import { userDetailColumn } from '@/common/common'
export default { export default {
name: 'user', name: 'user',
components: { components: {
UserForm UserForm,
UserDetail
}, },
data() { data() {
return { return {
userName: '', userName: '',
dialogFormVisible: false, dialogFormVisible: false,
userDetailVisible: false,
userDetailTitle: '用户详情',
columnParam: [],
consoleParam: [],
userData: { userData: {
border: true, border: true,
align: 'center', align: 'center',
...@@ -90,7 +97,8 @@ export default { ...@@ -90,7 +97,8 @@ export default {
label: '用户', label: '用户',
type: 'text', type: 'text',
callback: (index, rows) => { callback: (index, rows) => {
this.$alert(rows[index]) this.handleGetUserDetail()
// this.$alert(rows[index])
} }
}] }]
}, },
...@@ -157,6 +165,17 @@ export default { ...@@ -157,6 +165,17 @@ export default {
}, },
changeShowNumber(command) { changeShowNumber(command) {
this.showNumber = 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!