From 55119aeab85c9dc310ab8bc3de3091a20fa9a684 Mon Sep 17 00:00:00 2001
From: zhengyiming <540361168@qq.com>
Date: 星期四, 21 八月 2025 16:35:00 +0800
Subject: [PATCH] fix: 签约

---
 src/views/ProtocolManage/EditTemplate.vue |   88 +++++++++++++++++++++++++++++--------------
 1 files changed, 59 insertions(+), 29 deletions(-)

diff --git a/src/views/ProtocolManage/EditTemplate.vue b/src/views/ProtocolManage/EditTemplate.vue
index 257d4a3..c0c486a 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,
     },
   },
 
@@ -185,27 +195,35 @@
     file: [] as UploadUserFile[],
     access: '' as any as EnumElectronSignAccess,
     title: '鏂板妯℃澘',
+    isEnterpriseUserCreated: false,
+    templateEditData: '',
   },
 });
 
-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,
+      });
+    } 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 +231,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;
@@ -253,6 +270,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