zhengyiming
15 小时以前 97f29024ce18babeb4b635c5d73f907ac493976e
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,37 @@
    file: [] as UploadUserFile[],
    access: '' as any as EnumElectronSignAccess,
    title: '新增模板',
    isEnterpriseUserCreated: false,
    templateEditData: '',
    enterpriseId: '',
  },
});
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 +233,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 +272,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 {