lighter 10 months ago
parent
commit
c6743124dd

+ 17 - 8
src/components/cy/CyDialog/index.ts

@@ -1,4 +1,4 @@
-import { ref, shallowRef } from "vue";
+import { Component, ref, shallowRef } from "vue";
 import XEUtils from "xe-utils";
 
 interface DialogProps {
@@ -17,15 +17,24 @@ export interface DialogExpose {
   cancel: () => any | Promise<any>;
 }
 
-export namespace UseDialog {
-  export interface Expose extends DialogExpose {}
+export interface UseDialog {
+  Expose: {} & DialogExpose;
 
-  export interface Emits {
+  Emits: {
     (e: "cyDialogConfirm" | "cyDialogCancel", value?: any): void;
-  }
+  };
 }
 
-type FirstParam<T> = T extends Component<infer P> ? P : any;
+export interface UseDialogEmits {
+  (e: "cyDialogConfirm" | "cyDialogCancel", value?: any): void;
+}
+
+type FirstParam<T> =
+  T extends Component<infer P, any, any, any, any, any>
+    ? P extends Record<string, any>
+      ? P
+      : {}
+    : never;
 
 export interface DialogOptions<P = Component> {
   dialogProps: DialogProps;
@@ -50,11 +59,11 @@ export interface DialogState extends DialogOptions {
 export const dialogStore = ref<DialogState[]>([]);
 export const dialogKey = ref(1);
 
-export function useDialog<C = Component>(
+export function useDialog<R = any, C = Component>(
   component: C,
   props: DialogOptions<C>
 ) {
-  return new Promise<any>((resolve, reject) => {
+  return new Promise<R>((resolve, reject) => {
     props = {
       visible: true,
       component: shallowRef(component),

+ 1 - 1
src/components/zhu-yuan-yi-sheng/emr/emr-template/comp/PatientEmrData.vue

@@ -92,7 +92,7 @@ const opt = [
   {
     name: "新建病历",
     click: data => {
-      useDialog(AddEmrDialog, {
+      useDialog<string>(AddEmrDialog, {
         dialogProps: {
           title: `在【${data.name}】文件夹下面创建病历`,
           top: 0,

+ 1 - 1
src/views/hospitalization/adverse-event/component/EventPrinter.vue

@@ -130,7 +130,7 @@ const props = defineProps({
 
 const reasonAndProFilter = (arr, input) => {
   let temp = ''
-  if (arr.length === 0) {
+  if (!arr || arr.length === 0) {
     if (!input) {
       return temp
     }