feat: crm todo

pull/125/head^2
xingyu4j 2025-06-02 20:52:10 +08:00
parent b0c5b794fa
commit 454f9c5c3b
19 changed files with 409 additions and 64 deletions

View File

@ -0,0 +1,4 @@
<script lang="ts" setup></script>
<template>
<div>businessInfo</div>
</template>

View File

@ -0,0 +1,4 @@
<script lang="ts" setup></script>
<template>
<div>businessList</div>
</template>

View File

@ -0,0 +1,4 @@
<script lang="ts" setup></script>
<template>
<div>contactInfo</div>
</template>

View File

@ -0,0 +1,4 @@
<script lang="ts" setup></script>
<template>
<div>contactList</div>
</template>

View File

@ -146,73 +146,73 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{
title: '合同编号',
field: 'no',
width: 150,
minWidth: 150,
fixed: 'left',
},
{
title: '合同名称',
field: 'name',
width: 150,
minWidth: 150,
fixed: 'left',
slots: { default: 'name' },
},
{
title: '客户名称',
field: 'customerName',
width: 150,
minWidth: 150,
slots: { default: 'customerName' },
},
{
title: '商机名称',
field: 'businessName',
width: 150,
minWidth: 150,
slots: { default: 'businessName' },
},
{
title: '合同金额(元)',
field: 'totalPrice',
width: 150,
minWidth: 150,
formatter: 'formatNumber',
},
{
title: '下单时间',
field: 'orderDate',
width: 150,
minWidth: 150,
formatter: 'formatDateTime',
},
{
title: '合同开始时间',
field: 'startTime',
width: 150,
minWidth: 150,
formatter: 'formatDateTime',
},
{
title: '合同结束时间',
field: 'endTime',
width: 150,
minWidth: 150,
formatter: 'formatDateTime',
},
{
title: '客户签约人',
field: 'signContactName',
width: 150,
minWidth: 150,
slots: { default: 'signContactName' },
},
{
title: '公司签约人',
field: 'signUserName',
width: 150,
minWidth: 150,
},
{
title: '已回款金额(元)',
field: 'totalReceivablePrice',
width: 150,
minWidth: 150,
formatter: 'formatNumber',
},
{
title: '未回款金额(元)',
field: 'unpaidPrice',
width: 150,
minWidth: 150,
formatter: ({ row }) => {
return floatToFixed2(row.totalPrice - row.totalReceivablePrice);
},
@ -220,46 +220,46 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{
title: '最后跟进时间',
field: 'contactLastTime',
width: 150,
minWidth: 150,
formatter: 'formatDateTime',
},
{
title: '负责人',
field: 'ownerUserName',
width: 150,
minWidth: 150,
},
{
title: '所属部门',
field: 'ownerUserDeptName',
width: 150,
minWidth: 150,
},
{
title: '更新时间',
field: 'updateTime',
width: 150,
minWidth: 150,
formatter: 'formatDateTime',
},
{
title: '创建时间',
field: 'createTime',
width: 150,
minWidth: 150,
formatter: 'formatDateTime',
},
{
title: '创建人',
field: 'creatorName',
width: 150,
minWidth: 150,
},
{
title: '备注',
field: 'remark',
width: 150,
minWidth: 150,
},
{
title: '合同状态',
field: 'auditStatus',
fixed: 'right',
width: 100,
minWidth: 100,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.CRM_AUDIT_STATUS },

View File

@ -0,0 +1,4 @@
<script lang="ts" setup></script>
<template>
<div>contractInfo</div>
</template>

View File

@ -0,0 +1,4 @@
<script lang="ts" setup></script>
<template>
<div>contractList</div>
</template>

View File

@ -0,0 +1,4 @@
<script lang="ts" setup></script>
<template>
<div>customerList</div>
</template>

View File

@ -57,14 +57,14 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{
title: '客户名称',
field: 'name',
width: 160,
minWidth: 160,
fixed: 'left',
slots: { default: 'name' },
},
{
title: '客户来源',
field: 'source',
width: 100,
minWidth: 100,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.CRM_CUSTOMER_SOURCE },
@ -73,22 +73,22 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{
title: '手机',
field: 'mobile',
width: 120,
minWidth: 120,
},
{
title: '电话',
field: 'telephone',
width: 120,
minWidth: 120,
},
{
title: '邮箱',
field: 'email',
width: 140,
minWidth: 140,
},
{
title: '客户级别',
field: 'level',
width: 135,
minWidth: 135,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.CRM_CUSTOMER_LEVEL },
@ -97,7 +97,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{
title: '客户行业',
field: 'industryId',
width: 100,
minWidth: 100,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.CRM_CUSTOMER_INDUSTRY },
@ -106,18 +106,18 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{
title: '下次联系时间',
field: 'contactNextTime',
width: 180,
minWidth: 180,
formatter: 'formatDateTime',
},
{
title: '备注',
field: 'remark',
width: 200,
minWidth: 200,
},
{
title: '成交状态',
field: 'dealStatus',
width: 80,
minWidth: 80,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
@ -126,30 +126,30 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{
title: '最后跟进时间',
field: 'contactLastTime',
width: 180,
minWidth: 180,
formatter: 'formatDateTime',
},
{
title: '最后跟进记录',
field: 'contactLastContent',
width: 200,
minWidth: 200,
},
{
title: '更新时间',
field: 'updateTime',
width: 180,
minWidth: 180,
formatter: 'formatDateTime',
},
{
title: '创建时间',
field: 'createTime',
width: 180,
minWidth: 180,
formatter: 'formatDateTime',
},
{
title: '创建人',
field: 'creatorName',
width: 100,
minWidth: 100,
},
];
}

View File

@ -0,0 +1,205 @@
<script lang="ts" setup>
import type { FollowUpRecordApi, FollowUpRecordVO } from '@/api/crm/followup';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import { useRouter } from 'vue-router';
import { Page, useVbenModal } from '@vben/common-ui';
import { BizTypeEnum } from '@/api/crm/permission';
import { DICT_TYPE } from '@/utils/dict';
import { Button, message } from 'ant-design-vue';
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import { $t } from '#/locales';
import FollowUpRecordForm from './modules/form.vue';
/** 跟进记录列表 */
defineOptions({ name: 'FollowUpRecord' });
const props = defineProps<{
bizId: number;
bizType: number;
}>();
const { push } = useRouter();
/** 刷新表格 */
function onRefresh() {
gridApi.query();
}
/** 添加跟进记录 */
function handleCreate() {
formModalApi.setData(null).open();
}
/** 删除跟进记录 */
async function handleDelete(row: FollowUpRecordVO) {
const hideLoading = message.loading({
content: $t('ui.actionMessage.deleting', [row.id]),
key: 'action_key_msg',
});
try {
await FollowUpRecordApi.deleteFollowUpRecord(row.id);
message.success({
content: $t('ui.actionMessage.deleteSuccess', [row.id]),
key: 'action_key_msg',
});
onRefresh();
} catch {
hideLoading();
}
}
/** 打开联系人详情 */
function openContactDetail(id: number) {
push({ name: 'CrmContactDetail', params: { id } });
}
/** 打开商机详情 */
function openBusinessDetail(id: number) {
push({ name: 'CrmBusinessDetail', params: { id } });
}
const [FormModal, formModalApi] = useVbenModal({
connectedComponent: FollowUpRecordForm,
destroyOnClose: true,
});
const [Grid, gridApi] = useVbenVxeGrid({
gridOptions: {
columns: [
{
field: 'createTime',
title: '创建时间',
width: 180,
formatter: 'formatDateTime',
},
{ field: 'creatorName', title: '跟进人' },
{
field: 'type',
title: '跟进类型',
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.CRM_FOLLOW_UP_TYPE },
},
},
{ field: 'content', title: '跟进内容' },
{
field: 'nextTime',
title: '下次联系时间',
width: 180,
formatter: 'formatDateTime',
},
{
field: 'contacts',
title: '关联联系人',
visible: props.bizType === BizTypeEnum.CRM_CUSTOMER,
slots: {
default: ({ row }) =>
row.contacts?.map((contact) =>
h(
Button,
{
type: 'link',
onClick: () => openContactDetail(contact.id),
},
() => contact.name,
),
),
},
},
{
field: 'businesses',
title: '关联商机',
visible: props.bizType === BizTypeEnum.CRM_CUSTOMER,
slots: {
default: ({ row }) =>
row.businesses?.map((business) =>
h(
Button,
{
type: 'link',
onClick: () => openBusinessDetail(business.id),
},
() => business.name,
),
),
},
},
{
field: 'actions',
title: '操作',
width: 100,
slots: { default: 'actions' },
},
],
height: 'auto',
keepSource: true,
proxyConfig: {
ajax: {
query: async ({ page }) => {
return await FollowUpRecordApi.getFollowUpRecordPage({
pageNo: page.currentPage,
pageSize: page.pageSize,
bizType: props.bizType,
bizId: props.bizId,
});
},
},
},
rowConfig: {
keyField: 'id',
},
toolbarConfig: {
refresh: { code: 'query' },
},
} as VxeTableGridOptions<FollowUpRecordVO>,
});
watch(
() => props.bizId,
() => {
gridApi.query();
},
);
</script>
<template>
<Page auto-content-height>
<Grid table-title="">
<template #toolbar-tools>
<TableAction
:actions="[
{
label: '写跟进',
type: 'primary',
icon: ACTION_ICON.EDIT,
onClick: handleCreate,
},
]"
/>
</template>
<template #actions="{ row }">
<TableAction
:actions="[
{
label: $t('common.delete'),
type: 'link',
danger: true,
icon: ACTION_ICON.DELETE,
popConfirm: {
title: $t('ui.actionMessage.deleteConfirm', [row.name]),
confirm: handleDelete.bind(null, row),
},
},
]"
/>
</template>
</Grid>
<FormModal @success="onRefresh" />
</Page>
</template>

View File

@ -0,0 +1,87 @@
<script lang="ts" setup>
import type { CrmFollowUpRecordApi } from '#/api/crm/followup';
import { computed, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import { message } from 'ant-design-vue';
import { useVbenForm } from '#/adapter/form';
import {
createFollowUpRecord,
getFollowUpRecord,
updateFollowUpRecord,
} from '#/api/crm/followup';
import { $t } from '#/locales';
const emit = defineEmits(['success']);
const formData = ref<CrmFollowUpRecordApi.FollowUpRecord>();
const getTitle = computed(() => {
return formData.value?.id
? $t('ui.actionTitle.edit', ['跟进记录'])
: $t('ui.actionTitle.create', ['跟进记录']);
});
const [Form, formApi] = useVbenForm({
commonConfig: {
componentProps: {
class: 'w-full',
},
formItemClass: 'col-span-2',
labelWidth: 120,
},
layout: 'horizontal',
schema: [],
showDefaultActions: false,
});
const [Modal, modalApi] = useVbenModal({
async onConfirm() {
const { valid } = await formApi.validate();
if (!valid) {
return;
}
modalApi.lock();
//
const data =
(await formApi.getValues()) as CrmFollowUpRecordApi.FollowUpRecord;
try {
await (formData.value?.id
? updateFollowUpRecord(data)
: createFollowUpRecord(data));
//
await modalApi.close();
emit('success');
message.success($t('ui.actionMessage.operationSuccess'));
} finally {
modalApi.unlock();
}
},
async onOpenChange(isOpen: boolean) {
if (!isOpen) {
formData.value = undefined;
return;
}
//
const data = modalApi.getData<CrmFollowUpRecordApi.FollowUpRecord>();
if (!data || !data.id) {
return;
}
modalApi.lock();
try {
formData.value = await getFollowUpRecord(data.id as number);
// values
await formApi.setValues(formData.value);
} finally {
modalApi.unlock();
}
},
});
</script>
<template>
<Modal :title="getTitle" class="w-[40%]">
<Form class="mx-4" />
</Modal>
</template>

View File

@ -0,0 +1,4 @@
<script lang="ts" setup></script>
<template>
<div>productInfo</div>
</template>

View File

@ -0,0 +1,4 @@
<script lang="ts" setup></script>
<template>
<div>productList</div>
</template>

View File

@ -173,38 +173,38 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{
title: '回款编号',
field: 'no',
width: 150,
minWidth: 150,
fixed: 'left',
slots: { default: 'no' },
},
{
title: '客户名称',
field: 'customerName',
width: 150,
minWidth: 150,
slots: { default: 'customerName' },
},
{
title: '合同编号',
field: 'contract',
width: 150,
minWidth: 150,
slots: { default: 'contractNo' },
},
{
title: '回款日期',
field: 'returnTime',
width: 150,
minWidth: 150,
formatter: 'formatDateTime',
},
{
title: '回款金额(元)',
field: 'price',
width: 150,
minWidth: 150,
formatter: 'formatNumber',
},
{
title: '回款方式',
field: 'returnType',
width: 150,
minWidth: 150,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.CRM_RECEIVABLE_RETURN_TYPE },
@ -213,45 +213,45 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{
title: '备注',
field: 'remark',
width: 150,
minWidth: 150,
},
{
title: '合同金额(元)',
field: 'contract.totalPrice',
width: 150,
minWidth: 150,
formatter: 'formatNumber',
},
{
title: '负责人',
field: 'ownerUserName',
width: 150,
minWidth: 150,
},
{
title: '所属部门',
field: 'ownerUserDeptName',
width: 150,
minWidth: 150,
},
{
title: '更新时间',
field: 'updateTime',
width: 150,
minWidth: 150,
formatter: 'formatDateTime',
},
{
title: '创建时间',
field: 'createTime',
width: 150,
minWidth: 150,
formatter: 'formatDateTime',
},
{
title: '创建人',
field: 'creatorName',
width: 150,
minWidth: 150,
},
{
title: '回款状态',
field: 'auditStatus',
width: 100,
minWidth: 100,
fixed: 'right',
cellRender: {
name: 'CellDict',

View File

@ -0,0 +1,4 @@
<script lang="ts" setup></script>
<template>
<div>receivableInfo</div>
</template>

View File

@ -0,0 +1,4 @@
<script lang="ts" setup></script>
<template>
<div>receivableList</div>
</template>

View File

@ -122,48 +122,48 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{
title: '客户名称',
field: 'customerName',
width: 150,
minWidth: 150,
fixed: 'left',
slots: { default: 'customerName' },
},
{
title: '合同编号',
field: 'contractNo',
width: 200,
minWidth: 200,
},
{
title: '期数',
field: 'period',
width: 150,
minWidth: 150,
slots: { default: 'period' },
},
{
title: '计划回款金额(元)',
field: 'price',
width: 160,
minWidth: 160,
formatter: 'formatNumber',
},
{
title: '计划回款日期',
field: 'returnTime',
width: 180,
minWidth: 180,
formatter: 'formatDateTime',
},
{
title: '提前几天提醒',
field: 'remindDays',
width: 150,
minWidth: 150,
},
{
title: '提醒日期',
field: 'remindTime',
width: 180,
minWidth: 180,
formatter: 'formatDateTime',
},
{
title: '回款方式',
field: 'returnType',
width: 130,
minWidth: 130,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.CRM_RECEIVABLE_RETURN_TYPE },
@ -172,28 +172,29 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{
title: '备注',
field: 'remark',
minWidth: 120,
},
{
title: '负责人',
field: 'ownerUserName',
width: 120,
minWidth: 120,
},
{
title: '实际回款金额(元)',
field: 'receivable.price',
width: 160,
minWidth: 160,
formatter: 'formatNumber',
},
{
title: '实际回款日期',
field: 'receivable.returnTime',
width: 180,
minWidth: 180,
formatter: 'formatDateTime',
},
{
title: '未回款金额(元)',
field: 'unpaidPrice',
width: 160,
minWidth: 160,
formatter: ({ row }) => {
if (row.receivable) {
return row.price - row.receivable.price;
@ -204,19 +205,19 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{
title: '更新时间',
field: 'updateTime',
width: 180,
minWidth: 180,
formatter: 'formatDateTime',
},
{
title: '创建时间',
field: 'createTime',
width: 180,
minWidth: 180,
formatter: 'formatDateTime',
},
{
title: '创建人',
field: 'creatorName',
width: 100,
minWidth: 100,
},
{
title: '操作',

View File

@ -0,0 +1,4 @@
<script lang="ts" setup></script>
<template>
<div>receivablePlanInfo</div>
</template>

View File

@ -0,0 +1,4 @@
<script lang="ts" setup></script>
<template>
<div>receivablePlanList</div>
</template>