This commit is contained in:
张成
2026-04-13 14:10:40 +08:00
parent 45f6f330c6
commit a6db441c4f

View File

@@ -2,7 +2,7 @@
<div class="content-view"> <div class="content-view">
<Alert type="warning" show-icon style="margin-bottom: 12px"> <Alert type="warning" show-icon style="margin-bottom: 12px">
<strong>平台租户</strong>is_platform=1可维护租户列表普通租户登录后本页仅能看到自身租户信息 <strong>平台租户</strong>is_platform=1可维护租户列表普通租户登录后本页仅能看到自身租户信息
需在数据库执行迁移脚本创建 <code>sys_tenant</code> 表及默认数据 新增租户时<strong>租户编码由服务端自动生成</strong>列表中可查看需在数据库执行迁移脚本创建 <code>sys_tenant</code> 表及默认数据
</Alert> </Alert>
<div class="table-head-tool"> <div class="table-head-tool">
<Button type="primary" @click="showAddWarp">新增租户</Button> <Button type="primary" @click="showAddWarp">新增租户</Button>
@@ -27,7 +27,7 @@ export default {
columns: [ columns: [
{ title: 'id', key: 'id' }, { title: 'id', key: 'id' },
{ title: '名称', key: 'name' }, { title: '名称', key: 'name' },
{ title: '编码', key: 'code' }, { title: '编码', key: 'code', name: 'code', display: true },
{ title: '备注', key: 'remark' }, { title: '备注', key: 'remark' },
{ {
title: '状态', title: '状态',
@@ -44,6 +44,7 @@ export default {
{ {
title: '平台租户', title: '平台租户',
key: 'is_platform', key: 'is_platform',
com: 'Switch',
render(h, p) { render(h, p) {
return h('span', Number(p.row.is_platform) === 1 ? '是' : '否') return h('span', Number(p.row.is_platform) === 1 ? '是' : '否')
} }
@@ -78,6 +79,11 @@ export default {
this.init() this.init()
}, },
methods: { methods: {
normalizeTenantRow(row) {
const r = { ...row }
r.is_platform = r.is_platform === true || r.is_platform === 1 || r.is_platform === '1' ? 1 : 0
return r
},
async init() { async init() {
const res = await sysTenantServer.list() const res = await sysTenantServer.list()
if (res && res.code === 0) { if (res && res.code === 0) {
@@ -86,9 +92,9 @@ export default {
}, },
showAddWarp() { showAddWarp() {
this.$refs.editModal.addShow( this.$refs.editModal.addShow(
{ status: 1 }, { status: 1, is_platform: 0 },
async (row) => { async (row) => {
await sysTenantServer.add(row) await sysTenantServer.add(this.normalizeTenantRow(row))
this.$Message.success('新增成功') this.$Message.success('新增成功')
this.init() this.init()
} }
@@ -96,7 +102,7 @@ export default {
}, },
showEditWarp(row) { showEditWarp(row) {
this.$refs.editModal.editShow(row, async (newRow) => { this.$refs.editModal.editShow(row, async (newRow) => {
await sysTenantServer.edit(newRow) await sysTenantServer.edit(this.normalizeTenantRow(newRow))
this.$Message.success('修改成功') this.$Message.success('修改成功')
this.init() this.init()
}) })