Browse Source

修复w-db-table-select使用mock数据的问题

main
likunming 2 months ago
parent
commit
6ceaaa5d73
  1. 65
      io.sc.platform.core.frontend/src/platform/components/select/WDbTableSelect.vue

65
io.sc.platform.core.frontend/src/platform/components/select/WDbTableSelect.vue

@ -441,40 +441,53 @@ const tableGridFilter = (args) => {
} }
}; };
const schemaChanged = (datasource: string, schema: string) => { const schemaChanged = (datasource: string, schema: string) => {
// loading.value = true; loading.value = true;
// datasource = datasource || ''; datasource = datasource || '';
// schema = schema || ''; schema = schema || '';
// axios
// .get(Environment.apiContextPath('/api/jdbc/metadata/getTables?datasource=' + datasource + '&schema=' + schema))
// .then((response) => {
// const data = response?.data;
// const tablesOptions = <any>[];
// if (data && data.length > 0) {
// for (let item of data) {
// tablesOptions.push(item);
// }
// }
// tablesOptionsRef.value = tablesOptions;
// tableGridRef.value.setLocalData(tablesOptions);
// })
// .finally(() => {
// loading.value = false;
// });
const group = {}; const group = {};
dbTables.forEach((table: any) => { axios
const index = table.name.indexOf('_'); .get(Environment.apiContextPath('/api/jdbc/metadata/getTables?datasource=' + datasource + '&schema=' + schema))
.then((response) => {
const data = response?.data;
const tablesOptions = <any>[];
if (data && data.length > 0) {
for (let item of data) {
tablesOptions.push(item);
const index = item.name.indexOf('_');
if (index > 0) { if (index > 0) {
const groupName = table.name.substring(0, index); const groupName = item.name.substring(0, index);
table['groupName'] = groupName; item['groupName'] = groupName;
group[groupName] = groupName; group[groupName] = groupName;
} }
}); }
tablesOptionsRef.value = dbTables; }
tableGridRef.value.setLocalData(dbTables); tablesOptionsRef.value = tablesOptions;
tableGridRef.value.setLocalData(tablesOptions);
prefixs.value = []; prefixs.value = [];
Object.keys(group).forEach((item) => { Object.keys(group).forEach((item) => {
prefixs.value.push(item); prefixs.value.push(item);
}); });
})
.finally(() => {
loading.value = false;
});
// 使mock
// const group = {};
// dbTables.forEach((table: any) => {
// const index = table.name.indexOf('_');
// if (index > 0) {
// const groupName = table.name.substring(0, index);
// table['groupName'] = groupName;
// group[groupName] = groupName;
// }
// });
// tablesOptionsRef.value = dbTables;
// tableGridRef.value.setLocalData(dbTables);
// prefixs.value = [];
// Object.keys(group).forEach((item) => {
// prefixs.value.push(item);
// });
}; };
// //

Loading…
Cancel
Save