feat: detail contract detail
parent
a0281ef742
commit
43841be0d9
|
@ -25,6 +25,10 @@ const ContactDetailsList = defineAsyncComponent(
|
|||
() => import('#/views/crm/contact/modules/detail-list.vue'),
|
||||
);
|
||||
|
||||
const ContractDetailsList = defineAsyncComponent(
|
||||
() => import('#/views/crm/contract/modules/detail-list.vue'),
|
||||
);
|
||||
|
||||
const FollowUp = defineAsyncComponent(
|
||||
() => import('#/views/crm/followup/index.vue'),
|
||||
);
|
||||
|
@ -177,7 +181,10 @@ onMounted(async () => {
|
|||
<div>产品</div>
|
||||
</Tabs.TabPane>
|
||||
<Tabs.TabPane tab="合同" key="5" :force-render="true">
|
||||
<div>合同</div>
|
||||
<ContractDetailsList
|
||||
:biz-id="businessId"
|
||||
:biz-type="BizTypeEnum.CRM_BUSINESS"
|
||||
/>
|
||||
</Tabs.TabPane>
|
||||
<Tabs.TabPane tab="团队成员" key="6" :force-render="true">
|
||||
<PermissionList
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { DescriptionItemSchema } from '#/components/description';
|
||||
|
||||
import { h } from 'vue';
|
||||
|
||||
import { formatDateTime } from '@vben/utils';
|
||||
|
||||
import { getSimpleBusinessList } from '#/api/crm/business';
|
||||
import { getSimpleContactList } from '#/api/crm/contact';
|
||||
import { getCustomerSimpleList } from '#/api/crm/customer';
|
||||
import { floatToFixed2 } from '#/utils';
|
||||
import { DictTag } from '#/components/dict-tag';
|
||||
import { erpPriceInputFormatter, floatToFixed2 } from '#/utils';
|
||||
import { DICT_TYPE } from '#/utils/dict';
|
||||
|
||||
/** 新增/修改的表单 */
|
||||
|
@ -274,3 +280,182 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
|||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 详情头部的配置 */
|
||||
export function useDetailSchema(): DescriptionItemSchema[] {
|
||||
return [
|
||||
{
|
||||
field: 'customerName',
|
||||
label: '客户名称',
|
||||
},
|
||||
{
|
||||
field: 'totalPrice',
|
||||
label: '合同金额(元)',
|
||||
content: (data) => erpPriceInputFormatter(data?.totalPrice) as string,
|
||||
},
|
||||
{
|
||||
field: 'orderDate',
|
||||
label: '下单时间',
|
||||
content: (data) => formatDateTime(data?.orderDate) as string,
|
||||
},
|
||||
{
|
||||
field: 'totalReceivablePrice',
|
||||
label: '回款金额(元)',
|
||||
content: (data) =>
|
||||
erpPriceInputFormatter(data?.totalReceivablePrice) as string,
|
||||
},
|
||||
{
|
||||
field: 'ownerUserName',
|
||||
label: '负责人',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 详情基本信息的配置 */
|
||||
export function useDetailBaseSchema(): DescriptionItemSchema[] {
|
||||
return [
|
||||
{
|
||||
field: 'no',
|
||||
label: '合同编号',
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
label: '合同名称',
|
||||
},
|
||||
{
|
||||
field: 'customerName',
|
||||
label: '客户名称',
|
||||
},
|
||||
{
|
||||
field: 'businessName',
|
||||
label: '商机名称',
|
||||
},
|
||||
{
|
||||
field: 'totalPrice',
|
||||
label: '合同金额(元)',
|
||||
content: (data) => erpPriceInputFormatter(data?.totalPrice) as string,
|
||||
},
|
||||
{
|
||||
field: 'orderDate',
|
||||
label: '下单时间',
|
||||
content: (data) => formatDateTime(data?.orderDate) as string,
|
||||
},
|
||||
{
|
||||
field: 'startTime',
|
||||
label: '合同开始时间',
|
||||
content: (data) => formatDateTime(data?.startTime) as string,
|
||||
},
|
||||
{
|
||||
field: 'endTime',
|
||||
label: '合同结束时间',
|
||||
content: (data) => formatDateTime(data?.endTime) as string,
|
||||
},
|
||||
{
|
||||
field: 'signContactName',
|
||||
label: '客户签约人',
|
||||
},
|
||||
{
|
||||
field: 'signUserName',
|
||||
label: '公司签约人',
|
||||
},
|
||||
{
|
||||
field: 'remark',
|
||||
label: '备注',
|
||||
},
|
||||
{
|
||||
field: 'auditStatus',
|
||||
label: '合同状态',
|
||||
content: (data) =>
|
||||
h(DictTag, {
|
||||
type: DICT_TYPE.CRM_AUDIT_STATUS,
|
||||
value: data?.auditStatus,
|
||||
}),
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
export function useDetailListColumns(): VxeTableGridOptions['columns'] {
|
||||
return [
|
||||
{
|
||||
title: '合同编号',
|
||||
field: 'no',
|
||||
minWidth: 150,
|
||||
fixed: 'left',
|
||||
},
|
||||
{
|
||||
title: '合同名称',
|
||||
field: 'name',
|
||||
minWidth: 150,
|
||||
fixed: 'left',
|
||||
slots: { default: 'name' },
|
||||
},
|
||||
{
|
||||
title: '合同金额(元)',
|
||||
field: 'totalPrice',
|
||||
minWidth: 150,
|
||||
formatter: 'formatNumber',
|
||||
},
|
||||
{
|
||||
title: '合同开始时间',
|
||||
field: 'startTime',
|
||||
minWidth: 150,
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
title: '合同结束时间',
|
||||
field: 'endTime',
|
||||
minWidth: 150,
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
title: '已回款金额(元)',
|
||||
field: 'totalReceivablePrice',
|
||||
minWidth: 150,
|
||||
formatter: 'formatNumber',
|
||||
},
|
||||
{
|
||||
title: '未回款金额(元)',
|
||||
field: 'unpaidPrice',
|
||||
minWidth: 150,
|
||||
formatter: ({ row }) => {
|
||||
return floatToFixed2(row.totalPrice - row.totalReceivablePrice);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '负责人',
|
||||
field: 'ownerUserName',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
title: '所属部门',
|
||||
field: 'ownerUserDeptName',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
field: 'createTime',
|
||||
minWidth: 150,
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
title: '创建人',
|
||||
field: 'creatorName',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
title: '备注',
|
||||
field: 'remark',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
title: '合同状态',
|
||||
field: 'auditStatus',
|
||||
fixed: 'right',
|
||||
minWidth: 100,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.CRM_AUDIT_STATUS },
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
|
@ -1,4 +1,44 @@
|
|||
<script lang="ts" setup></script>
|
||||
<script lang="ts" setup>
|
||||
import type { CrmContractApi } from '#/api/crm/contract';
|
||||
|
||||
import { Divider } from 'ant-design-vue';
|
||||
|
||||
import { useDescription } from '#/components/description';
|
||||
import { useFollowUpDetailSchema } from '#/views/crm/followup/data';
|
||||
|
||||
import { useDetailBaseSchema } from '../data';
|
||||
|
||||
defineOptions({ name: 'CrmContractDetailsInfo' });
|
||||
|
||||
defineProps<{
|
||||
contract: CrmContractApi.Contract; // 合同信息
|
||||
}>();
|
||||
|
||||
const [BaseDescription] = useDescription({
|
||||
componentProps: {
|
||||
title: '基本信息',
|
||||
bordered: false,
|
||||
column: 4,
|
||||
class: 'mx-4',
|
||||
},
|
||||
schema: useDetailBaseSchema(),
|
||||
});
|
||||
|
||||
const [SystemDescription] = useDescription({
|
||||
componentProps: {
|
||||
title: '系统信息',
|
||||
bordered: false,
|
||||
column: 3,
|
||||
class: 'mx-4',
|
||||
},
|
||||
schema: useFollowUpDetailSchema(),
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>contractInfo</div>
|
||||
<div class="p-4">
|
||||
<BaseDescription :data="contract" />
|
||||
<Divider />
|
||||
<SystemDescription :data="contract" />
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
@ -1,4 +1,123 @@
|
|||
<script lang="ts" setup></script>
|
||||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { CrmBusinessApi } from '#/api/crm/business';
|
||||
import type { CrmContractApi } from '#/api/crm/contract';
|
||||
|
||||
import { ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { Button } from 'ant-design-vue';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
getContractPageByBusiness,
|
||||
getContractPageByCustomer,
|
||||
} from '#/api/crm/contract';
|
||||
import { BizTypeEnum } from '#/api/crm/permission';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useDetailListColumns } from '../data';
|
||||
import Form from './form.vue';
|
||||
|
||||
const props = defineProps<{
|
||||
bizId: number; // 业务编号
|
||||
bizType: number; // 业务类型
|
||||
}>();
|
||||
|
||||
const { push } = useRouter();
|
||||
|
||||
const [FormModal, formModalApi] = useVbenModal({
|
||||
connectedComponent: Form,
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
const checkedRows = ref<CrmContractApi.Contract[]>([]);
|
||||
function setCheckedRows({ records }: { records: CrmContractApi.Contract[] }) {
|
||||
checkedRows.value = records;
|
||||
}
|
||||
|
||||
/** 刷新表格 */
|
||||
function onRefresh() {
|
||||
gridApi.query();
|
||||
}
|
||||
|
||||
/** 创建合同 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData(null).open();
|
||||
}
|
||||
|
||||
/** 查看合同详情 */
|
||||
function handleDetail(row: CrmContractApi.Contract) {
|
||||
push({ name: 'CrmContractDetail', params: { id: row.id } });
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions: {
|
||||
columns: useDetailListColumns(),
|
||||
height: 600,
|
||||
keepSource: true,
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }, formValues) => {
|
||||
if (props.bizType === BizTypeEnum.CRM_CUSTOMER) {
|
||||
return await getContractPageByCustomer({
|
||||
page: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
customerId: props.bizId,
|
||||
...formValues,
|
||||
});
|
||||
} else if (props.bizType === BizTypeEnum.CRM_CONTACT) {
|
||||
return await getContractPageByBusiness({
|
||||
page: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
businessId: props.bizId,
|
||||
...formValues,
|
||||
});
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: { code: 'query' },
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<CrmBusinessApi.Business>,
|
||||
gridEvents: {
|
||||
checkboxAll: setCheckedRows,
|
||||
checkboxChange: setCheckedRows,
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>contractList</div>
|
||||
<div>
|
||||
<FormModal @success="onRefresh" />
|
||||
<Grid>
|
||||
<template #toolbar-tools>
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('ui.actionTitle.create', ['合同']),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.ADD,
|
||||
auth: ['crm:contract:create'],
|
||||
onClick: handleCreate,
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
<template #name="{ row }">
|
||||
<Button type="link" @click="handleDetail(row)">
|
||||
{{ row.name }}
|
||||
</Button>
|
||||
</template>
|
||||
</Grid>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
@ -1,7 +1,167 @@
|
|||
<script lang="ts" setup></script>
|
||||
<script setup lang="ts">
|
||||
import type { CrmContractApi } from '#/api/crm/contract';
|
||||
import type { SystemOperateLogApi } from '#/api/system/operate-log';
|
||||
|
||||
import { computed, defineAsyncComponent, onMounted, ref } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
|
||||
import { Page, useVbenModal } from '@vben/common-ui';
|
||||
import { useTabs } from '@vben/hooks';
|
||||
import { ArrowLeft } from '@vben/icons';
|
||||
|
||||
import { Button, Card, Tabs } from 'ant-design-vue';
|
||||
|
||||
import { getContract } from '#/api/crm/contract';
|
||||
import { getOperateLogPage } from '#/api/crm/operateLog';
|
||||
import { BizTypeEnum } from '#/api/crm/permission';
|
||||
import { useDescription } from '#/components/description';
|
||||
|
||||
import { useDetailSchema } from '../data';
|
||||
import ClueForm from './form.vue';
|
||||
|
||||
const FollowUp = defineAsyncComponent(
|
||||
() => import('#/views/crm/followup/index.vue'),
|
||||
);
|
||||
|
||||
const PermissionList = defineAsyncComponent(
|
||||
() => import('#/views/crm/permission/modules/permission-list.vue'),
|
||||
);
|
||||
|
||||
const TransferForm = defineAsyncComponent(
|
||||
() => import('#/views/crm/permission/modules/transfer-form.vue'),
|
||||
);
|
||||
|
||||
const OperateLog = defineAsyncComponent(
|
||||
() => import('#/components/operate-log'),
|
||||
);
|
||||
|
||||
const ContractDetailsInfo = defineAsyncComponent(
|
||||
() => import('./detail-info.vue'),
|
||||
);
|
||||
|
||||
const loading = ref(false);
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const tabs = useTabs();
|
||||
|
||||
const contractId = ref(0);
|
||||
|
||||
const contract = ref<CrmContractApi.Contract>({} as CrmContractApi.Contract);
|
||||
const contractLogList = ref<SystemOperateLogApi.OperateLog[]>([]);
|
||||
const permissionListRef = ref<InstanceType<typeof PermissionList>>(); // 团队成员列表 Ref
|
||||
|
||||
// 校验负责人权限和编辑权限
|
||||
const validateOwnerUser = computed(
|
||||
() => permissionListRef.value?.validateOwnerUser,
|
||||
);
|
||||
const validateWrite = computed(() => permissionListRef.value?.validateWrite);
|
||||
|
||||
const [Description] = useDescription({
|
||||
componentProps: {
|
||||
bordered: false,
|
||||
column: 4,
|
||||
class: 'mx-4',
|
||||
},
|
||||
schema: useDetailSchema(),
|
||||
});
|
||||
|
||||
const [FormModal, formModalApi] = useVbenModal({
|
||||
connectedComponent: ClueForm,
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
const [TransferModal, transferModalApi] = useVbenModal({
|
||||
connectedComponent: TransferForm,
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
/** 加载线索详情 */
|
||||
async function loadContractDetail() {
|
||||
loading.value = true;
|
||||
const data = await getContract(contractId.value);
|
||||
contract.value = data;
|
||||
// 操作日志
|
||||
const logList = await getOperateLogPage({
|
||||
bizType: BizTypeEnum.CRM_CLUE,
|
||||
bizId: contractId.value,
|
||||
});
|
||||
contractLogList.value = logList.list;
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
/** 返回列表页 */
|
||||
function handleBack() {
|
||||
tabs.closeCurrentTab();
|
||||
router.push('/crm/contract');
|
||||
}
|
||||
|
||||
/** 编辑 */
|
||||
function handleEdit() {
|
||||
formModalApi.setData({ id: contractId.value }).open();
|
||||
}
|
||||
|
||||
/** 转移 */
|
||||
function handleTransfer() {
|
||||
transferModalApi.setData({ bizType: BizTypeEnum.CRM_CONTRACT }).open();
|
||||
}
|
||||
|
||||
// 加载数据
|
||||
onMounted(async () => {
|
||||
contractId.value = Number(route.params.id);
|
||||
await loadContractDetail();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<p>待完成</p>
|
||||
</div>
|
||||
<Page auto-content-height :title="contract?.name" :loading="loading">
|
||||
<FormModal @success="loadContractDetail" />
|
||||
<TransferModal @success="loadContractDetail" />
|
||||
<template #extra>
|
||||
<div class="flex items-center gap-2">
|
||||
<Button @click="handleBack">
|
||||
<ArrowLeft class="size-5" />
|
||||
返回
|
||||
</Button>
|
||||
<Button
|
||||
v-if="validateWrite"
|
||||
type="primary"
|
||||
@click="handleEdit"
|
||||
v-access:code="['crm:contract:update']"
|
||||
>
|
||||
{{ $t('ui.actionTitle.edit') }}
|
||||
</Button>
|
||||
<Button v-if="validateOwnerUser" type="primary" @click="handleTransfer">
|
||||
转移
|
||||
</Button>
|
||||
</div>
|
||||
</template>
|
||||
<Card class="min-h-[10%]">
|
||||
<Description :data="contract" />
|
||||
</Card>
|
||||
<Card class="mt-4 min-h-[60%]">
|
||||
<Tabs>
|
||||
<Tabs.TabPane tab="详细资料" key="1" :force-render="true">
|
||||
<ContractDetailsInfo :contract="contract" />
|
||||
</Tabs.TabPane>
|
||||
<Tabs.TabPane tab="合同跟进" key="2" :force-render="true">
|
||||
<FollowUp :biz-id="contractId" :biz-type="BizTypeEnum.CRM_CONTRACT" />
|
||||
</Tabs.TabPane>
|
||||
<Tabs.TabPane tab="产品" key="3" :force-render="true" />
|
||||
<Tabs.TabPane tab="回款" key="4" :force-render="true" />
|
||||
<Tabs.TabPane tab="团队成员" key="5" :force-render="true">
|
||||
<PermissionList
|
||||
ref="permissionListRef"
|
||||
:biz-id="contractId"
|
||||
:biz-type="BizTypeEnum.CRM_CONTRACT"
|
||||
:show-action="true"
|
||||
@quit-team="handleBack"
|
||||
/>
|
||||
</Tabs.TabPane>
|
||||
<Tabs.TabPane tab="操作日志" key="6" :force-render="true">
|
||||
<OperateLog :log-list="contractLogList" />
|
||||
</Tabs.TabPane>
|
||||
</Tabs>
|
||||
</Card>
|
||||
</Page>
|
||||
</template>
|
||||
|
|
|
@ -25,6 +25,10 @@ const ContactDetailsList = defineAsyncComponent(
|
|||
() => import('#/views/crm/contact/modules/detail-list.vue'),
|
||||
);
|
||||
|
||||
const ContractDetailsList = defineAsyncComponent(
|
||||
() => import('#/views/crm/contract/modules/detail-list.vue'),
|
||||
);
|
||||
|
||||
const CustomerForm = defineAsyncComponent(
|
||||
() => import('#/views/crm/customer/modules/form.vue'),
|
||||
);
|
||||
|
@ -255,7 +259,10 @@ onMounted(async () => {
|
|||
/>
|
||||
</Tabs.TabPane>
|
||||
<Tabs.TabPane tab="合同" key="6" :force-render="true">
|
||||
<div>合同</div>
|
||||
<ContractDetailsList
|
||||
:biz-id="customerId"
|
||||
:biz-type="BizTypeEnum.CRM_CUSTOMER"
|
||||
/>
|
||||
</Tabs.TabPane>
|
||||
<Tabs.TabPane tab="回款" key="7" :force-render="true">
|
||||
<div>回款</div>
|
||||
|
|
Loading…
Reference in New Issue