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.
33 lines
1.3 KiB
33 lines
1.3 KiB
import { model, Model } from '@core/core'; |
|
import { ConnectionModel } from '../connection.model'; |
|
import { ApiFactory } from 'src/modules/crud/apiFactory'; |
|
const api = new ApiFactory().create(); |
|
export const ConnectionListModelXtype = 'dec.dcm.model.connection.list'; |
|
@model(ConnectionListModelXtype) |
|
export class ConnectionListModel extends Model<{ |
|
context : { |
|
connections: ConnectionModel['$$childContext']['connections']; |
|
connectionSelected: ConnectionModel['$$childContext']['connectionSelected']; |
|
} |
|
}> { |
|
context = ['connections', 'connectionSelected']; |
|
|
|
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); |
|
}); |
|
this.model.connectionSelected = data.data[0].connectionName; |
|
} else { |
|
this.model.connectionSelected = ''; |
|
} |
|
|
|
return new Promise(resolve => { |
|
resolve(); |
|
}); |
|
}), |
|
} |
|
}
|
|
|