feat:【antd】【crm】跟进记录的代码优化
This commit is contained in:
@@ -1,7 +1,162 @@
|
||||
import type { Ref } from 'vue';
|
||||
|
||||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { DescriptionItemSchema } from '#/components/description';
|
||||
|
||||
import { DICT_TYPE } from '@vben/constants';
|
||||
import { getDictOptions } from '@vben/hooks';
|
||||
import { formatDateTime } from '@vben/utils';
|
||||
|
||||
import { getBusinessPageByCustomer } from '#/api/crm/business';
|
||||
import { getContactPageByCustomer } from '#/api/crm/contact';
|
||||
import { BizTypeEnum } from '#/api/crm/permission';
|
||||
|
||||
/** 新增/修改的表单 */
|
||||
export function useFormSchema(
|
||||
bizId: Ref<number | undefined>,
|
||||
): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'bizId',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'bizType',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'type',
|
||||
label: '跟进类型',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
options: getDictOptions(DICT_TYPE.CRM_FOLLOW_UP_TYPE, 'number'),
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'nextTime',
|
||||
label: '下次联系时间',
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
showTime: true,
|
||||
format: 'YYYY-MM-DD HH:mm:ss',
|
||||
valueFormat: 'x',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'content',
|
||||
label: '跟进内容',
|
||||
component: 'Textarea',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'picUrls',
|
||||
label: '图片',
|
||||
component: 'ImageUpload',
|
||||
},
|
||||
{
|
||||
fieldName: 'fileUrls',
|
||||
label: '附件',
|
||||
component: 'FileUpload',
|
||||
},
|
||||
{
|
||||
fieldName: 'contactIds',
|
||||
label: '关联联系人',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
api: async () => {
|
||||
if (!bizId.value) {
|
||||
return [];
|
||||
}
|
||||
const res = await getContactPageByCustomer({
|
||||
pageNo: 1,
|
||||
pageSize: 100,
|
||||
customerId: bizId.value,
|
||||
});
|
||||
return res.list;
|
||||
},
|
||||
mode: 'multiple',
|
||||
fieldNames: { label: 'name', value: 'id' },
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'businessIds',
|
||||
label: '关联商机',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
api: async () => {
|
||||
if (!bizId.value) {
|
||||
return [];
|
||||
}
|
||||
const res = await getBusinessPageByCustomer({
|
||||
pageNo: 1,
|
||||
pageSize: 100,
|
||||
customerId: bizId.value,
|
||||
});
|
||||
return res.list;
|
||||
},
|
||||
mode: 'multiple',
|
||||
fieldNames: { label: 'name', value: 'id' },
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns(
|
||||
bizType: number,
|
||||
): VxeTableGridOptions['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间',
|
||||
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: '下次联系时间',
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
field: 'contacts',
|
||||
title: '关联联系人',
|
||||
visible: bizType === BizTypeEnum.CRM_CUSTOMER,
|
||||
slots: { default: 'contacts' },
|
||||
},
|
||||
{
|
||||
field: 'businesses',
|
||||
title: '关联商机',
|
||||
visible: bizType === BizTypeEnum.CRM_CUSTOMER,
|
||||
slots: { default: 'businesses' },
|
||||
},
|
||||
{
|
||||
field: 'actions',
|
||||
title: '操作',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 详情页的系统字段 */
|
||||
export function useFollowUpDetailSchema(): DescriptionItemSchema[] {
|
||||
return [
|
||||
@@ -33,4 +188,4 @@ export function useFollowUpDetailSchema(): DescriptionItemSchema[] {
|
||||
content: (data) => formatDateTime(data?.updateTime) as string,
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user