feat: crm

pull/121/head^2
xingyu4j 2025-05-29 14:51:23 +08:00
parent 2aaf8aad8b
commit c18b6a9b75
5 changed files with 272 additions and 257 deletions

View File

@ -133,14 +133,12 @@ export function useClueFollowColumns(): VxeTableGridOptions['columns'] {
{ {
field: 'name', field: 'name',
title: '线索名称', title: '线索名称',
minWidth: 160,
fixed: 'left', fixed: 'left',
slots: { default: 'name' }, slots: { default: 'name' },
}, },
{ {
field: 'source', field: 'source',
title: '线索来源', title: '线索来源',
minWidth: 100,
cellRender: { cellRender: {
name: 'CellDict', name: 'CellDict',
props: { type: DICT_TYPE.CRM_CUSTOMER_SOURCE }, props: { type: DICT_TYPE.CRM_CUSTOMER_SOURCE },
@ -149,27 +147,22 @@ export function useClueFollowColumns(): VxeTableGridOptions['columns'] {
{ {
field: 'mobile', field: 'mobile',
title: '手机', title: '手机',
minWidth: 120,
}, },
{ {
field: 'telephone', field: 'telephone',
title: '电话', title: '电话',
minWidth: 130,
}, },
{ {
field: 'email', field: 'email',
title: '邮箱', title: '邮箱',
minWidth: 180,
}, },
{ {
field: 'detailAddress', field: 'detailAddress',
title: '地址', title: '地址',
minWidth: 180,
}, },
{ {
field: 'industryId', field: 'industryId',
title: '客户行业', title: '客户行业',
minWidth: 100,
cellRender: { cellRender: {
name: 'CellDict', name: 'CellDict',
props: { type: DICT_TYPE.CRM_CUSTOMER_INDUSTRY }, props: { type: DICT_TYPE.CRM_CUSTOMER_INDUSTRY },
@ -178,7 +171,6 @@ export function useClueFollowColumns(): VxeTableGridOptions['columns'] {
{ {
field: 'level', field: 'level',
title: '客户级别', title: '客户级别',
minWidth: 100,
cellRender: { cellRender: {
name: 'CellDict', name: 'CellDict',
props: { type: DICT_TYPE.CRM_CUSTOMER_LEVEL }, props: { type: DICT_TYPE.CRM_CUSTOMER_LEVEL },
@ -187,51 +179,42 @@ export function useClueFollowColumns(): VxeTableGridOptions['columns'] {
{ {
field: 'contactNextTime', field: 'contactNextTime',
title: '下次联系时间', title: '下次联系时间',
minWidth: 180,
formatter: 'formatDateTime', formatter: 'formatDateTime',
}, },
{ {
field: 'remark', field: 'remark',
title: '备注', title: '备注',
minWidth: 200,
}, },
{ {
field: 'contactLastTime', field: 'contactLastTime',
title: '最后跟进时间', title: '最后跟进时间',
minWidth: 180,
formatter: 'formatDateTime', formatter: 'formatDateTime',
}, },
{ {
field: 'contactLastContent', field: 'contactLastContent',
title: '最后跟进记录', title: '最后跟进记录',
minWidth: 200,
}, },
{ {
field: 'ownerUserName', field: 'ownerUserName',
title: '负责人', title: '负责人',
minWidth: 100,
}, },
{ {
field: 'ownerUserDeptName', field: 'ownerUserDeptName',
title: '所属部门', title: '所属部门',
minWidth: 100,
}, },
{ {
field: 'updateTime', field: 'updateTime',
title: '更新时间', title: '更新时间',
minWidth: 180,
formatter: 'formatDateTime', formatter: 'formatDateTime',
}, },
{ {
field: 'createTime', field: 'createTime',
title: '创建时间', title: '创建时间',
minWidth: 180,
formatter: 'formatDateTime', formatter: 'formatDateTime',
}, },
{ {
field: 'creatorName', field: 'creatorName',
title: '创建人', title: '创建人',
minWidth: 100,
}, },
]; ];
} }
@ -276,124 +259,96 @@ export function useContractColumns<T = CrmContractApi.Contract>(
{ {
field: 'no', field: 'no',
title: '合同编号', title: '合同编号',
minWidth: 160,
fixed: 'left', fixed: 'left',
}, },
{ {
field: 'name', field: 'name',
title: '合同名称', title: '合同名称',
minWidth: 160, slots: { default: 'name' },
slots: {
default: 'name',
},
}, },
{ {
field: 'customerName', field: 'customerName',
title: '客户名称', title: '客户名称',
minWidth: 160, slots: { default: 'customerName' },
slots: {
default: 'customerName',
},
}, },
{ {
field: 'businessName', field: 'businessName',
title: '商机名称', title: '商机名称',
minWidth: 160, slots: { default: 'businessName' },
slots: {
default: 'businessName',
},
}, },
{ {
field: 'price', field: 'price',
title: '合同金额(元)', title: '合同金额(元)',
minWidth: 120,
formatter: 'formatNumber', formatter: 'formatNumber',
}, },
{ {
field: 'orderDate', field: 'orderDate',
title: '下单时间', title: '下单时间',
minWidth: 120,
formatter: 'formatDateTime', formatter: 'formatDateTime',
}, },
{ {
field: 'startTime', field: 'startTime',
title: '合同开始时间', title: '合同开始时间',
minWidth: 120,
formatter: 'formatDateTime', formatter: 'formatDateTime',
}, },
{ {
field: 'endTime', field: 'endTime',
title: '合同结束时间', title: '合同结束时间',
minWidth: 120,
formatter: 'formatDateTime', formatter: 'formatDateTime',
}, },
{ {
field: 'contactName', field: 'contactName',
title: '客户签约人', title: '客户签约人',
minWidth: 130, slots: { default: 'contactName' },
slots: {
default: 'contactName',
},
}, },
{ {
field: 'signUserName', field: 'signUserName',
title: '公司签约人', title: '公司签约人',
minWidth: 130,
}, },
{ {
field: 'remark', field: 'remark',
title: '备注', title: '备注',
minWidth: 200,
}, },
{ {
field: 'totalReceivablePrice', field: 'totalReceivablePrice',
title: '已回款金额(元)', title: '已回款金额(元)',
minWidth: 140,
formatter: 'formatNumber', formatter: 'formatNumber',
}, },
{ {
field: 'noReceivablePrice', field: 'noReceivablePrice',
title: '未回款金额(元)', title: '未回款金额(元)',
minWidth: 120,
formatter: 'formatNumber', formatter: 'formatNumber',
}, },
{ {
field: 'contactLastTime', field: 'contactLastTime',
title: '最后跟进时间', title: '最后跟进时间',
minWidth: 180,
formatter: 'formatDateTime', formatter: 'formatDateTime',
}, },
{ {
field: 'ownerUserName', field: 'ownerUserName',
title: '负责人', title: '负责人',
minWidth: 120,
}, },
{ {
field: 'ownerUserDeptName', field: 'ownerUserDeptName',
title: '所属部门', title: '所属部门',
minWidth: 100,
}, },
{ {
field: 'updateTime', field: 'updateTime',
title: '更新时间', title: '更新时间',
minWidth: 180,
formatter: 'formatDateTime', formatter: 'formatDateTime',
}, },
{ {
field: 'createTime', field: 'createTime',
title: '创建时间', title: '创建时间',
minWidth: 180,
formatter: 'formatDateTime', formatter: 'formatDateTime',
}, },
{ {
field: 'creatorName', field: 'creatorName',
title: '创建人', title: '创建人',
minWidth: 100,
}, },
{ {
field: 'auditStatus', field: 'auditStatus',
title: '合同状态', title: '合同状态',
minWidth: 120,
cellRender: { cellRender: {
name: 'CellDict', name: 'CellDict',
props: { type: DICT_TYPE.CRM_AUDIT_STATUS }, props: { type: DICT_TYPE.CRM_AUDIT_STATUS },
@ -402,7 +357,7 @@ export function useContractColumns<T = CrmContractApi.Contract>(
{ {
field: 'operation', field: 'operation',
title: '操作', title: '操作',
minWidth: 130, width: 130,
align: 'center', align: 'center',
fixed: 'right', fixed: 'right',
cellRender: { cellRender: {
@ -487,15 +442,11 @@ export function useCustomerColumns(): VxeTableGridOptions['columns'] {
{ {
field: 'name', field: 'name',
title: '客户名称', title: '客户名称',
minWidth: 160, slots: { default: 'name' },
slots: {
default: 'name',
},
}, },
{ {
field: 'source', field: 'source',
title: '客户来源', title: '客户来源',
minWidth: 100,
cellRender: { cellRender: {
name: 'CellDict', name: 'CellDict',
props: { type: DICT_TYPE.CRM_CUSTOMER_SOURCE }, props: { type: DICT_TYPE.CRM_CUSTOMER_SOURCE },
@ -504,22 +455,18 @@ export function useCustomerColumns(): VxeTableGridOptions['columns'] {
{ {
field: 'mobile', field: 'mobile',
title: '手机', title: '手机',
minWidth: 120,
}, },
{ {
field: 'telephone', field: 'telephone',
title: '电话', title: '电话',
minWidth: 130,
}, },
{ {
field: 'email', field: 'email',
title: '邮箱', title: '邮箱',
minWidth: 180,
}, },
{ {
field: 'level', field: 'level',
title: '客户级别', title: '客户级别',
minWidth: 100,
cellRender: { cellRender: {
name: 'CellDict', name: 'CellDict',
props: { type: DICT_TYPE.CRM_CUSTOMER_LEVEL }, props: { type: DICT_TYPE.CRM_CUSTOMER_LEVEL },
@ -528,7 +475,6 @@ export function useCustomerColumns(): VxeTableGridOptions['columns'] {
{ {
field: 'industryId', field: 'industryId',
title: '客户行业', title: '客户行业',
minWidth: 100,
cellRender: { cellRender: {
name: 'CellDict', name: 'CellDict',
props: { type: DICT_TYPE.CRM_CUSTOMER_INDUSTRY }, props: { type: DICT_TYPE.CRM_CUSTOMER_INDUSTRY },
@ -537,18 +483,15 @@ export function useCustomerColumns(): VxeTableGridOptions['columns'] {
{ {
field: 'contactNextTime', field: 'contactNextTime',
title: '下次联系时间', title: '下次联系时间',
minWidth: 180,
formatter: 'formatDateTime', formatter: 'formatDateTime',
}, },
{ {
field: 'remark', field: 'remark',
title: '备注', title: '备注',
minWidth: 200,
}, },
{ {
field: 'lockStatus', field: 'lockStatus',
title: '锁定状态', title: '锁定状态',
minWidth: 100,
cellRender: { cellRender: {
name: 'CellDict', name: 'CellDict',
props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING }, props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
@ -557,7 +500,6 @@ export function useCustomerColumns(): VxeTableGridOptions['columns'] {
{ {
field: 'dealStatus', field: 'dealStatus',
title: '成交状态', title: '成交状态',
minWidth: 100,
cellRender: { cellRender: {
name: 'CellDict', name: 'CellDict',
props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING }, props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
@ -566,50 +508,41 @@ export function useCustomerColumns(): VxeTableGridOptions['columns'] {
{ {
field: 'contactLastTime', field: 'contactLastTime',
title: '最后跟进时间', title: '最后跟进时间',
minWidth: 180,
formatter: 'formatDateTime', formatter: 'formatDateTime',
}, },
{ {
field: 'contactLastContent', field: 'contactLastContent',
title: '最后跟进记录', title: '最后跟进记录',
minWidth: 200,
}, },
{ {
field: 'detailAddress', field: 'detailAddress',
title: '地址', title: '地址',
minWidth: 200,
}, },
{ {
field: 'poolDay', field: 'poolDay',
title: '距离进入公海天数', title: '距离进入公海天数',
minWidth: 180,
}, },
{ {
field: 'ownerUserName', field: 'ownerUserName',
title: '负责人', title: '负责人',
minWidth: 100,
}, },
{ {
field: 'ownerUserDeptName', field: 'ownerUserDeptName',
title: '所属部门', title: '所属部门',
minWidth: 100,
}, },
{ {
field: 'updateTime', field: 'updateTime',
title: '更新时间', title: '更新时间',
minWidth: 180,
formatter: 'formatDateTime', formatter: 'formatDateTime',
}, },
{ {
field: 'createTime', field: 'createTime',
title: '创建时间', title: '创建时间',
minWidth: 180,
formatter: 'formatDateTime', formatter: 'formatDateTime',
}, },
{ {
field: 'creatorName', field: 'creatorName',
title: '创建人', title: '创建人',
minWidth: 100,
}, },
]; ];
} }
@ -638,44 +571,32 @@ export function useReceivableAuditColumns<T = CrmReceivableApi.Receivable>(
{ {
field: 'no', field: 'no',
title: '回款编号', title: '回款编号',
minWidth: 180,
fixed: 'left', fixed: 'left',
slots: { slots: { default: 'no' },
default: 'no',
},
}, },
{ {
field: 'customerName', field: 'customerName',
title: '客户名称', title: '客户名称',
minWidth: 120, slots: { default: 'customerName' },
slots: {
default: 'customerName',
},
}, },
{ {
field: 'contractNo', field: 'contractNo',
title: '合同编号', title: '合同编号',
minWidth: 180, slots: { default: 'contractNo' },
slots: {
default: 'contractNo',
},
}, },
{ {
field: 'returnTime', field: 'returnTime',
title: '回款日期', title: '回款日期',
minWidth: 150,
formatter: 'formatDateTime', formatter: 'formatDateTime',
}, },
{ {
field: 'price', field: 'price',
title: '回款金额(元)', title: '回款金额(元)',
minWidth: 140,
formatter: 'formatNumber', formatter: 'formatNumber',
}, },
{ {
field: 'returnType', field: 'returnType',
title: '回款方式', title: '回款方式',
minWidth: 130,
cellRender: { cellRender: {
name: 'CellDict', name: 'CellDict',
props: { type: DICT_TYPE.CRM_RECEIVABLE_RETURN_TYPE }, props: { type: DICT_TYPE.CRM_RECEIVABLE_RETURN_TYPE },
@ -684,45 +605,37 @@ export function useReceivableAuditColumns<T = CrmReceivableApi.Receivable>(
{ {
field: 'remark', field: 'remark',
title: '备注', title: '备注',
minWidth: 200,
}, },
{ {
field: 'contract.totalPrice', field: 'contract.totalPrice',
title: '合同金额(元)', title: '合同金额(元)',
minWidth: 140,
formatter: 'formatNumber', formatter: 'formatNumber',
}, },
{ {
field: 'ownerUserName', field: 'ownerUserName',
title: '负责人', title: '负责人',
minWidth: 120,
}, },
{ {
field: 'ownerUserDeptName', field: 'ownerUserDeptName',
title: '所属部门', title: '所属部门',
minWidth: 100,
}, },
{ {
field: 'updateTime', field: 'updateTime',
title: '更新时间', title: '更新时间',
minWidth: 180,
formatter: 'formatDateTime', formatter: 'formatDateTime',
}, },
{ {
field: 'createTime', field: 'createTime',
title: '创建时间', title: '创建时间',
minWidth: 180,
formatter: 'formatDateTime', formatter: 'formatDateTime',
}, },
{ {
field: 'creatorName', field: 'creatorName',
title: '创建人', title: '创建人',
minWidth: 120,
}, },
{ {
field: 'auditStatus', field: 'auditStatus',
title: '回款状态', title: '回款状态',
minWidth: 120,
fixed: 'right', fixed: 'right',
cellRender: { cellRender: {
name: 'CellDict', name: 'CellDict',
@ -778,52 +691,40 @@ export function useReceivablePlanRemindColumns<T = CrmReceivableApi.Receivable>(
{ {
field: 'customerName', field: 'customerName',
title: '客户名称', title: '客户名称',
minWidth: 160,
fixed: 'left', fixed: 'left',
slots: { slots: { default: 'customerName' },
default: 'customerName',
},
}, },
{ {
field: 'contractNo', field: 'contractNo',
title: '合同编号', title: '合同编号',
minWidth: 200,
}, },
{ {
field: 'period', field: 'period',
title: '期数', title: '期数',
minWidth: 160, slots: { default: 'period' },
slots: {
default: 'period',
},
}, },
{ {
field: 'price', field: 'price',
title: '计划回款金额(元)', title: '计划回款金额(元)',
minWidth: 120,
formatter: 'formatNumber', formatter: 'formatNumber',
}, },
{ {
field: 'returnTime', field: 'returnTime',
title: '计划回款日期', title: '计划回款日期',
minWidth: 180,
formatter: 'formatDateTime', formatter: 'formatDateTime',
}, },
{ {
field: 'remindDays', field: 'remindDays',
title: '提前几天提醒', title: '提前几天提醒',
minWidth: 150,
}, },
{ {
field: 'remindTime', field: 'remindTime',
title: '提醒日期', title: '提醒日期',
minWidth: 180,
formatter: 'formatDateTime', formatter: 'formatDateTime',
}, },
{ {
field: 'returnType', field: 'returnType',
title: '回款方式', title: '回款方式',
minWidth: 120,
fixed: 'right', fixed: 'right',
cellRender: { cellRender: {
name: 'CellDict', name: 'CellDict',
@ -833,41 +734,34 @@ export function useReceivablePlanRemindColumns<T = CrmReceivableApi.Receivable>(
{ {
field: 'remark', field: 'remark',
title: '备注', title: '备注',
minWidth: 200,
}, },
{ {
field: 'ownerUserName', field: 'ownerUserName',
title: '负责人', title: '负责人',
minWidth: 100,
}, },
{ {
field: 'receivable.price', field: 'receivable.price',
title: '实际回款金额(元)', title: '实际回款金额(元)',
minWidth: 160,
formatter: 'formatNumber', formatter: 'formatNumber',
}, },
{ {
field: 'receivable.returnTime', field: 'receivable.returnTime',
title: '实际回款日期', title: '实际回款日期',
minWidth: 180,
formatter: 'formatDateTime', formatter: 'formatDateTime',
}, },
{ {
field: 'updateTime', field: 'updateTime',
title: '更新时间', title: '更新时间',
minWidth: 180,
formatter: 'formatDateTime', formatter: 'formatDateTime',
}, },
{ {
field: 'createTime', field: 'createTime',
title: '创建时间', title: '创建时间',
minWidth: 180,
formatter: 'formatDateTime', formatter: 'formatDateTime',
}, },
{ {
field: 'creatorName', field: 'creatorName',
title: '创建人', title: '创建人',
minWidth: 100,
}, },
{ {
field: 'operation', field: 'operation',

View File

@ -99,87 +99,69 @@ export function useGridColumns<T = CrmBusinessApi.Business>(
{ {
field: 'name', field: 'name',
title: '商机名称', title: '商机名称',
minWidth: 160,
fixed: 'left', fixed: 'left',
slots: { slots: { default: 'name' },
default: 'name',
},
}, },
{ {
field: 'customerName', field: 'customerName',
title: '客户名称', title: '客户名称',
minWidth: 120,
fixed: 'left', fixed: 'left',
slots: { slots: { default: 'customerName' },
default: 'customerName',
},
}, },
{ {
field: 'totalPrice', field: 'totalPrice',
title: '商机金额(元)', title: '商机金额(元)',
minWidth: 140,
formatter: 'formatNumber', formatter: 'formatNumber',
}, },
{ {
field: 'dealTime', field: 'dealTime',
title: '预计成交日期', title: '预计成交日期',
minWidth: 180,
formatter: 'formatDate', formatter: 'formatDate',
}, },
{ {
field: 'remark', field: 'remark',
title: '备注', title: '备注',
minWidth: 200,
}, },
{ {
field: 'contactNextTime', field: 'contactNextTime',
title: '下次联系时间', title: '下次联系时间',
minWidth: 180,
formatter: 'formatDate', formatter: 'formatDate',
}, },
{ {
field: 'ownerUserName', field: 'ownerUserName',
title: '负责人', title: '负责人',
minWidth: 100,
}, },
{ {
field: 'ownerUserDeptName', field: 'ownerUserDeptName',
title: '所属部门', title: '所属部门',
minWidth: 100,
}, },
{ {
field: 'contactLastTime', field: 'contactLastTime',
title: '最后跟进时间', title: '最后跟进时间',
minWidth: 180,
formatter: 'formatDateTime', formatter: 'formatDateTime',
}, },
{ {
field: 'updateTime', field: 'updateTime',
title: '更新时间', title: '更新时间',
minWidth: 180,
formatter: 'formatDateTime', formatter: 'formatDateTime',
}, },
{ {
field: 'createTime', field: 'createTime',
title: '创建时间', title: '创建时间',
minWidth: 180,
formatter: 'formatDateTime', formatter: 'formatDateTime',
}, },
{ {
field: 'creatorName', field: 'creatorName',
title: '创建人', title: '创建人',
minWidth: 100,
}, },
{ {
field: 'statusTypeName', field: 'statusTypeName',
title: '商机状态组', title: '商机状态组',
minWidth: 140,
fixed: 'right', fixed: 'right',
}, },
{ {
field: 'statusName', field: 'statusName',
title: '商机阶段', title: '商机阶段',
minWidth: 120,
fixed: 'right', fixed: 'right',
}, },
{ {

View File

@ -1,38 +1,207 @@
<script lang="ts" setup> <script lang="ts" setup>
import { Page } from '@vben/common-ui'; import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { CrmContactApi } from '#/api/crm/contact';
import { Button } from 'ant-design-vue'; import { ref } from 'vue';
import { useRouter } from 'vue-router';
import { Page, useVbenModal } from '@vben/common-ui';
import { downloadFileFromBlobPart } from '@vben/utils';
import { Button, message, Tabs } from 'ant-design-vue';
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import {
deleteContact,
exportContact,
getContactPage,
} from '#/api/crm/contact';
import { DocAlert } from '#/components/doc-alert'; import { DocAlert } from '#/components/doc-alert';
import { $t } from '#/locales';
import { useGridColumns, useGridFormSchema } from './data';
import Form from './modules/form.vue';
const { push } = useRouter();
const sceneType = ref('1');
const [FormModal, formModalApi] = useVbenModal({
connectedComponent: Form,
destroyOnClose: true,
});
/** 刷新表格 */
function onRefresh() {
gridApi.query();
}
/** 导出表格 */
async function handleExport() {
const data = await exportContact(await gridApi.formApi.getValues());
downloadFileFromBlobPart({ fileName: '联系人.xls', source: data });
}
/** 创建联系人 */
function handleCreate() {
formModalApi.setData(null).open();
}
/** 编辑联系人 */
function handleEdit(row: CrmContactApi.Contact) {
formModalApi.setData(row).open();
}
/** 删除联系人 */
async function handleDelete(row: CrmContactApi.Contact) {
const hideLoading = message.loading({
content: $t('ui.actionMessage.deleting', [row.name]),
key: 'action_key_msg',
});
try {
await deleteContact(row.id as number);
message.success({
content: $t('ui.actionMessage.deleteSuccess', [row.name]),
key: 'action_key_msg',
});
onRefresh();
} finally {
hideLoading();
}
}
/** 查看联系人详情 */
function handleDetail(row: CrmContactApi.Contact) {
push({ name: 'CrmContactDetail', params: { id: row.id } });
}
/** 查看客户详情 */
function handleCustomerDetail(row: CrmContactApi.Contact) {
push({ name: 'CrmCustomerDetail', params: { id: row.customerId } });
}
const [Grid, gridApi] = useVbenVxeGrid({
formOptions: {
schema: useGridFormSchema(),
},
gridOptions: {
columns: useGridColumns(),
height: 'auto',
keepSource: true,
proxyConfig: {
ajax: {
query: async ({ page }, formValues) => {
return await getContactPage({
page: page.currentPage,
pageSize: page.pageSize,
sceneType: sceneType.value,
...formValues,
});
},
},
},
rowConfig: {
keyField: 'id',
},
toolbarConfig: {
refresh: { code: 'query' },
search: true,
},
} as VxeTableGridOptions<CrmContactApi.Contact>,
});
function onChangeSceneType(key: number | string) {
sceneType.value = key.toString();
gridApi.query();
}
</script> </script>
<template> <template>
<Page> <Page auto-content-height>
<DocAlert <template #doc>
title="【客户】客户管理、公海客户" <DocAlert
url="https://doc.iocoder.cn/crm/customer/" title="【客户】客户管理、公海客户"
/> url="https://doc.iocoder.cn/crm/customer/"
<DocAlert />
title="【通用】数据权限" <DocAlert
url="https://doc.iocoder.cn/crm/permission/" title="【通用】数据权限"
/> url="https://doc.iocoder.cn/crm/permission/"
<Button />
danger </template>
type="link"
target="_blank" <FormModal @success="onRefresh" />
href="https://github.com/yudaocode/yudao-ui-admin-vue3" <Grid>
> <template #top>
该功能支持 Vue3 + element-plus 版本 <Tabs class="border-none" @change="onChangeSceneType">
</Button> <Tabs.TabPane tab="我负责的" key="1" />
<br /> <Tabs.TabPane tab="我参与的" key="2" />
<Button <Tabs.TabPane tab="下属负责的" key="3" />
type="link" </Tabs>
target="_blank" </template>
href="https://github.com/yudaocode/yudao-ui-admin-vue3/blob/master/src/views/crm/contact/index" <template #toolbar-tools>
> <TableAction
可参考 :actions="[
https://github.com/yudaocode/yudao-ui-admin-vue3/blob/master/src/views/crm/contact/index {
代码pull request 贡献给我们 label: $t('ui.actionTitle.create', ['联系人']),
</Button> type: 'primary',
icon: ACTION_ICON.ADD,
auth: ['crm:contact:create'],
onClick: handleCreate,
},
{
label: $t('ui.actionTitle.export'),
type: 'primary',
icon: ACTION_ICON.DOWNLOAD,
auth: ['crm:contact:export'],
onClick: handleExport,
},
]"
/>
</template>
<template #name="{ row }">
<Button type="link" @click="handleDetail(row)">
{{ row.name }}
</Button>
</template>
<template #customerName="{ row }">
<Button type="link" @click="handleCustomerDetail(row)">
{{ row.customerName }}
</Button>
</template>
<template #parentId="{ row }">
<Button type="link" @click="handleDetail(row)">
{{ row.parentId }}
</Button>
</template>
<template #actions="{ row }">
<TableAction
:actions="[
{
label: $t('common.edit'),
type: 'link',
icon: ACTION_ICON.EDIT,
auth: ['crm:contact:update'],
onClick: handleEdit.bind(null, row),
},
{
label: $t('common.detail'),
type: 'link',
icon: ACTION_ICON.VIEW,
onClick: handleDetail.bind(null, row),
},
{
label: $t('common.delete'),
type: 'link',
danger: true,
icon: ACTION_ICON.DELETE,
auth: ['crm:contact:delete'],
popConfirm: {
title: $t('ui.actionMessage.deleteConfirm', [row.name]),
confirm: handleDelete.bind(null, row),
},
},
]"
/>
</template>
</Grid>
</Page> </Page>
</template> </template>

View File

@ -1,11 +1,9 @@
import type { VbenFormSchema } from '#/adapter/form'; import type { VbenFormSchema } from '#/adapter/form';
import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table'; import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { CrmCustomerApi } from '#/api/crm/customer';
import type { DescriptionItemSchema } from '#/components/description'; import type { DescriptionItemSchema } from '#/components/description';
import { h } from 'vue'; import { h } from 'vue';
import { useAccess } from '@vben/access';
import { formatDateTime } from '@vben/utils'; import { formatDateTime } from '@vben/utils';
import { getAreaTree } from '#/api/system/area'; import { getAreaTree } from '#/api/system/area';
@ -13,8 +11,6 @@ import { getSimpleUserList } from '#/api/system/user';
import { DictTag } from '#/components/dict-tag'; import { DictTag } from '#/components/dict-tag';
import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps } from '#/utils'; import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps } from '#/utils';
const { hasAccessByCodes } = useAccess();
/** 新增/修改的表单 */ /** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] { export function useFormSchema(): VbenFormSchema[] {
return [ return [
@ -158,14 +154,11 @@ export function useGridFormSchema(): VbenFormSchema[] {
} }
/** 列表的字段 */ /** 列表的字段 */
export function useGridColumns<T = CrmCustomerApi.Customer>( export function useGridColumns(): VxeTableGridOptions['columns'] {
onActionClick: OnActionClickFn<T>,
): VxeTableGridOptions['columns'] {
return [ return [
{ {
field: 'name', field: 'name',
title: '客户名称', title: '客户名称',
minWidth: 160,
fixed: 'left', fixed: 'left',
slots: { slots: {
default: 'name', default: 'name',
@ -174,7 +167,6 @@ export function useGridColumns<T = CrmCustomerApi.Customer>(
{ {
field: 'source', field: 'source',
title: '客户来源', title: '客户来源',
minWidth: 100,
cellRender: { cellRender: {
name: 'CellDict', name: 'CellDict',
props: { type: DICT_TYPE.CRM_CUSTOMER_SOURCE }, props: { type: DICT_TYPE.CRM_CUSTOMER_SOURCE },
@ -183,27 +175,22 @@ export function useGridColumns<T = CrmCustomerApi.Customer>(
{ {
field: 'mobile', field: 'mobile',
title: '手机', title: '手机',
minWidth: 120,
}, },
{ {
field: 'telephone', field: 'telephone',
title: '电话', title: '电话',
minWidth: 130,
}, },
{ {
field: 'email', field: 'email',
title: '邮箱', title: '邮箱',
minWidth: 180,
}, },
{ {
field: 'detailAddress', field: 'detailAddress',
title: '地址', title: '地址',
minWidth: 180,
}, },
{ {
field: 'industryId', field: 'industryId',
title: '客户行业', title: '客户行业',
minWidth: 100,
cellRender: { cellRender: {
name: 'CellDict', name: 'CellDict',
props: { type: DICT_TYPE.CRM_CUSTOMER_INDUSTRY }, props: { type: DICT_TYPE.CRM_CUSTOMER_INDUSTRY },
@ -212,7 +199,6 @@ export function useGridColumns<T = CrmCustomerApi.Customer>(
{ {
field: 'level', field: 'level',
title: '客户级别', title: '客户级别',
minWidth: 100,
cellRender: { cellRender: {
name: 'CellDict', name: 'CellDict',
props: { type: DICT_TYPE.CRM_CUSTOMER_LEVEL }, props: { type: DICT_TYPE.CRM_CUSTOMER_LEVEL },
@ -221,61 +207,36 @@ export function useGridColumns<T = CrmCustomerApi.Customer>(
{ {
field: 'ownerUserName', field: 'ownerUserName',
title: '负责人', title: '负责人',
minWidth: 100,
}, },
{ {
field: 'ownerUserDeptName', field: 'ownerUserDeptName',
title: '所属部门', title: '所属部门',
minWidth: 100,
}, },
{ {
field: 'contactNextTime', field: 'contactNextTime',
title: '下次联系时间', title: '下次联系时间',
minWidth: 180,
formatter: 'formatDateTime', formatter: 'formatDateTime',
}, },
{ {
field: 'contactLastTime', field: 'contactLastTime',
title: '最后跟进时间', title: '最后跟进时间',
minWidth: 180,
formatter: 'formatDateTime', formatter: 'formatDateTime',
}, },
{ {
field: 'updateTime', field: 'updateTime',
title: '更新时间', title: '更新时间',
minWidth: 180,
formatter: 'formatDateTime', formatter: 'formatDateTime',
}, },
{ {
field: 'createTime', field: 'createTime',
title: '创建时间', title: '创建时间',
minWidth: 180,
formatter: 'formatDateTime', formatter: 'formatDateTime',
}, },
{ {
field: 'operation',
title: '操作', title: '操作',
width: 130, width: 180,
fixed: 'right', fixed: 'right',
align: 'center', slots: { default: 'actions' },
cellRender: {
attrs: {
nameField: 'name',
nameTitle: '线索',
onClick: onActionClick,
},
name: 'CellOperation',
options: [
{
code: 'edit',
show: hasAccessByCodes(['crm:clue:update']),
},
{
code: 'delete',
show: hasAccessByCodes(['crm:clue:delete']),
},
],
},
}, },
]; ];
} }

View File

@ -1,20 +1,16 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { import type { VxeTableGridOptions } from '#/adapter/vxe-table';
OnActionClickParams,
VxeTableGridOptions,
} from '#/adapter/vxe-table';
import type { CrmCustomerApi } from '#/api/crm/customer'; import type { CrmCustomerApi } from '#/api/crm/customer';
import { ref } from 'vue'; import { ref } from 'vue';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
import { Page, useVbenModal } from '@vben/common-ui'; import { Page, useVbenModal } from '@vben/common-ui';
import { Download, Plus } from '@vben/icons';
import { downloadFileFromBlobPart } from '@vben/utils'; import { downloadFileFromBlobPart } from '@vben/utils';
import { Button, message, Tabs } from 'ant-design-vue'; import { Button, message, Tabs } from 'ant-design-vue';
import { useVbenVxeGrid } from '#/adapter/vxe-table'; import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import { import {
deleteCustomer, deleteCustomer,
exportCustomer, exportCustomer,
@ -40,23 +36,23 @@ function onRefresh() {
} }
/** 导出表格 */ /** 导出表格 */
async function onExport() { async function handleExport() {
const data = await exportCustomer(await gridApi.formApi.getValues()); const data = await exportCustomer(await gridApi.formApi.getValues());
downloadFileFromBlobPart({ fileName: '客户.xls', source: data }); downloadFileFromBlobPart({ fileName: '客户.xls', source: data });
} }
/** 创建客户 */ /** 创建客户 */
function onCreate() { function handleCreate() {
formModalApi.setData(null).open(); formModalApi.setData(null).open();
} }
/** 编辑客户 */ /** 编辑客户 */
function onEdit(row: CrmCustomerApi.Customer) { function handleEdit(row: CrmCustomerApi.Customer) {
formModalApi.setData(row).open(); formModalApi.setData(row).open();
} }
/** 删除客户 */ /** 删除客户 */
async function onDelete(row: CrmCustomerApi.Customer) { async function handleDelete(row: CrmCustomerApi.Customer) {
const hideLoading = message.loading({ const hideLoading = message.loading({
content: $t('ui.actionMessage.deleting', [row.name]), content: $t('ui.actionMessage.deleting', [row.name]),
key: 'action_key_msg', key: 'action_key_msg',
@ -74,33 +70,16 @@ async function onDelete(row: CrmCustomerApi.Customer) {
} }
/** 查看客户详情 */ /** 查看客户详情 */
function onDetail(row: CrmCustomerApi.Customer) { function handleDetail(row: CrmCustomerApi.Customer) {
push({ name: 'CrmCustomerDetail', params: { id: row.id } }); push({ name: 'CrmCustomerDetail', params: { id: row.id } });
} }
/** 表格操作按钮的回调函数 */
function onActionClick({
code,
row,
}: OnActionClickParams<CrmCustomerApi.Customer>) {
switch (code) {
case 'delete': {
onDelete(row);
break;
}
case 'edit': {
onEdit(row);
break;
}
}
}
const [Grid, gridApi] = useVbenVxeGrid({ const [Grid, gridApi] = useVbenVxeGrid({
formOptions: { formOptions: {
schema: useGridFormSchema(), schema: useGridFormSchema(),
}, },
gridOptions: { gridOptions: {
columns: useGridColumns(onActionClick), columns: useGridColumns(),
height: 'auto', height: 'auto',
keepSource: true, keepSource: true,
proxyConfig: { proxyConfig: {
@ -145,7 +124,6 @@ function onChangeSceneType(key: number | string) {
</template> </template>
<FormModal @success="onRefresh" /> <FormModal @success="onRefresh" />
<Grid> <Grid>
<template #top> <template #top>
<Tabs class="border-none" @change="onChangeSceneType"> <Tabs class="border-none" @change="onChangeSceneType">
@ -155,29 +133,60 @@ function onChangeSceneType(key: number | string) {
</Tabs> </Tabs>
</template> </template>
<template #toolbar-tools> <template #toolbar-tools>
<Button <TableAction
type="primary" :actions="[
@click="onCreate" {
v-access:code="['crm:customer:create']" label: $t('ui.actionTitle.create', ['客户']),
> type: 'primary',
<Plus class="size-5" /> icon: ACTION_ICON.ADD,
{{ $t('ui.actionTitle.create', ['客户']) }} auth: ['crm:customer:create'],
</Button> onClick: handleCreate,
<Button },
type="primary" {
class="ml-2" label: $t('ui.actionTitle.export'),
@click="onExport" type: 'primary',
v-access:code="['crm:customer:export']" icon: ACTION_ICON.DOWNLOAD,
> auth: ['crm:customer:export'],
<Download class="size-5" /> onClick: handleExport,
{{ $t('ui.actionTitle.export') }} },
</Button> ]"
/>
</template> </template>
<template #name="{ row }"> <template #name="{ row }">
<Button type="link" @click="onDetail(row)"> <Button type="link" @click="handleDetail(row)">
{{ row.name }} {{ row.name }}
</Button> </Button>
</template> </template>
<template #actions="{ row }">
<TableAction
:actions="[
{
label: $t('common.edit'),
type: 'link',
icon: ACTION_ICON.EDIT,
auth: ['crm:customer:update'],
onClick: handleEdit.bind(null, row),
},
{
label: $t('common.detail'),
type: 'link',
icon: ACTION_ICON.VIEW,
onClick: handleDetail.bind(null, row),
},
{
label: $t('common.delete'),
type: 'link',
danger: true,
icon: ACTION_ICON.DELETE,
auth: ['crm:customer:delete'],
popConfirm: {
title: $t('ui.actionMessage.deleteConfirm', [row.name]),
confirm: handleDelete.bind(null, row),
},
},
]"
/>
</template>
</Grid> </Grid>
</Page> </Page>
</template> </template>