feat: 新增客户拜访、建筑、房间及项目全流程业务模块

本次提交新增了客户拜访、客户建筑、客户房间的完整业务模块,同时补充了项目勘察、项目方案、合同管理、项目验收、回访记录的全项目流程相关功能,包括:
1.  新增对应业务的实体类、DTO、控制器、服务层代码
2.  完善RBAC权限映射配置
3.  添加前端API、路由及页面菜单配置
4.  更新数据库种子数据补充菜单和权限绑定
This commit is contained in:
andyesfly committed 2026-08-26 14:08:08 +08:00
1 parent f61ade107b
commit 219091f864
53 files changed
+5990 -6

No files matched your search

+423
View File
@@ -0,0 +1,423 @@
<template>
<div class="page-management">
<a-card title="客户拜访管理">
<template #extra>
<a-space>
<a-button type="primary" @click="handleAdd">
<template #icon><PlusOutlined /></template>
新增拜访
</a-button>
</a-space>
</template>
<div class="search-bar">
<a-input
v-model:value="searchForm.keyword"
placeholder="拜访人/电话"
allow-clear
style="width: 220px"
@pressEnter="handleSearch"
>
<template #prefix><SearchOutlined /></template>
</a-input>
<a-select
v-if="isAdmin"
v-model:value="searchForm.salesmanId"
placeholder="负责业务员"
allow-clear
style="width: 160px"
:options="salesmanOptions"
/>
<a-button type="primary" @click="handleSearch">
<template #icon><SearchOutlined /></template>
查询
</a-button>
<a-button @click="handleReset">
<template #icon><ReloadOutlined /></template>
重置
</a-button>
</div>
<div class="table-wrapper" ref="wrapperRef">
<a-table
:columns="columns"
:data-source="dataSource"
:loading="loading"
:pagination="pagination"
row-key="id"
:scroll="{ x: 'max-content', y: tableHeight }"
@change="handleTableChange"
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'customerName'">
{{ getCustomerName(record.customerId) }}
</template>
<template v-if="column.key === 'willPlan'">
<a-tag :color="record.willPlan === 1 ? 'orange' : 'default'">
{{ record.willPlan === 1 ? '有意向方案' : '暂无' }}
</a-tag>
</template>
<template v-if="column.key === 'createdAt'">
{{ formatDateTime(record.createdAt) }}
</template>
<template v-if="column.key === 'action'">
<a-space>
<a-button type="link" size="small" @click="handleEdit(record)">
<template #icon><EditOutlined /></template>
编辑
</a-button>
<a-popconfirm title="确定要删除该拜访记录吗?" ok-text="确定" cancel-text="取消" @confirm="handleDelete(record.id)">
<a-button type="link" size="small" danger>
<template #icon><DeleteOutlined /></template>
删除
</a-button>
</a-popconfirm>
</a-space>
</template>
</template>
<template #emptyText>
<a-empty description="暂无拜访数据" />
</template>
</a-table>
</div>
</a-card>
<a-modal
v-model:open="modalVisible"
:title="modalTitle"
:confirm-loading="modalLoading"
width="680px"
@ok="handleSubmit"
@cancel="handleCancel"
>
<a-form
ref="formRef"
:model="formData"
:rules="formRules"
:label-col="{ span: 6 }"
:wrapper-col="{ span: 16 }"
>
<a-form-item label="所属客户" name="customerId">
<a-select
v-model:value="formData.customerId"
placeholder="请选择客户"
:options="customerOptions"
:disabled="!isAdmin && isEdit"
show-search
option-filter-prop="label"
/>
</a-form-item>
<a-form-item label="拜访人" name="visitPerson">
<a-input v-model:value="formData.visitPerson" placeholder="请输入拜访人" maxlength="64" />
</a-form-item>
<a-form-item label="联系电话" name="visitPhone">
<a-input v-model:value="formData.visitPhone" placeholder="请输入联系电话" />
</a-form-item>
<a-form-item label="拜访时间" name="visitTime">
<a-date-picker v-model:value="formData.visitTime" style="width: 100%" placeholder="请选择拜访时间" />
</a-form-item>
<a-form-item label="是否有意向方案" name="willPlan">
<a-radio-group v-model:value="formData.willPlan">
<a-radio :value="1">有</a-radio>
<a-radio :value="0">无</a-radio>
</a-radio-group>
</a-form-item>
<a-form-item label="拜访内容" name="visitContent">
<a-textarea v-model:value="formData.visitContent" :rows="3" placeholder="请输入拜访内容" maxlength="2000" />
</a-form-item>
<a-form-item v-if="isAdmin" label="负责业务员" name="salesmanId">
<a-select
v-model:value="formData.salesmanId"
placeholder="请选择负责业务员"
:options="salesmanOptions"
allow-clear
/>
</a-form-item>
</a-form>
</a-modal>
</div>
</template>
<script setup lang="ts">
import { ref, reactive, computed, onMounted } from 'vue';
import { message } from 'ant-design-vue';
import { SearchOutlined, ReloadOutlined, PlusOutlined, DeleteOutlined, EditOutlined } from '@ant-design/icons-vue';
import dayjs from 'dayjs';
import { customerVisitApi, type CustomerVisitInfo, type CustomerVisitQuery } from '@/api/customerVisit';
import { customerApi } from '@/api/customer';
import { userApi } from '@/api/user';
import { useTableScroll } from '@/composables/useTableScroll';
import { usePermissionStore } from '@/stores/permission';
const { wrapperRef, tableHeight } = useTableScroll();
const permissionStore = usePermissionStore();
const isAdmin = computed(() => permissionStore.hasRole('ADMIN'));
const loading = ref(false);
const dataSource = ref<CustomerVisitInfo[]>([]);
const total = ref(0);
const searchForm = reactive<CustomerVisitQuery>({
page: 1,
pageSize: 10,
keyword: '',
salesmanId: undefined as any,
});
const modalVisible = ref(false);
const modalTitle = ref('');
const modalLoading = ref(false);
const formRef = ref();
const isEdit = ref(false);
const editId = ref<number | null>(null);
const customerOptions = ref<{ label: string; value: number }[]>([]);
const salesmanOptions = ref<{ label: string; value: number }[]>([]);
const formData = reactive({
customerId: undefined as number | undefined,
visitPerson: '',
visitPhone: '',
visitTime: undefined as any,
visitContent: '',
willPlan: 0,
salesmanId: undefined as number | undefined,
});
const formRules = {
customerId: [{ required: true, message: '请选择所属客户', trigger: 'change' }],
visitPerson: [{ required: true, message: '请输入拜访人', trigger: 'blur' }],
visitPhone: [{ pattern: /^1[3-9]\d{9}$/, message: '手机号格式不正确', trigger: 'blur' }],
};
const columns = [
{ title: '拜访单号', dataIndex: 'visitNo', key: 'visitNo', ellipsis: true, width: 160 },
{ title: '所属客户', key: 'customerName', ellipsis: true },
{ title: '拜访人', dataIndex: 'visitPerson', key: 'visitPerson', ellipsis: true },
{ title: '联系电话', dataIndex: 'visitPhone', key: 'visitPhone', ellipsis: true },
{ title: '拜访时间', dataIndex: 'visitTime', key: 'visitTime' },
{ title: '拜访内容', dataIndex: 'visitContent', key: 'visitContent', ellipsis: true },
{ title: '意向方案', key: 'willPlan', align: 'center' as const, width: 100 },
{ title: '创建时间', dataIndex: 'createdAt', key: 'createdAt', ellipsis: true },
{ title: '操作', key: 'action', width: 140, fixed: 'right' as const },
];
const pagination = computed(() => ({
current: searchForm.page,
pageSize: searchForm.pageSize,
total: total.value,
showSizeChanger: true,
showQuickJumper: true,
showTotal: (t: number) => `共 ${t} 条数据`,
}));
onMounted(() => {
fetchList();
fetchCustomerOptions();
fetchSalesmanList();
});
async function fetchList() {
loading.value = true;
try {
const res: any = await customerVisitApi.getList(searchForm);
if (res.code === 200) {
dataSource.value = res.data.list;
total.value = res.data.total;
}
} catch {
message.error('获取拜访列表失败');
} finally {
loading.value = false;
}
}
async function fetchCustomerOptions() {
try {
const res: any = await customerApi.getCustomerOptions();
if (res.code === 200) {
customerOptions.value = res.data.map((item: any) => ({ label: item.customerName, value: item.id }));
}
} catch {
console.error('获取客户选项失败');
}
}
async function fetchSalesmanList() {
try {
const res: any = await userApi.getUserList({ page: 1, pageSize: 999 });
if (res.code === 200) {
salesmanOptions.value = res.data.list.map((item: any) => ({ label: item.realName, value: item.id }));
}
} catch {
console.error('获取业务员列表失败');
}
}
function getCustomerName(customerId: number): string {
const found = customerOptions.value.find((c) => c.value === customerId);
return found ? found.label : `#${customerId}`;
}
function handleSearch() {
searchForm.page = 1;
fetchList();
}
function handleReset() {
searchForm.keyword = '';
searchForm.salesmanId = undefined as any;
searchForm.page = 1;
fetchList();
}
function handleTableChange(pag: any) {
searchForm.page = pag.current;
searchForm.pageSize = pag.pageSize;
fetchList();
}
function handleAdd() {
isEdit.value = false;
editId.value = null;
modalTitle.value = '新增拜访';
resetForm();
modalVisible.value = true;
}
function handleEdit(record: CustomerVisitInfo) {
isEdit.value = true;
editId.value = record.id;
modalTitle.value = '编辑拜访';
resetForm();
formData.customerId = record.customerId;
formData.visitPerson = record.visitPerson;
formData.visitPhone = record.visitPhone;
formData.visitTime = record.visitTime ? dayjs(record.visitTime) : undefined;
formData.visitContent = record.visitContent;
formData.willPlan = record.willPlan ?? 0;
formData.salesmanId = record.salesmanId;
modalVisible.value = true;
}
function resetForm() {
formData.customerId = undefined;
formData.visitPerson = '';
formData.visitPhone = '';
formData.visitTime = undefined;
formData.visitContent = '';
formData.willPlan = 0;
formData.salesmanId = undefined;
if (formRef.value) {
formRef.value.resetFields();
}
}
async function handleSubmit() {
try {
await formRef.value.validate();
} catch {
return;
}
modalLoading.value = true;
try {
const submitData: any = {
customerId: formData.customerId,
visitPerson: formData.visitPerson,
visitPhone: formData.visitPhone,
visitTime: formData.visitTime ? formData.visitTime.format('YYYY-MM-DD') : undefined,
visitContent: formData.visitContent,
willPlan: formData.willPlan,
};
if (isAdmin.value && formData.salesmanId !== undefined) {
submitData.salesmanId = formData.salesmanId;
}
let res: any;
if (isEdit.value && editId.value) {
res = await customerVisitApi.update(editId.value, submitData);
} else {
res = await customerVisitApi.create(submitData);
}
if (res.code === 200) {
message.success(isEdit.value ? '更新成功' : '创建成功');
modalVisible.value = false;
fetchList();
} else {
message.error(res.message || '操作失败');
}
} catch {
message.error('操作失败');
} finally {
modalLoading.value = false;
}
}
function handleCancel() {
modalVisible.value = false;
resetForm();
}
async function handleDelete(id: number) {
try {
const res: any = await customerVisitApi.delete(id);
if (res.code === 200) {
message.success('删除成功');
fetchList();
} else {
message.error(res.message || '删除失败');
}
} catch {
message.error('删除失败');
}
}
function formatDateTime(dateStr: string) {
if (!dateStr) return '-';
return dayjs(dateStr).format('YYYY-MM-DD HH:mm:ss');
}
</script>
<style scoped>
.page-management {
height: 100%;
display: flex;
flex-direction: column;
overflow: hidden;
padding: 20px;
box-sizing: border-box;
}
:deep(.ant-card) {
flex: 1;
display: flex;
flex-direction: column;
overflow: hidden;
min-height: 0;
}
:deep(.ant-card-body) {
flex: 1;
display: flex;
flex-direction: column;
overflow: hidden;
min-height: 0;
}
.search-bar {
flex-shrink: 0;
margin-bottom: 16px;
display: flex;
justify-content: flex-end;
gap: 8px;
}
.table-wrapper {
flex: 1;
min-height: 0;
overflow: hidden;
}
:deep(.ant-table) {
font-size: 14px;
height: 100%;
}
:deep(.ant-btn-link) {
padding: 0 4px;
}
</style>