gaoluyang
23 小时以前 cd8b52bdf89a4d1101f72e0ece9f4df22a3d3f7a
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
<!-- 即将到期的合同 -->
<script lang="ts" setup>
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { CrmContractApi } from '#/api/crm/contract';
 
import { useRouter } from 'vue-router';
 
import { Button, Tag } from 'ant-design-vue';
 
import { TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import { getContractPage } from '#/api/crm/contract';
import { useGridColumns } from '#/views/crm/contract/data';
 
import { CONTRACT_EXPIRY_TYPE } from '../data';
 
const { push } = useRouter();
 
/** 查看审批 */
function handleProcessDetail(row: CrmContractApi.Contract) {
  push({
    name: 'BpmProcessInstanceDetail',
    query: { id: row.processInstanceId },
  });
}
 
/** 打开合同详情 */
function handleContractDetail(row: CrmContractApi.Contract) {
  push({ name: 'CrmContractDetail', params: { id: row.id } });
}
 
/** 打开客户详情 */
function handleCustomerDetail(row: CrmContractApi.Contract) {
  if (row.customerId) push({ name: 'CrmCustomerDetail', params: { id: row.customerId } });
}
 
/** 打开联系人详情 */
function handleContactDetail(row: CrmContractApi.Contract) {
  if (row.signContactId) push({ name: 'CrmContactDetail', params: { id: row.signContactId } });
}
 
/** 打开商机详情 */
function handleBusinessDetail(row: CrmContractApi.Contract) {
  if (row.businessId) push({ name: 'CrmBusinessDetail', params: { id: row.businessId } });
}
 
function handleViewOrder(row: CrmContractApi.Contract) {
  if (row.orderId) push({ name: 'ErpSaleOrder', query: { id: row.orderId } });
}
 
const [Grid] = useVbenVxeGrid({
  formOptions: {
    schema: [
      {
        fieldName: 'expiryType',
        label: '到期状态',
        component: 'Select',
        componentProps: {
          allowClear: true,
          options: CONTRACT_EXPIRY_TYPE,
        },
        defaultValue: CONTRACT_EXPIRY_TYPE[0]!.value,
      },
    ],
  },
  gridOptions: {
    columns: useGridColumns(),
    height: 'auto',
    keepSource: true,
    proxyConfig: {
      ajax: {
        query: async ({ page }, formValues) => {
          return await getContractPage({
            pageNo: page.currentPage,
            pageSize: page.pageSize,
            sceneType: 1, // 自己负责的
            ...formValues,
          });
        },
      },
    },
    rowConfig: {
      keyField: 'id',
      isHover: true,
    },
    toolbarConfig: {
      refresh: true,
      search: true,
    },
  } as VxeTableGridOptions<CrmContractApi.Contract>,
});
</script>
 
<template>
  <Grid>
    <template #no="{ row }">
      <Button type="link" @click="handleContractDetail(row)">
        {{ row.no }}
      </Button>
    </template>
    <template #name="{ row }">
      <Button type="link" @click="handleContractDetail(row)">
        {{ row.name }}
      </Button>
    </template>
    <template #customerName="{ row }">
      <Button type="link" @click="handleCustomerDetail(row)">
        {{ row.customerName }}
      </Button>
    </template>
    <template #businessName="{ row }">
      <Button type="link" @click="handleBusinessDetail(row)">
        {{ row.businessName }}
      </Button>
    </template>
    <template #signContactName="{ row }">
      <Button type="link" @click="handleContactDetail(row)">
        {{ row.signContactName }}
      </Button>
    </template>
    <template #auditStatus="{ row }">
      <Tag v-if="row.auditStatus === 0">未提交</Tag>
      <Tag v-else-if="row.auditStatus === 10" color="warning">审批中</Tag>
      <Tag v-else-if="row.auditStatus === 20" color="success">审核通过</Tag>
      <Tag v-else-if="row.auditStatus === 30" color="error">审核不通过</Tag>
      <Tag v-else-if="row.auditStatus === 40">已取消</Tag>
      <Tag v-else-if="row.auditStatus === 50" color="error">已作废</Tag>
      <span v-else>—</span>
    </template>
    <template #orderNo="{ row }">
      <Button v-if="row.orderId" type="link" @click="handleViewOrder(row)">{{ row.orderNo }}</Button>
      <span v-else>—</span>
    </template>
    <template #actions="{ row }">
      <TableAction
        :actions="[
          {
            label: '查看审批',
            type: 'link',
            auth: ['crm:contract:update'],
            ifShow: !!row.processInstanceId,
            onClick: handleProcessDetail.bind(null, row),
          },
        ]"
      />
    </template>
  </Grid>
</template>