1
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
import { mapGetters, mapState } from 'vuex'
|
||||
import userServer from '@/api/system/userServer'
|
||||
import roleServer from '@/api/system/roleServer'
|
||||
import sysTenantServer from '@/api/system/sysTenantServer'
|
||||
import uiTool from '@/utils/uiTool'
|
||||
|
||||
export default {
|
||||
@@ -33,16 +34,19 @@ export default {
|
||||
gridOption: {
|
||||
editRow: {},
|
||||
columns: [
|
||||
{ title: '登陆名', key: 'name' },
|
||||
{ title: '登陆名', key: 'name', name: 'name' },
|
||||
{
|
||||
title: '租户',
|
||||
key: 'tenantName',
|
||||
display: true,
|
||||
key: 'tenant_id',
|
||||
name: 'tenant_id',
|
||||
com: 'Select',
|
||||
required: true,
|
||||
render(h, params) {
|
||||
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: '所属角色',
|
||||
key: 'roleId',
|
||||
name: 'roleId',
|
||||
com: 'Select',
|
||||
render: (h, params) => {
|
||||
if (params.row.role) {
|
||||
@@ -114,24 +119,41 @@ export default {
|
||||
this.gridOption.data = res.data
|
||||
},
|
||||
async initCol() {
|
||||
let res = await roleServer.list()
|
||||
const res = await roleServer.list()
|
||||
this.roles = res.data || []
|
||||
let roleSource = this.roles.map((p) => {
|
||||
return {
|
||||
const roleSource = this.roles.map((p) => ({
|
||||
key: p.id,
|
||||
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) {
|
||||
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() {
|
||||
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 }
|
||||
if (payload.tenant_id != null) {
|
||||
payload.tenant_id = Number(payload.tenant_id)
|
||||
}
|
||||
await userServer.add(payload)
|
||||
this.$Message.success('新增成功!')
|
||||
this.init()
|
||||
@@ -140,6 +162,9 @@ export default {
|
||||
showEditWarp(row) {
|
||||
this.$refs.editModal.editShow({ ...row }, async (newRow) => {
|
||||
const payload = { ...newRow }
|
||||
if (payload.tenant_id != null) {
|
||||
payload.tenant_id = Number(payload.tenant_id)
|
||||
}
|
||||
await userServer.edit(payload)
|
||||
this.$Message.success('修改成功!')
|
||||
this.init()
|
||||
|
||||
Reference in New Issue
Block a user