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