帆软决策平台数据连接界面库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

39 lines
1.3 KiB

import { model, Model } from '@core/core';
import { ApiFactory } from '../../..//crud/apiFactory';
import { AppModel } from '../../../app.model';
const api = new ApiFactory().create();
@model()
export class ConnectionListModel extends Model<{
types : {
connections: AppModel['TYPE']['connections'];
connectionSelected: AppModel['TYPE']['connectionSelected'];
},
context: ConnectionListModel['context'];
}> {
static xtype = 'dec.dcm.model.connection.list';
context = <const>['connections', 'connectionSelected'];
computed = {
shwoType: () => BI.size(this.model.connections) > 0 ? 'list' : 'none',
}
actions = {
setConnections: ():Promise<void> => api.getConnectionList().then(data => {
if (BI.size(data.data) > 0) {
this.model.connections = data.data;
this.model.connections.forEach(item => {
// 后端传过来的是字符串,转为对象
item.connectionData = JSON.parse(item.connectionData as string);
});
this.model.connectionSelected = data.data[0].connectionName;
} else {
this.model.connectionSelected = '';
}
return new Promise(resolve => {
resolve();
});
}),
}
}