|
|
@ -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); |
|
|
|
// }); |
|
|
|
}; |
|
|
|
|
|
|
|
// 根据实际值设置显示值 |
|
|
|