|  | @@ -8,9 +8,11 @@ import {
 | 
	
		
			
				|  |  |    EmrStore,
 | 
	
		
			
				|  |  |    rightCompIndex,
 | 
	
		
			
				|  |  |  } from "@/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-func/useEmrStore";
 | 
	
		
			
				|  |  | -import { EmrRightTabs } from "@/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-editor/emr-init";
 | 
	
		
			
				|  |  | +import {
 | 
	
		
			
				|  |  | +  EmrRightTabs,
 | 
	
		
			
				|  |  | +  patientInfo,
 | 
	
		
			
				|  |  | +} from "@/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-editor/emr-init";
 | 
	
		
			
				|  |  |  import { stringNotBlank } from "@/utils/blank-utils";
 | 
	
		
			
				|  |  | -import { setEmrComponentClick } from "@/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-func/emr-component-click";
 | 
	
		
			
				|  |  |  import { ElMessageBox } from "element-plus";
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  const GenerateSignature = defineAsyncComponent(
 | 
	
	
		
			
				|  | @@ -20,101 +22,6 @@ const GenerateSignature = defineAsyncComponent(
 | 
	
		
			
				|  |  |      )
 | 
	
		
			
				|  |  |  );
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -const testInput = {
 | 
	
		
			
				|  |  | -  required: false,
 | 
	
		
			
				|  |  | -  readonly: false,
 | 
	
		
			
				|  |  | -  deletable: true,
 | 
	
		
			
				|  |  | -  privacy: false,
 | 
	
		
			
				|  |  | -  script: {
 | 
	
		
			
				|  |  | -    content: null,
 | 
	
		
			
				|  |  | -    dynamicScript: "2154eae0167611ef8717efceee160e36",
 | 
	
		
			
				|  |  | -  },
 | 
	
		
			
				|  |  | -  format: {
 | 
	
		
			
				|  |  | -    dataType: null,
 | 
	
		
			
				|  |  | -    showType: null,
 | 
	
		
			
				|  |  | -    minLength: null,
 | 
	
		
			
				|  |  | -    maxLength: null,
 | 
	
		
			
				|  |  | -    minRows: null,
 | 
	
		
			
				|  |  | -    maxRows: null,
 | 
	
		
			
				|  |  | -    scale: null,
 | 
	
		
			
				|  |  | -    enums: null,
 | 
	
		
			
				|  |  | -    dictionary: null,
 | 
	
		
			
				|  |  | -  },
 | 
	
		
			
				|  |  | -  element: {
 | 
	
		
			
				|  |  | -    id: "552c4a60167711ef8717efceee160e36",
 | 
	
		
			
				|  |  | -    type: "element",
 | 
	
		
			
				|  |  | -    name: "医生签名",
 | 
	
		
			
				|  |  | -    code: {
 | 
	
		
			
				|  |  | -      business: "自动签名",
 | 
	
		
			
				|  |  | -      internal: "编辑者CA签名",
 | 
	
		
			
				|  |  | -      dataElement: "",
 | 
	
		
			
				|  |  | -    },
 | 
	
		
			
				|  |  | -  },
 | 
	
		
			
				|  |  | -  tips: "医生签名",
 | 
	
		
			
				|  |  | -  borderStyle: "none",
 | 
	
		
			
				|  |  | -  style: {
 | 
	
		
			
				|  |  | -    id: "e6aRxaE7OLt",
 | 
	
		
			
				|  |  | -  },
 | 
	
		
			
				|  |  | -  picker: {
 | 
	
		
			
				|  |  | -    type: null,
 | 
	
		
			
				|  |  | -    propertiesConfig: {
 | 
	
		
			
				|  |  | -      signCount: {
 | 
	
		
			
				|  |  | -        name: "签名数量",
 | 
	
		
			
				|  |  | -        code: "signCount",
 | 
	
		
			
				|  |  | -        category: "extend",
 | 
	
		
			
				|  |  | -        categoryName: "扩展",
 | 
	
		
			
				|  |  | -        value: 1,
 | 
	
		
			
				|  |  | -        editor: {
 | 
	
		
			
				|  |  | -          type: "numberfield",
 | 
	
		
			
				|  |  | -          minvalue: 1,
 | 
	
		
			
				|  |  | -        },
 | 
	
		
			
				|  |  | -      },
 | 
	
		
			
				|  |  | -      maxHeight: {
 | 
	
		
			
				|  |  | -        name: "最大高度",
 | 
	
		
			
				|  |  | -        code: "maxHeight",
 | 
	
		
			
				|  |  | -        category: "extend",
 | 
	
		
			
				|  |  | -        categoryName: "扩展",
 | 
	
		
			
				|  |  | -        editor: {
 | 
	
		
			
				|  |  | -          type: "numberfield",
 | 
	
		
			
				|  |  | -        },
 | 
	
		
			
				|  |  | -      },
 | 
	
		
			
				|  |  | -      valign: {
 | 
	
		
			
				|  |  | -        name: "对齐方式",
 | 
	
		
			
				|  |  | -        code: "valign",
 | 
	
		
			
				|  |  | -        category: "extend",
 | 
	
		
			
				|  |  | -        categoryName: "扩展",
 | 
	
		
			
				|  |  | -        editor: {
 | 
	
		
			
				|  |  | -          type: "select",
 | 
	
		
			
				|  |  | -          valueField: "code",
 | 
	
		
			
				|  |  | -          displayField: "name",
 | 
	
		
			
				|  |  | -          store: {
 | 
	
		
			
				|  |  | -            type: "store",
 | 
	
		
			
				|  |  | -            fields: ["code", "name"],
 | 
	
		
			
				|  |  | -            data: [
 | 
	
		
			
				|  |  | -              {
 | 
	
		
			
				|  |  | -                code: "top",
 | 
	
		
			
				|  |  | -                name: "上对齐",
 | 
	
		
			
				|  |  | -              },
 | 
	
		
			
				|  |  | -              {
 | 
	
		
			
				|  |  | -                code: "middle",
 | 
	
		
			
				|  |  | -                name: "中对齐",
 | 
	
		
			
				|  |  | -              },
 | 
	
		
			
				|  |  | -              {
 | 
	
		
			
				|  |  | -                code: "bottom",
 | 
	
		
			
				|  |  | -                name: "下对齐",
 | 
	
		
			
				|  |  | -              },
 | 
	
		
			
				|  |  | -            ],
 | 
	
		
			
				|  |  | -          },
 | 
	
		
			
				|  |  | -        },
 | 
	
		
			
				|  |  | -      },
 | 
	
		
			
				|  |  | -    },
 | 
	
		
			
				|  |  | -  },
 | 
	
		
			
				|  |  | -  editable: false,
 | 
	
		
			
				|  |  | -  contentWrap: true,
 | 
	
		
			
				|  |  | -  signCount: 1,
 | 
	
		
			
				|  |  | -  type: "smarttext",
 | 
	
		
			
				|  |  | -};
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |  export type SignComp = {
 | 
	
		
			
				|  |  |    id: string;
 | 
	
		
			
				|  |  |    signType: number | null;
 | 
	
	
		
			
				|  | @@ -148,25 +55,6 @@ export const selectData = [
 | 
	
		
			
				|  |  |    },
 | 
	
		
			
				|  |  |  ];
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -function getTestContent(editor: EditType, internal = "", dataElement = "") {
 | 
	
		
			
				|  |  | -  editor.setCursor("DOCUMENT_START");
 | 
	
		
			
				|  |  | -  const tmp = XEUtils.cloneDeep(testInput);
 | 
	
		
			
				|  |  | -  tmp.element.code.internal = internal;
 | 
	
		
			
				|  |  | -  tmp.element.code.dataElement = dataElement;
 | 
	
		
			
				|  |  | -  editor.execute("insertContents", {
 | 
	
		
			
				|  |  | -    value: [tmp],
 | 
	
		
			
				|  |  | -  });
 | 
	
		
			
				|  |  | -}
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -function testFunc(editor: EditType) {
 | 
	
		
			
				|  |  | -  if (!isDev) return;
 | 
	
		
			
				|  |  | -  getTestContent(editor, "患者CA签名", "1");
 | 
	
		
			
				|  |  | -  getTestContent(editor, "患者CA签名", "2");
 | 
	
		
			
				|  |  | -  getTestContent(editor, "患者CA签名", "3");
 | 
	
		
			
				|  |  | -  getTestContent(editor, "患者CA签名", "4");
 | 
	
		
			
				|  |  | -  getTestContent(editor, "编辑者CA签名");
 | 
	
		
			
				|  |  | -}
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |  type saveType =
 | 
	
		
			
				|  |  |    | {
 | 
	
		
			
				|  |  |        // 病历的名称
 | 
	
	
		
			
				|  | @@ -178,12 +66,15 @@ type saveType =
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |    | any;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +const us = useUserStore().userInfo;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  export function getInternalByCode(
 | 
	
		
			
				|  |  |    editor: EditType,
 | 
	
		
			
				|  |  |    name: string,
 | 
	
		
			
				|  |  | +  code: "internal" | "business" = "internal",
 | 
	
		
			
				|  |  |    removeNotNull = true
 | 
	
		
			
				|  |  |  ): DataElementItem[] {
 | 
	
		
			
				|  |  | -  const signatureControl = editor.getDataElements("internal", false, true);
 | 
	
		
			
				|  |  | +  const signatureControl = editor.getDataElements(code, false, true);
 | 
	
		
			
				|  |  |    let data = signatureControl[name] as DataElementItem[];
 | 
	
		
			
				|  |  |    if (!data) {
 | 
	
		
			
				|  |  |      return null;
 | 
	
	
		
			
				|  | @@ -271,7 +162,7 @@ export function emrCa() {
 | 
	
		
			
				|  |  |        {
 | 
	
		
			
				|  |  |          name: res.name,
 | 
	
		
			
				|  |  |          code: res.code,
 | 
	
		
			
				|  |  | -        signature: `http://172.16.32.167:8077/doctorSignatureImage/${res.code}.png`,
 | 
	
		
			
				|  |  | +        signature: `/doctorSignatureImage/${res.code}.png`,
 | 
	
		
			
				|  |  |        },
 | 
	
		
			
				|  |  |      ]);
 | 
	
		
			
				|  |  |    }
 | 
	
	
		
			
				|  | @@ -284,11 +175,6 @@ export function emrCa() {
 | 
	
		
			
				|  |  |          value: 400,
 | 
	
		
			
				|  |  |        },
 | 
	
		
			
				|  |  |      };
 | 
	
		
			
				|  |  | -    setEmrComponentClick((evt, view, eleInfo, value) => {
 | 
	
		
			
				|  |  | -      授权CA签名(evt, view, eleInfo, value).then(XEUtils.noop);
 | 
	
		
			
				|  |  | -      患者CA签名(evt, view, eleInfo, value);
 | 
	
		
			
				|  |  | -      老授权签名(evt, view, eleInfo, value).then(XEUtils.noop);
 | 
	
		
			
				|  |  | -    });
 | 
	
		
			
				|  |  |    };
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    const loaded = () => {
 | 
	
	
		
			
				|  | @@ -337,6 +223,35 @@ export function emrCa() {
 | 
	
		
			
				|  |  |      });
 | 
	
		
			
				|  |  |    };
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +  const caPush = async value => {
 | 
	
		
			
				|  |  | +    await pushSign(value).catch(async () => {
 | 
	
		
			
				|  |  | +      await ElMessageBox.alert(
 | 
	
		
			
				|  |  | +        "生成自己的签名失败,请检查是否开启了免签功能,或者云医签APP是否为登录状态,可重新保存病历触发签名功能。",
 | 
	
		
			
				|  |  | +        "签名失败",
 | 
	
		
			
				|  |  | +        {
 | 
	
		
			
				|  |  | +          type: "warning",
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +      ).catch(XEUtils.noop);
 | 
	
		
			
				|  |  | +    });
 | 
	
		
			
				|  |  | +  };
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  const oldSign = () => {
 | 
	
		
			
				|  |  | +    const signatureControl = getInternalByCode(editor, "自动签名", "business");
 | 
	
		
			
				|  |  | +    if (signatureControl) {
 | 
	
		
			
				|  |  | +      signatureControl.forEach(item => {
 | 
	
		
			
				|  |  | +        const element = getViewById(editor, item.id);
 | 
	
		
			
				|  |  | +        element.view.sign([
 | 
	
		
			
				|  |  | +          {
 | 
	
		
			
				|  |  | +            name: us.name,
 | 
	
		
			
				|  |  | +            code: us.code,
 | 
	
		
			
				|  |  | +            signature: `/doctorSignatureImage/${us.code}.png`,
 | 
	
		
			
				|  |  | +          },
 | 
	
		
			
				|  |  | +        ]);
 | 
	
		
			
				|  |  | +      });
 | 
	
		
			
				|  |  | +      console.log(signatureControl);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  };
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |    return {
 | 
	
		
			
				|  |  |      install({ e, s }) {
 | 
	
		
			
				|  |  |        editor = e;
 | 
	
	
		
			
				|  | @@ -345,17 +260,20 @@ export function emrCa() {
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  |      event: {
 | 
	
		
			
				|  |  |        loaded,
 | 
	
		
			
				|  |  | +      componentClick: (evt, view) => {
 | 
	
		
			
				|  |  | +        const eleInfo = view.getAttribute("element");
 | 
	
		
			
				|  |  | +        const value = {
 | 
	
		
			
				|  |  | +          patientInfo: patientInfo.value,
 | 
	
		
			
				|  |  | +          emrName: store.store.templateName,
 | 
	
		
			
				|  |  | +        };
 | 
	
		
			
				|  |  | +        授权CA签名(evt, view, eleInfo, value).then(XEUtils.noop);
 | 
	
		
			
				|  |  | +        患者CA签名(evt, view, eleInfo, value);
 | 
	
		
			
				|  |  | +        老授权签名(evt, view, eleInfo, value).then(XEUtils.noop);
 | 
	
		
			
				|  |  | +      },
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  |      beforeSaving: async value => {
 | 
	
		
			
				|  |  | -      await pushSign(value).catch(async () => {
 | 
	
		
			
				|  |  | -        await ElMessageBox.alert(
 | 
	
		
			
				|  |  | -          "生成自己的签名失败,请检查是否开启了免签功能,或者云医签APP是否为登录状态,可重新保存病历触发签名功能。",
 | 
	
		
			
				|  |  | -          "签名失败",
 | 
	
		
			
				|  |  | -          {
 | 
	
		
			
				|  |  | -            type: "warning",
 | 
	
		
			
				|  |  | -          }
 | 
	
		
			
				|  |  | -        ).catch(XEUtils.noop);
 | 
	
		
			
				|  |  | -      });
 | 
	
		
			
				|  |  | +      await caPush(value);
 | 
	
		
			
				|  |  | +      oldSign();
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  |    };
 | 
	
		
			
				|  |  |  }
 |