Browse Source

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

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

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

@ -441,40 +441,53 @@ const tableGridFilter = (args) => {
}
};
const schemaChanged = (datasource: string, schema: string) => {
// loading.value = true;
// datasource = datasource || '';
// 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;
// });
loading.value = true;
datasource = datasource || '';
schema = schema || '';
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);
});
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);
const index = item.name.indexOf('_');
if (index > 0) {
const groupName = item.name.substring(0, index);
item['groupName'] = groupName;
group[groupName] = groupName;
}
}
}
tablesOptionsRef.value = tablesOptions;
tableGridRef.value.setLocalData(tablesOptions);
prefixs.value = [];
Object.keys(group).forEach((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