|
@@ -5,6 +5,7 @@ import { dictionary } from '/@/utils/dictionary';
|
|
|
import { successMessage, errorMessage } from '/@/utils/message';
|
|
import { successMessage, errorMessage } from '/@/utils/message';
|
|
|
import { auth } from '/@/utils/authFunction';
|
|
import { auth } from '/@/utils/authFunction';
|
|
|
import { useRouter } from 'vue-router';
|
|
import { useRouter } from 'vue-router';
|
|
|
|
|
+import { ElMessageBox } from 'element-plus';
|
|
|
|
|
|
|
|
export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOptionsRet {
|
|
export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOptionsRet {
|
|
|
const router = useRouter();
|
|
const router = useRouter();
|
|
@@ -70,7 +71,31 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
|
|
|
throw error;
|
|
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 {
|
|
return {
|
|
|
crudOptions: {
|
|
crudOptions: {
|
|
|
toolbar:{
|
|
toolbar:{
|
|
@@ -169,9 +194,11 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
|
|
|
show: true,
|
|
show: true,
|
|
|
},
|
|
},
|
|
|
remove: {
|
|
remove: {
|
|
|
|
|
+ iconRight: 'Delete',
|
|
|
size: 'small',
|
|
size: 'small',
|
|
|
type: 'text',
|
|
type: 'text',
|
|
|
show: true,
|
|
show: true,
|
|
|
|
|
+ click: handleDeleteConfirm
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|