feat:【ele】【crm】receivable 迁移的初始化

This commit is contained in:
YunaiV
2025-11-18 10:58:27 +08:00
parent 9680f80735
commit ffd74a749f
19 changed files with 2270 additions and 18 deletions

View File

@@ -47,24 +47,24 @@ const routes: RouteRecordRaw[] = [
// },
// component: () => import('#/views/crm/contract/detail/index.vue'),
// },
// {
// path: 'receivable-plan/detail/:id',
// name: 'CrmReceivablePlanDetail',
// meta: {
// title: '回款计划详情',
// activePath: '/crm/receivable-plan',
// },
// component: () => import('#/views/crm/receivable/plan/detail/index.vue'),
// },
// {
// path: 'receivable/detail/:id',
// name: 'CrmReceivableDetail',
// meta: {
// title: '回款详情',
// activePath: '/crm/receivable',
// },
// component: () => import('#/views/crm/receivable/detail/index.vue'),
// },
{
path: 'receivable-plan/detail/:id',
name: 'CrmReceivablePlanDetail',
meta: {
title: '回款计划详情',
activePath: '/crm/receivable-plan',
},
component: () => import('#/views/crm/receivable/plan/detail/index.vue'),
},
{
path: 'receivable/detail/:id',
name: 'CrmReceivableDetail',
meta: {
title: '回款详情',
activePath: '/crm/receivable',
},
component: () => import('#/views/crm/receivable/detail/index.vue'),
},
// {
// path: 'contact/detail/:id',
// name: 'CrmContactDetail',

View File

@@ -0,0 +1,73 @@
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import { DICT_TYPE } from '@vben/constants';
/** 详情列表的字段 */
export function useDetailListColumns(): VxeTableGridOptions['columns'] {
return [
{
title: '回款编号',
field: 'no',
minWidth: 150,
fixed: 'left',
},
{
title: '客户名称',
field: 'customerName',
minWidth: 150,
},
{
title: '合同编号',
field: 'contract.no',
minWidth: 150,
},
{
title: '回款日期',
field: 'returnTime',
minWidth: 150,
formatter: 'formatDateTime',
},
{
title: '回款金额(元)',
field: 'price',
minWidth: 150,
formatter: 'formatAmount2',
},
{
title: '回款方式',
field: 'returnType',
minWidth: 150,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.CRM_RECEIVABLE_RETURN_TYPE },
},
},
{
title: '负责人',
field: 'ownerUserName',
minWidth: 150,
},
{
title: '备注',
field: 'remark',
minWidth: 150,
},
{
title: '回款状态',
field: 'auditStatus',
minWidth: 100,
fixed: 'right',
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.CRM_AUDIT_STATUS },
},
},
{
title: '操作',
field: 'actions',
width: 130,
fixed: 'right',
slots: { default: 'actions' },
},
];
}

View File

@@ -0,0 +1,144 @@
<!-- 回款列表用于客户合同详情中展示它们关联的回款列表 -->
<script lang="ts" setup>
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { CrmReceivableApi } from '#/api/crm/receivable';
import { useVbenModal } from '@vben/common-ui';
import { ElLoading, ElMessage } from 'element-plus';
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import {
deleteReceivable,
getReceivablePageByCustomer,
} from '#/api/crm/receivable';
import { $t } from '#/locales';
import Form from '../modules/form.vue';
import { useDetailListColumns } from './data';
const props = defineProps<{
contractId?: number; // 合同编号
customerId?: number; // 客户编号
}>();
const [FormModal, formModalApi] = useVbenModal({
connectedComponent: Form,
destroyOnClose: true,
});
/** 刷新表格 */
function handleRefresh() {
gridApi.query();
}
/** 创建回款 */
function handleCreate() {
formModalApi
.setData({
contractId: props.contractId,
customerId: props.customerId,
})
.open();
}
/** 编辑回款 */
function handleEdit(row: CrmReceivableApi.Receivable) {
formModalApi.setData({ receivable: row }).open();
}
/** 删除回款 */
async function handleDelete(row: CrmReceivableApi.Receivable) {
const loadingInstance = ElLoading.service({
text: $t('ui.actionMessage.deleting', [row.no]),
});
try {
await deleteReceivable(row.id!);
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.no]));
handleRefresh();
} finally {
loadingInstance.close();
}
}
const [Grid, gridApi] = useVbenVxeGrid({
gridOptions: {
columns: useDetailListColumns(),
height: 500,
keepSource: true,
proxyConfig: {
ajax: {
query: async ({ page }) => {
const queryParams: CrmReceivableApi.ReceivablePageParam = {
pageNo: page.currentPage,
pageSize: page.pageSize,
};
if (props.customerId && !props.contractId) {
queryParams.customerId = props.customerId;
} else if (props.customerId && props.contractId) {
// 如果是合同的话客户编号也需要带上因为权限基于客户
queryParams.customerId = props.customerId;
queryParams.contractId = props.contractId;
}
return await getReceivablePageByCustomer(queryParams);
},
},
},
rowConfig: {
keyField: 'id',
isHover: true,
},
toolbarConfig: {
refresh: true,
search: true,
},
} as VxeTableGridOptions<CrmReceivableApi.Receivable>,
});
</script>
<template>
<div>
<FormModal @success="handleRefresh" />
<Grid>
<template #toolbar-tools>
<TableAction
:actions="[
{
label: $t('ui.actionTitle.create', ['回款']),
type: 'primary',
icon: ACTION_ICON.ADD,
auth: ['crm:receivable:create'],
onClick: handleCreate,
},
]"
/>
</template>
<template #actions="{ row }">
<TableAction
:actions="[
{
label: $t('common.edit'),
type: 'primary',
link: true,
icon: ACTION_ICON.EDIT,
auth: ['crm:receivable:update'],
onClick: handleEdit.bind(null, row),
ifShow: row.auditStatus === 0,
},
{
label: $t('common.delete'),
type: 'danger',
link: true,
icon: ACTION_ICON.DELETE,
auth: ['crm:receivable:delete'],
popConfirm: {
title: $t('ui.actionMessage.deleteConfirm', [row.no]),
confirm: handleDelete.bind(null, row),
},
},
]"
/>
</template>
</Grid>
</div>
</template>

View File

@@ -0,0 +1 @@
export { default as ReceivableDetailsList } from './detail-list.vue';

View File

@@ -0,0 +1,300 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { useUserStore } from '@vben/stores';
import { getContractSimpleList } from '#/api/crm/contract';
import { getCustomerSimpleList } from '#/api/crm/customer';
import {
getReceivablePlan,
getReceivablePlanSimpleList,
} from '#/api/crm/receivable/plan';
import { getSimpleUserList } from '#/api/system/user';
/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
const userStore = useUserStore();
return [
{
fieldName: 'id',
component: 'Input',
dependencies: {
triggerFields: [''],
show: () => false,
},
},
{
fieldName: 'no',
label: '回款编号',
component: 'Input',
componentProps: {
placeholder: '保存时自动生成',
disabled: true,
},
},
{
fieldName: 'ownerUserId',
label: '负责人',
component: 'ApiSelect',
rules: 'required',
dependencies: {
triggerFields: ['id'],
disabled: (values) => values.id,
},
componentProps: {
api: getSimpleUserList,
labelField: 'nickname',
valueField: 'id',
placeholder: '请选择负责人',
allowClear: true,
},
defaultValue: userStore.userInfo?.id,
},
{
fieldName: 'customerId',
label: '客户名称',
component: 'ApiSelect',
rules: 'required',
componentProps: {
api: getCustomerSimpleList,
labelField: 'name',
valueField: 'id',
placeholder: '请选择客户',
},
dependencies: {
triggerFields: ['id'],
disabled: (values) => values.id,
},
},
{
fieldName: 'contractId',
label: '合同名称',
component: 'Select',
rules: 'required',
dependencies: {
triggerFields: ['customerId'],
disabled: (values) => !values.customerId || values.id,
async componentProps(values) {
if (values.customerId) {
if (!values.id) {
// 特殊:只有在【新增】时,才清空合同编号
values.contractId = undefined;
}
const contracts = await getContractSimpleList(values.customerId);
return {
options: contracts.map((item) => ({
label: item.name,
value: item.id,
})),
placeholder: '请选择合同',
} as any;
}
},
},
},
{
fieldName: 'planId',
label: '回款期数',
component: 'Select',
rules: 'required',
dependencies: {
triggerFields: ['contractId'],
disabled: (values) => !values.contractId,
async componentProps(values) {
if (values.contractId) {
values.planId = undefined;
const plans = await getReceivablePlanSimpleList(
values.customerId,
values.contractId,
);
return {
options: plans.map((item) => ({
label: item.period,
value: item.id,
})),
placeholder: '请选择回款期数',
onChange: async (value: any) => {
const plan = await getReceivablePlan(value);
values.returnTime = plan?.returnTime;
values.price = plan?.price;
values.returnType = plan?.returnType;
},
} as any;
}
},
},
},
{
fieldName: 'returnType',
label: '回款方式',
component: 'Select',
componentProps: {
options: getDictOptions(DICT_TYPE.CRM_RECEIVABLE_RETURN_TYPE, 'number'),
placeholder: '请选择回款方式',
},
},
{
fieldName: 'price',
label: '回款金额',
component: 'InputNumber',
rules: 'required',
componentProps: {
placeholder: '请输入回款金额',
min: 0,
precision: 2,
controlsPosition: 'right',
class: '!w-full',
},
},
{
fieldName: 'returnTime',
label: '回款日期',
component: 'DatePicker',
rules: 'required',
componentProps: {
placeholder: '请选择回款日期',
valueFormat: 'x',
format: 'YYYY-MM-DD',
},
},
{
fieldName: 'remark',
label: '备注',
component: 'Textarea',
componentProps: {
placeholder: '请输入备注',
rows: 4,
},
formItemClass: 'md:col-span-2',
},
];
}
/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
return [
{
fieldName: 'no',
label: '回款编号',
component: 'Input',
componentProps: {
placeholder: '请输入回款编号',
allowClear: true,
},
},
{
fieldName: 'customerId',
label: '客户',
component: 'ApiSelect',
componentProps: {
api: getCustomerSimpleList,
labelField: 'name',
valueField: 'id',
placeholder: '请选择客户',
allowClear: true,
},
},
];
}
export function useGridColumns(): VxeTableGridOptions['columns'] {
return [
{
title: '回款编号',
field: 'no',
minWidth: 160,
fixed: 'left',
slots: { default: 'no' },
},
{
title: '客户名称',
field: 'customerName',
minWidth: 150,
slots: { default: 'customerName' },
},
{
title: '合同编号',
field: 'contract',
minWidth: 160,
slots: { default: 'contractNo' },
},
{
title: '回款日期',
field: 'returnTime',
minWidth: 150,
formatter: 'formatDateTime',
},
{
title: '回款金额(元)',
field: 'price',
minWidth: 150,
formatter: 'formatAmount2',
},
{
title: '回款方式',
field: 'returnType',
minWidth: 150,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.CRM_RECEIVABLE_RETURN_TYPE },
},
},
{
title: '备注',
field: 'remark',
minWidth: 150,
},
{
title: '合同金额(元)',
field: 'contract.totalPrice',
minWidth: 150,
formatter: 'formatAmount2',
},
{
title: '负责人',
field: 'ownerUserName',
minWidth: 150,
},
{
title: '所属部门',
field: 'ownerUserDeptName',
minWidth: 150,
},
{
title: '更新时间',
field: 'updateTime',
minWidth: 150,
formatter: 'formatDateTime',
},
{
title: '创建时间',
field: 'createTime',
minWidth: 150,
formatter: 'formatDateTime',
},
{
title: '创建人',
field: 'creatorName',
minWidth: 150,
},
{
title: '回款状态',
field: 'auditStatus',
minWidth: 100,
fixed: 'right',
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.CRM_AUDIT_STATUS },
},
},
{
title: '操作',
field: 'actions',
minWidth: 200,
fixed: 'right',
slots: { default: 'actions' },
},
];
}

View File

@@ -0,0 +1,105 @@
import type { DescriptionItemSchema } from '#/components/description';
import { h } from 'vue';
import { DICT_TYPE } from '@vben/constants';
import { erpPriceInputFormatter, formatDateTime } from '@vben/utils';
import { DictTag } from '#/components/dict-tag';
/** 详情页的字段 */
export function useDetailSchema(): DescriptionItemSchema[] {
return [
{
field: 'customerName',
label: '客户名称',
},
{
field: 'totalPrice',
label: '合同金额(元)',
render: (val, data) =>
erpPriceInputFormatter(val ?? data?.contract?.totalPrice ?? 0),
},
{
field: 'returnTime',
label: '回款日期',
render: (val) => formatDateTime(val) as string,
},
{
field: 'price',
label: '回款金额(元)',
render: (val) => erpPriceInputFormatter(val),
},
{
field: 'ownerUserName',
label: '负责人',
},
];
}
/** 详情页的基础字段 */
export function useDetailBaseSchema(): DescriptionItemSchema[] {
return [
{
field: 'no',
label: '回款编号',
},
{
field: 'customerName',
label: '客户名称',
},
{
field: 'contract',
label: '合同编号',
render: (val, data) =>
val && data?.contract?.no ? data?.contract?.no : '',
},
{
field: 'returnTime',
label: '回款日期',
render: (val) => formatDateTime(val) as string,
},
{
field: 'price',
label: '回款金额',
render: (val) => erpPriceInputFormatter(val),
},
{
field: 'returnType',
label: '回款方式',
render: (val) =>
h(DictTag, {
type: DICT_TYPE.CRM_RECEIVABLE_RETURN_TYPE,
value: val,
}),
},
{
field: 'remark',
label: '备注',
},
];
}
/** 系统信息字段 */
export function useDetailSystemSchema(): DescriptionItemSchema[] {
return [
{
field: 'ownerUserName',
label: '负责人',
},
{
field: 'creatorName',
label: '创建人',
},
{
field: 'createTime',
label: '创建时间',
render: (val) => formatDateTime(val) as string,
},
{
field: 'updateTime',
label: '更新时间',
render: (val) => formatDateTime(val) as string,
},
];
}

View File

@@ -0,0 +1,133 @@
<script setup lang="ts">
import type { CrmReceivableApi } from '#/api/crm/receivable';
import type { SystemOperateLogApi } from '#/api/system/operate-log';
import { onMounted, ref } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { Page, useVbenModal } from '@vben/common-ui';
import { useTabs } from '@vben/hooks';
import { ElCard, ElTabPane, ElTabs } from 'element-plus';
import { getOperateLogPage } from '#/api/crm/operateLog';
import { BizTypeEnum } from '#/api/crm/permission';
import { getReceivable } from '#/api/crm/receivable';
import { useDescription } from '#/components/description';
import { OperateLog } from '#/components/operate-log';
import { ACTION_ICON, TableAction } from '#/components/table-action';
import { $t } from '#/locales';
import { PermissionList } from '#/views/crm/permission';
import ReceivableForm from '../modules/form.vue';
import { useDetailSchema } from './data';
import Info from './modules/info.vue';
const props = defineProps<{ id?: number }>();
const route = useRoute();
const router = useRouter();
const tabs = useTabs();
const loading = ref(false); // 加载中
const receivableId = ref(0); // 回款编号
const receivable = ref<CrmReceivableApi.Receivable>(
{} as CrmReceivableApi.Receivable,
); // 回款详情
const activeTabName = ref('1'); // 选中 Tab 名
const logList = ref<SystemOperateLogApi.OperateLog[]>([]); // 操作日志
const permissionListRef = ref<InstanceType<typeof PermissionList>>(); // 团队成员列表 Ref
const [Descriptions] = useDescription({
border: false,
column: 4,
class: 'mx-4',
schema: useDetailSchema(),
});
const [FormModal, formModalApi] = useVbenModal({
connectedComponent: ReceivableForm,
destroyOnClose: true,
});
/** 加载回款详情 */
async function loadReceivableDetail() {
loading.value = true;
try {
receivable.value = await getReceivable(receivableId.value);
// 操作日志
const res = await getOperateLogPage({
bizType: BizTypeEnum.CRM_RECEIVABLE,
bizId: receivableId.value,
});
logList.value = res.list;
} finally {
loading.value = false;
}
}
/** 返回列表页 */
function handleBack() {
tabs.closeCurrentTab();
router.push({ name: 'CrmReceivable' });
}
/** 编辑收款 */
function handleEdit() {
formModalApi.setData({ receivable: { id: receivableId.value } }).open();
}
/** 加载数据 */
onMounted(() => {
receivableId.value = Number(props.id || route.params.id);
loadReceivableDetail();
});
</script>
<template>
<Page auto-content-height :title="receivable?.no" :loading="loading">
<FormModal @success="loadReceivableDetail" />
<template #extra>
<TableAction
:actions="[
{
label: '返回',
type: 'default',
icon: 'lucide:arrow-left',
onClick: handleBack,
},
{
label: $t('ui.actionTitle.edit'),
type: 'primary',
icon: ACTION_ICON.EDIT,
auth: ['crm:receivable:update'],
ifShow: permissionListRef?.validateWrite,
onClick: handleEdit,
},
]"
/>
</template>
<ElCard class="min-h-[10%]">
<Descriptions :data="receivable" />
</ElCard>
<ElCard class="mt-4 min-h-[60%]">
<ElTabs v-model:model-value="activeTabName">
<ElTabPane label="详细资料" name="1" :lazy="false">
<Info :receivable="receivable" />
</ElTabPane>
<ElTabPane label="操作日志" name="2" :lazy="false">
<OperateLog :log-list="logList" />
</ElTabPane>
<ElTabPane label="团队成员" name="3" :lazy="false">
<PermissionList
ref="permissionListRef"
:biz-id="receivableId"
:biz-type="BizTypeEnum.CRM_RECEIVABLE"
:show-action="true"
@quit-team="handleBack"
/>
</ElTabPane>
</ElTabs>
</ElCard>
</Page>
</template>

View File

@@ -0,0 +1,37 @@
<script lang="ts" setup>
import type { CrmReceivableApi } from '#/api/crm/receivable';
import { ElDivider } from 'element-plus';
import { useDescription } from '#/components/description';
import { useDetailBaseSchema, useDetailSystemSchema } from '../data';
defineProps<{
receivable: CrmReceivableApi.Receivable; // 收款信息
}>();
const [BaseDescriptions] = useDescription({
title: '基本信息',
border: false,
column: 4,
class: 'mx-4',
schema: useDetailBaseSchema(),
});
const [SystemDescriptions] = useDescription({
title: '系统信息',
border: false,
column: 3,
class: 'mx-4',
schema: useDetailSystemSchema(),
});
</script>
<template>
<div class="p-4">
<BaseDescriptions :data="receivable" />
<ElDivider />
<SystemDescriptions :data="receivable" />
</div>
</template>

View File

@@ -0,0 +1,253 @@
<script lang="ts" setup>
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { CrmReceivableApi } from '#/api/crm/receivable';
import { ref } from 'vue';
import { useRouter } from 'vue-router';
import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
import { downloadFileFromBlobPart } from '@vben/utils';
import { ElButton, ElLoading, ElMessage, ElTabPane, ElTabs } from 'element-plus';
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import {
deleteReceivable,
exportReceivable,
getReceivablePage,
submitReceivable,
} from '#/api/crm/receivable';
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 handleRefresh() {
gridApi.query();
}
/** 处理场景类型的切换 */
function handleChangeSceneType(key: number | string) {
sceneType.value = key.toString();
gridApi.query();
}
/** 导出表格 */
async function handleExport() {
const formValues = await gridApi.formApi.getValues();
const data = await exportReceivable({
sceneType: sceneType.value,
...formValues,
});
downloadFileFromBlobPart({ fileName: '回款.xls', source: data });
}
/** 创建回款 */
function handleCreate() {
formModalApi.setData(null).open();
}
/** 编辑回款 */
function handleEdit(row: CrmReceivableApi.Receivable) {
formModalApi.setData({ receivable: row }).open();
}
/** 删除回款 */
async function handleDelete(row: CrmReceivableApi.Receivable) {
const loadingInstance = ElLoading.service({
text: $t('ui.actionMessage.deleting', [row.no]),
});
try {
await deleteReceivable(row.id!);
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.no]));
handleRefresh();
} finally {
loadingInstance.close();
}
}
/** 提交审核 */
async function handleSubmit(row: CrmReceivableApi.Receivable) {
const loadingInstance = ElLoading.service({
text: '提交审核中...',
});
try {
await submitReceivable(row.id!);
ElMessage.success('提交审核成功');
handleRefresh();
} finally {
loadingInstance.close();
}
}
/** 查看回款详情 */
function handleDetail(row: CrmReceivableApi.Receivable) {
push({ name: 'CrmReceivableDetail', params: { id: row.id } });
}
/** 查看客户详情 */
function handleCustomerDetail(row: CrmReceivableApi.Receivable) {
push({ name: 'CrmCustomerDetail', params: { id: row.customerId } });
}
/** 查看合同详情 */
function handleContractDetail(row: CrmReceivableApi.Receivable) {
push({ name: 'CrmContractDetail', params: { id: row.contractId } });
}
/** 查看审批详情 */
function handleProcessDetail(row: CrmReceivableApi.Receivable) {
push({
name: 'BpmProcessInstanceDetail',
query: { id: row.processInstanceId },
});
}
const [Grid, gridApi] = useVbenVxeGrid({
formOptions: {
schema: useGridFormSchema(),
},
gridOptions: {
columns: useGridColumns(),
height: 'auto',
keepSource: true,
proxyConfig: {
ajax: {
query: async ({ page }, formValues) => {
return await getReceivablePage({
pageNo: page.currentPage,
pageSize: page.pageSize,
sceneType: sceneType.value,
...formValues,
});
},
},
},
rowConfig: {
keyField: 'id',
isHover: true,
},
toolbarConfig: {
refresh: true,
search: true,
},
} as VxeTableGridOptions<CrmReceivableApi.Receivable>,
});
</script>
<template>
<Page auto-content-height>
<template #doc>
<DocAlert
title="【回款】回款管理、回款计划"
url="https://doc.iocoder.cn/crm/receivable/"
/>
<DocAlert
title="【通用】数据权限"
url="https://doc.iocoder.cn/crm/permission/"
/>
</template>
<FormModal @success="handleRefresh" />
<Grid>
<template #toolbar-actions>
<ElTabs v-model:model-value="sceneType" class="w-full" @tab-change="handleChangeSceneType">
<ElTabPane label="我负责的" name="1" />
<ElTabPane label="我参与的" name="2" />
<ElTabPane label="下属负责的" name="3" />
</ElTabs>
</template>
<template #toolbar-tools>
<TableAction
:actions="[
{
label: $t('ui.actionTitle.create', ['回款']),
type: 'primary',
icon: ACTION_ICON.ADD,
auth: ['crm:receivable:create'],
onClick: handleCreate,
},
{
label: $t('ui.actionTitle.export'),
type: 'primary',
icon: ACTION_ICON.DOWNLOAD,
auth: ['crm:receivable:export'],
onClick: handleExport,
},
]"
/>
</template>
<template #no="{ row }">
<ElButton type="primary" link @click="handleDetail(row)">
{{ row.no }}
</ElButton>
</template>
<template #customerName="{ row }">
<ElButton type="primary" link @click="handleCustomerDetail(row)">
{{ row.customerName }}
</ElButton>
</template>
<template #contractNo="{ row }">
<ElButton
v-if="row.contract"
type="primary"
link
@click="handleContractDetail(row)"
>
{{ row.contract.no }}
</ElButton>
<span v-else>--</span>
</template>
<template #actions="{ row }">
<TableAction
:actions="[
{
label: $t('common.edit'),
type: 'primary',
link: true,
icon: ACTION_ICON.EDIT,
auth: ['crm:receivable:update'],
onClick: handleEdit.bind(null, row),
},
{
label: '提交审核',
type: 'primary',
link: true,
auth: ['crm:receivable:update'],
onClick: handleSubmit.bind(null, row),
ifShow: row.auditStatus === 0,
},
{
label: '查看审批',
type: 'primary',
link: true,
auth: ['crm:receivable:update'],
onClick: handleProcessDetail.bind(null, row),
ifShow: row.auditStatus !== 0,
},
{
label: $t('common.delete'),
type: 'danger',
link: true,
icon: ACTION_ICON.DELETE,
auth: ['crm:receivable:delete'],
popConfirm: {
title: $t('ui.actionMessage.deleteConfirm', [row.no]),
confirm: handleDelete.bind(null, row),
},
},
]"
/>
</template>
</Grid>
</Page>
</template>

View File

@@ -0,0 +1,102 @@
<script lang="ts" setup>
import type { CrmReceivableApi } from '#/api/crm/receivable';
import { computed, ref } from 'vue';
import { useVbenForm, useVbenModal } from '@vben/common-ui';
import { ElMessage } from 'element-plus';
import {
createReceivable,
getReceivable,
updateReceivable,
} from '#/api/crm/receivable';
import { $t } from '#/locales';
import { useFormSchema } from '../data';
const emit = defineEmits(['success']);
const formData = ref<CrmReceivableApi.Receivable>();
const getTitle = computed(() => {
return formData.value?.id
? $t('ui.actionTitle.edit', ['回款'])
: $t('ui.actionTitle.create', ['回款']);
});
const [Form, formApi] = useVbenForm({
commonConfig: {
componentProps: {
class: 'w-full',
},
},
wrapperClass: 'grid-cols-2',
layout: 'horizontal',
schema: useFormSchema(),
showDefaultActions: false,
});
const [Modal, modalApi] = useVbenModal({
async onConfirm() {
const { valid } = await formApi.validate();
if (!valid) {
return;
}
modalApi.lock();
// 提交表单
const data = (await formApi.getValues()) as CrmReceivableApi.Receivable;
try {
await (formData.value?.id
? updateReceivable(data)
: createReceivable(data));
// 关闭并提示
await modalApi.close();
emit('success');
ElMessage.success($t('ui.actionMessage.operationSuccess'));
} finally {
modalApi.unlock();
}
},
async onOpenChange(isOpen: boolean) {
if (!isOpen) {
formData.value = undefined;
return;
}
// 加载数据
const data = modalApi.getData();
if (!data) {
return;
}
const { receivable, plan } = data;
modalApi.lock();
try {
if (receivable) {
formData.value = await getReceivable(receivable.id!);
} else if (plan) {
formData.value = plan.id
? {
planId: plan.id,
price: plan.price,
returnType: plan.returnType,
customerId: plan.customerId,
contractId: plan.contractId,
}
: ({
customerId: plan.customerId,
contractId: plan.contractId,
} as any);
}
// 设置到 values
await formApi.setValues(formData.value as any);
} finally {
modalApi.unlock();
}
},
});
</script>
<template>
<Modal :title="getTitle" class="w-2/5">
<Form class="mx-4" />
</Modal>
</template>

View File

@@ -0,0 +1,62 @@
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
/** 详情列表的字段 */
export function useDetailListColumns(): VxeTableGridOptions['columns'] {
return [
{
title: '客户名称',
field: 'customerName',
minWidth: 150,
},
{
title: '合同编号',
field: 'contractNo',
minWidth: 150,
},
{
title: '期数',
field: 'period',
minWidth: 150,
},
{
title: '计划回款(元)',
field: 'price',
minWidth: 150,
formatter: 'formatAmount2',
},
{
title: '计划回款日期',
field: 'returnTime',
minWidth: 150,
formatter: 'formatDateTime',
},
{
title: '提前几天提醒',
field: 'remindDays',
minWidth: 150,
},
{
title: '提醒日期',
field: 'remindTime',
minWidth: 150,
formatter: 'formatDateTime',
},
{
title: '负责人',
field: 'ownerUserName',
minWidth: 150,
},
{
title: '备注',
field: 'remark',
minWidth: 150,
},
{
title: '操作',
field: 'actions',
width: 240,
fixed: 'right',
slots: { default: 'actions' },
},
];
}

View File

@@ -0,0 +1,147 @@
<!-- 回款计划列表用于客户合同详情中展示它们关联的回款计划列表 -->
<script lang="ts" setup>
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { CrmReceivablePlanApi } from '#/api/crm/receivable/plan';
import { useVbenModal } from '@vben/common-ui';
import { ElLoading, ElMessage } from 'element-plus';
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import {
deleteReceivablePlan,
getReceivablePlanPageByCustomer,
} from '#/api/crm/receivable/plan';
import { $t } from '#/locales';
import Form from '../modules/form.vue';
import { useDetailListColumns } from './data';
const props = defineProps<{
contractId?: number; // 合同编号
customerId?: number; // 客户编号
}>();
const [FormModal, formModalApi] = useVbenModal({
connectedComponent: Form,
destroyOnClose: true,
});
/** 刷新表格 */
function handleRefresh() {
gridApi.query();
}
/** 创建回款计划 */
function handleCreate() {
formModalApi
.setData({
contractId: props.contractId,
customerId: props.customerId,
})
.open();
}
/** 编辑回款计划 */
function handleEdit(row: CrmReceivablePlanApi.Plan) {
formModalApi.setData({ receivablePlan: row }).open();
}
/** 删除回款计划 */
async function handleDelete(row: CrmReceivablePlanApi.Plan) {
const loadingInstance = ElLoading.service({
text: $t('ui.actionMessage.deleting', [`${row.period}`]),
});
try {
await deleteReceivablePlan(row.id!);
ElMessage.success(
$t('ui.actionMessage.deleteSuccess', [`${row.period}`]),
);
handleRefresh();
} finally {
loadingInstance.close();
}
}
const [Grid, gridApi] = useVbenVxeGrid({
gridOptions: {
columns: useDetailListColumns(),
height: 500,
keepSource: true,
proxyConfig: {
ajax: {
query: async ({ page }) => {
const queryParams: CrmReceivablePlanApi.PlanPageParam = {
pageNo: page.currentPage,
pageSize: page.pageSize,
};
if (props.customerId && !props.contractId) {
queryParams.customerId = props.customerId;
} else if (props.customerId && props.contractId) {
// 如果是合同的话客户编号也需要带上因为权限基于客户
queryParams.customerId = props.customerId;
queryParams.contractId = props.contractId;
}
return await getReceivablePlanPageByCustomer(queryParams);
},
},
},
rowConfig: {
keyField: 'id',
isHover: true,
},
toolbarConfig: {
refresh: true,
search: true,
},
} as VxeTableGridOptions<CrmReceivablePlanApi.Plan>,
});
</script>
<template>
<div>
<FormModal @success="handleRefresh" />
<Grid>
<template #toolbar-tools>
<TableAction
:actions="[
{
label: $t('ui.actionTitle.create', ['回款计划']),
type: 'primary',
icon: ACTION_ICON.ADD,
auth: ['crm:receivable-plan:create'],
onClick: handleCreate,
},
]"
/>
</template>
<template #actions="{ row }">
<TableAction
:actions="[
{
label: $t('common.edit'),
type: 'primary',
link: true,
icon: ACTION_ICON.EDIT,
auth: ['crm:receivable-plan:update'],
onClick: handleEdit.bind(null, row),
},
{
label: $t('common.delete'),
type: 'danger',
link: true,
icon: ACTION_ICON.DELETE,
auth: ['crm:receivable-plan:delete'],
popConfirm: {
title: $t('ui.actionMessage.deleteConfirm', [
`第${row.period}期`,
]),
confirm: handleDelete.bind(null, row),
},
},
]"
/>
</template>
</Grid>
</div>
</template>

View File

@@ -0,0 +1,2 @@
export { default as ReceivablePlanDetailsInfo } from '../detail/modules/info.vue';
export { default as ReceivablePlanDetailsList } from './detail-list.vue';

View File

@@ -0,0 +1,288 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { useUserStore } from '@vben/stores';
import { erpPriceInputFormatter } from '@vben/utils';
import { getContractSimpleList } from '#/api/crm/contract';
import { getCustomerSimpleList } from '#/api/crm/customer';
import { getSimpleUserList } from '#/api/system/user';
/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
const userStore = useUserStore();
return [
{
fieldName: 'period',
label: '期数',
component: 'Input',
componentProps: {
placeholder: '保存时自动生成',
disabled: true,
},
},
{
fieldName: 'ownerUserId',
label: '负责人',
component: 'ApiSelect',
componentProps: {
api: getSimpleUserList,
labelField: 'nickname',
valueField: 'id',
},
dependencies: {
triggerFields: ['id'],
disabled: (values) => values.id,
},
defaultValue: userStore.userInfo?.id,
rules: 'required',
},
{
fieldName: 'customerId',
label: '客户',
component: 'ApiSelect',
rules: 'required',
componentProps: {
api: getCustomerSimpleList,
labelField: 'name',
valueField: 'id',
placeholder: '请选择客户',
allowClear: true,
},
},
{
fieldName: 'contractId',
label: '合同',
component: 'Select',
rules: 'required',
componentProps: {
options: [],
placeholder: '请选择合同',
allowClear: true,
},
dependencies: {
triggerFields: ['customerId'],
disabled: (values) => !values.customerId,
async componentProps(values) {
if (!values.customerId) {
return {
options: [],
placeholder: '请选择客户',
};
}
const res = await getContractSimpleList(values.customerId);
return {
options: res.map((item) => ({
label: item.name,
value: item.id,
})),
placeholder: '请选择合同',
onChange: (value: number) => {
const contract = res.find((item) => item.id === value);
if (contract) {
values.price =
contract.totalPrice - contract.totalReceivablePrice;
}
},
};
},
},
},
{
fieldName: 'price',
label: '计划回款金额',
component: 'InputNumber',
rules: 'required',
componentProps: {
placeholder: '请输入计划回款金额',
min: 0,
precision: 2,
controlsPosition: 'right',
class: '!w-full',
},
},
{
fieldName: 'returnTime',
label: '计划回款日期',
component: 'DatePicker',
rules: 'required',
componentProps: {
placeholder: '请选择计划回款日期',
valueFormat: 'x',
format: 'YYYY-MM-DD',
},
defaultValue: new Date(),
},
{
fieldName: 'remindDays',
label: '提前几天提醒',
component: 'InputNumber',
componentProps: {
placeholder: '请输入提前几天提醒',
min: 0,
controlsPosition: 'right',
class: '!w-full',
},
},
{
fieldName: 'returnType',
label: '回款方式',
component: 'Select',
componentProps: {
options: getDictOptions(DICT_TYPE.CRM_RECEIVABLE_RETURN_TYPE, 'number'),
placeholder: '请选择回款方式',
},
},
{
fieldName: 'remark',
label: '备注',
component: 'Textarea',
componentProps: {
placeholder: '请输入备注',
rows: 4,
},
formItemClass: 'md:col-span-2',
},
];
}
/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
return [
{
fieldName: 'customerId',
label: '客户',
component: 'ApiSelect',
componentProps: {
api: getCustomerSimpleList,
labelField: 'name',
valueField: 'id',
placeholder: '请选择客户',
allowClear: true,
},
},
{
fieldName: 'contractNo',
label: '合同编号',
component: 'Input',
componentProps: {
placeholder: '请输入合同编号',
allowClear: true,
},
},
];
}
export function useGridColumns(): VxeTableGridOptions['columns'] {
return [
{
title: '客户名称',
field: 'customerName',
minWidth: 150,
fixed: 'left',
slots: { default: 'customerName' },
},
{
title: '合同编号',
field: 'contractNo',
minWidth: 200,
},
{
title: '期数',
field: 'period',
minWidth: 150,
slots: { default: 'period' },
},
{
title: '计划回款金额(元)',
field: 'price',
minWidth: 160,
formatter: 'formatAmount2',
},
{
title: '计划回款日期',
field: 'returnTime',
minWidth: 180,
formatter: 'formatDateTime',
},
{
title: '提前几天提醒',
field: 'remindDays',
minWidth: 150,
},
{
title: '提醒日期',
field: 'remindTime',
minWidth: 180,
formatter: 'formatDateTime',
},
{
title: '回款方式',
field: 'returnType',
minWidth: 130,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.CRM_RECEIVABLE_RETURN_TYPE },
},
},
{
title: '备注',
field: 'remark',
minWidth: 120,
},
{
title: '负责人',
field: 'ownerUserName',
minWidth: 120,
},
{
title: '实际回款金额(元)',
field: 'receivable.price',
minWidth: 160,
formatter: 'formatAmount2',
},
{
title: '实际回款日期',
field: 'receivable.returnTime',
minWidth: 180,
formatter: 'formatDateTime',
},
{
title: '未回款金额(元)',
field: 'unpaidPrice',
minWidth: 160,
formatter: ({ row }) => {
if (row.receivable) {
return erpPriceInputFormatter(row.price - row.receivable.price);
}
return erpPriceInputFormatter(row.price);
},
},
{
title: '更新时间',
field: 'updateTime',
minWidth: 180,
formatter: 'formatDateTime',
},
{
title: '创建时间',
field: 'createTime',
minWidth: 180,
formatter: 'formatDateTime',
},
{
title: '创建人',
field: 'creatorName',
minWidth: 100,
},
{
title: '操作',
field: 'actions',
width: 220,
fixed: 'right',
slots: { default: 'actions' },
},
];
}

View File

@@ -0,0 +1,124 @@
import type { DescriptionItemSchema } from '#/components/description';
import { h } from 'vue';
import { DICT_TYPE } from '@vben/constants';
import { erpPriceInputFormatter, formatDateTime } from '@vben/utils';
import { DictTag } from '#/components/dict-tag';
/** 详情页的字段 */
export function useDetailSchema(): DescriptionItemSchema[] {
return [
{
field: 'customerName',
label: '客户名称',
},
{
field: 'contractNo',
label: '合同编号',
},
{
field: 'price',
label: '计划回款金额',
render: (val) => erpPriceInputFormatter(val),
},
{
field: 'returnTime',
label: '计划回款日期',
render: (val) => formatDateTime(val) as string,
},
{
field: 'receivable',
label: '实际回款金额',
render: (val) => erpPriceInputFormatter(val?.price ?? 0),
},
];
}
/** 详情页的基础字段 */
export function useDetailBaseSchema(): DescriptionItemSchema[] {
return [
{
field: 'period',
label: '期数',
},
{
field: 'customerName',
label: '客户名称',
},
{
field: 'contractNo',
label: '合同编号',
},
{
field: 'returnTime',
label: '计划回款日期',
render: (val) => formatDateTime(val) as string,
},
{
field: 'price',
label: '计划回款金额',
render: (val) => erpPriceInputFormatter(val),
},
{
field: 'returnType',
label: '计划回款方式',
render: (val) =>
h(DictTag, {
type: DICT_TYPE.CRM_RECEIVABLE_RETURN_TYPE,
value: val,
}),
},
{
field: 'remindDays',
label: '提前几天提醒',
},
{
field: 'receivable',
label: '实际回款金额',
render: (val) => erpPriceInputFormatter(val ?? 0),
},
{
field: 'receivableRemain',
label: '未回款金额',
render: (val, data) => {
const paid = data?.receivable?.price ?? 0;
return erpPriceInputFormatter(Math.max(val - paid, 0));
},
},
{
field: 'receivable.returnTime',
label: '实际回款日期',
render: (val) => formatDateTime(val) as string,
},
{
field: 'remark',
label: '备注',
},
];
}
/** 系统信息字段 */
export function useDetailSystemSchema(): DescriptionItemSchema[] {
return [
{
field: 'ownerUserName',
label: '负责人',
},
{
field: 'creatorName',
label: '创建人',
},
{
field: 'createTime',
label: '创建时间',
render: (val) => formatDateTime(val) as string,
},
{
field: 'updateTime',
label: '更新时间',
render: (val) => formatDateTime(val) as string,
},
];
}

View File

@@ -0,0 +1,138 @@
<script setup lang="ts">
import type { CrmReceivablePlanApi } from '#/api/crm/receivable/plan';
import type { SystemOperateLogApi } from '#/api/system/operate-log';
import { onMounted, ref } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { Page, useVbenModal } from '@vben/common-ui';
import { useTabs } from '@vben/hooks';
import { ElCard, ElTabPane, ElTabs } from 'element-plus';
import { ACTION_ICON, TableAction } from '#/adapter/vxe-table';
import { getOperateLogPage } from '#/api/crm/operateLog';
import { BizTypeEnum } from '#/api/crm/permission';
import { getReceivablePlan } from '#/api/crm/receivable/plan';
import { useDescription } from '#/components/description';
import { OperateLog } from '#/components/operate-log';
import { $t } from '#/locales';
import { PermissionList } from '#/views/crm/permission';
import { ReceivablePlanDetailsInfo } from '#/views/crm/receivable/plan/components';
import ReceivablePlanForm from '../modules/form.vue';
import { useDetailSchema } from './data';
const route = useRoute();
const router = useRouter();
const tabs = useTabs();
const loading = ref(false); // 加载中
const receivablePlanId = ref(0); // 回款计划编号
const receivablePlan = ref<CrmReceivablePlanApi.Plan>(
{} as CrmReceivablePlanApi.Plan,
);
const activeTabName = ref('1'); // 选中 Tab 名
const logList = ref<SystemOperateLogApi.OperateLog[]>([]); // 操作日志
const permissionListRef = ref<InstanceType<typeof PermissionList>>(); // 团队成员列表 Ref
// 校验编辑权限
const validateWrite = () => permissionListRef.value?.validateWrite;
const [Descriptions] = useDescription({
border: false,
column: 4,
class: 'mx-4',
schema: useDetailSchema(),
});
const [FormModal, formModalApi] = useVbenModal({
connectedComponent: ReceivablePlanForm,
destroyOnClose: true,
});
/** 加载回款计划详情 */
async function getReceivablePlanDetail() {
loading.value = true;
try {
receivablePlan.value = await getReceivablePlan(receivablePlanId.value);
// 操作日志
const res = await getOperateLogPage({
bizType: BizTypeEnum.CRM_RECEIVABLE_PLAN,
bizId: receivablePlanId.value,
});
logList.value = res.list;
} finally {
loading.value = false;
}
}
/** 返回列表页 */
function handleBack() {
tabs.closeCurrentTab();
router.push({ name: 'CrmReceivablePlan' });
}
/** 编辑收款 */
function handleEdit() {
formModalApi.setData({ id: receivablePlanId.value }).open();
}
/** 加载数据 */
onMounted(() => {
receivablePlanId.value = Number(route.params.id);
getReceivablePlanDetail();
});
</script>
<template>
<Page
auto-content-height
:title="`第 ${receivablePlan?.period} 期`"
:loading="loading"
>
<FormModal @success="getReceivablePlanDetail" />
<template #extra>
<TableAction
:actions="[
{
label: '返回',
type: 'default',
icon: 'lucide:arrow-left',
onClick: handleBack,
},
{
label: $t('ui.actionTitle.edit'),
type: 'primary',
icon: ACTION_ICON.EDIT,
disabled: !validateWrite(),
onClick: handleEdit,
auth: ['crm:receivable-plan:update'],
},
]"
/>
</template>
<ElCard class="min-h-[10%]">
<Descriptions :data="receivablePlan" />
</ElCard>
<ElCard class="mt-4 min-h-[60%]">
<ElTabs v-model:model-value="activeTabName">
<ElTabPane label="详细资料" name="1" :lazy="false">
<ReceivablePlanDetailsInfo :receivable-plan="receivablePlan" />
</ElTabPane>
<ElTabPane label="操作日志" name="2" :lazy="false">
<OperateLog :log-list="logList" />
</ElTabPane>
<ElTabPane label="团队成员" name="3" :lazy="false">
<PermissionList
ref="permissionListRef"
:biz-id="receivablePlanId"
:biz-type="BizTypeEnum.CRM_RECEIVABLE_PLAN"
:show-action="true"
@quit-team="handleBack"
/>
</ElTabPane>
</ElTabs>
</ElCard>
</Page>
</template>

View File

@@ -0,0 +1,37 @@
<script lang="ts" setup>
import type { CrmReceivablePlanApi } from '#/api/crm/receivable/plan';
import { ElDivider } from 'element-plus';
import { useDescription } from '#/components/description';
import { useDetailBaseSchema, useDetailSystemSchema } from '../data';
defineProps<{
receivablePlan: CrmReceivablePlanApi.Plan; // 收款计划信息
}>();
const [BaseDescriptions] = useDescription({
title: '基本信息',
border: false,
column: 4,
class: 'mx-4',
schema: useDetailBaseSchema(),
});
const [SystemDescriptions] = useDescription({
title: '系统信息',
border: false,
column: 3,
class: 'mx-4',
schema: useDetailSystemSchema(),
});
</script>
<template>
<div class="p-4">
<BaseDescriptions :data="receivablePlan" />
<ElDivider />
<SystemDescriptions :data="receivablePlan" />
</div>
</template>

View File

@@ -0,0 +1,218 @@
<script lang="ts" setup>
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { CrmReceivablePlanApi } from '#/api/crm/receivable/plan';
import { ref } from 'vue';
import { useRouter } from 'vue-router';
import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
import { downloadFileFromBlobPart } from '@vben/utils';
import { ElButton, ElLoading, ElMessage, ElTabPane, ElTabs } from 'element-plus';
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import {
deleteReceivablePlan,
exportReceivablePlan,
getReceivablePlanPage,
} from '#/api/crm/receivable/plan';
import { $t } from '#/locales';
import ReceivableForm from '../modules/form.vue';
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,
});
const [ReceivableFormModal, receivableFormModalApi] = useVbenModal({
connectedComponent: ReceivableForm,
destroyOnClose: true,
});
/** 刷新表格 */
function handleRefresh() {
gridApi.query();
}
/** 处理场景类型的切换 */
function handleChangeSceneType(key: number | string) {
sceneType.value = key.toString();
gridApi.query();
}
/** 导出表格 */
async function handleExport() {
const formValues = await gridApi.formApi.getValues();
const data = await exportReceivablePlan({
sceneType: sceneType.value,
...formValues,
});
downloadFileFromBlobPart({ fileName: '回款计划.xls', source: data });
}
/** 创建回款计划 */
function handleCreate() {
formModalApi.setData(null).open();
}
/** 编辑回款计划 */
function handleEdit(row: CrmReceivablePlanApi.Plan) {
formModalApi.setData(row).open();
}
/** 删除回款计划 */
async function handleDelete(row: CrmReceivablePlanApi.Plan) {
const loadingInstance = ElLoading.service({
text: $t('ui.actionMessage.deleting', [row.period]),
});
try {
await deleteReceivablePlan(row.id!);
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.period]));
handleRefresh();
} finally {
loadingInstance.close();
}
}
/** 创建回款计划 */
function handleCreateReceivable(row: CrmReceivablePlanApi.Plan) {
receivableFormModalApi.setData({ plan: row }).open();
}
/** 查看回款计划详情 */
function handleDetail(row: CrmReceivablePlanApi.Plan) {
push({ name: 'CrmReceivablePlanDetail', params: { id: row.id } });
}
/** 查看客户详情 */
function handleCustomerDetail(row: CrmReceivablePlanApi.Plan) {
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 getReceivablePlanPage({
pageNo: page.currentPage,
pageSize: page.pageSize,
sceneType: sceneType.value,
...formValues,
});
},
},
},
rowConfig: {
keyField: 'id',
isHover: true,
},
toolbarConfig: {
refresh: true,
search: true,
},
} as VxeTableGridOptions<CrmReceivablePlanApi.Plan>,
});
</script>
<template>
<Page auto-content-height>
<template #doc>
<DocAlert
title="【回款】回款管理、回款计划"
url="https://doc.iocoder.cn/crm/receivable/"
/>
<DocAlert
title="【通用】数据权限"
url="https://doc.iocoder.cn/crm/permission/"
/>
</template>
<FormModal @success="handleRefresh" />
<ReceivableFormModal @success="handleRefresh" />
<Grid>
<template #toolbar-actions>
<ElTabs v-model:model-value="sceneType" class="w-full" @tab-change="handleChangeSceneType">
<ElTabPane label="我负责的" name="1" />
<ElTabPane label="下属负责的" name="3" />
</ElTabs>
</template>
<template #toolbar-tools>
<TableAction
:actions="[
{
label: $t('ui.actionTitle.create', ['回款计划']),
type: 'primary',
icon: ACTION_ICON.ADD,
auth: ['crm:receivable-plan:create'],
onClick: handleCreate,
},
{
label: $t('ui.actionTitle.export'),
type: 'primary',
icon: ACTION_ICON.DOWNLOAD,
auth: ['crm:receivable-plan:export'],
onClick: handleExport,
},
]"
/>
</template>
<template #customerName="{ row }">
<ElButton type="primary" link @click="handleCustomerDetail(row)">
{{ row.customerName }}
</ElButton>
</template>
<template #period="{ row }">
<ElButton type="primary" link @click="handleDetail(row)">
{{ row.period }}
</ElButton>
</template>
<template #actions="{ row }">
<TableAction
:actions="[
{
label: $t('ui.actionTitle.create', ['回款']),
type: 'primary',
link: true,
icon: ACTION_ICON.ADD,
auth: ['crm:receivable:create'],
onClick: handleCreateReceivable.bind(null, row),
ifShow: !row.receivableId,
},
{
label: $t('common.edit'),
type: 'primary',
link: true,
icon: ACTION_ICON.EDIT,
auth: ['crm:receivable-plan:update'],
onClick: handleEdit.bind(null, row),
},
{
label: $t('common.delete'),
type: 'danger',
link: true,
icon: ACTION_ICON.DELETE,
auth: ['crm:receivable-plan:delete'],
popConfirm: {
title: $t('ui.actionMessage.deleteConfirm', [row.period]),
confirm: handleDelete.bind(null, row),
},
},
]"
/>
</template>
</Grid>
</Page>
</template>

View File

@@ -0,0 +1,88 @@
<script lang="ts" setup>
import type { CrmReceivablePlanApi } from '#/api/crm/receivable/plan';
import { computed, ref } from 'vue';
import { useVbenForm, useVbenModal } from '@vben/common-ui';
import { ElMessage } from 'element-plus';
import {
createReceivablePlan,
getReceivablePlan,
updateReceivablePlan,
} from '#/api/crm/receivable/plan';
import { $t } from '#/locales';
import { useFormSchema } from '../data';
const emit = defineEmits(['success']);
const formData = ref<CrmReceivablePlanApi.Plan>();
const getTitle = computed(() => {
return formData.value?.id
? $t('ui.actionTitle.edit', ['回款计划'])
: $t('ui.actionTitle.create', ['回款计划']);
});
const [Form, formApi] = useVbenForm({
commonConfig: {
componentProps: {
class: 'w-full',
},
},
wrapperClass: 'grid-cols-2',
layout: 'horizontal',
schema: useFormSchema(),
showDefaultActions: false,
});
const [Modal, modalApi] = useVbenModal({
async onConfirm() {
const { valid } = await formApi.validate();
if (!valid) {
return;
}
modalApi.lock();
// 提交表单
const data = (await formApi.getValues()) as CrmReceivablePlanApi.Plan;
try {
await (formData.value?.id
? updateReceivablePlan(data)
: createReceivablePlan(data));
// 关闭并提示
await modalApi.close();
emit('success');
ElMessage.success($t('ui.actionMessage.operationSuccess'));
} finally {
modalApi.unlock();
}
},
async onOpenChange(isOpen: boolean) {
if (!isOpen) {
formData.value = undefined;
return;
}
// 加载数据
const data = modalApi.getData<CrmReceivablePlanApi.Plan>();
if (!data || !data.id) {
// 设置到 values
await formApi.setValues(data);
return;
}
modalApi.lock();
try {
formData.value = await getReceivablePlan(data.id);
// 设置到 values
await formApi.setValues(formData.value);
} finally {
modalApi.unlock();
}
},
});
</script>
<template>
<Modal :title="getTitle" class="w-2/5">
<Form class="mx-4" />
</Modal>
</template>