fix: bug#11106
This commit is contained in:
parent
57af547bfb
commit
c88706282f
|
@ -64,6 +64,11 @@ const columns = [
|
||||||
dataIndex: 'summary',
|
dataIndex: 'summary',
|
||||||
key: 'summary',
|
key: 'summary',
|
||||||
},
|
},
|
||||||
|
// {
|
||||||
|
// title: 'ID',
|
||||||
|
// dataIndex: 'id',
|
||||||
|
// key: 'id',
|
||||||
|
// },
|
||||||
];
|
];
|
||||||
const rowSelection = {
|
const rowSelection = {
|
||||||
// onSelect: (record: any) => {
|
// onSelect: (record: any) => {
|
||||||
|
@ -83,43 +88,60 @@ const rowSelection = {
|
||||||
// }
|
// }
|
||||||
// },
|
// },
|
||||||
onChange: (keys: string[]) => {
|
onChange: (keys: string[]) => {
|
||||||
// rowSelection.selectedRowKeys.value = keys;
|
// 当前节点表格数据id
|
||||||
emits('update:selectedRowKeys', keys);
|
const currenTableKeys = props.tableData.map((m: any) => m.id);
|
||||||
keys.forEach((key: string) => {
|
// 当前表格, 原有选中的id
|
||||||
if (props.mode === 'appManger') {
|
const oldSelectedKeys = currenTableKeys.filter((key) =>
|
||||||
emits('update:changedApis', {
|
props.sourceKeys.includes(key),
|
||||||
...props.changedApis,
|
);
|
||||||
[key]: props.tableData.find((f: any) => f.id === key),
|
// 除当前表格之外, 勾选上的数据
|
||||||
});
|
const otherSelectedKeys = props.sourceKeys.filter(
|
||||||
}
|
(key) => !currenTableKeys.includes(key),
|
||||||
|
);
|
||||||
|
|
||||||
|
// 取消选择的数据项
|
||||||
|
const removeKeys = oldSelectedKeys.filter((key) => !keys.includes(key));
|
||||||
|
// 新增选择的项
|
||||||
|
const addKeys = keys.filter((key) => !oldSelectedKeys.includes(key));
|
||||||
|
emits('update:selectedRowKeys', [...otherSelectedKeys, ...keys]);
|
||||||
|
|
||||||
|
// 新增选中/取消选中的数据
|
||||||
|
const changed = {};
|
||||||
|
[...addKeys, ...removeKeys].forEach((key: string) => {
|
||||||
|
changed[key] = props.tableData.find((f: any) => f.id === key);
|
||||||
});
|
});
|
||||||
|
if (props.mode === 'appManger') {
|
||||||
|
emits('update:changedApis', changed);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
selectedRowKeys: ref<string[]>([]),
|
selectedRowKeys: ref<string[]>([]),
|
||||||
};
|
};
|
||||||
const save = async () => {
|
const save = async () => {
|
||||||
// fix: #bug10828
|
// fix: #bug10828
|
||||||
// 当前节点表格数据id
|
// 当前节点表格数据id
|
||||||
const currenTableKeys = props.tableData.map((m: any) => m.id);
|
// const currenTableKeys = props.tableData.map((m: any) => m.id);
|
||||||
// 当前表格选中的id
|
// // 当前表格选中的id
|
||||||
const currentSelectedKeys = rowSelection.selectedRowKeys.value.filter(
|
// const currentSelectedKeys = rowSelection.selectedRowKeys.value.filter(
|
||||||
(key: string) => currenTableKeys.includes(key),
|
// (key: string) => currenTableKeys.includes(key),
|
||||||
);
|
// );
|
||||||
// 当前表格, 原有选中的id
|
// // 当前表格, 原有选中的id
|
||||||
const oldSelectedKeys = currenTableKeys.filter((key) =>
|
// const oldSelectedKeys = currenTableKeys.filter((key) =>
|
||||||
props.sourceKeys.includes(key),
|
// props.sourceKeys.includes(key),
|
||||||
);
|
// );
|
||||||
|
|
||||||
// const keys = props.selectedRowKeys;
|
const keys = props.selectedRowKeys;
|
||||||
// const removeKeys = props.sourceKeys.filter((key) => !keys.includes(key));
|
const removeKeys = props.sourceKeys.filter((key) => !keys.includes(key));
|
||||||
// const addKeys = keys.filter((key) => !props.sourceKeys.includes(key));
|
const addKeys = keys.filter((key) => !props.sourceKeys.includes(key));
|
||||||
|
// console.log('addKeys: ', addKeys);
|
||||||
|
// console.log('removeKeys: ', removeKeys);
|
||||||
// 取消选择的数据项
|
// 取消选择的数据项
|
||||||
const removeKeys = oldSelectedKeys.filter(
|
// const removeKeys = oldSelectedKeys.filter(
|
||||||
(key) => !currentSelectedKeys.includes(key),
|
// (key) => !currentSelectedKeys.includes(key),
|
||||||
);
|
// );
|
||||||
// 新增选择的项
|
// // 新增选择的项
|
||||||
const addKeys = currentSelectedKeys.filter(
|
// const addKeys = currentSelectedKeys.filter(
|
||||||
(key) => !oldSelectedKeys.includes(key),
|
// (key) => !oldSelectedKeys.includes(key),
|
||||||
);
|
// );
|
||||||
|
|
||||||
if (props.mode === 'api') {
|
if (props.mode === 'api') {
|
||||||
// 此时是api配置
|
// 此时是api配置
|
||||||
|
@ -140,15 +162,15 @@ const save = async () => {
|
||||||
} else if (props.mode === 'appManger') {
|
} else if (props.mode === 'appManger') {
|
||||||
const removeItems = removeKeys.map((key) => ({
|
const removeItems = removeKeys.map((key) => ({
|
||||||
id: key,
|
id: key,
|
||||||
// permissions: props.changedApis[key]?.security,
|
permissions: props.changedApis[key]?.security,
|
||||||
permissions: props.tableData.find((f: any) => f.id === key)
|
// permissions: props.tableData.find((f: any) => f.id === key)
|
||||||
?.security,
|
// ?.security,
|
||||||
}));
|
}));
|
||||||
const addItems = addKeys.map((key) => ({
|
const addItems = addKeys.map((key) => ({
|
||||||
id: key,
|
id: key,
|
||||||
// permissions: props.changedApis[key]?.security,
|
permissions: props.changedApis[key]?.security,
|
||||||
permissions: props.tableData.find((f: any) => f.id === key)
|
// permissions: props.tableData.find((f: any) => f.id === key)
|
||||||
?.security,
|
// ?.security,
|
||||||
}));
|
}));
|
||||||
Promise.all([
|
Promise.all([
|
||||||
updateOperations_api(code, '_delete', { operations: removeItems }),
|
updateOperations_api(code, '_delete', { operations: removeItems }),
|
||||||
|
@ -161,9 +183,11 @@ const save = async () => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.selectedRowKeys,
|
() => props.selectedRowKeys,
|
||||||
(n) => {
|
(n) => {
|
||||||
|
// console.log('props.selectedRowKeys: ', n);
|
||||||
rowSelection.selectedRowKeys.value = n;
|
rowSelection.selectedRowKeys.value = n;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
@ -109,7 +109,7 @@ const treeSelect = (node: treeNodeTpye, nodeSchemas: object = {}) => {
|
||||||
tableData.value = table;
|
tableData.value = table;
|
||||||
};
|
};
|
||||||
|
|
||||||
const activeKey = ref<'does' | 'test'>('does');
|
const activeKey = ref<'does' | 'test'>('does');
|
||||||
const schemas = ref({}); // 对应一级api相关的类
|
const schemas = ref({}); // 对应一级api相关的类
|
||||||
const initSelectedApi: apiDetailsType = {
|
const initSelectedApi: apiDetailsType = {
|
||||||
url: '',
|
url: '',
|
||||||
|
@ -156,6 +156,13 @@ function getSelectKeys() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// watch(
|
||||||
|
// () => changedApis.value,
|
||||||
|
// (val: any) => {
|
||||||
|
// console.log('changedApis: ', val);
|
||||||
|
// },
|
||||||
|
// );
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
|
|
Loading…
Reference in New Issue