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

View File

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

View File

@ -1,38 +1,207 @@
<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 { $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>
<template>
<Page>
<DocAlert
title="【客户】客户管理、公海客户"
url="https://doc.iocoder.cn/crm/customer/"
/>
<DocAlert
title="【通用】数据权限"
url="https://doc.iocoder.cn/crm/permission/"
/>
<Button
danger
type="link"
target="_blank"
href="https://github.com/yudaocode/yudao-ui-admin-vue3"
>
该功能支持 Vue3 + element-plus 版本
</Button>
<br />
<Button
type="link"
target="_blank"
href="https://github.com/yudaocode/yudao-ui-admin-vue3/blob/master/src/views/crm/contact/index"
>
可参考
https://github.com/yudaocode/yudao-ui-admin-vue3/blob/master/src/views/crm/contact/index
代码pull request 贡献给我们
</Button>
<Page auto-content-height>
<template #doc>
<DocAlert
title="【客户】客户管理、公海客户"
url="https://doc.iocoder.cn/crm/customer/"
/>
<DocAlert
title="【通用】数据权限"
url="https://doc.iocoder.cn/crm/permission/"
/>
</template>
<FormModal @success="onRefresh" />
<Grid>
<template #top>
<Tabs class="border-none" @change="onChangeSceneType">
<Tabs.TabPane tab="我负责的" key="1" />
<Tabs.TabPane tab="我参与的" key="2" />
<Tabs.TabPane tab="下属负责的" key="3" />
</Tabs>
</template>
<template #toolbar-tools>
<TableAction
:actions="[
{
label: $t('ui.actionTitle.create', ['联系人']),
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>
</template>

View File

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

View File

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