1
This commit is contained in:
@@ -23,6 +23,7 @@
|
|||||||
import { mapGetters, mapState } from 'vuex'
|
import { mapGetters, mapState } from 'vuex'
|
||||||
import userServer from '@/api/system/userServer'
|
import userServer from '@/api/system/userServer'
|
||||||
import roleServer from '@/api/system/roleServer'
|
import roleServer from '@/api/system/roleServer'
|
||||||
|
import sysTenantServer from '@/api/system/sysTenantServer'
|
||||||
import uiTool from '@/utils/uiTool'
|
import uiTool from '@/utils/uiTool'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -33,16 +34,19 @@ export default {
|
|||||||
gridOption: {
|
gridOption: {
|
||||||
editRow: {},
|
editRow: {},
|
||||||
columns: [
|
columns: [
|
||||||
{ title: '登陆名', key: 'name' },
|
{ title: '登陆名', key: 'name', name: 'name' },
|
||||||
{
|
{
|
||||||
title: '租户',
|
title: '租户',
|
||||||
key: 'tenantName',
|
key: 'tenant_id',
|
||||||
display: true,
|
name: 'tenant_id',
|
||||||
|
com: 'Select',
|
||||||
|
required: true,
|
||||||
render(h, params) {
|
render(h, params) {
|
||||||
if (params.row.tenant) {
|
if (params.row.tenant) {
|
||||||
return h('span', params.row.tenant.name || '')
|
const t = params.row.tenant
|
||||||
|
return h('span', `${t.name || ''}(${t.code || ''})`)
|
||||||
}
|
}
|
||||||
return h('span', '')
|
return h('span', params.row.tenant_id != null ? String(params.row.tenant_id) : '')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -55,6 +59,7 @@ export default {
|
|||||||
{
|
{
|
||||||
title: '所属角色',
|
title: '所属角色',
|
||||||
key: 'roleId',
|
key: 'roleId',
|
||||||
|
name: 'roleId',
|
||||||
com: 'Select',
|
com: 'Select',
|
||||||
render: (h, params) => {
|
render: (h, params) => {
|
||||||
if (params.row.role) {
|
if (params.row.role) {
|
||||||
@@ -114,24 +119,41 @@ export default {
|
|||||||
this.gridOption.data = res.data
|
this.gridOption.data = res.data
|
||||||
},
|
},
|
||||||
async initCol() {
|
async initCol() {
|
||||||
let res = await roleServer.list()
|
const res = await roleServer.list()
|
||||||
this.roles = res.data || []
|
this.roles = res.data || []
|
||||||
let roleSource = this.roles.map((p) => {
|
const roleSource = this.roles.map((p) => ({
|
||||||
return {
|
key: p.id,
|
||||||
key: p.id,
|
value: p.name,
|
||||||
value: p.name,
|
}))
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
let roleRow = this.gridOption.columns.find((p) => p.key === 'roleId')
|
const roleRow = this.gridOption.columns.find((p) => p.key === 'roleId')
|
||||||
if (roleRow) {
|
if (roleRow) {
|
||||||
roleRow.source = roleSource
|
roleRow.source = roleSource
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const tenantRes = await sysTenantServer.list()
|
||||||
|
const tenants = tenantRes && tenantRes.code === 0 && Array.isArray(tenantRes.data) ? tenantRes.data : []
|
||||||
|
const tenantSource = tenants.map((t) => ({
|
||||||
|
key: Number(t.id),
|
||||||
|
value: `${t.name || ''}(${t.code || ''})`,
|
||||||
|
}))
|
||||||
|
|
||||||
|
const platform = this.currentTenant && Number(this.currentTenant.is_platform) === 1
|
||||||
|
const tenantCol = this.gridOption.columns.find((p) => p.key === 'tenant_id')
|
||||||
|
if (tenantCol) {
|
||||||
|
tenantCol.source = tenantSource
|
||||||
|
tenantCol.disabled = !platform
|
||||||
|
tenantCol.disabledOnAdd = !platform
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
showAddWarp() {
|
showAddWarp() {
|
||||||
this.$refs.editModal.addShow({}, async (newRow) => {
|
const tid = this.currentTenant && this.currentTenant.id != null ? Number(this.currentTenant.id) : undefined
|
||||||
|
this.$refs.editModal.addShow({ tenant_id: tid }, async (newRow) => {
|
||||||
const payload = { ...newRow }
|
const payload = { ...newRow }
|
||||||
|
if (payload.tenant_id != null) {
|
||||||
|
payload.tenant_id = Number(payload.tenant_id)
|
||||||
|
}
|
||||||
await userServer.add(payload)
|
await userServer.add(payload)
|
||||||
this.$Message.success('新增成功!')
|
this.$Message.success('新增成功!')
|
||||||
this.init()
|
this.init()
|
||||||
@@ -140,6 +162,9 @@ export default {
|
|||||||
showEditWarp(row) {
|
showEditWarp(row) {
|
||||||
this.$refs.editModal.editShow({ ...row }, async (newRow) => {
|
this.$refs.editModal.editShow({ ...row }, async (newRow) => {
|
||||||
const payload = { ...newRow }
|
const payload = { ...newRow }
|
||||||
|
if (payload.tenant_id != null) {
|
||||||
|
payload.tenant_id = Number(payload.tenant_id)
|
||||||
|
}
|
||||||
await userServer.edit(payload)
|
await userServer.edit(payload)
|
||||||
this.$Message.success('修改成功!')
|
this.$Message.success('修改成功!')
|
||||||
this.init()
|
this.init()
|
||||||
|
|||||||
Reference in New Issue
Block a user