feat: crm receivable
parent
45bcc79241
commit
d71d312237
|
@ -0,0 +1,205 @@
|
||||||
|
import type { VbenFormSchema } from '#/adapter/form';
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
|
||||||
|
import { getCustomerSimpleList } from '#/api/crm/customer';
|
||||||
|
import { DICT_TYPE } from '#/utils/dict';
|
||||||
|
|
||||||
|
/** 新增/修改的表单 */
|
||||||
|
export function useFormSchema(): VbenFormSchema[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
fieldName: 'no',
|
||||||
|
label: '回款编号',
|
||||||
|
component: 'Input',
|
||||||
|
rules: 'required',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入回款编号',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
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: 'returnTime',
|
||||||
|
label: '回款日期',
|
||||||
|
component: 'DatePicker',
|
||||||
|
rules: 'required',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请选择回款日期',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'price',
|
||||||
|
label: '回款金额',
|
||||||
|
component: 'InputNumber',
|
||||||
|
rules: 'required',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入回款金额',
|
||||||
|
min: 0,
|
||||||
|
precision: 2,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'returnType',
|
||||||
|
label: '回款方式',
|
||||||
|
component: 'DictSelect',
|
||||||
|
rules: 'required',
|
||||||
|
componentProps: {
|
||||||
|
type: DICT_TYPE.CRM_RECEIVABLE_RETURN_TYPE,
|
||||||
|
placeholder: '请选择回款方式',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'remark',
|
||||||
|
label: '备注',
|
||||||
|
component: 'Textarea',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入备注',
|
||||||
|
rows: 4,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 列表的搜索表单 */
|
||||||
|
export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
fieldName: 'no',
|
||||||
|
label: '回款编号',
|
||||||
|
component: 'Input',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'customerId',
|
||||||
|
label: '客户',
|
||||||
|
component: 'ApiSelect',
|
||||||
|
componentProps: {
|
||||||
|
api: getCustomerSimpleList,
|
||||||
|
labelField: 'name',
|
||||||
|
valueField: 'id',
|
||||||
|
placeholder: '请选择客户',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
title: '回款编号',
|
||||||
|
field: 'no',
|
||||||
|
width: 150,
|
||||||
|
fixed: 'left',
|
||||||
|
slots: { default: 'no' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '客户名称',
|
||||||
|
field: 'customerName',
|
||||||
|
width: 150,
|
||||||
|
slots: { default: 'customerName' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '合同编号',
|
||||||
|
field: 'contract',
|
||||||
|
width: 150,
|
||||||
|
slots: { default: 'contractNo' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '回款日期',
|
||||||
|
field: 'returnTime',
|
||||||
|
width: 150,
|
||||||
|
formatter: 'formatDateTime',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '回款金额(元)',
|
||||||
|
field: 'price',
|
||||||
|
width: 150,
|
||||||
|
formatter: 'formatNumber',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '回款方式',
|
||||||
|
field: 'returnType',
|
||||||
|
width: 150,
|
||||||
|
cellRender: {
|
||||||
|
name: 'CellDict',
|
||||||
|
props: { type: DICT_TYPE.CRM_RECEIVABLE_RETURN_TYPE },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '备注',
|
||||||
|
field: 'remark',
|
||||||
|
width: 150,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '合同金额(元)',
|
||||||
|
field: 'contract.totalPrice',
|
||||||
|
width: 150,
|
||||||
|
formatter: 'formatNumber',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '负责人',
|
||||||
|
field: 'ownerUserName',
|
||||||
|
width: 150,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '所属部门',
|
||||||
|
field: 'ownerUserDeptName',
|
||||||
|
width: 150,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '更新时间',
|
||||||
|
field: 'updateTime',
|
||||||
|
width: 150,
|
||||||
|
formatter: 'formatDateTime',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '创建时间',
|
||||||
|
field: 'createTime',
|
||||||
|
width: 150,
|
||||||
|
formatter: 'formatDateTime',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '创建人',
|
||||||
|
field: 'creatorName',
|
||||||
|
width: 150,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '回款状态',
|
||||||
|
field: 'auditStatus',
|
||||||
|
width: 100,
|
||||||
|
fixed: 'right',
|
||||||
|
cellRender: {
|
||||||
|
name: 'CellDict',
|
||||||
|
props: { type: DICT_TYPE.CRM_AUDIT_STATUS },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
field: 'actions',
|
||||||
|
width: 130,
|
||||||
|
fixed: 'right',
|
||||||
|
slots: { default: 'actions' },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
|
@ -1,38 +1,255 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { Page } from '@vben/common-ui';
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { CrmReceivableApi } from '#/api/crm/receivable';
|
||||||
|
|
||||||
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 {
|
||||||
|
deleteReceivable,
|
||||||
|
exportReceivable,
|
||||||
|
getReceivablePage,
|
||||||
|
submitReceivable,
|
||||||
|
} from '#/api/crm/receivable';
|
||||||
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 exportReceivable(await gridApi.formApi.getValues());
|
||||||
|
downloadFileFromBlobPart({ fileName: '回款.xls', source: data });
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 创建回款 */
|
||||||
|
function handleCreate() {
|
||||||
|
formModalApi.setData(null).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 编辑回款 */
|
||||||
|
function handleEdit(row: CrmReceivableApi.Receivable) {
|
||||||
|
formModalApi.setData(row).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除回款 */
|
||||||
|
async function handleDelete(row: CrmReceivableApi.Receivable) {
|
||||||
|
const hideLoading = message.loading({
|
||||||
|
content: $t('ui.actionMessage.deleting', [row.no]),
|
||||||
|
key: 'action_key_msg',
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await deleteReceivable(row.id as number);
|
||||||
|
message.success({
|
||||||
|
content: $t('ui.actionMessage.deleteSuccess', [row.no]),
|
||||||
|
key: 'action_key_msg',
|
||||||
|
});
|
||||||
|
onRefresh();
|
||||||
|
} finally {
|
||||||
|
hideLoading();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 提交审核 */
|
||||||
|
async function handleSubmit(row: CrmReceivableApi.Receivable) {
|
||||||
|
const hideLoading = message.loading({
|
||||||
|
content: $t('ui.actionMessage.submitting', [row.no]),
|
||||||
|
key: 'action_key_msg',
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await submitReceivable(row.id as number);
|
||||||
|
message.success({
|
||||||
|
content: $t('ui.actionMessage.submitSuccess', [row.no]),
|
||||||
|
key: 'action_key_msg',
|
||||||
|
});
|
||||||
|
onRefresh();
|
||||||
|
} finally {
|
||||||
|
hideLoading();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查看回款详情 */
|
||||||
|
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({
|
||||||
|
page: page.currentPage,
|
||||||
|
pageSize: page.pageSize,
|
||||||
|
sceneType: sceneType.value,
|
||||||
|
...formValues,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rowConfig: {
|
||||||
|
keyField: 'id',
|
||||||
|
},
|
||||||
|
toolbarConfig: {
|
||||||
|
refresh: { code: 'query' },
|
||||||
|
search: true,
|
||||||
|
},
|
||||||
|
} as VxeTableGridOptions<CrmReceivableApi.Receivable>,
|
||||||
|
});
|
||||||
|
|
||||||
|
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"
|
<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/receivable/index"
|
<template #toolbar-tools>
|
||||||
>
|
<TableAction
|
||||||
可参考
|
:actions="[
|
||||||
https://github.com/yudaocode/yudao-ui-admin-vue3/blob/master/src/views/crm/receivable/index
|
{
|
||||||
代码,pull request 贡献给我们!
|
label: $t('ui.actionTitle.create', ['回款']),
|
||||||
</Button>
|
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 }">
|
||||||
|
<Button type="link" @click="handleDetail(row)">
|
||||||
|
{{ row.no }}
|
||||||
|
</Button>
|
||||||
|
</template>
|
||||||
|
<template #customerName="{ row }">
|
||||||
|
<Button type="link" @click="handleCustomerDetail(row)">
|
||||||
|
{{ row.customerName }}
|
||||||
|
</Button>
|
||||||
|
</template>
|
||||||
|
<template #contractNo="{ row }">
|
||||||
|
<Button
|
||||||
|
v-if="row.contract"
|
||||||
|
type="link"
|
||||||
|
@click="handleContractDetail(row)"
|
||||||
|
>
|
||||||
|
{{ row.contract.no }}
|
||||||
|
</Button>
|
||||||
|
<span v-else>--</span>
|
||||||
|
</template>
|
||||||
|
<template #actions="{ row }">
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: $t('common.edit'),
|
||||||
|
type: 'link',
|
||||||
|
icon: ACTION_ICON.EDIT,
|
||||||
|
auth: ['crm:receivable:update'],
|
||||||
|
onClick: handleEdit.bind(null, row),
|
||||||
|
ifShow: row.auditStatus === 0,
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
:drop-down-actions="[
|
||||||
|
{
|
||||||
|
label: '提交审核',
|
||||||
|
type: 'link',
|
||||||
|
auth: ['crm:receivable:update'],
|
||||||
|
onClick: handleSubmit.bind(null, row),
|
||||||
|
ifShow: row.auditStatus === 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '查看审批',
|
||||||
|
type: 'link',
|
||||||
|
auth: ['crm:receivable:update'],
|
||||||
|
onClick: handleProcessDetail.bind(null, row),
|
||||||
|
ifShow: row.auditStatus !== 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('common.delete'),
|
||||||
|
type: 'link',
|
||||||
|
danger: 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>
|
</Page>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -0,0 +1,87 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { CrmReceivableApi } from '#/api/crm/receivable';
|
||||||
|
|
||||||
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
|
import { useVbenForm, useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import { message } from 'ant-design-vue';
|
||||||
|
|
||||||
|
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',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// 一共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 CrmReceivableApi.Receivable;
|
||||||
|
try {
|
||||||
|
await (formData.value?.id
|
||||||
|
? updateReceivable(data)
|
||||||
|
: createReceivable(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<CrmReceivableApi.Receivable>();
|
||||||
|
if (!data || !data.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
modalApi.lock();
|
||||||
|
try {
|
||||||
|
formData.value = await getReceivable(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