1
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
<Alert v-if="currentTenant" type="info" show-icon closable style="margin-bottom: 12px">
|
||||
当前租户:<strong>{{ currentTenant.name }}</strong>({{ currentTenant.code }})。用户按租户隔离;
|
||||
<strong>角色全库共用</strong>,下拉中的角色对所有租户一致。
|
||||
<span v-if="isPlatformTenant">平台租户可为他人指定「目标租户」。</span>
|
||||
</Alert>
|
||||
|
||||
<div class="table-head-tool">
|
||||
@@ -24,7 +23,6 @@
|
||||
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 {
|
||||
@@ -100,13 +98,9 @@ export default {
|
||||
shopList: 'shop/shopList',
|
||||
}),
|
||||
...mapState('user', ['currentTenant']),
|
||||
isPlatformTenant() {
|
||||
return this.currentTenant && Number(this.currentTenant.is_platform) === 1
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
currentTenant() {
|
||||
this.syncTenantSelectColumn()
|
||||
this.initCol()
|
||||
},
|
||||
},
|
||||
@@ -115,19 +109,11 @@ export default {
|
||||
this.initCol()
|
||||
},
|
||||
methods: {
|
||||
syncTenantSelectColumn() {
|
||||
const idx = this.gridOption.columns.findIndex((c) => c.key === 'tenant_id_select')
|
||||
if (idx !== -1) {
|
||||
this.gridOption.columns.splice(idx, 1)
|
||||
}
|
||||
},
|
||||
async init() {
|
||||
let res = await userServer.all()
|
||||
this.gridOption.data = res.data
|
||||
},
|
||||
async initCol() {
|
||||
this.syncTenantSelectColumn()
|
||||
|
||||
let res = await roleServer.list()
|
||||
this.roles = res.data || []
|
||||
let roleSource = this.roles.map((p) => {
|
||||
@@ -141,50 +127,19 @@ export default {
|
||||
if (roleRow) {
|
||||
roleRow.source = roleSource
|
||||
}
|
||||
|
||||
if (this.isPlatformTenant) {
|
||||
try {
|
||||
const tr = await sysTenantServer.list()
|
||||
const tenants = (tr && tr.data) || []
|
||||
const tenantSource = tenants.map((t) => ({
|
||||
key: t.id,
|
||||
value: `${t.name}(${t.code})`,
|
||||
}))
|
||||
this.gridOption.columns.splice(1, 0, {
|
||||
title: '目标租户',
|
||||
key: 'tenant_id_select',
|
||||
com: 'Select',
|
||||
source: tenantSource,
|
||||
})
|
||||
} catch (e) {
|
||||
console.warn('加载租户列表失败', e)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
showAddWarp() {
|
||||
this.$refs.editModal.addShow({}, async (newRow) => {
|
||||
const payload = { ...newRow }
|
||||
if (payload.tenant_id_select != null && payload.tenant_id_select !== '') {
|
||||
payload.tenant_id = Number(payload.tenant_id_select)
|
||||
}
|
||||
delete payload.tenant_id_select
|
||||
await userServer.add(payload)
|
||||
this.$Message.success('新增成功!')
|
||||
this.init()
|
||||
})
|
||||
},
|
||||
showEditWarp(row) {
|
||||
const rowWithSelect = { ...row }
|
||||
if (this.isPlatformTenant) {
|
||||
rowWithSelect.tenant_id_select = row.tenant_id
|
||||
}
|
||||
this.$refs.editModal.editShow(rowWithSelect, async (newRow) => {
|
||||
this.$refs.editModal.editShow({ ...row }, async (newRow) => {
|
||||
const payload = { ...newRow }
|
||||
if (payload.tenant_id_select != null && payload.tenant_id_select !== '') {
|
||||
payload.tenant_id = Number(payload.tenant_id_select)
|
||||
}
|
||||
delete payload.tenant_id_select
|
||||
await userServer.edit(payload)
|
||||
this.$Message.success('修改成功!')
|
||||
this.init()
|
||||
|
||||
Reference in New Issue
Block a user