小区,房屋导入
parent
25f79e9d61
commit
80481f1dcb
|
|
@ -18,6 +18,11 @@ export interface Community {
|
||||||
committeeNum?: number
|
committeeNum?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface CommunitySimpleVO {
|
||||||
|
id: number
|
||||||
|
communityName: string
|
||||||
|
}
|
||||||
|
|
||||||
export const CommunityApi = {
|
export const CommunityApi = {
|
||||||
getCommunityPage: async (params: any) => {
|
getCommunityPage: async (params: any) => {
|
||||||
return await request.get({ url: `/community/community/page`, params })
|
return await request.get({ url: `/community/community/page`, params })
|
||||||
|
|
@ -49,5 +54,9 @@ export const CommunityApi = {
|
||||||
|
|
||||||
importCommunityTemplate: async () => {
|
importCommunityTemplate: async () => {
|
||||||
return await request.download({ url: `/community/community/get-import-template` })
|
return await request.download({ url: `/community/community/get-import-template` })
|
||||||
|
},
|
||||||
|
|
||||||
|
getCommunitySimpleList: async () => {
|
||||||
|
return await request.get({ url: `/community/community/simple-list` })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,11 +25,11 @@ export const useMessage = () => {
|
||||||
},
|
},
|
||||||
// 错误提示
|
// 错误提示
|
||||||
alertError(content: string) {
|
alertError(content: string) {
|
||||||
ElMessageBox.alert(content, t('common.confirmTitle'), { type: 'error' })
|
ElMessageBox.alert(content, t('common.confirmTitle'), { type: 'error', dangerouslyUseHTMLString: true })
|
||||||
},
|
},
|
||||||
// 成功提示
|
// 成功提示
|
||||||
alertSuccess(content: string) {
|
alertSuccess(content: string) {
|
||||||
ElMessageBox.alert(content, t('common.confirmTitle'), { type: 'success' })
|
ElMessageBox.alert(content, t('common.confirmTitle'), { type: 'success', dangerouslyUseHTMLString: true })
|
||||||
},
|
},
|
||||||
// 警告提示
|
// 警告提示
|
||||||
alertWarning(content: string) {
|
alertWarning(content: string) {
|
||||||
|
|
|
||||||
|
|
@ -91,29 +91,37 @@ const submitFormSuccess = (response: any) => {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const data = response.data
|
const data = response.data
|
||||||
const createCount = data.createCommunityNames?.length || 0
|
const createCount = data.createCount || 0
|
||||||
const updateCount = data.updateCommunityNames?.length || 0
|
const updateCount = data.updateCount || 0
|
||||||
const failureCount = Object.keys(data.failureCommunities || {}).length
|
const failureCount = data.failureMessages?.length || 0
|
||||||
|
|
||||||
let text = `创建成功:${createCount} 条;`
|
// 构建提示信息(使用 HTML 的 <br> 标签实现换行)
|
||||||
if (createCount > 0) {
|
const messages: string[] = []
|
||||||
text += '\n创建的小区:' + data.createCommunityNames.join('、')
|
messages.push(`创建成功:${createCount} 条<br/>`)
|
||||||
}
|
messages.push(`更新成功:${updateCount} 条<br/>`)
|
||||||
|
|
||||||
text += `\n更新成功:${updateCount} 条;`
|
|
||||||
if (updateCount > 0) {
|
|
||||||
text += '\n更新的小区:' + data.updateCommunityNames.join('、')
|
|
||||||
}
|
|
||||||
|
|
||||||
text += `\n导入失败:${failureCount} 条;`
|
|
||||||
if (failureCount > 0) {
|
if (failureCount > 0) {
|
||||||
text += '\n失败详情:'
|
messages.push(`导入失败:${failureCount} 条<br/><br/>`)
|
||||||
for (const [name, reason] of Object.entries(data.failureCommunities)) {
|
|
||||||
text += `\n - ${name}: ${reason}`
|
// 展示失败详情,每条记录单独换行
|
||||||
|
if (data.failureMessages) {
|
||||||
|
messages.push(`<div style="text-align: left; margin-top: 10px;">`)
|
||||||
|
messages.push(`<strong>失败详情:</strong><br/>`)
|
||||||
|
data.failureMessages.forEach((msg: string) => {
|
||||||
|
messages.push(`${msg}<br/>`)
|
||||||
|
})
|
||||||
|
messages.push(`</div>`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
message.alert(text)
|
const htmlContent = messages.join('')
|
||||||
|
|
||||||
|
if (failureCount > 0) {
|
||||||
|
message.alertError(htmlContent)
|
||||||
|
} else {
|
||||||
|
message.alertSuccess('导入成功!<br/>' + htmlContent)
|
||||||
|
}
|
||||||
|
|
||||||
formLoading.value = false
|
formLoading.value = false
|
||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
emits('success')
|
emits('success')
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,22 @@
|
||||||
label-width="100px"
|
label-width="100px"
|
||||||
v-loading="formLoading"
|
v-loading="formLoading"
|
||||||
>
|
>
|
||||||
<el-form-item label="小区ID" prop="communityId">
|
<el-form-item label="小区名称" prop="communityId">
|
||||||
<el-input v-model="formData.communityId" placeholder="请输入小区ID" />
|
<el-select
|
||||||
</el-form-item>
|
v-model="formData.communityId"
|
||||||
<el-form-item label="小区名称" prop="communityName">
|
placeholder="请选择小区"
|
||||||
<el-input v-model="formData.communityName" placeholder="请输入小区名称" />
|
clearable
|
||||||
|
filterable
|
||||||
|
style="width: 100%"
|
||||||
|
@change="handleCommunityChange"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="item in communityOptions"
|
||||||
|
:key="item.id"
|
||||||
|
:label="item.communityName"
|
||||||
|
:value="item.id"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="楼号" prop="buildingNo">
|
<el-form-item label="楼号" prop="buildingNo">
|
||||||
<el-input v-model="formData.buildingNo" placeholder="请输入楼号" />
|
<el-input v-model="formData.buildingNo" placeholder="请输入楼号" />
|
||||||
|
|
@ -43,6 +54,7 @@
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { HouseApi, House } from '@/api/community/house'
|
import { HouseApi, House } from '@/api/community/house'
|
||||||
|
import { CommunityApi, CommunitySimpleVO } from '@/api/community/community'
|
||||||
|
|
||||||
/** 房屋信息主 表单 */
|
/** 房屋信息主 表单 */
|
||||||
defineOptions({ name: 'HouseForm' })
|
defineOptions({ name: 'HouseForm' })
|
||||||
|
|
@ -67,13 +79,34 @@ const formData = ref({
|
||||||
ownerPhone: undefined
|
ownerPhone: undefined
|
||||||
})
|
})
|
||||||
const formRules = reactive({
|
const formRules = reactive({
|
||||||
communityId: [{ required: true, message: '小区ID不能为空', trigger: 'blur' }],
|
communityId: [{ required: true, message: '小区不能为空', trigger: 'change' }],
|
||||||
communityName: [{ required: true, message: '小区名称不能为空', trigger: 'blur' }],
|
|
||||||
buildingNo: [{ required: true, message: '楼号不能为空', trigger: 'blur' }],
|
buildingNo: [{ required: true, message: '楼号不能为空', trigger: 'blur' }],
|
||||||
unitNo: [{ required: true, message: '单元号不能为空', trigger: 'blur' }],
|
unitNo: [{ required: true, message: '单元号不能为空', trigger: 'blur' }],
|
||||||
roomNo: [{ required: true, message: '门牌号不能为空', trigger: 'blur' }]
|
roomNo: [{ required: true, message: '门牌号不能为空', trigger: 'blur' }]
|
||||||
})
|
})
|
||||||
const formRef = ref() // 表单 Ref
|
const formRef = ref() // 表单 Ref
|
||||||
|
const communityOptions = ref<CommunitySimpleVO[]>([]) // 小区选项列表
|
||||||
|
|
||||||
|
/** 加载小区列表 */
|
||||||
|
const loadCommunityList = async () => {
|
||||||
|
try {
|
||||||
|
communityOptions.value = await CommunityApi.getCommunitySimpleList()
|
||||||
|
} catch (error) {
|
||||||
|
console.error('加载小区列表失败:', error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 小区选择变化 */
|
||||||
|
const handleCommunityChange = (communityId: number | undefined) => {
|
||||||
|
if (communityId) {
|
||||||
|
const community = communityOptions.value.find(item => item.id === communityId)
|
||||||
|
if (community) {
|
||||||
|
formData.value.communityName = community.communityName
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
formData.value.communityName = undefined
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** 打开弹窗 */
|
/** 打开弹窗 */
|
||||||
const open = async (type: string, id?: number) => {
|
const open = async (type: string, id?: number) => {
|
||||||
|
|
@ -81,6 +114,8 @@ const open = async (type: string, id?: number) => {
|
||||||
dialogTitle.value = t('action.' + type)
|
dialogTitle.value = t('action.' + type)
|
||||||
formType.value = type
|
formType.value = type
|
||||||
resetForm()
|
resetForm()
|
||||||
|
// 加载小区列表
|
||||||
|
await loadCommunityList()
|
||||||
// 修改时,设置数据
|
// 修改时,设置数据
|
||||||
if (id) {
|
if (id) {
|
||||||
formLoading.value = true
|
formLoading.value = true
|
||||||
|
|
|
||||||
|
|
@ -91,13 +91,37 @@ const submitFormSuccess = (response: any) => {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const data = response.data
|
const data = response.data
|
||||||
let text = '上传成功数量:' + (data.createCount || 0) + ';'
|
const createCount = data.createCount || 0
|
||||||
text += '更新成功数量:' + (data.updateCount || 0) + ';'
|
const updateCount = data.updateCount || 0
|
||||||
text += '更新失败数量:' + (data.failureCount || 0) + ';'
|
const failureCount = data.failureMessages?.length || 0
|
||||||
if (data.failureMessages && data.failureMessages.length > 0) {
|
|
||||||
text += '失败信息:' + data.failureMessages.join('; ')
|
// 构建提示信息(使用 HTML 的 <br> 标签实现换行)
|
||||||
|
const messages: string[] = []
|
||||||
|
messages.push(`创建成功:${createCount} 条<br/>`)
|
||||||
|
messages.push(`更新成功:${updateCount} 条<br/>`)
|
||||||
|
|
||||||
|
if (failureCount > 0) {
|
||||||
|
messages.push(`导入失败:${failureCount} 条<br/><br/>`)
|
||||||
|
|
||||||
|
// 展示失败详情,每条记录单独换行
|
||||||
|
if (data.failureMessages) {
|
||||||
|
messages.push(`<div style="text-align: left; margin-top: 10px;">`)
|
||||||
|
messages.push(`<strong>失败详情:</strong><br/>`)
|
||||||
|
data.failureMessages.forEach((msg: string) => {
|
||||||
|
messages.push(`${msg}<br/>`)
|
||||||
|
})
|
||||||
|
messages.push(`</div>`)
|
||||||
}
|
}
|
||||||
message.alert(text)
|
}
|
||||||
|
|
||||||
|
const htmlContent = messages.join('')
|
||||||
|
|
||||||
|
if (failureCount > 0) {
|
||||||
|
message.alertError(htmlContent)
|
||||||
|
} else {
|
||||||
|
message.alertSuccess('导入成功!<br/>' + htmlContent)
|
||||||
|
}
|
||||||
|
|
||||||
formLoading.value = false
|
formLoading.value = false
|
||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
emits('success')
|
emits('success')
|
||||||
|
|
|
||||||
|
|
@ -8,14 +8,21 @@
|
||||||
:inline="true"
|
:inline="true"
|
||||||
label-width="80px"
|
label-width="80px"
|
||||||
>
|
>
|
||||||
<el-form-item label="小区名称" prop="communityName">
|
<el-form-item label="小区名称" prop="communityId">
|
||||||
<el-input
|
<el-select
|
||||||
v-model="queryParams.communityName"
|
v-model="queryParams.communityId"
|
||||||
placeholder="请输入小区名称"
|
placeholder="请选择小区"
|
||||||
clearable
|
clearable
|
||||||
@keyup.enter="handleQuery"
|
filterable
|
||||||
class="!w-240px"
|
class="!w-240px"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="item in communityOptions"
|
||||||
|
:key="item.id"
|
||||||
|
:label="item.communityName"
|
||||||
|
:value="item.id"
|
||||||
/>
|
/>
|
||||||
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="业主姓名" prop="ownerName">
|
<el-form-item label="业主姓名" prop="ownerName">
|
||||||
<el-input
|
<el-input
|
||||||
|
|
@ -144,6 +151,7 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import download from '@/utils/download'
|
import download from '@/utils/download'
|
||||||
import { HouseApi, House } from '@/api/community/house'
|
import { HouseApi, House } from '@/api/community/house'
|
||||||
|
import { CommunityApi, CommunitySimpleVO } from '@/api/community/community'
|
||||||
import HouseForm from './HouseForm.vue'
|
import HouseForm from './HouseForm.vue'
|
||||||
import ImportForm from './ImportForm.vue'
|
import ImportForm from './ImportForm.vue'
|
||||||
|
|
||||||
|
|
@ -159,11 +167,12 @@ const total = ref(0) // 列表的总页数
|
||||||
const queryParams = reactive({
|
const queryParams = reactive({
|
||||||
pageNo: 1,
|
pageNo: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
communityName: undefined,
|
communityId: undefined,
|
||||||
ownerName: undefined
|
ownerName: undefined
|
||||||
})
|
})
|
||||||
const queryFormRef = ref() // 搜索的表单
|
const queryFormRef = ref() // 搜索的表单
|
||||||
const exportLoading = ref(false) // 导出的加载中
|
const exportLoading = ref(false) // 导出的加载中
|
||||||
|
const communityOptions = ref<CommunitySimpleVO[]>([]) // 小区选项列表
|
||||||
|
|
||||||
/** 格式化手机号(脱敏显示) */
|
/** 格式化手机号(脱敏显示) */
|
||||||
const formatPhone = (phone: string) => {
|
const formatPhone = (phone: string) => {
|
||||||
|
|
@ -174,6 +183,15 @@ const formatPhone = (phone: string) => {
|
||||||
return phone
|
return phone
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 加载小区列表 */
|
||||||
|
const loadCommunityList = async () => {
|
||||||
|
try {
|
||||||
|
communityOptions.value = await CommunityApi.getCommunitySimpleList()
|
||||||
|
} catch (error) {
|
||||||
|
console.error('加载小区列表失败:', error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** 查询列表 */
|
/** 查询列表 */
|
||||||
const getList = async () => {
|
const getList = async () => {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
|
|
@ -257,6 +275,7 @@ const handleExport = async () => {
|
||||||
|
|
||||||
/** 初始化 **/
|
/** 初始化 **/
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
loadCommunityList()
|
||||||
getList()
|
getList()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue