feat:【antd】【crm】优化 receivable 的整体代码风格
This commit is contained in:
79
apps/web-antd/src/views/crm/receivable/detail/data.ts
Normal file
79
apps/web-antd/src/views/crm/receivable/detail/data.ts
Normal file
@@ -0,0 +1,79 @@
|
||||
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: '合同金额',
|
||||
content: (data) => erpPriceInputFormatter(data.totalPrice),
|
||||
},
|
||||
{
|
||||
field: 'returnTime',
|
||||
label: '回款日期',
|
||||
content: (data) => formatDateTime(data?.returnTime) as string,
|
||||
},
|
||||
{
|
||||
field: 'price',
|
||||
label: '回款金额',
|
||||
content: (data) => erpPriceInputFormatter(data.price),
|
||||
},
|
||||
{
|
||||
field: 'ownerUserName',
|
||||
label: '负责人',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 详情页的基础字段 */
|
||||
export function useDetailBaseSchema(): DescriptionItemSchema[] {
|
||||
return [
|
||||
{
|
||||
field: 'no',
|
||||
label: '回款编号',
|
||||
},
|
||||
{
|
||||
field: 'customerName',
|
||||
label: '客户名称',
|
||||
},
|
||||
{
|
||||
field: 'contract',
|
||||
label: '合同编号',
|
||||
content: (data) => data?.contract?.no,
|
||||
},
|
||||
{
|
||||
field: 'returnTime',
|
||||
label: '回款日期',
|
||||
content: (data) => formatDateTime(data?.returnTime) as string,
|
||||
},
|
||||
{
|
||||
field: 'price',
|
||||
label: '回款金额',
|
||||
content: (data) => erpPriceInputFormatter(data.price),
|
||||
},
|
||||
{
|
||||
field: 'returnType',
|
||||
label: '回款方式',
|
||||
content: (data) =>
|
||||
h(DictTag, {
|
||||
type: DICT_TYPE.CRM_RECEIVABLE_RETURN_TYPE,
|
||||
value: data?.returnType,
|
||||
}),
|
||||
},
|
||||
{
|
||||
field: 'remark',
|
||||
label: '备注',
|
||||
},
|
||||
];
|
||||
}
|
||||
130
apps/web-antd/src/views/crm/receivable/detail/index.vue
Normal file
130
apps/web-antd/src/views/crm/receivable/detail/index.vue
Normal file
@@ -0,0 +1,130 @@
|
||||
<script setup lang="ts">
|
||||
import type { CrmReceivableApi } from '#/api/crm/receivable';
|
||||
import type { SystemOperateLogApi } from '#/api/system/operate-log';
|
||||
|
||||
import { computed, 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 { getOperateLogPage } from '#/api/crm/operateLog';
|
||||
import { BizTypeEnum } from '#/api/crm/permission';
|
||||
import { getReceivable } from '#/api/crm/receivable';
|
||||
import { useDescription } from '#/components/description';
|
||||
import { AsyncOperateLog } from '#/components/operate-log';
|
||||
import { PermissionList } from '#/views/crm/permission';
|
||||
|
||||
import ReceivableForm from '../modules/form.vue';
|
||||
import { useDetailSchema } from './data';
|
||||
import Info from './modules/info.vue';
|
||||
|
||||
const loading = ref(false);
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const tabs = useTabs();
|
||||
|
||||
const receivableId = ref(0);
|
||||
|
||||
const receivable = ref<CrmReceivableApi.Receivable>(
|
||||
{} as CrmReceivableApi.Receivable,
|
||||
);
|
||||
const receivableLogList = ref<SystemOperateLogApi.OperateLog[]>([]);
|
||||
const permissionListRef = ref<InstanceType<typeof PermissionList>>(); // 团队成员列表 Ref
|
||||
|
||||
// 校验编辑权限
|
||||
const validateWrite = computed(() => permissionListRef.value?.validateWrite);
|
||||
|
||||
const [Descriptions] = useDescription({
|
||||
componentProps: {
|
||||
bordered: false,
|
||||
column: 4,
|
||||
class: 'mx-4',
|
||||
},
|
||||
schema: useDetailSchema(),
|
||||
});
|
||||
|
||||
const [FormModal, formModalApi] = useVbenModal({
|
||||
connectedComponent: ReceivableForm,
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
/** 加载回款详情 */
|
||||
async function loadReceivableDetail() {
|
||||
loading.value = true;
|
||||
const data = await getReceivable(receivableId.value);
|
||||
receivable.value = data;
|
||||
// 操作日志
|
||||
const logList = await getOperateLogPage({
|
||||
bizType: BizTypeEnum.CRM_RECEIVABLE,
|
||||
bizId: receivableId.value,
|
||||
});
|
||||
receivableLogList.value = logList.list;
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
/** 返回列表页 */
|
||||
function handleBack() {
|
||||
tabs.closeCurrentTab();
|
||||
router.push('/crm/receivable');
|
||||
}
|
||||
|
||||
/** 编辑收款 */
|
||||
function handleEdit() {
|
||||
formModalApi.setData({ id: receivableId.value }).open();
|
||||
}
|
||||
|
||||
// 加载数据
|
||||
onMounted(() => {
|
||||
receivableId.value = Number(route.params.id);
|
||||
loadReceivableDetail();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height :title="receivable?.no" :loading="loading">
|
||||
<FormModal @success="loadReceivableDetail" />
|
||||
<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:receivable:update']"
|
||||
>
|
||||
{{ $t('ui.actionTitle.edit') }}
|
||||
</Button>
|
||||
</div>
|
||||
</template>
|
||||
<Card class="min-h-[10%]">
|
||||
<Descriptions :data="receivable" />
|
||||
</Card>
|
||||
<Card class="mt-4 min-h-[60%]">
|
||||
<Tabs>
|
||||
<Tabs.TabPane tab="详细资料" key="1" :force-render="true">
|
||||
<Info :receivable="receivable" />
|
||||
</Tabs.TabPane>
|
||||
<Tabs.TabPane tab="团队成员" key="2" :force-render="true">
|
||||
<PermissionList
|
||||
ref="permissionListRef"
|
||||
:biz-id="receivableId"
|
||||
:biz-type="BizTypeEnum.CRM_RECEIVABLE"
|
||||
:show-action="true"
|
||||
@quit-team="handleBack"
|
||||
/>
|
||||
</Tabs.TabPane>
|
||||
<Tabs.TabPane tab="操作日志" key="3" :force-render="true">
|
||||
<AsyncOperateLog :log-list="receivableLogList" />
|
||||
</Tabs.TabPane>
|
||||
</Tabs>
|
||||
</Card>
|
||||
</Page>
|
||||
</template>
|
||||
@@ -0,0 +1,42 @@
|
||||
<script lang="ts" setup>
|
||||
import type { CrmReceivableApi } from '#/api/crm/receivable';
|
||||
|
||||
import { Divider } from 'ant-design-vue';
|
||||
|
||||
import { useDescription } from '#/components/description';
|
||||
import { useFollowUpDetailSchema } from '#/views/crm/followup/data';
|
||||
|
||||
import { useDetailBaseSchema } from '../data';
|
||||
|
||||
defineProps<{
|
||||
receivable: CrmReceivableApi.Receivable; // 收款信息
|
||||
}>();
|
||||
|
||||
const [BaseDescriptions] = useDescription({
|
||||
componentProps: {
|
||||
title: '基本信息',
|
||||
bordered: false,
|
||||
column: 4,
|
||||
class: 'mx-4',
|
||||
},
|
||||
schema: useDetailBaseSchema(),
|
||||
});
|
||||
|
||||
const [SystemDescriptions] = useDescription({
|
||||
componentProps: {
|
||||
title: '系统信息',
|
||||
bordered: false,
|
||||
column: 3,
|
||||
class: 'mx-4',
|
||||
},
|
||||
schema: useFollowUpDetailSchema(),
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="p-4">
|
||||
<BaseDescriptions :data="receivable" />
|
||||
<Divider />
|
||||
<SystemDescriptions :data="receivable" />
|
||||
</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user