Browse Source

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

feature/x
Austin.Duan 11 months ago
parent
commit
792392ee47
  1. 61
      src/modules/pages/connection/connection.ts
  2. 11
      src/modules/pages/connection/list/list.model.ts
  3. 3
      src/modules/pages/connection/list/list_item/list_item.model.ts
  4. 5
      src/modules/pages/maintain/forms/form.model.ts
  5. 2
      src/modules/pages/maintain/forms/form.ts

61
src/modules/pages/connection/connection.ts

@ -24,24 +24,13 @@ export class Connection extends BI.Widget {
title: HTapeLayout; title: HTapeLayout;
watch = { watch = {
connectionSelected: (name: string) => { connectionSelected: {
if (name) { immediate: true,
const canEdit = connectionCanEdit(this.model.connectionSelectedOne); handler: (name: string) => {
const type = this.getSelectConnectionType(); BI.nextTick(() => {
this.connectionTitleWidget.setText(`${name}${getTextByDatabaseType(type)}`); name ? this.renderConnectionListView(name) : this.renderEmptyListView();
this.connectionEditWidget.setVisible(canEdit); });
const hasRegistered = this.hasRegistered(); },
this.title.setVisible(hasRegistered);
if (!hasRegistered) {
this.listView.populate(BI.createItems(this.renderNoRegistered()));
} else {
this.listView.populate(BI.createItems(this.renderItems()));
}
} else {
this.listView.populate(BI.createItems(this.renderEmpty()));
this.connectionTitleWidget.setText('');
this.connectionEditWidget.setVisible(false);
}
}, },
}; };
@ -50,8 +39,6 @@ export class Connection extends BI.Widget {
} }
render() { render() {
this.store.setConnectionSelected('');
return { return {
type: BI.HTapeLayout.xtype, type: BI.HTapeLayout.xtype,
hgap: 10, hgap: 10,
@ -214,12 +201,6 @@ export class Connection extends BI.Widget {
}]; }];
} }
private renderEmpty() {
return [{
type: BI.Layout.xtype,
}];
}
private hasRegistered() { private hasRegistered() {
const allDatabaseTypes = getAllDatabaseTypes(); const allDatabaseTypes = getAllDatabaseTypes();
switch (this.model.connectionSelectedOne.connectionType) { switch (this.model.connectionSelectedOne.connectionType) {
@ -246,4 +227,32 @@ export class Connection extends BI.Widget {
this.store.setPageIndex(PAGE_INDEX.MAINTAIN); this.store.setPageIndex(PAGE_INDEX.MAINTAIN);
this.store.setDatebaseTypeSelected(''); this.store.setDatebaseTypeSelected('');
} }
private renderConnectionListView(name: string) {
const canEdit = connectionCanEdit(this.model.connectionSelectedOne),
type = this.getSelectConnectionType(),
hasRegistered = this.hasRegistered();
this.connectionTitleWidget.setText(`${name}${getTextByDatabaseType(type)}`);
this.connectionEditWidget.setVisible(canEdit);
this.title.setVisible(hasRegistered);
hasRegistered
? this.listView.populate(BI.createItems(this.renderItems()))
: this.listView.populate(BI.createItems(this.renderNoRegistered()));
}
private renderEmptyListView() {
this.listView.populate(
BI.createItems([
{
type: BI.Layout.xtype,
}
])
);
this.connectionTitleWidget.setText('');
this.connectionEditWidget.setVisible(false);
}
} }

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

@ -38,14 +38,19 @@ export class ConnectionListModel extends Model<{
} }
}); });
this.model.connectionSelected = defaultDatabaseName ?? data.data[0].connectionName; // 仅首次进入时从url中读取参数,其他情况保留选中状态
} else { defaultDatabaseName ||= data.data[0].connectionName;
this.model.connectionSelected = '';
this.setSelectedConnection(this.model.connectionSelected || defaultDatabaseName);
} }
return new Promise(resolve => { return new Promise(resolve => {
resolve(); resolve();
}); });
}), }),
setSelectedConnection(name: string) {
this.model.connectionSelected = name;
}
} }
} }

3
src/modules/pages/connection/list/list_item/list_item.model.ts

@ -139,8 +139,9 @@ export class ListItemModel extends Model<{
// 后端传过来的是字符串,转为对象 // 后端传过来的是字符串,转为对象
item.connectionData = JSON.parse(item.connectionData as string); item.connectionData = JSON.parse(item.connectionData as string);
}); });
if (name === this.model.connectionSelected) { if (name === this.model.connectionSelected) {
this.model.connectionSelected = BI.size(this.model.connections) > 0 ? this.model.connections[0].connectionName : ''; this.setConnectionSelected(this.model.connections?.[0]?.connectionName || '');
} }
api.shutdownConnectionStatus(name); api.shutdownConnectionStatus(name);
}); });

5
src/modules/pages/maintain/forms/form.model.ts

@ -17,6 +17,7 @@ export class MaintainFormModel extends Model<{
pageIndex: AppModel['TYPE']['pageIndex']; pageIndex: AppModel['TYPE']['pageIndex'];
connections: AppModel['TYPE']['connections']; connections: AppModel['TYPE']['connections'];
isCopy: AppModel['TYPE']['isCopy']; isCopy: AppModel['TYPE']['isCopy'];
connectionSelected: AppModel['TYPE']['connectionSelected'];
}, },
context: MaintainFormModel['context']; context: MaintainFormModel['context'];
}> { }> {
@ -31,6 +32,7 @@ export class MaintainFormModel extends Model<{
'testEvent', 'testEvent',
'connections', 'connections',
'isCopy', 'isCopy',
'connectionSelected',
]; ];
actions = { actions = {
@ -51,5 +53,8 @@ export class MaintainFormModel extends Model<{
goFirstPage() { goFirstPage() {
this.model.pageIndex = PAGE_INDEX.CONNECTION; this.model.pageIndex = PAGE_INDEX.CONNECTION;
}, },
setConnectionSelected(name: string) {
this.model.connectionSelected = name;
}
} }
} }

2
src/modules/pages/maintain/forms/form.ts

@ -295,6 +295,8 @@ export class MaintainForm extends BI.Widget {
return; return;
} }
// 新增之后connections待更新,connectionSelected先置空
this.store.setConnectionSelected('');
this.store.goFirstPage(); this.store.goFirstPage();
this.store.setIsCopy(false); this.store.setIsCopy(false);
}); });

Loading…
Cancel
Save