mirror of
				https://github.com/pure-admin/vue-pure-admin.git
				synced 2025-11-03 13:44:47 +08:00 
			
		
		
		
	feat: 函数式弹框组件添加 beforeCancel和beforeSure回调
				
					
				
			This commit is contained in:
		
							parent
							
								
									b2d06d2b3b
								
							
						
					
					
						commit
						47f951312e
					
				@ -19,7 +19,13 @@ const footerButtons = computed(() => {
 | 
			
		||||
            text: true,
 | 
			
		||||
            bg: true,
 | 
			
		||||
            btnClick: ({ dialog: { options, index } }) => {
 | 
			
		||||
              closeDialog(options, index, { command: "cancel" });
 | 
			
		||||
              const done = () =>
 | 
			
		||||
                closeDialog(options, index, { command: "cancel" });
 | 
			
		||||
              if (options?.beforeCancel && isFunction(options?.beforeCancel)) {
 | 
			
		||||
                options.beforeCancel(done);
 | 
			
		||||
              } else {
 | 
			
		||||
                done();
 | 
			
		||||
              }
 | 
			
		||||
            }
 | 
			
		||||
          },
 | 
			
		||||
          {
 | 
			
		||||
@ -28,7 +34,13 @@ const footerButtons = computed(() => {
 | 
			
		||||
            text: true,
 | 
			
		||||
            bg: true,
 | 
			
		||||
            btnClick: ({ dialog: { options, index } }) => {
 | 
			
		||||
              closeDialog(options, index, { command: "sure" });
 | 
			
		||||
              const done = () =>
 | 
			
		||||
                closeDialog(options, index, { command: "sure" });
 | 
			
		||||
              if (options?.beforeSure && isFunction(options?.beforeSure)) {
 | 
			
		||||
                options.beforeSure(done);
 | 
			
		||||
              } else {
 | 
			
		||||
                done();
 | 
			
		||||
              }
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
        ] as Array<ButtonProps>);
 | 
			
		||||
 | 
			
		||||
@ -189,6 +189,10 @@ interface DialogOptions extends DialogProps {
 | 
			
		||||
    options: DialogOptions;
 | 
			
		||||
    index: number;
 | 
			
		||||
  }) => void;
 | 
			
		||||
  /** 点击底部取消按钮的回调,会暂停 `Dialog` 的关闭. 回调函数内执行 `done` 参数方法的时候才是真正关闭对话框的时候 */
 | 
			
		||||
  beforeCancel?: (done: Function) => void;
 | 
			
		||||
  /** 点击底部确定按钮的回调,会暂停 `Dialog` 的关闭. 回调函数内执行 `done` 参数方法的时候才是真正关闭对话框的时候 */
 | 
			
		||||
  beforeSure?: (done: Function) => void;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export type { EventType, ArgsType, DialogProps, ButtonProps, DialogOptions };
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user