2026-08-10 f9e6eb6fc2c2e0c2a2b17238b817fcbfcb6bab56
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<script setup lang="ts">
import type { CrmInvoiceApi } from '#/api/crm/invoice';
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 { Card, Tabs } from 'ant-design-vue';
 
import { getInvoice } from '#/api/crm/invoice';
import { getOperateLogPage } from '#/api/crm/operateLog';
import { BizTypeEnum } from '#/api/crm/permission';
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 InvoiceForm 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 invoiceId = ref(0);
const invoice = ref<CrmInvoiceApi.Invoice>({} as CrmInvoiceApi.Invoice);
const logList = ref<SystemOperateLogApi.OperateLog[]>([]);
const permissionListRef = ref<InstanceType<typeof PermissionList>>();
 
const [Descriptions] = useDescription({
  bordered: false,
  column: 4,
  schema: useDetailSchema(),
});
 
const [FormModal, formModalApi] = useVbenModal({
  connectedComponent: InvoiceForm,
  destroyOnClose: true,
});
 
/** 加载开票详情 */
async function loadInvoiceDetail() {
  loading.value = true;
  try {
    invoice.value = await getInvoice(invoiceId.value);
    const res = await getOperateLogPage({
      bizType: BizTypeEnum.CRM_INVOICE,
      bizId: invoiceId.value,
    });
    logList.value = res.list;
  } finally {
    loading.value = false;
  }
}
 
/** 返回列表页 */
function handleBack() {
  tabs.closeCurrentTab();
  router.push({ name: 'CrmInvoice' });
}
 
/** 编辑开票 */
function handleEdit() {
  formModalApi.setData({ invoice: { id: invoiceId.value } }).open();
}
 
/** 加载数据 */
onMounted(() => {
  invoiceId.value = Number(props.id || route.params.id);
  loadInvoiceDetail();
});
</script>
 
<template>
  <Page auto-content-height :title="invoice?.no" :loading="loading">
    <FormModal @success="loadInvoiceDetail" />
    <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:invoice:update'],
            ifShow: permissionListRef?.validateWrite,
            onClick: handleEdit,
          },
        ]"
      />
    </template>
    <Card class="min-h-[10%]">
      <Descriptions :data="invoice" />
    </Card>
    <Card class="mt-4 min-h-[60%]">
      <Tabs>
        <Tabs.TabPane tab="详细资料" key="1" :force-render="true">
          <Info :invoice="invoice" />
        </Tabs.TabPane>
        <Tabs.TabPane tab="操作日志" key="2" :force-render="true">
          <OperateLog :log-list="logList" />
        </Tabs.TabPane>
        <Tabs.TabPane tab="团队成员" key="3" :force-render="true">
          <PermissionList
            ref="permissionListRef"
            :biz-id="invoiceId"
            :biz-type="BizTypeEnum.CRM_INVOICE"
            :show-action="true"
            @quit-team="handleBack"
          />
        </Tabs.TabPane>
      </Tabs>
    </Card>
  </Page>
</template>