| | |
| | | submitContract, |
| | | } from '#/api/crm/contract'; |
| | | import { $t } from '#/locales'; |
| | | import { automaticApproval } from '#/store/audit-policy'; |
| | | import { downloadContractWord } from '#/utils/contract-document'; |
| | | |
| | | import { useGridColumns, useGridFormSchema } from './data'; |
| | | import Form from './modules/form.vue'; |
| | | import ImportForm from './modules/import-form.vue'; |
| | | |
| | | const { push } = useRouter(); |
| | | const sceneType = ref('1'); |
| | |
| | | destroyOnClose: true, |
| | | }); |
| | | |
| | | const [ImportModal, importModalApi] = useVbenModal({ |
| | | connectedComponent: ImportForm, |
| | | destroyOnClose: true, |
| | | }); |
| | | |
| | | /** 刷新表格 */ |
| | | function handleRefresh() { |
| | | gridApi.grid.clearCheckboxRow(); |
| | | gridApi.query(); |
| | | } |
| | | |
| | |
| | | ...formValues, |
| | | }); |
| | | downloadFileFromBlobPart({ fileName: '合同.xls', source: data }); |
| | | } |
| | | |
| | | /** 导出勾选的合同 */ |
| | | async function handleExportSelected() { |
| | | const rows: CrmContractApi.Contract[] = |
| | | gridApi.grid.getCheckboxRecords?.() ?? []; |
| | | const ids = rows.map((row) => row.id!); |
| | | if (ids.length === 0) { |
| | | message.warning('请先勾选要导出的合同'); |
| | | return; |
| | | } |
| | | const formValues = await gridApi.formApi.getValues(); |
| | | const data = await exportContract({ |
| | | sceneType: sceneType.value, |
| | | ids: ids.join(','), |
| | | ...formValues, |
| | | }); |
| | | downloadFileFromBlobPart({ fileName: '合同.xls', source: data }); |
| | | } |
| | | |
| | | /** 导入合同 */ |
| | | function handleImport() { |
| | | importModalApi.open(); |
| | | } |
| | | |
| | | /** 创建合同 */ |
| | |
| | | const submitLoading = ref(false); |
| | | |
| | | async function handleSubmit(row: CrmContractApi.Contract) { |
| | | const res = await getContractApproveProcessList(); |
| | | const res = automaticApproval.value ? [] : await getContractApproveProcessList(); |
| | | processList.value = res; |
| | | currentRow.value = row; |
| | | selectedProcessKey.value = undefined; |
| | | if (automaticApproval.value) { |
| | | selectedProcessKey.value = 'contract_approve'; |
| | | await confirmSubmit(); |
| | | return; |
| | | } |
| | | submitModalVisible.value = true; |
| | | } |
| | | |
| | |
| | | submitLoading.value = true; |
| | | try { |
| | | await submitContract(currentRow.value!.id!, selectedProcessKey.value); |
| | | message.success('提交审批成功'); |
| | | message.success(automaticApproval.value ? '已提交生效' : '提交审批成功'); |
| | | submitModalVisible.value = false; |
| | | handleRefresh(); |
| | | } finally { |
| | |
| | | <template> |
| | | <Page auto-content-height> |
| | | <FormModal @success="handleRefresh" /> |
| | | <ImportModal @success="handleRefresh" /> |
| | | <Grid> |
| | | <template #toolbar-actions> |
| | | <Tabs class="w-full" @change="handleChangeSceneType"> |
| | |
| | | icon: ACTION_ICON.DOWNLOAD, |
| | | auth: ['crm:contract:export'], |
| | | onClick: handleExport, |
| | | }, |
| | | { |
| | | label: '导出选中', |
| | | type: 'primary', |
| | | icon: ACTION_ICON.DOWNLOAD, |
| | | auth: ['crm:contract:export'], |
| | | onClick: handleExportSelected, |
| | | }, |
| | | { |
| | | label: '导入', |
| | | type: 'primary', |
| | | icon: ACTION_ICON.UPLOAD, |
| | | auth: ['crm:contract:import'], |
| | | onClick: handleImport, |
| | | }, |
| | | ]" |
| | | /> |
| | |
| | | <TableAction |
| | | :actions="[ |
| | | { |
| | | label: '下载合同', |
| | | type: 'link', |
| | | icon: 'lucide:download', |
| | | auth: ['crm:contract:query'], |
| | | onClick: () => downloadContractWord(row.id, row.no), |
| | | }, |
| | | { |
| | | label: $t('common.edit'), |
| | | type: 'link', |
| | | icon: ACTION_ICON.EDIT, |