From 3f27c350e28437554176331f0671c82d854da681 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=88=90?= Date: Mon, 13 Apr 2026 14:31:40 +0800 Subject: [PATCH] 1 --- src/views/system/sys_user.vue | 53 ++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 14 deletions(-) diff --git a/src/views/system/sys_user.vue b/src/views/system/sys_user.vue index c4d94b8..2f12a1c 100644 --- a/src/views/system/sys_user.vue +++ b/src/views/system/sys_user.vue @@ -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 { - key: p.id, - value: p.name, - } - }) + 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()