feat(company): 租户详情展示企业信息(CompanyInfo),未填写引导 epcreate 向导,支持编辑
This commit is contained in:
1 parent
e04e1bc91f
commit
b9e72ccf0e
1 file changed
+218
-2
@@ -45,6 +45,15 @@ const editSubmitting = ref(false)
|
|||||||
const columns = ref<ColumnSchema[]>([])
|
const columns = ref<ColumnSchema[]>([])
|
||||||
const editForm = reactive<Record<string, any>>({})
|
const editForm = reactive<Record<string, any>>({})
|
||||||
|
|
||||||
|
// === 企业信息(CompanyInfo,epcreate 提交) ===
|
||||||
|
const companyInfo = ref<Record<string, any> | null>(null)
|
||||||
|
const companyInfoLoading = ref(false)
|
||||||
|
const ciColumns = ref<ColumnSchema[]>([])
|
||||||
|
const ciEditVisible = ref(false)
|
||||||
|
const ciSubmitting = ref(false)
|
||||||
|
const ciEditForm = reactive<Record<string, any>>({})
|
||||||
|
const CI_PK_FIELD = 'CompanyInfoUUID'
|
||||||
|
|
||||||
// 主键字段
|
// 主键字段
|
||||||
const PK_FIELD = 'TenantUUID'
|
const PK_FIELD = 'TenantUUID'
|
||||||
|
|
||||||
@@ -114,6 +123,89 @@ async function loadColumns(): Promise<void> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// === 企业信息(CompanyInfo)逻辑 ===
|
||||||
|
|
||||||
|
/** 企业信息展示值:select 字段按列配置解析 label,其余原值 */
|
||||||
|
function ciValue(field: string): string {
|
||||||
|
const val = companyInfo.value?.[field]
|
||||||
|
if (val === undefined || val === null || val === '') return '-'
|
||||||
|
const col = ciColumns.value.find((c) => c.field === field)
|
||||||
|
const opt = col?.options?.find((o) => String(o.value) === String(val))
|
||||||
|
if (opt) return opt.label
|
||||||
|
return String(val)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 企业信息审核状态:0→待审核,1→已通过,2→已拒绝 */
|
||||||
|
function ciReviewTag(v: unknown): { text: string; type: 'success' | 'danger' | 'warning' | 'info' } {
|
||||||
|
if (v === 0 || v === '0') return { text: '待审核', type: 'warning' }
|
||||||
|
if (v === 1 || v === '1') return { text: '已通过', type: 'success' }
|
||||||
|
if (v === 2 || v === '2') return { text: '已拒绝', type: 'danger' }
|
||||||
|
return { text: String(v ?? '-'), type: 'info' }
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 按当前租户加载企业信息(CompanyInfo 由 epcreate 向导提交,同一租户仅一条) */
|
||||||
|
async function loadCompanyInfo(): Promise<void> {
|
||||||
|
if (!tenantUUID.value) {
|
||||||
|
companyInfo.value = null
|
||||||
|
return
|
||||||
|
}
|
||||||
|
companyInfoLoading.value = true
|
||||||
|
try {
|
||||||
|
const result = await formApi.list('CompanyInfo', { TenantUUID: tenantUUID.value, pageSize: 1 })
|
||||||
|
const list: any[] = Array.isArray(result) ? result : (result as any)?.list || []
|
||||||
|
companyInfo.value = list.find((c) => c.TenantUUID === tenantUUID.value) || list[0] || null
|
||||||
|
} catch {
|
||||||
|
companyInfo.value = null
|
||||||
|
} finally {
|
||||||
|
companyInfoLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadCiColumns(): Promise<void> {
|
||||||
|
try {
|
||||||
|
ciColumns.value = await formApi.getColumns('CompanyInfo')
|
||||||
|
} catch {
|
||||||
|
// 列定义加载失败不阻塞展示
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 企业信息编辑弹窗可见列 */
|
||||||
|
const ciFormColumns = computed(() =>
|
||||||
|
ciColumns.value.filter(
|
||||||
|
(c) =>
|
||||||
|
c.editable !== false &&
|
||||||
|
!c.hideInForm &&
|
||||||
|
c.type !== 'hidden' &&
|
||||||
|
c.type !== 'divider' &&
|
||||||
|
c.type !== 'html' &&
|
||||||
|
c.field !== CI_PK_FIELD,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
function handleCiEdit(): void {
|
||||||
|
if (!companyInfo.value) return
|
||||||
|
Object.keys(ciEditForm).forEach((k) => delete ciEditForm[k])
|
||||||
|
Object.assign(ciEditForm, companyInfo.value)
|
||||||
|
ciEditVisible.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleCiSubmit(): Promise<void> {
|
||||||
|
ciSubmitting.value = true
|
||||||
|
try {
|
||||||
|
await formApi.update('CompanyInfo', ciEditForm[CI_PK_FIELD], ciEditForm)
|
||||||
|
ElMessage.success('保存成功')
|
||||||
|
ciEditVisible.value = false
|
||||||
|
await loadCompanyInfo()
|
||||||
|
} finally {
|
||||||
|
ciSubmitting.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 未填写企业信息 → 跳企业创建向导(epcreate) */
|
||||||
|
function goEpCreate(): void {
|
||||||
|
router.push('/debug/epcreate')
|
||||||
|
}
|
||||||
|
|
||||||
// === 编辑弹窗 ===
|
// === 编辑弹窗 ===
|
||||||
|
|
||||||
function handleEdit(): void {
|
function handleEdit(): void {
|
||||||
@@ -143,7 +235,8 @@ function goCompanyDetail(row: Record<string, any>): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await Promise.all([loadData(), loadColumns()])
|
await Promise.all([loadData(), loadColumns(), loadCiColumns()])
|
||||||
|
await loadCompanyInfo()
|
||||||
})
|
})
|
||||||
|
|
||||||
// 同一 tab 复用(v-show 常驻)时 query 变化:重新加载(防展示旧租户数据 / 缺参报错)
|
// 同一 tab 复用(v-show 常驻)时 query 变化:重新加载(防展示旧租户数据 / 缺参报错)
|
||||||
@@ -151,6 +244,7 @@ onMounted(async () => {
|
|||||||
// 空值场景静默显示空态(loadData 内处理),不再弹警告
|
// 空值场景静默显示空态(loadData 内处理),不再弹警告
|
||||||
watch(tenantUUID, () => {
|
watch(tenantUUID, () => {
|
||||||
void loadData()
|
void loadData()
|
||||||
|
void loadCompanyInfo()
|
||||||
}, { immediate: true })
|
}, { immediate: true })
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -193,6 +287,51 @@ watch(tenantUUID, () => {
|
|||||||
<el-descriptions-item label="审核备注">{{ data?.ReviewRemark || '-' }}</el-descriptions-item>
|
<el-descriptions-item label="审核备注">{{ data?.ReviewRemark || '-' }}</el-descriptions-item>
|
||||||
</InfoGrid>
|
</InfoGrid>
|
||||||
|
|
||||||
|
<!-- 企业信息(epcreate 向导提交的 CompanyInfo) -->
|
||||||
|
<el-card v-loading="companyInfoLoading" shadow="never" class="detail-card">
|
||||||
|
<template #header>
|
||||||
|
<div class="detail-card-header">
|
||||||
|
<el-icon><OfficeBuilding /></el-icon>
|
||||||
|
<span>企业信息</span>
|
||||||
|
<div class="detail-card-actions">
|
||||||
|
<el-button v-if="companyInfo" size="small" type="primary" @click="handleCiEdit">编辑</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<!-- 已填写:展示企业信息 -->
|
||||||
|
<template v-if="companyInfo">
|
||||||
|
<InfoGrid title="企业基本信息" :columns="3">
|
||||||
|
<el-descriptions-item label="企业全称">{{ ciValue('EnterpriseName') }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="企业简称">{{ ciValue('EnterpriseShortName') }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="统一社会信用代码">{{ ciValue('CreditCode') }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="企业类型">{{ ciValue('EnterpriseType') }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="所属行业">{{ ciValue('Industry') }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="企业规模">{{ ciValue('Scale') }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="注册资本">{{ ciValue('RegisteredCapital') }} 万元</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="成立日期">{{ ciValue('EstablishDate') }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="经营状态">{{ ciValue('BusinessStatus') }}</el-descriptions-item>
|
||||||
|
</InfoGrid>
|
||||||
|
<InfoGrid title="联系方式与法人" :columns="3">
|
||||||
|
<el-descriptions-item label="注册地址">{{ ciValue('RegAddress') }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="联系电话">{{ ciValue('Phone') }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="企业邮箱">{{ ciValue('Email') }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="法人姓名">{{ ciValue('LegalPersonName') }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="法人电话">{{ ciValue('LegalPersonPhone') }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="审核状态">
|
||||||
|
<el-tag :type="ciReviewTag(companyInfo.ReviewStatus).type" size="small">
|
||||||
|
{{ ciReviewTag(companyInfo.ReviewStatus).text }}
|
||||||
|
</el-tag>
|
||||||
|
</el-descriptions-item>
|
||||||
|
</InfoGrid>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<!-- 未填写:引导去企业创建向导 -->
|
||||||
|
<el-empty v-else description="尚未填写企业信息" :image-size="70">
|
||||||
|
<el-button type="primary" @click="goEpCreate">去填写企业信息</el-button>
|
||||||
|
</el-empty>
|
||||||
|
</el-card>
|
||||||
|
|
||||||
<!-- 关联公司子表 -->
|
<!-- 关联公司子表 -->
|
||||||
<el-card shadow="never" class="detail-card">
|
<el-card shadow="never" class="detail-card">
|
||||||
<template #header>
|
<template #header>
|
||||||
@@ -293,7 +432,84 @@ watch(tenantUUID, () => {
|
|||||||
<el-button type="primary" :loading="editSubmitting" @click="handleSubmit">保存</el-button>
|
<el-button type="primary" :loading="editSubmitting" @click="handleSubmit">保存</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
|
<!-- 企业信息编辑弹窗 -->
|
||||||
|
<el-dialog v-model="ciEditVisible" title="编辑企业信息" width="700px" destroy-on-close>
|
||||||
|
<el-form :model="ciEditForm" label-width="140px" label-position="right">
|
||||||
|
<el-form-item
|
||||||
|
v-for="col in ciFormColumns"
|
||||||
|
:key="col.field"
|
||||||
|
:label="col.title"
|
||||||
|
:required="col.required"
|
||||||
|
>
|
||||||
|
<el-input
|
||||||
|
v-if="!col.type || col.type === 'text' || col.type === 'string'"
|
||||||
|
v-model="ciEditForm[col.field]"
|
||||||
|
:placeholder="col.placeholder"
|
||||||
|
:maxlength="col.maxLength"
|
||||||
|
:disabled="col.disabled"
|
||||||
|
/>
|
||||||
|
<el-input
|
||||||
|
v-else-if="col.type === 'textarea'"
|
||||||
|
v-model="ciEditForm[col.field]"
|
||||||
|
type="textarea"
|
||||||
|
:rows="col.rows || 3"
|
||||||
|
:disabled="col.disabled"
|
||||||
|
/>
|
||||||
|
<el-input-number
|
||||||
|
v-else-if="col.type === 'number'"
|
||||||
|
v-model="ciEditForm[col.field]"
|
||||||
|
:min="col.min"
|
||||||
|
:max="col.max"
|
||||||
|
:step="col.step"
|
||||||
|
:disabled="col.disabled"
|
||||||
|
/>
|
||||||
|
<el-select
|
||||||
|
v-else-if="col.type === 'select'"
|
||||||
|
v-model="ciEditForm[col.field]"
|
||||||
|
:placeholder="col.placeholder"
|
||||||
|
:disabled="col.disabled"
|
||||||
|
style="width: 100%"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="opt in col.options"
|
||||||
|
:key="String(opt.value)"
|
||||||
|
:label="opt.label"
|
||||||
|
:value="opt.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
<el-date-picker
|
||||||
|
v-else-if="col.type === 'date' || col.type === 'datetime'"
|
||||||
|
v-model="ciEditForm[col.field]"
|
||||||
|
:type="col.type as 'date' | 'datetime'"
|
||||||
|
:placeholder="col.placeholder"
|
||||||
|
style="width: 100%"
|
||||||
|
/>
|
||||||
|
<el-switch
|
||||||
|
v-else-if="col.type === 'switch' || col.type === 'boolean'"
|
||||||
|
v-model="ciEditForm[col.field]"
|
||||||
|
:disabled="col.disabled"
|
||||||
|
/>
|
||||||
|
<el-input
|
||||||
|
v-else
|
||||||
|
:model-value="String(ciEditForm[col.field] ?? '')"
|
||||||
|
readonly
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<el-button @click="ciEditVisible = false">取消</el-button>
|
||||||
|
<el-button type="primary" :loading="ciSubmitting" @click="handleCiSubmit">保存</el-button>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
</DetailPage>
|
</DetailPage>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped lang="scss"></style>
|
<style scoped lang="scss">
|
||||||
|
.detail-card-actions {
|
||||||
|
margin-left: auto;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Reference in new issue
Block a user