购房记录

This commit is contained in:
qiuyuan 2025-12-18 09:51:00 +08:00
parent be2c76d9bc
commit 32693979d5
7 changed files with 471 additions and 38 deletions

View File

@ -13,3 +13,12 @@ export const createHomer = (params) => request.basic.post('/api/v1/customers/up_
export const updateItem = (id, params) => request.basic.put(`/api/v1/customers/${id}`, params)
// 删除数据
export const delItem = (id) => request.basic.delete(`/api/v1/customers/${id}`)
// 获取购房记录
export const getHouseOwners = (params) => request.basic.get('/api/v1/house-owners', params)
// 删除购房记录
export const delHouseOwner = (id) => request.basic.delete(`/api/v1/house-owners/${id}`)
// 上传文件
export const pushFile = (areaId, params) => request.basic.post(`/api/v1/house-owners/push/${areaId}`, params)

View File

@ -11,3 +11,4 @@ export const getcustomers = (params) => request.basic.get('/api/v1/customers', p
// export const updatePassword = (_, params) => request.basic.put(`/api/v1/current/password`, params)
// // 用户权限菜单
// export const getUserMenu = () => request.basic.get('/api/v1/current/menus')

View File

@ -1,7 +1,8 @@
<template>
<div class="clearfix">
<a-upload list-type="picture-card" :multiple="multiple" v-model:file-list="fileList" @preview="handlePreview"
@change="handleChange" :customRequest="handleCustomRequest" :beforeUpload="beforeUpload">
@change="handleChange" :customRequest="handleCustomRequest" :beforeUpload="beforeUpload"
:accept="acceptTypes">
<div v-if="fileList.length < fileNumber">
<plus-outlined />
<div class="ant-upload-text">上传</div>
@ -15,9 +16,8 @@
</template>
<script setup>
import { ref, watch, onMounted } from 'vue';
import { ref, watch, onMounted, computed } from 'vue';
import { PlusOutlined } from '@ant-design/icons-vue';
import { UploadOutlined } from '@ant-design/icons-vue';
import { message } from 'ant-design-vue';
import { config } from '@/config'
import apis from '@/apis'
@ -46,14 +46,25 @@ const props = defineProps({
type: Number,
default: 120,
},
customUploadHandler: {
type: Function,
default: null //
},
});
const emit = defineEmits(['update:modelValue', 'uploadSuccess', 'uploadError']);
const uploadUrl = config('http.apiBasic') + '/api/v1/upload'
const fileList = ref([]);
// Excel
const isExcelFile = (fileName) => {
const excelExtensions = ['.xlsx', '.xls'];
const fileSuffix = fileName.substring(fileName.lastIndexOf('.')).toLowerCase();
return excelExtensions.includes(fileSuffix);
};
//
onMounted(() => {
console.log(' props.modelValue', props.modelValue)
fileList.value = props.modelValue.map(url => ({
uid: `preview-${Date.now()}-${Math.random()}`,
name: url.substring(url.lastIndexOf('/') + 1),
@ -61,25 +72,16 @@ onMounted(() => {
url: url
}));
});
//
const beforeUpload = (file) => {
// const isValidType = props.acceptTypes === '*' ||
// props.acceptTypes.split(',').some(type => file.name.endsWith(type.replace('*', '')));
// const isValidSize = file.size / 1024 / 1024 < props.maxSize;
// if (!isValidType) {
// message.error(` ${props.acceptTypes} `);
// return false;
// }
// if (!isValidSize) {
// message.error(` ${props.maxSize}MB`);
// return false;
// }
return true;
};
const handleCancel = () => {
previewVisible.value = false;
};
const getBase64 = (file) => {
return new Promise((resolve, reject) => {
const reader = new FileReader();
@ -88,23 +90,48 @@ const getBase64 = (file) => {
reader.onerror = error => reject(error);
});
}
const handlePreview = async (file) => {
console.log(file.name)
const list = ['.avi', '.mp4', '.mov', '.wmv', '.mkv', '.m4v']
const fileSuffix = file.name.substring(file.name.lastIndexOf('.'))
if (list.includes(fileSuffix)) {
fileType.value = 'video'
const videoExtensions = ['.avi', '.mp4', '.mov', '.wmv', '.mkv', '.m4v'];
const imageExtensions = ['.png', '.jpg', '.jpeg', '.gif', '.bmp', '.webp'];
const excelExtensions = ['.xlsx', '.xls'];
const fileSuffix = file.name.substring(file.name.lastIndexOf('.')).toLowerCase();
// Excel
if (excelExtensions.includes(fileSuffix)) {
message.info('Excel 文件不支持预览');
return;
}
//
if (videoExtensions.includes(fileSuffix)) {
fileType.value = 'video';
} else if (imageExtensions.includes(fileSuffix)) {
fileType.value = 'img';
} else {
// pdf
fileType.value = 'img';
}
if (!file.url && !file.preview) {
file.preview = await getBase64(file.originFileObj)
file.preview = await getBase64(file.originFileObj);
}
previewImage.value = file.url || file.preview;
previewVisible.value = true;
};
// handleChange
const handleChange = ({ file, fileList: updatedList }) => {
// Excel
if (isExcelFile(file.name) && file.status === 'error') {
//
const filteredList = updatedList.filter(item => item.uid !== file.uid);
fileList.value = filteredList;
//
return;
}
//
if (file.status === 'done') {
const response = file.response;
@ -113,7 +140,10 @@ const handleChange = ({ file, fileList: updatedList }) => {
const targetFile = updatedList.find(f => f.uid === file.uid);
if (targetFile) {
targetFile.url = response.url;
message.success(`${file.name} 上传成功`);
// Excel
if (!isExcelFile(file.name)) {
message.success(`${file.name} 上传成功`);
}
}
//
@ -127,41 +157,64 @@ const handleChange = ({ file, fileList: updatedList }) => {
const urls = updatedList
.filter(item => item.status === 'done')
.map(item => item.url);
emit('update:modelValue', urls);
emit('update:modelValue', urls)
} else if (file.status === 'uploading') {
// Excel
if (!isExcelFile(file.name)) {
message.success(`${file.name} 上传成功`);
}
} else if (file.status === 'error') {
message.error(`${file.name} 上传失败`);
// Excel
if (!isExcelFile(file.name)) {
message.error(`${file.name} 上传失败`);
}
}
};
//
const handleCustomRequest = async (options) => {
const { file, onProgress, onSuccess, onError } = options;
const { file, onSuccess, onError } = options;
try {
const formData = new FormData();
formData.append('file', file);
const { data } = await apis.common.uploadImg(formData);
const fullUrl = config('http.apiBasic') + data;
//
let result;
let fullUrl;
if (props.customUploadHandler) {
// 使
result = await props.customUploadHandler(file);
// URL
fullUrl = typeof result === 'string'
? result.startsWith('http') ? result : config('http.apiBasic') + result
: result.url; // { url: '...' }
} else {
//
const formData = new FormData();
formData.append('file', file);
const { data } = await apis.common.uploadImg(formData);
fullUrl = config('http.apiBasic') + data;
}
onSuccess({
uid: file.uid,
name: file.name,
status: 'done',
url: fullUrl,
response: { url: fullUrl } // responseURL
response: { url: fullUrl }
}, file);
//
emit('uploadSuccess', data);
emit('uploadSuccess', fullUrl); // data
} catch (err) {
onError(err);
message.error('上传失败');
// Excel
if (!isExcelFile(file.name)) {
message.error('上传失败');
}
emit('uploadError', err);
}
};
// v-model
watch(() => props.modelValue, (newVal) => {
// fileList.value=[...newVal]
//
const doneFiles = fileList.value.filter(f => f.status === 'done');
const doneUrls = doneFiles.map(f => f.url);
@ -181,6 +234,7 @@ watch(() => props.modelValue, (newVal) => {
}
}, { deep: true });
</script>
<style>
/* you can make up upload button and sample style by using stylesheets */
.ant-upload-select-picture-card i {

View File

@ -109,4 +109,5 @@ export default {
earnPointModule:'赚海贝模块',
earnPointLog:'赚海贝记录',
earnPointRule:'赚海贝规则',
houseList:'购房记录',
}

View File

@ -70,6 +70,17 @@ export default [
permission: '*',
},
},
{
path: 'houseList',
name: 'houseList',
component: 'userManagement/houseList/index.vue',
meta: {
title: '购房记录',
isMenu: true,
keepAlive: true,
permission: '*',
},
},
],
},
]

View File

@ -0,0 +1,151 @@
<template>
<a-modal :open="modal.open" :title="modal.title" :width="640" :confirm-loading="modal.confirmLoading"
:after-close="onAfterClose" :cancel-text="cancelText" :ok-text="okText" @ok="handleOk" @cancel="handleCancel">
<a-spin :spinning="spining">
<a-form ref="formRef" :model="formData" :rules="formRules">
<a-card class="mb-8-2">
<a-col :span="24">
<a-form-item label="所属区域" name="areaId">
<a-select v-model:value="formData.areaId" allowClear>
<a-select-option :value="1">南通</a-select-option>
<a-select-option :value="2">盐城</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item :label="'导入文件'" name="fileList">
<gx-upload v-model="formData.fileList" accept=".xlsx,.xls"
:customUploadHandler="uploadExcelFile" @uploadSuccess="uploadSuccess" />
</a-form-item>
</a-col>
</a-card>
</a-form>
</a-spin>
</a-modal>
</template>
<script setup>
import { ref, onBeforeMount } from 'vue'
import { config } from '@/config'
import apis from '@/apis'
import { useForm, useModal, useSpining } from '@/hooks'
import { message } from 'ant-design-vue'
import { useI18n } from 'vue-i18n'
import dayjs from 'dayjs'
import GxUpload from '@/components/GxUpload/index.vue'
const emit = defineEmits(['ok'])
const { t } = useI18n() // t
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
const { formData, formRef, formRules, resetForm } = useForm()
const { spining, showSpining, hideSpining } = useSpining()
const cancelText = ref(t('button.cancel'))
const okText = ref(t('button.confirm'))
const fileList = ref([])
onBeforeMount(() => {
formData.value.areaId = ''
})
/**
* 新建
*/
function handleCreate() {
showModal({
type: 'create',
title: '导入文件',
})
// initData()
// formData.value.status = 'enabled'
}
/**
* 编辑
*/
async function handleEdit(record = {}) {
showModal({
type: 'edit',
title: '编辑客户',
})
try {
showSpining()
const { data, success } = await apis.customer.getItem(record.id).catch()
if (!success) {
hideModal()
return
}
hideSpining()
formData.value = { ...data }
formData.value.birthday = dayjs(data.birthday)
if (data.avatar) {
formData.value.fileList = [config('http.apiBasic') + data.avatar]
}
} catch (error) {
message.error({ content: error.message })
hideSpining()
}
}
const uploadSuccess = (data) => {
fileList.value.push(data)
}
/**
* 确定
*/
function handleOk() {
hideModal()
formData.value.areaId = null
fileList.value = []
}
// Excel
const uploadExcelFile = async (file) => {
const areaId = formData.value.areaId
if (!areaId) {
message.error('请先选择所属区域')
throw new Error('缺少 areaId')
}
const formDataUpload = new FormData()
formDataUpload.append('file', file)
//
const res = await apis.customer.pushFile(areaId, formDataUpload)
if (!res.success) {
// message.error('Excel ')
throw new Error(res.message)
}
message.success('Excel 上传成功')
emit('ok')
hideModal()
formData.value.areaId = null
fileList.value = []
return res.data
}
/**
* 取消
*/
function handleCancel() {
formData.value.areaId = null
hideModal()
}
/**
* 关闭后
*/
function onAfterClose() {
resetForm()
hideLoading()
}
defineExpose({
handleCreate,
handleEdit,
})
</script>
<style lang="less" scoped></style>

View File

@ -0,0 +1,206 @@
<template>
<x-search-bar class="mb-8-2">
<template #default="{ gutter, colSpan }">
<a-form :model="searchFormData" layout="inline">
<a-row :gutter="gutter">
<a-col v-bind="colSpan">
<a-form-item label="所属区域" name="areaId">
<a-select v-model:value="searchFormData.areaId" allowClear>
<a-select-option :value="1">南通</a-select-option>
<a-select-option :value="2">盐城</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col v-bind="colSpan">
<a-form-item label="客户姓名" name="customerName">
<a-input placeholder="请输入客户姓名" v-model:value="searchFormData.customerName"></a-input>
</a-form-item>
</a-col>
<a-col v-bind="colSpan">
<a-form-item label="客户手机号" name="customerPhone">
<a-input placeholder="请输入客户手机号" v-model:value="searchFormData.customerPhone"></a-input>
</a-form-item>
</a-col>
<a-col v-bind="colSpan">
<a-form-item label="客户身份证号" name="idCard">
<a-input placeholder="请输入客户身份证号" v-model:value="searchFormData.idCard"></a-input>
</a-form-item>
</a-col>
<a-col class="align-right" v-bind="colSpan">
<a-space>
<a-button @click="handleResetSearch">{{ $t('button.reset') }}</a-button>
<a-button ghost type="primary" @click="handleSearch">
{{ $t('button.search') }}
</a-button>
</a-space>
</a-col>
</a-row>
</a-form>
</template>
</x-search-bar>
<a-row :gutter="8" :wrap="false">
<a-col flex="auto">
<a-card type="flex">
<x-action-bar class="mb-8-2">
<a-button type="primary" @click="$refs.editDialogRef.handleCreate()">
<template #icon>
<plus-outlined></plus-outlined>
</template>
导入记录
</a-button>
</x-action-bar>
<a-table :columns="columns" :data-source="listData" bordered="true" :loading="loading"
:pagination="paginationState" :scroll="{ x: 'max-content' }" @change="onTableChange">
<template #bodyCell="{ column, record }">
<template v-if="column.dataIndex === 'areaId'">
<span>{{ record.areaId === 1 ? '南通' : '盐城' }}</span>
</template>
<template v-if="column.dataIndex === 'status'">
<span>{{ record.status == "uncheck" ? '未审核' : '已审核' }}</span>
</template>
<template v-if="'action' === column.key">
<!-- <x-action-button @click="$refs.editDialogRef.handleEdit(record)">
<a-tooltip>
<template #title> {{ $t('pages.system.user.edit') }}</template>
<edit-outlined /> </a-tooltip></x-action-button> -->
<x-action-button @click="handleDelete(record)">
<a-tooltip>
<template #title>{{ $t('pages.system.delete') }}</template>
<delete-outlined style="color: #ff4d4f" /> </a-tooltip></x-action-button>
</template>
</template>
</a-table>
</a-card>
</a-col>
</a-row>
<edit-dialog ref="editDialogRef" @ok="onOk"></edit-dialog>
</template>
<script setup>
import { message, Modal } from 'ant-design-vue'
import { ref } from 'vue'
import apis from '@/apis'
import { formatUtcDateTime } from '@/utils/util'
import { config } from '@/config'
import dayjs from 'dayjs'
import { usePagination } from '@/hooks'
import { customersEnum, areaEnum } from "@/enums/useEnum"
import EditDialog from './components/EditDialog.vue'
import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons-vue'
import { useI18n } from 'vue-i18n'
import { render } from 'less'
defineOptions({
name: 'owner',
})
const { t } = useI18n() // t
const columns = [
{ title: '所属城市', dataIndex: 'areaId', width: 120, align: 'center' },
{ title: '楼盘名称', dataIndex: 'productName', width: 120, align: 'center' },
{ title: '楼盘期数', dataIndex: 'productStages', width: 120, align: 'center' },
{ title: '房源信息', dataIndex: 'roomName', width: 120, align: 'center' },
{ title: '客户姓名', dataIndex: 'customerName', width: 120 },
{ title: '客户手机号', dataIndex: 'customerPhone', width: 120 },
{ title: '客户身份证号', dataIndex: 'idCard', width: 300, align: 'center' },
{ title: '来源信息', dataIndex: 'formInfo', width: 300, align: 'center' },
{ title: '积分', dataIndex: 'point', width: 60, align: 'center' },
{ title: '状态', dataIndex: 'status', width: 60, align: 'center' },
{ title: t('button.action'), key: 'action', fixed: 'right', width: 100, align: 'center' },
]
const { listData, loading, showLoading, hideLoading, paginationState, resetPagination, searchFormData } =
usePagination()
const editDialogRef = ref()
getPageList()
/**
* 获取表格数据
* @returns {Promise<void>}
*/
async function getPageList() {
try {
showLoading()
const { pageSize, current } = paginationState
const { success, data, total } = await apis.customer
.getHouseOwners({
pageSize,
current: current,
...searchFormData.value,
})
.catch(() => {
throw new Error()
})
hideLoading()
if (config('http.code.success') === success) {
listData.value = data
paginationState.total = total
}
} catch (error) {
hideLoading()
}
}
/**
* 删除
*/
function handleDelete({ id }) {
console.log(id);
Modal.confirm({
title: t('pages.system.user.delTip'),
content: t('button.confirm'),
okText: t('button.confirm'),
onOk: async () => {
try {
const { success } = await apis.customer.delHouseOwner(id);
if (success === config('http.code.success')) {
message.success('删除成功');
await getPageList();
} else {
message.error('删除失败');
throw new Error('Delete API returned non-success status');
}
} catch (error) {
message.error('删除失败');
throw error; // Modal unhandled rejection
}
},
});
}
/**
* 分页
*/
function onTableChange({ current, pageSize }) {
paginationState.current = current
paginationState.pageSize = pageSize
getPageList()
}
/**
* 搜索
*/
function handleSearch() {
resetPagination()
getPageList()
}
/**
* 重置
*/
function handleResetSearch() {
searchFormData.value = {}
resetPagination()
getPageList()
}
/**
* 编辑完成
*/
async function onOk() {
await getPageList()
}
</script>
<style lang="less" scoped></style>