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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
| <script lang="ts" setup>
| import type { VxeTableGridOptions } from '#/adapter/vxe-table';
| import type { CrmContractApi } from '#/api/crm/contract';
| import type { DescriptionItemSchema } from '#/components/description';
|
| import { h, nextTick, onMounted, ref } from 'vue';
|
| import { ContentWrap } from '@vben/common-ui';
| import { DICT_TYPE } from '@vben/constants';
| import {
| erpCountInputFormatter,
| erpPriceInputFormatter,
| formatDateTime,
| } from '@vben/utils';
|
| import { Spin } from 'ant-design-vue';
|
| import { useVbenVxeGrid } from '#/adapter/vxe-table';
| import { getContract } from '#/api/crm/contract';
| import { DictTag } from '#/components/dict-tag';
| import { useDescription } from '#/components/description';
|
| defineOptions({ name: 'CrmContractApproveDetail' });
|
| const props = defineProps<{ id: string }>();
|
| const loading = ref(false);
| const formData = ref<CrmContractApi.Contract>();
|
| /** 文本字段空值占位 */
| function textRender(val: unknown) {
| return val === 0 || val ? String(val) : '-';
| }
|
| /** 合同产品明细(审批详情只读列) */
| function useProductColumns(): VxeTableGridOptions['columns'] {
| return [
| { type: 'seq', title: '序号', width: 60 },
| { field: 'itemName', title: '产品名称', minWidth: 180 },
| { field: 'itemCode', title: '物料编码', minWidth: 120 },
| { field: 'itemUnitName', title: '单位', minWidth: 80, formatter: ({ cellValue }) => textRender(cellValue) },
| {
| field: 'contractPrice',
| title: '合同价格(元)',
| minWidth: 120,
| formatter: ({ cellValue }) => erpPriceInputFormatter(cellValue) || '-',
| },
| {
| field: 'count',
| title: '数量',
| minWidth: 100,
| formatter: ({ cellValue }) => erpCountInputFormatter(cellValue) || '-',
| },
| {
| field: 'totalPrice',
| title: '合计金额(元)',
| minWidth: 120,
| formatter: ({ cellValue }) => erpPriceInputFormatter(cellValue) || '-',
| },
| ];
| }
|
| const [Grid, gridApi] = useVbenVxeGrid({
| gridOptions: {
| columns: useProductColumns(),
| data: [],
| minHeight: 200,
| autoResize: true,
| border: true,
| rowConfig: {
| keyField: 'id',
| isHover: true,
| },
| pagerConfig: {
| enabled: false,
| },
| toolbarConfig: {
| enabled: false,
| },
| },
| });
|
| const [Descriptions] = useDescription({
| bordered: true,
| column: 2,
| schema: [
| { label: '合同编号', field: 'no', render: textRender },
| { label: '合同名称', field: 'name', render: textRender },
| { label: '客户名称', field: 'customerName', render: textRender },
| { label: '商机名称', field: 'businessName', render: textRender },
| {
| label: '合同金额(元)',
| field: 'totalPrice',
| render: (val) => erpPriceInputFormatter(val) || '-',
| },
| {
| label: '定金金额(元)',
| field: 'depositPrice',
| render: (val) => erpPriceInputFormatter(val) || '-',
| },
| {
| label: '回款金额(元)',
| field: 'totalReceivablePrice',
| render: (val) => erpPriceInputFormatter(val) || '-',
| },
| {
| label: '已开票金额(元)',
| field: 'totalInvoicePrice',
| render: (val) => erpPriceInputFormatter(val) || '-',
| },
| {
| label: '未开票金额(元)',
| field: 'unInvoicePrice',
| render: (val) => erpPriceInputFormatter(val) || '-',
| },
| {
| label: '下单时间',
| field: 'orderDate',
| render: (val) => formatDateTime(val) as string,
| },
| {
| label: '合同开始时间',
| field: 'startTime',
| render: (val) => formatDateTime(val) as string,
| },
| {
| label: '合同结束时间',
| field: 'endTime',
| render: (val) => formatDateTime(val) as string,
| },
| { label: '客户签约人', field: 'signContactName', render: textRender },
| { label: '公司签约人', field: 'signUserName', render: textRender },
| { label: '销售订单', field: 'orderNo', render: textRender },
| { label: '创建人', field: 'creatorName', render: textRender },
| {
| label: '创建时间',
| field: 'createTime',
| render: (val) => formatDateTime(val) as string,
| },
| {
| label: '合同状态',
| field: 'auditStatus',
| render: (val) =>
| h(DictTag, { type: DICT_TYPE.CRM_AUDIT_STATUS, value: val }),
| },
| { label: '备注', field: 'remark', render: textRender },
| ] as DescriptionItemSchema[],
| });
|
| onMounted(async () => {
| try {
| loading.value = true;
| formData.value = await getContract(Number(props.id));
| if (formData.value?.products?.length) {
| await nextTick();
| await gridApi.grid.reloadData(formData.value.products);
| }
| } finally {
| loading.value = false;
| }
| });
| </script>
|
| <template>
| <ContentWrap class="m-2">
| <Spin :spinning="loading" tip="加载中...">
| <div class="space-y-4">
| <!-- 合同基本信息 -->
| <div class="rounded-lg border border-border bg-background p-4">
| <div class="mb-4 flex items-center gap-2">
| <span class="inline-block h-4 w-1 rounded bg-primary" />
| <span class="text-base font-semibold">合同基本信息</span>
| </div>
| <Descriptions :data="formData" />
| </div>
| <!-- 产品明细 -->
| <div
| v-if="formData?.products?.length"
| class="rounded-lg border border-border bg-background p-4"
| >
| <div class="mb-4 flex items-center gap-2">
| <span class="inline-block h-4 w-1 rounded bg-primary" />
| <span class="text-base font-semibold">产品明细</span>
| </div>
| <Grid />
| </div>
| </div>
| </Spin>
| </ContentWrap>
| </template>
|
|