feat: crm receivable
parent
d71d312237
commit
5424775317
|
@ -1,24 +1,48 @@
|
||||||
import type { VbenFormSchema } from '#/adapter/form';
|
import type { VbenFormSchema } from '#/adapter/form';
|
||||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
|
||||||
|
import { getContractSimpleList } from '#/api/crm/contract';
|
||||||
import { getCustomerSimpleList } from '#/api/crm/customer';
|
import { getCustomerSimpleList } from '#/api/crm/customer';
|
||||||
import { DICT_TYPE } from '#/utils/dict';
|
import { getReceivablePlanSimpleList } from '#/api/crm/receivable/plan';
|
||||||
|
import { getSimpleUserList } from '#/api/system/user';
|
||||||
|
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
||||||
|
|
||||||
/** 新增/修改的表单 */
|
/** 新增/修改的表单 */
|
||||||
export function useFormSchema(): VbenFormSchema[] {
|
export function useFormSchema(): VbenFormSchema[] {
|
||||||
return [
|
return [
|
||||||
|
{
|
||||||
|
fieldName: 'id',
|
||||||
|
component: 'Input',
|
||||||
|
dependencies: {
|
||||||
|
triggerFields: [''],
|
||||||
|
show: () => false,
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
fieldName: 'no',
|
fieldName: 'no',
|
||||||
label: '回款编号',
|
label: '回款编号',
|
||||||
component: 'Input',
|
component: 'Input',
|
||||||
rules: 'required',
|
rules: 'required',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
placeholder: '请输入回款编号',
|
placeholder: '保存时自动生成',
|
||||||
|
disabled: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'ownerUserId',
|
||||||
|
label: '负责人',
|
||||||
|
component: 'ApiSelect',
|
||||||
|
rules: 'required',
|
||||||
|
componentProps: {
|
||||||
|
api: getSimpleUserList,
|
||||||
|
labelField: 'nickname',
|
||||||
|
valueField: 'id',
|
||||||
|
placeholder: '请选择客户',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldName: 'customerId',
|
fieldName: 'customerId',
|
||||||
label: '客户',
|
label: '客户名称',
|
||||||
component: 'ApiSelect',
|
component: 'ApiSelect',
|
||||||
rules: 'required',
|
rules: 'required',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
|
@ -30,23 +54,63 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldName: 'contractId',
|
fieldName: 'contractId',
|
||||||
label: '合同',
|
label: '合同名称',
|
||||||
component: 'ApiSelect',
|
component: 'Select',
|
||||||
rules: 'required',
|
rules: 'required',
|
||||||
componentProps: {
|
dependencies: {
|
||||||
api: getCustomerSimpleList,
|
triggerFields: ['customerId'],
|
||||||
labelField: 'name',
|
disabled: (values) => !values.customerId,
|
||||||
valueField: 'id',
|
async componentProps(values) {
|
||||||
placeholder: '请选择合同',
|
if (values.customerId) {
|
||||||
|
values.contractId = undefined;
|
||||||
|
const contracts = await getContractSimpleList(values.customerId);
|
||||||
|
return {
|
||||||
|
options: contracts.map((item) => ({
|
||||||
|
label: item.name,
|
||||||
|
value: item.id,
|
||||||
|
disabled: item.auditStatus === 20,
|
||||||
|
})),
|
||||||
|
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: '请选择回款期数',
|
||||||
|
} as any;
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldName: 'returnTime',
|
fieldName: 'returnTime',
|
||||||
label: '回款日期',
|
label: '回款日期',
|
||||||
component: 'DatePicker',
|
component: 'DatePicker',
|
||||||
rules: 'required',
|
|
||||||
componentProps: {
|
componentProps: {
|
||||||
placeholder: '请选择回款日期',
|
placeholder: '请选择回款日期',
|
||||||
|
showTime: false,
|
||||||
|
valueFormat: 'x',
|
||||||
|
format: 'YYYY-MM-DD',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -63,10 +127,10 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||||
{
|
{
|
||||||
fieldName: 'returnType',
|
fieldName: 'returnType',
|
||||||
label: '回款方式',
|
label: '回款方式',
|
||||||
component: 'DictSelect',
|
component: 'Select',
|
||||||
rules: 'required',
|
rules: 'required',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
type: DICT_TYPE.CRM_RECEIVABLE_RETURN_TYPE,
|
options: getDictOptions(DICT_TYPE.CRM_RECEIVABLE_RETURN_TYPE, 'number'),
|
||||||
placeholder: '请选择回款方式',
|
placeholder: '请选择回款方式',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -49,7 +49,7 @@ function handleCreate() {
|
||||||
|
|
||||||
/** 编辑回款 */
|
/** 编辑回款 */
|
||||||
function handleEdit(row: CrmReceivableApi.Receivable) {
|
function handleEdit(row: CrmReceivableApi.Receivable) {
|
||||||
formModalApi.setData(row).open();
|
formModalApi.setData({ receivable: row }).open();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 删除回款 */
|
/** 删除回款 */
|
||||||
|
|
|
@ -65,12 +65,28 @@ const [Modal, modalApi] = useVbenModal({
|
||||||
}
|
}
|
||||||
// 加载数据
|
// 加载数据
|
||||||
const data = modalApi.getData<CrmReceivableApi.Receivable>();
|
const data = modalApi.getData<CrmReceivableApi.Receivable>();
|
||||||
if (!data || !data.id) {
|
if (!data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const { receivable, plan } = data;
|
||||||
modalApi.lock();
|
modalApi.lock();
|
||||||
try {
|
try {
|
||||||
formData.value = await getReceivable(data.id as number);
|
if (receivable) {
|
||||||
|
formData.value = await getReceivable(receivable.id as number);
|
||||||
|
} 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,
|
||||||
|
};
|
||||||
|
}
|
||||||
// 设置到 values
|
// 设置到 values
|
||||||
await formApi.setValues(formData.value);
|
await formApi.setValues(formData.value);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -0,0 +1,229 @@
|
||||||
|
import type { VbenFormSchema } from '#/adapter/form';
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
|
||||||
|
import { getCustomerSimpleList } from '#/api/crm/customer';
|
||||||
|
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
||||||
|
|
||||||
|
/** 新增/修改的表单 */
|
||||||
|
export function useFormSchema(): VbenFormSchema[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
fieldName: 'customerId',
|
||||||
|
label: '客户',
|
||||||
|
component: 'ApiSelect',
|
||||||
|
rules: 'required',
|
||||||
|
componentProps: {
|
||||||
|
api: getCustomerSimpleList,
|
||||||
|
labelField: 'name',
|
||||||
|
valueField: 'id',
|
||||||
|
placeholder: '请选择客户',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'contractId',
|
||||||
|
label: '合同',
|
||||||
|
component: 'ApiSelect',
|
||||||
|
rules: 'required',
|
||||||
|
componentProps: {
|
||||||
|
api: getCustomerSimpleList,
|
||||||
|
labelField: 'name',
|
||||||
|
valueField: 'id',
|
||||||
|
placeholder: '请选择合同',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'period',
|
||||||
|
label: '期数',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '保存时自动生成',
|
||||||
|
disabled: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'price',
|
||||||
|
label: '计划回款金额',
|
||||||
|
component: 'InputNumber',
|
||||||
|
rules: 'required',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入计划回款金额',
|
||||||
|
min: 0,
|
||||||
|
precision: 2,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'returnTime',
|
||||||
|
label: '计划回款日期',
|
||||||
|
component: 'DatePicker',
|
||||||
|
rules: 'required',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请选择计划回款日期',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'remindDays',
|
||||||
|
label: '提前几天提醒',
|
||||||
|
component: 'InputNumber',
|
||||||
|
rules: 'required',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入提前几天提醒',
|
||||||
|
min: 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'returnType',
|
||||||
|
label: '回款方式',
|
||||||
|
component: 'Select',
|
||||||
|
rules: 'required',
|
||||||
|
componentProps: {
|
||||||
|
options: getDictOptions(DICT_TYPE.CRM_RECEIVABLE_RETURN_TYPE, 'number'),
|
||||||
|
placeholder: '请选择回款方式',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'remark',
|
||||||
|
label: '备注',
|
||||||
|
component: 'Textarea',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入备注',
|
||||||
|
rows: 4,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 列表的搜索表单 */
|
||||||
|
export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
fieldName: 'customerId',
|
||||||
|
label: '客户',
|
||||||
|
component: 'ApiSelect',
|
||||||
|
componentProps: {
|
||||||
|
api: getCustomerSimpleList,
|
||||||
|
labelField: 'name',
|
||||||
|
valueField: 'id',
|
||||||
|
placeholder: '请选择客户',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'contractNo',
|
||||||
|
label: '合同编号',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入合同编号',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
title: '客户名称',
|
||||||
|
field: 'customerName',
|
||||||
|
width: 150,
|
||||||
|
fixed: 'left',
|
||||||
|
slots: { default: 'customerName' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '合同编号',
|
||||||
|
field: 'contractNo',
|
||||||
|
width: 200,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '期数',
|
||||||
|
field: 'period',
|
||||||
|
width: 150,
|
||||||
|
slots: { default: 'period' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '计划回款金额(元)',
|
||||||
|
field: 'price',
|
||||||
|
width: 160,
|
||||||
|
formatter: 'formatNumber',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '计划回款日期',
|
||||||
|
field: 'returnTime',
|
||||||
|
width: 180,
|
||||||
|
formatter: 'formatDateTime',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '提前几天提醒',
|
||||||
|
field: 'remindDays',
|
||||||
|
width: 150,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '提醒日期',
|
||||||
|
field: 'remindTime',
|
||||||
|
width: 180,
|
||||||
|
formatter: 'formatDateTime',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '回款方式',
|
||||||
|
field: 'returnType',
|
||||||
|
width: 130,
|
||||||
|
cellRender: {
|
||||||
|
name: 'CellDict',
|
||||||
|
props: { type: DICT_TYPE.CRM_RECEIVABLE_RETURN_TYPE },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '备注',
|
||||||
|
field: 'remark',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '负责人',
|
||||||
|
field: 'ownerUserName',
|
||||||
|
width: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '实际回款金额(元)',
|
||||||
|
field: 'receivable.price',
|
||||||
|
width: 160,
|
||||||
|
formatter: 'formatNumber',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '实际回款日期',
|
||||||
|
field: 'receivable.returnTime',
|
||||||
|
width: 180,
|
||||||
|
formatter: 'formatDateTime',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '未回款金额(元)',
|
||||||
|
field: 'unpaidPrice',
|
||||||
|
width: 160,
|
||||||
|
formatter: ({ row }) => {
|
||||||
|
if (row.receivable) {
|
||||||
|
return row.price - row.receivable.price;
|
||||||
|
}
|
||||||
|
return row.price;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '更新时间',
|
||||||
|
field: 'updateTime',
|
||||||
|
width: 180,
|
||||||
|
formatter: 'formatDateTime',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '创建时间',
|
||||||
|
field: 'createTime',
|
||||||
|
width: 180,
|
||||||
|
formatter: 'formatDateTime',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '创建人',
|
||||||
|
field: 'creatorName',
|
||||||
|
width: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
field: 'actions',
|
||||||
|
width: 180,
|
||||||
|
fixed: 'right',
|
||||||
|
slots: { default: 'actions' },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
|
@ -1,38 +1,217 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { Page } from '@vben/common-ui';
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { CrmReceivablePlanApi } from '#/api/crm/receivable/plan';
|
||||||
|
|
||||||
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 {
|
||||||
|
deleteReceivablePlan,
|
||||||
|
exportReceivablePlan,
|
||||||
|
getReceivablePlanPage,
|
||||||
|
} from '#/api/crm/receivable/plan';
|
||||||
import { DocAlert } from '#/components/doc-alert';
|
import { DocAlert } from '#/components/doc-alert';
|
||||||
|
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 onRefresh() {
|
||||||
|
gridApi.query();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出表格 */
|
||||||
|
async function handleExport() {
|
||||||
|
const data = await exportReceivablePlan(await gridApi.formApi.getValues());
|
||||||
|
downloadFileFromBlobPart({ fileName: '回款计划.xls', source: data });
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 创建回款计划 */
|
||||||
|
function handleCreate() {
|
||||||
|
formModalApi.setData(null).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 编辑回款计划 */
|
||||||
|
function handleEdit(row: CrmReceivablePlanApi.ReceivablePlan) {
|
||||||
|
formModalApi.setData(row).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除回款计划 */
|
||||||
|
async function handleDelete(row: CrmReceivablePlanApi.ReceivablePlan) {
|
||||||
|
const hideLoading = message.loading({
|
||||||
|
content: $t('ui.actionMessage.deleting', [row.period]),
|
||||||
|
key: 'action_key_msg',
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await deleteReceivablePlan(row.id as number);
|
||||||
|
message.success({
|
||||||
|
content: $t('ui.actionMessage.deleteSuccess', [row.period]),
|
||||||
|
key: 'action_key_msg',
|
||||||
|
});
|
||||||
|
onRefresh();
|
||||||
|
} finally {
|
||||||
|
hideLoading();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 创建回款 */
|
||||||
|
function handleCreateReceivable(row: CrmReceivablePlanApi.ReceivablePlan) {
|
||||||
|
receivableFormModalApi.setData({ plan: row }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查看回款计划详情 */
|
||||||
|
function handleDetail(row: CrmReceivablePlanApi.ReceivablePlan) {
|
||||||
|
push({ name: 'CrmReceivablePlanDetail', params: { id: row.id } });
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查看客户详情 */
|
||||||
|
function handleCustomerDetail(row: CrmReceivablePlanApi.ReceivablePlan) {
|
||||||
|
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({
|
||||||
|
page: page.currentPage,
|
||||||
|
pageSize: page.pageSize,
|
||||||
|
sceneType: sceneType.value,
|
||||||
|
...formValues,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rowConfig: {
|
||||||
|
keyField: 'id',
|
||||||
|
},
|
||||||
|
toolbarConfig: {
|
||||||
|
refresh: { code: 'query' },
|
||||||
|
search: true,
|
||||||
|
},
|
||||||
|
} as VxeTableGridOptions<CrmReceivablePlanApi.ReceivablePlan>,
|
||||||
|
});
|
||||||
|
|
||||||
|
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/receivable/"
|
title="【回款】回款管理、回款计划"
|
||||||
/>
|
url="https://doc.iocoder.cn/crm/receivable/"
|
||||||
<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"
|
<ReceivableFormModal @success="onRefresh" />
|
||||||
>
|
<Grid>
|
||||||
该功能支持 Vue3 + element-plus 版本!
|
<template #top>
|
||||||
</Button>
|
<Tabs class="border-none" @change="onChangeSceneType">
|
||||||
<br />
|
<Tabs.TabPane tab="我负责的" key="1" />
|
||||||
<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/receivable/plan/index"
|
<template #toolbar-tools>
|
||||||
>
|
<TableAction
|
||||||
可参考
|
:actions="[
|
||||||
https://github.com/yudaocode/yudao-ui-admin-vue3/blob/master/src/views/crm/receivable/plan/index
|
{
|
||||||
代码,pull request 贡献给我们!
|
label: $t('ui.actionTitle.create', ['回款计划']),
|
||||||
</Button>
|
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 }">
|
||||||
|
<Button type="link" @click="handleCustomerDetail(row)">
|
||||||
|
{{ row.customerName }}
|
||||||
|
</Button>
|
||||||
|
</template>
|
||||||
|
<template #period="{ row }">
|
||||||
|
<Button type="link" @click="handleDetail(row)">
|
||||||
|
{{ row.period }}
|
||||||
|
</Button>
|
||||||
|
</template>
|
||||||
|
<template #actions="{ row }">
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: $t('ui.actionTitle.create', ['回款']),
|
||||||
|
type: 'link',
|
||||||
|
icon: ACTION_ICON.ADD,
|
||||||
|
auth: ['crm:receivable:create'],
|
||||||
|
onClick: handleCreateReceivable.bind(null, row),
|
||||||
|
ifShow: !row.receivableId,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('common.edit'),
|
||||||
|
type: 'link',
|
||||||
|
icon: ACTION_ICON.EDIT,
|
||||||
|
auth: ['crm:receivable-plan:update'],
|
||||||
|
onClick: handleEdit.bind(null, row),
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
:drop-down-actions="[
|
||||||
|
{
|
||||||
|
label: $t('common.delete'),
|
||||||
|
type: 'link',
|
||||||
|
danger: 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>
|
</Page>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -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 { message } from 'ant-design-vue';
|
||||||
|
|
||||||
|
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.ReceivablePlan>();
|
||||||
|
const getTitle = computed(() => {
|
||||||
|
return formData.value?.id
|
||||||
|
? $t('ui.actionTitle.edit', ['回款计划'])
|
||||||
|
: $t('ui.actionTitle.create', ['回款计划']);
|
||||||
|
});
|
||||||
|
|
||||||
|
const [Form, formApi] = useVbenForm({
|
||||||
|
commonConfig: {
|
||||||
|
componentProps: {
|
||||||
|
class: 'w-full',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// 一共2列
|
||||||
|
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.ReceivablePlan;
|
||||||
|
try {
|
||||||
|
await (formData.value?.id
|
||||||
|
? updateReceivablePlan(data)
|
||||||
|
: createReceivablePlan(data));
|
||||||
|
// 关闭并提示
|
||||||
|
await modalApi.close();
|
||||||
|
emit('success');
|
||||||
|
message.success($t('ui.actionMessage.operationSuccess'));
|
||||||
|
} finally {
|
||||||
|
modalApi.unlock();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async onOpenChange(isOpen: boolean) {
|
||||||
|
if (!isOpen) {
|
||||||
|
formData.value = undefined;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 加载数据
|
||||||
|
const data = modalApi.getData<CrmReceivablePlanApi.ReceivablePlan>();
|
||||||
|
if (!data || !data.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
modalApi.lock();
|
||||||
|
try {
|
||||||
|
formData.value = await getReceivablePlan(data.id as number);
|
||||||
|
// 设置到 values
|
||||||
|
await formApi.setValues(formData.value);
|
||||||
|
} finally {
|
||||||
|
modalApi.unlock();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Modal :title="getTitle" class="w-[40%]">
|
||||||
|
<Form class="mx-4" />
|
||||||
|
</Modal>
|
||||||
|
</template>
|
Loading…
Reference in New Issue