|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
import { model, Model } from '@core/core'; |
|
|
|
|
import { ConnectionModel } from '../../connection.model'; |
|
|
|
|
import { AppModel } from '../../../../app.model'; |
|
|
|
|
import { ApiFactory } from 'src/modules/crud/apiFactory'; |
|
|
|
|
const api = new ApiFactory().create(); |
|
|
|
|
|
|
|
|
@ -7,15 +7,16 @@ export const ListItemModelXtype = 'dec.dcm.model.connection.list_item';
|
|
|
|
|
@model(ListItemModelXtype) |
|
|
|
|
export class ListItemModel extends Model<{ |
|
|
|
|
context : { |
|
|
|
|
connectionSelected: ConnectionModel['$$childContext']['connectionSelected']; |
|
|
|
|
connectionSelectedOne: ConnectionModel['$$childContext']['connectionSelectedOne']; |
|
|
|
|
datebaseTypeSelectedOne: ConnectionModel['$$childContext']['datebaseTypeSelectedOne']; |
|
|
|
|
connections: ConnectionModel['$$childContext']['connections']; |
|
|
|
|
pageIndex: ConnectionModel['$$childContext']['pageIndex']; |
|
|
|
|
datebaseTypeSelected: ConnectionModel['$$childContext']['datebaseTypeSelected']; |
|
|
|
|
connectionSelected: AppModel['$$childContext']['connectionSelected']; |
|
|
|
|
connectionSelectedOne: AppModel['$$childContext']['connectionSelectedOne']; |
|
|
|
|
datebaseTypeSelectedOne: AppModel['$$childContext']['datebaseTypeSelectedOne']; |
|
|
|
|
connections: AppModel['$$childContext']['connections']; |
|
|
|
|
pageIndex: AppModel['$$childContext']['pageIndex']; |
|
|
|
|
datebaseTypeSelected: AppModel['$$childContext']['datebaseTypeSelected']; |
|
|
|
|
isCopy: AppModel['$$childContext']['isCopy'] |
|
|
|
|
} |
|
|
|
|
}> { |
|
|
|
|
context = ['connectionSelected', 'connections', 'pageIndex', 'datebaseTypeSelectedOne', 'connectionSelectedOne', 'datebaseTypeSelected']; |
|
|
|
|
context = ['connectionSelected', 'connections', 'pageIndex', 'datebaseTypeSelectedOne', 'connectionSelectedOne', 'datebaseTypeSelected', 'isCopy']; |
|
|
|
|
|
|
|
|
|
state() { |
|
|
|
|
return { |
|
|
|
@ -63,6 +64,9 @@ export class ListItemModel extends Model<{
|
|
|
|
|
|
|
|
|
|
return api.updateConnection(connections); |
|
|
|
|
}, |
|
|
|
|
setIsCopy(isCopy: boolean) { |
|
|
|
|
this.model.isCopy = isCopy; |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
removeConnection(name: string) { |
|
|
|
|
api.deleteConnection(name).then(re => api.getConnectionlist()) |
|
|
|
@ -70,7 +74,7 @@ export class ListItemModel extends Model<{
|
|
|
|
|
this.model.connections = connections.data; |
|
|
|
|
this.model.connections.forEach(item => { |
|
|
|
|
// 后端传过来的是字符串,转为对象
|
|
|
|
|
item.connectionData = JSON.parse(item.connectionData); |
|
|
|
|
item.connectionData = JSON.parse(item.connectionData as string); |
|
|
|
|
}); |
|
|
|
|
if (name === this.model.connectionSelected) { |
|
|
|
|
this.model.connectionSelected = ''; |
|
|
|
|