From be028017a461af4c9745c69c4df084d4c3e6b296 Mon Sep 17 00:00:00 2001
From: zhengyiming <540361168@qq.com>
Date: 星期三, 22 十月 2025 18:08:49 +0800
Subject: [PATCH] fix: bug
---
src/views/ProtocolManage/EditTemplate.vue | 98 +++++++++++++++++++++++++++++++++---------------
1 files changed, 67 insertions(+), 31 deletions(-)
diff --git a/src/views/ProtocolManage/EditTemplate.vue b/src/views/ProtocolManage/EditTemplate.vue
index 257d4a3..0154140 100644
--- a/src/views/ProtocolManage/EditTemplate.vue
+++ b/src/views/ProtocolManage/EditTemplate.vue
@@ -76,7 +76,13 @@
import * as electronSignServices from '@/services/api/electronSign';
import AddOrEditTemplateDialog from './components/AddOrEditTemplateDialog.vue';
import { downloadFileByUrl, Message } from '@bole-core/core';
-import { convertApi2FormUrlOnlyOne, format, setOSSLink } from '@/utils';
+import {
+ convertApi2FormUrlOnlyOne,
+ convertPdfToImage,
+ format,
+ openLink,
+ setOSSLink,
+} from '@/utils';
import { EnumContractTemplateStatus, EnumContractTemplateStatusText } from '@/constants';
defineOptions({
@@ -84,11 +90,14 @@
});
const operationBtnMap: Record<string, OperationBtnType> = {
- editBtn: { emits: { onClick: (role) => openDialog(role) } },
- editTemplateBtn: {
+ editBtn: {
emits: { onClick: (role) => openDialog(role) },
+ },
+ editTemplateBtn: {
+ emits: { onClick: (role) => goEditTemplate(role) },
extraProps: {
- hide: (row) => false,
+ hide: (row: API.GetEnterpriseContractTemplatesQueryResultItem) =>
+ row.status !== EnumContractTemplateStatus.Wait,
},
},
downloadBtn: {
@@ -98,7 +107,8 @@
emits: { onClick: (role) => handleDelete(role) },
props: { type: 'danger' },
extraProps: {
- hide: (row) => false,
+ hide: (row: API.GetEnterpriseContractTemplatesQueryResultItem) =>
+ row.status !== EnumContractTemplateStatus.Completed,
},
},
@@ -175,7 +185,7 @@
}
);
-const { dialogProps, handleEdit, handleAdd, editForm } = useFormDialog({
+const { dialogProps, handleEdit, handleAdd, editForm, dialogState } = useFormDialog({
onConfirm: handleAddOrEdit,
defaultFormParams: {
id: '',
@@ -185,27 +195,38 @@
file: [] as UploadUserFile[],
access: '' as any as EnumElectronSignAccess,
title: '鏂板妯℃澘',
+ isEnterpriseUserCreated: false,
+ templateEditData: '',
+ enterpriseId: '',
},
+ closeAfterConfirm: false,
});
-function openDialog(row?: API.GetEnterpriseContractTemplatesQueryResultItem) {
- if (row) {
- handleEdit({
- id: row.id,
- templateId: row.templateId,
- name: row.name,
- code: row.code,
- file: convertApi2FormUrlOnlyOne(row.file),
- access: row.access,
- });
- } else {
- handleAdd();
- }
+async function openDialog(row?: API.GetEnterpriseContractTemplatesQueryResultItem) {
+ try {
+ if (row) {
+ let detail = await electronSignServices.getContractTemplate({ id: row.id });
+ handleEdit({
+ id: row.id,
+ templateId: row.templateId,
+ name: row.name,
+ code: row.code,
+ file: convertApi2FormUrlOnlyOne(row.file),
+ access: row.access,
+ isEnterpriseUserCreated: detail.isEnterpriseUserCreated,
+ templateEditData: detail.templateEditData,
+ enterpriseId: enterpriseId,
+ });
+ } else {
+ handleAdd();
+ }
+ } catch (error) {}
}
async function handleAddOrEdit() {
try {
let isEdit = !!editForm.id;
+ let pdfToImage = await convertPdfToImage(editForm.file?.[0].url);
let params: API.SaveContractTemplateCommand = {
name: editForm.name,
file: editForm.file[0]?.path ?? '',
@@ -213,17 +234,16 @@
code: editForm.code,
access: editForm.access,
templateId: editForm.templateId,
- // values: [
- // {
- // id: '3fa85f64-5717-4562-b3fc-2c963f66afa6',
- // type: 10,
- // recorder: 10,
- // userType: 10,
- // label: 'string',
- // name: 'string',
- // required: true,
- // },
- // ],
+ templateEditData: JSON.stringify(
+ pdfToImage.map(
+ (x) =>
+ ({
+ path: x.path,
+ width: x.width,
+ height: x.height,
+ } as TemplateEditDataItem)
+ )
+ ),
};
if (isEdit) {
params.id = editForm.id;
@@ -232,8 +252,11 @@
if (res) {
Message.successMessage('鎿嶄綔鎴愬姛');
getList();
+ dialogState.dialogVisible = false;
}
- } catch (error) {}
+ } catch (error) {
+ dialogState.dialogVisible = true;
+ }
}
function handleDownload(row: API.GetEnterpriseContractTemplatesQueryResultItem) {
@@ -253,6 +276,19 @@
} catch (error) {}
}
+const router = useRouter();
+
+function goEditTemplate(row: API.GetEnterpriseContractTemplatesQueryResultItem) {
+ openLink(
+ router.resolve({
+ name: 'TemplateKeyEdit',
+ params: {
+ id: row.id ?? '',
+ },
+ }).fullPath
+ );
+}
+
const { openLogDialog, logDialogProps } = useOpenLogDialog({
service: async ({ pageIndex, pageSize }, extraParamState) => {
try {
--
Gitblit v1.9.1