From 80481f1dcbd50aa982bb0ca5ba855eb8192eb23f Mon Sep 17 00:00:00 2001 From: zzy Date: Mon, 20 Apr 2026 18:10:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E5=8C=BA=EF=BC=8C=E6=88=BF=E5=B1=8B?= =?UTF-8?q?=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/community/community/index.ts | 9 ++++ src/hooks/web/useMessage.ts | 4 +- .../components/CommunityImportForm.vue | 42 ++++++++------- src/views/community/house/HouseForm.vue | 51 ++++++++++++++++--- src/views/community/house/ImportForm.vue | 36 ++++++++++--- src/views/community/house/index.vue | 33 +++++++++--- 6 files changed, 135 insertions(+), 40 deletions(-) diff --git a/src/api/community/community/index.ts b/src/api/community/community/index.ts index e611542..27facdc 100644 --- a/src/api/community/community/index.ts +++ b/src/api/community/community/index.ts @@ -18,6 +18,11 @@ export interface Community { committeeNum?: number } +export interface CommunitySimpleVO { + id: number + communityName: string +} + export const CommunityApi = { getCommunityPage: async (params: any) => { return await request.get({ url: `/community/community/page`, params }) @@ -49,5 +54,9 @@ export const CommunityApi = { importCommunityTemplate: async () => { return await request.download({ url: `/community/community/get-import-template` }) + }, + + getCommunitySimpleList: async () => { + return await request.get({ url: `/community/community/simple-list` }) } } diff --git a/src/hooks/web/useMessage.ts b/src/hooks/web/useMessage.ts index ac2b552..79a095a 100644 --- a/src/hooks/web/useMessage.ts +++ b/src/hooks/web/useMessage.ts @@ -25,11 +25,11 @@ export const useMessage = () => { }, // 错误提示 alertError(content: string) { - ElMessageBox.alert(content, t('common.confirmTitle'), { type: 'error' }) + ElMessageBox.alert(content, t('common.confirmTitle'), { type: 'error', dangerouslyUseHTMLString: true }) }, // 成功提示 alertSuccess(content: string) { - ElMessageBox.alert(content, t('common.confirmTitle'), { type: 'success' }) + ElMessageBox.alert(content, t('common.confirmTitle'), { type: 'success', dangerouslyUseHTMLString: true }) }, // 警告提示 alertWarning(content: string) { diff --git a/src/views/community/community/components/CommunityImportForm.vue b/src/views/community/community/components/CommunityImportForm.vue index 800022a..1d8da82 100644 --- a/src/views/community/community/components/CommunityImportForm.vue +++ b/src/views/community/community/components/CommunityImportForm.vue @@ -91,29 +91,37 @@ const submitFormSuccess = (response: any) => { return } const data = response.data - const createCount = data.createCommunityNames?.length || 0 - const updateCount = data.updateCommunityNames?.length || 0 - const failureCount = Object.keys(data.failureCommunities || {}).length + const createCount = data.createCount || 0 + const updateCount = data.updateCount || 0 + const failureCount = data.failureMessages?.length || 0 - let text = `创建成功:${createCount} 条;` - if (createCount > 0) { - text += '\n创建的小区:' + data.createCommunityNames.join('、') - } + // 构建提示信息(使用 HTML 的
标签实现换行) + const messages: string[] = [] + messages.push(`创建成功:${createCount} 条
`) + messages.push(`更新成功:${updateCount} 条
`) - text += `\n更新成功:${updateCount} 条;` - if (updateCount > 0) { - text += '\n更新的小区:' + data.updateCommunityNames.join('、') - } - - text += `\n导入失败:${failureCount} 条;` if (failureCount > 0) { - text += '\n失败详情:' - for (const [name, reason] of Object.entries(data.failureCommunities)) { - text += `\n - ${name}: ${reason}` + messages.push(`导入失败:${failureCount} 条

`) + + // 展示失败详情,每条记录单独换行 + if (data.failureMessages) { + messages.push(`
`) + messages.push(`失败详情:
`) + data.failureMessages.forEach((msg: string) => { + messages.push(`${msg}
`) + }) + messages.push(`
`) } } - message.alert(text) + const htmlContent = messages.join('') + + if (failureCount > 0) { + message.alertError(htmlContent) + } else { + message.alertSuccess('导入成功!
' + htmlContent) + } + formLoading.value = false dialogVisible.value = false emits('success') diff --git a/src/views/community/house/HouseForm.vue b/src/views/community/house/HouseForm.vue index 8aec8e6..b5d987f 100644 --- a/src/views/community/house/HouseForm.vue +++ b/src/views/community/house/HouseForm.vue @@ -7,11 +7,22 @@ label-width="100px" v-loading="formLoading" > - - - - - + + + + @@ -43,6 +54,7 @@ \ No newline at end of file + diff --git a/src/views/community/house/ImportForm.vue b/src/views/community/house/ImportForm.vue index 2d47a63..8538caa 100644 --- a/src/views/community/house/ImportForm.vue +++ b/src/views/community/house/ImportForm.vue @@ -91,13 +91,37 @@ const submitFormSuccess = (response: any) => { return } const data = response.data - let text = '上传成功数量:' + (data.createCount || 0) + ';' - text += '更新成功数量:' + (data.updateCount || 0) + ';' - text += '更新失败数量:' + (data.failureCount || 0) + ';' - if (data.failureMessages && data.failureMessages.length > 0) { - text += '失败信息:' + data.failureMessages.join('; ') + const createCount = data.createCount || 0 + const updateCount = data.updateCount || 0 + const failureCount = data.failureMessages?.length || 0 + + // 构建提示信息(使用 HTML 的
标签实现换行) + const messages: string[] = [] + messages.push(`创建成功:${createCount} 条
`) + messages.push(`更新成功:${updateCount} 条
`) + + if (failureCount > 0) { + messages.push(`导入失败:${failureCount} 条

`) + + // 展示失败详情,每条记录单独换行 + if (data.failureMessages) { + messages.push(`
`) + messages.push(`失败详情:
`) + data.failureMessages.forEach((msg: string) => { + messages.push(`${msg}
`) + }) + messages.push(`
`) + } } - message.alert(text) + + const htmlContent = messages.join('') + + if (failureCount > 0) { + message.alertError(htmlContent) + } else { + message.alertSuccess('导入成功!
' + htmlContent) + } + formLoading.value = false dialogVisible.value = false emits('success') diff --git a/src/views/community/house/index.vue b/src/views/community/house/index.vue index a6e6be6..2750893 100644 --- a/src/views/community/house/index.vue +++ b/src/views/community/house/index.vue @@ -8,14 +8,21 @@ :inline="true" label-width="80px" > - - + + > + + import download from '@/utils/download' import { HouseApi, House } from '@/api/community/house' +import { CommunityApi, CommunitySimpleVO } from '@/api/community/community' import HouseForm from './HouseForm.vue' import ImportForm from './ImportForm.vue' @@ -159,11 +167,12 @@ const total = ref(0) // 列表的总页数 const queryParams = reactive({ pageNo: 1, pageSize: 10, - communityName: undefined, + communityId: undefined, ownerName: undefined }) const queryFormRef = ref() // 搜索的表单 const exportLoading = ref(false) // 导出的加载中 +const communityOptions = ref([]) // 小区选项列表 /** 格式化手机号(脱敏显示) */ const formatPhone = (phone: string) => { @@ -174,6 +183,15 @@ const formatPhone = (phone: string) => { return phone } +/** 加载小区列表 */ +const loadCommunityList = async () => { + try { + communityOptions.value = await CommunityApi.getCommunitySimpleList() + } catch (error) { + console.error('加载小区列表失败:', error) + } +} + /** 查询列表 */ const getList = async () => { loading.value = true @@ -257,6 +275,7 @@ const handleExport = async () => { /** 初始化 **/ onMounted(() => { + loadCommunityList() getList() })