feat: 表格行内编辑修改失败恢复原值
This commit is contained in:
parent
f3e8fc208b
commit
37fe90457d
|
@ -29,6 +29,11 @@ export function createOrUpdateOrg(data: CreateOrUpdateSystemOrgParams | CreateOr
|
|||
return MSR.post({ url: data.id ? orgUrl.postModifyOrgUrl : orgUrl.postAddOrgUrl, data });
|
||||
}
|
||||
|
||||
// 修改组织名称
|
||||
export function modifyOrgName(data: { id: string; name: string }) {
|
||||
return MSR.post({ url: orgUrl.postModifyOrgNameUrl, data });
|
||||
}
|
||||
|
||||
// 删除组织
|
||||
export function deleteOrg(id: string) {
|
||||
return MSR.get({ url: `${orgUrl.getDeleteOrgUrl}${id}` });
|
||||
|
@ -104,6 +109,10 @@ export function getSystemOrgOption() {
|
|||
export function createOrUpdateProject(data: Partial<OrgProjectTableItem>) {
|
||||
return MSR.post({ url: data.id ? orgUrl.postModifyProjectUrl : orgUrl.postAddProjectUrl, data });
|
||||
}
|
||||
// 修改项目名称
|
||||
export function renameProject(data: { id: string; name: string; organizationId: string }) {
|
||||
return MSR.post({ url: orgUrl.postModifyProjectNameUrl, data });
|
||||
}
|
||||
|
||||
// 创建项目或组织时获取所有用户
|
||||
export function getAllUser() {
|
||||
|
@ -141,6 +150,11 @@ export function createOrUpdateProjectByOrg(data: CreateOrUpdateOrgProjectParams)
|
|||
return MSR.post({ url: data.id ? orgUrl.postModifyProjectByOrgUrl : orgUrl.postAddProjectByOrgUrl, data });
|
||||
}
|
||||
|
||||
// 修改项目名称
|
||||
export function renameProjectByOrg(data: { id: string; name: string; organizationId: string }) {
|
||||
return MSR.post({ url: orgUrl.postModifyProjectNameByOrgUrl, data });
|
||||
}
|
||||
|
||||
// 组织-获取项目下的成员列表
|
||||
export function postProjectMemberByProjectId(data: TableQueryParams) {
|
||||
return MSR.post({ url: orgUrl.postProjectMemberByOrgIdUrl, data });
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
// 系统-组织
|
||||
// 修改组织
|
||||
export const postModifyOrgUrl = '/system/organization/update';
|
||||
// 修改组织名称
|
||||
export const postModifyOrgNameUrl = '/system/organization/rename';
|
||||
// 获取系统下所有组织-下拉选项
|
||||
export const postOrgOptionsUrl = '/system/organization/option/all';
|
||||
// 获取系统下所有组织-Table
|
||||
|
@ -35,6 +37,8 @@ export const postProjectTableUrl = '/system/project/page';
|
|||
export const postProjectMemberUrl = '/system/project/member-list';
|
||||
// 添加项目
|
||||
export const postAddProjectUrl = '/system/project/add';
|
||||
// 修改项目名称
|
||||
export const postModifyProjectNameUrl = '/system/project/rename';
|
||||
// 添加项目成员
|
||||
export const postAddProjectMemberUrl = '/system/project/add-member';
|
||||
// 撤销项目
|
||||
|
@ -67,6 +71,8 @@ export const postProjectTableByOrgIdUrl = '/organization/project/page';
|
|||
// 获取项目下的成员列表
|
||||
export const postProjectMemberByOrgIdUrl = '/organization/project/member-list';
|
||||
// 添加项目
|
||||
// 修改项目名称
|
||||
export const postModifyProjectNameByOrgUrl = '/organization/project/rename';
|
||||
export const postAddProjectByOrgUrl = '/organization/project/add';
|
||||
// 添加项目成员
|
||||
export const postAddProjectMemberByOrgUrl = '/organization/project/add-members';
|
||||
|
|
|
@ -224,7 +224,7 @@
|
|||
(e: 'batchAction', value: BatchActionParams, queryParams: BatchActionQueryParams): void;
|
||||
(e: 'pageChange', value: number): void;
|
||||
(e: 'pageSizeChange', value: number): void;
|
||||
(e: 'rowNameChange', value: TableData): void;
|
||||
(e: 'rowNameChange', value: TableData, cb: (v: boolean) => void): void;
|
||||
(e: 'rowSelectChange', key: string): void;
|
||||
(e: 'selectAllChange', value: SelectAllEnum): void;
|
||||
(e: 'sorterChange', value: { [key: string]: string }): void;
|
||||
|
@ -349,9 +349,14 @@
|
|||
currentEditValue.value = '';
|
||||
} else {
|
||||
// 触发的是Enter
|
||||
emit('rowNameChange', record);
|
||||
isEnter.value = true;
|
||||
editActiveKey.value = '';
|
||||
emit('rowNameChange', record, (v: boolean) => {
|
||||
if (!v) {
|
||||
// 如果接口报错,没有成功的修改,恢复旧值
|
||||
record[dataIndex] = currentEditValue.value;
|
||||
}
|
||||
isEnter.value = true;
|
||||
editActiveKey.value = '';
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -199,6 +199,7 @@ export default function useTableProps<T>(
|
|||
}
|
||||
} catch (err) {
|
||||
setTableErrorStatus('error');
|
||||
propsRes.value.data = [];
|
||||
} finally {
|
||||
setLoading(false);
|
||||
// debug 模式下打印属性
|
||||
|
@ -233,9 +234,8 @@ export default function useTableProps<T>(
|
|||
return data;
|
||||
}
|
||||
} catch (err) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(err);
|
||||
setTableErrorStatus('error');
|
||||
propsRes.value.data = [];
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
|
@ -311,9 +311,10 @@ export default function useTableProps<T>(
|
|||
}
|
||||
},
|
||||
// 编辑触发
|
||||
rowNameChange: (record: T) => {
|
||||
rowNameChange: async (record: T, cb: (v: boolean) => void) => {
|
||||
if (saveCallBack) {
|
||||
saveCallBack(record);
|
||||
const res = await saveCallBack(record);
|
||||
cb(res);
|
||||
}
|
||||
},
|
||||
// 重置排序
|
||||
|
|
|
@ -76,10 +76,10 @@
|
|||
import UserDrawer from './components/userDrawer.vue';
|
||||
|
||||
import {
|
||||
createOrUpdateProjectByOrg,
|
||||
deleteProjectByOrg,
|
||||
enableOrDisableProjectByOrg,
|
||||
postProjectTableByOrg,
|
||||
renameProjectByOrg,
|
||||
revokeDeleteProjectByOrg,
|
||||
} from '@/api/modules/setting/organizationAndProject';
|
||||
import { useI18n } from '@/hooks/useI18n';
|
||||
|
@ -163,10 +163,11 @@
|
|||
|
||||
const handleNameChange = async (record: OrgProjectTableItem) => {
|
||||
try {
|
||||
await createOrUpdateProjectByOrg(record);
|
||||
await renameProjectByOrg({ id: record.id, name: record.name, organizationId: record.organizationId });
|
||||
Message.success(t('common.updateSuccess'));
|
||||
return true;
|
||||
} catch (error) {
|
||||
Message.error(t('common.updateFailed'));
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -68,9 +68,9 @@
|
|||
import UserDrawer from './userDrawer.vue';
|
||||
|
||||
import {
|
||||
createOrUpdateOrg,
|
||||
deleteOrg,
|
||||
enableOrDisableOrg,
|
||||
modifyOrgName,
|
||||
postOrgTable,
|
||||
revokeDeleteOrg,
|
||||
} from '@/api/modules/setting/organizationAndProject';
|
||||
|
@ -150,10 +150,11 @@
|
|||
|
||||
const handleNameChange = async (record: OrgProjectTableItem) => {
|
||||
try {
|
||||
await createOrUpdateOrg(record);
|
||||
await modifyOrgName({ id: record.id, name: record.name });
|
||||
Message.success(t('common.updateSuccess'));
|
||||
return true;
|
||||
} catch (error) {
|
||||
Message.error(t('common.updateFailed'));
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -62,10 +62,10 @@
|
|||
import UserDrawer from './userDrawer.vue';
|
||||
|
||||
import {
|
||||
createOrUpdateProject,
|
||||
deleteProject,
|
||||
enableOrDisableProject,
|
||||
postProjectTable,
|
||||
renameProject,
|
||||
revokeDeleteProject,
|
||||
} from '@/api/modules/setting/organizationAndProject';
|
||||
import { useI18n } from '@/hooks/useI18n';
|
||||
|
@ -148,10 +148,11 @@
|
|||
|
||||
const handleNameChange = async (record: OrgProjectTableItem) => {
|
||||
try {
|
||||
await createOrUpdateProject(record);
|
||||
await renameProject({ id: record.id, name: record.name, organizationId: record.organizationId });
|
||||
Message.success(t('common.updateSuccess'));
|
||||
return true;
|
||||
} catch (error) {
|
||||
Message.error(t('common.updateFailed'));
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue