Browse Source

REPORT-110986 feat: 数据连接支持跳转至详情&联动

feature/x
Austin.Duan 11 months ago
parent
commit
57340b4d11
  1. 19
      src/modules/pages/connection/list/list.model.ts

19
src/modules/pages/connection/list/list.model.ts

@ -1,10 +1,11 @@
import { model, Model } from '@core/core';
import { ApiFactory } from '../../..//crud/apiFactory';
import { AppModel } from '../../../app.model';
import type { ConnectionJDBC } from '../../../crud/crud.typings';
const api = new ApiFactory().create();
@model()
export class ConnectionListModel extends Model<{
types : {
types: {
connections: AppModel['TYPE']['connections'];
connectionSelected: AppModel['TYPE']['connectionSelected'];
},
@ -19,15 +20,25 @@ export class ConnectionListModel extends Model<{
}
actions = {
setConnections: ():Promise<void> => api.getConnectionList().then(data => {
setConnections: (): Promise<void> => api.getConnectionList().then(data => {
data.data.push(...BI.Constants.getConstant('dec.constant.connection.list'));
if (BI.size(data.data) > 0) {
this.model.connections = data.data;
let defaultDatabaseName,
defaultDatabaseId = BI.Services.getService("dec.service.global")
.getHashSearchParams("databaseId");
this.model.connections.forEach(item => {
// 后端传过来的是字符串,转为对象
// 后端传过来的是字符串,转为对象
BI.isString(item.connectionData) && (item.connectionData = JSON.parse(item.connectionData as string));
// 目前只有jdbc存在identity,后期拓展
if ((item.connectionData as ConnectionJDBC).identity === defaultDatabaseId) {
defaultDatabaseName = item.connectionName;
}
});
this.model.connectionSelected = data.data[0].connectionName;
this.model.connectionSelected = defaultDatabaseName ?? data.data[0].connectionName;
} else {
this.model.connectionSelected = '';
}

Loading…
Cancel
Save