Przeglądaj źródła

修改删除提示

yangg 2 tygodni temu
rodzic
commit
26285f83c7
1 zmienionych plików z 28 dodań i 1 usunięć
  1. 28 1
      src/views/system/company/crud.tsx

+ 28 - 1
src/views/system/company/crud.tsx

@@ -5,6 +5,7 @@ import { dictionary } from '/@/utils/dictionary';
 import { successMessage, errorMessage } from '/@/utils/message';
 import { auth } from '/@/utils/authFunction';
 import { useRouter } from 'vue-router';
+import { ElMessageBox } from 'element-plus';
 
 export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOptionsRet {
 	const router = useRouter();
@@ -70,7 +71,31 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
 			throw error;
 		}
 	};
-
+// 删除确认处理函数
+	const handleDeleteConfirm = async (opts: any) => {
+		try {
+			await ElMessageBox.confirm(
+				`确定要删除企业"${opts.row.name}"吗?此操作不可撤销。`,
+				'删除确认',
+				{
+					confirmButtonText: '确定删除',
+					cancelButtonText: '取消',
+					type: 'warning',
+					confirmButtonClass: 'el-button--danger'
+				}
+			);
+			// 用户确认后,调用原有的删除逻辑
+			await delRequest(opts);
+			successMessage('删除成功');
+			// 刷新列表
+			crudExpose.doRefresh();
+		} catch (error) {
+			// 用户取消删除,不做任何操作
+			if (error !== 'cancel') {
+				errorMessage('删除失败');
+			}
+		}
+	};
 	return {
 		crudOptions: {
 			toolbar:{
@@ -169,9 +194,11 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
 						show: true,
 					},
 					remove: {
+						iconRight: 'Delete', 
 						size: 'small',
 						type: 'text',
 						show: true,
+						click: handleDeleteConfirm
 					},
 				},
 			},