| | |
| | | <el-button |
| | | v-if="checkSubModuleItemShow('pageButton', 'addBtn')" |
| | | type="primary" |
| | | @click="handleAdd()" |
| | | @click="openDialog()" |
| | | >新增模板</el-button |
| | | > |
| | | </template> |
| | |
| | | bolePreview, |
| | | } from '@bole-core/components'; |
| | | import { EnumContractTemplateStatus, EnumContractTemplateStatusText } from '@/constants'; |
| | | import { convertPdfToImage, downloadFileByUrl, format, setOSSLink } from '@/utils'; |
| | | import { |
| | | convertApi2FormUrlOnlyOne, |
| | | convertPdfToImage, |
| | | downloadFileByUrl, |
| | | format, |
| | | setOSSLink, |
| | | } from '@/utils'; |
| | | import { ModelValueType } from 'element-plus'; |
| | | import * as electronSignServices from '@/services/api/electronSign'; |
| | | import TemplateAddDialog from './components/TemplateAddDialog.vue'; |
| | |
| | | checkBtn: { |
| | | emits: { |
| | | onClick: (role) => handleCheck(role), |
| | | }, |
| | | extraProps: { |
| | | hide: (row) => row.status !== EnumContractTemplateStatus.Completed, |
| | | }, |
| | | }, |
| | | editBtn: { |
| | | emits: { |
| | | onClick: (role) => openDialog(role), |
| | | }, |
| | | extraProps: { |
| | | hide: (row) => row.status !== EnumContractTemplateStatus.Completed, |
| | |
| | | } |
| | | ); |
| | | |
| | | const { dialogProps, handleAdd, editForm } = useFormDialog({ |
| | | async function openDialog(row?: API.GetEnterpriseContractTemplatesQueryResultItem) { |
| | | try { |
| | | if (row) { |
| | | let detail = await electronSignServices.getContractTemplate({ id: row.id }); |
| | | handleTemplateEdit({ |
| | | id: row.id, |
| | | templateId: row.templateId, |
| | | name: row.name, |
| | | code: row.code, |
| | | url: convertApi2FormUrlOnlyOne(row.file), |
| | | access: row.access, |
| | | isEnterpriseUserCreated: detail.isEnterpriseUserCreated, |
| | | templateEditData: detail.templateEditData, |
| | | isAutoSign: detail.isAutoSign ?? false, |
| | | autoSignPowerAttorneyUrl: convertApi2FormUrlOnlyOne(detail.autoSignPowerAttorneyUrl), |
| | | enterpriseId: detail.enterpriseId, |
| | | |
| | | customContents: detail.customContents.map((x) => x.name), |
| | | }); |
| | | } else { |
| | | handleTemplateAdd(); |
| | | } |
| | | } catch (error) {} |
| | | } |
| | | |
| | | const { |
| | | dialogProps, |
| | | handleAdd: handleTemplateAdd, |
| | | handleEdit: handleTemplateEdit, |
| | | editForm, |
| | | } = useFormDialog({ |
| | | onConfirm: handleAddOrEdit, |
| | | defaultFormParams: { |
| | | id: '', |
| | | templateId: '', |
| | | name: '', |
| | | code: '', |
| | | url: [] as UploadUserFile[], |
| | | access: '' as any as EnumElectronSignAccess, |
| | | isEnterpriseUserCreated: false, |
| | | templateEditData: '', |
| | | enterpriseId: '', |
| | | isAutoSign: true, |
| | | autoSignPowerAttorneyUrl: [] as UploadUserFile[], |
| | | |
| | | customContents: [] as string[], |
| | | }, |
| | | }); |
| | | |
| | | async function handleAddOrEdit() { |
| | | try { |
| | | let isEdit = !!editForm.id; |
| | | let pdfToImage = await convertPdfToImage(editForm.url?.[0].url); |
| | | let params: API.SaveContractTemplateCommand = { |
| | | name: editForm.name, |
| | | file: editForm.url[0]?.path ?? '', |
| | | enterpriseId: editForm.enterpriseId, |
| | | code: editForm.code, |
| | | access: editForm.access, |
| | | templateId: editForm.templateId, |
| | | autoSignPowerAttorneyUrl: editForm.autoSignPowerAttorneyUrl?.[0]?.path ?? '', |
| | | templateEditData: JSON.stringify( |
| | | pdfToImage.map( |
| | | (x) => |
| | |
| | | } as TemplateEditDataItem) |
| | | ) |
| | | ), |
| | | autoSignPowerAttorneyUrl: editForm.autoSignPowerAttorneyUrl?.[0]?.path ?? '', |
| | | isAutoSign: editForm.isAutoSign, |
| | | customContents: editForm.customContents, |
| | | }; |
| | | if (editForm.access === EnumElectronSignAccess.BestSign) { |
| | | params.isAutoSign = editForm.isAutoSign; |
| | | } else { |
| | | params.isAutoSign = false; |
| | | } |
| | | if (isEdit) { |
| | | params.id = editForm.id; |
| | | } |
| | | let res = await electronSignServices.saveContractTemplate(params); |
| | | if (res) { |
| | | Message.successMessage('保存成功'); |