|
|
@ -4,11 +4,13 @@ import { ApiFactory } from '../../../../crud/apiFactory'; |
|
|
|
import { ResultType } from '../../../../crud/crud.typings'; |
|
|
|
import { ResultType } from '../../../../crud/crud.typings'; |
|
|
|
import { getChartLength } from '../../../../app.service'; |
|
|
|
import { getChartLength } from '../../../../app.service'; |
|
|
|
import { NAME_MAX_LENGTH } from '../../../../app.constant'; |
|
|
|
import { NAME_MAX_LENGTH } from '../../../../app.constant'; |
|
|
|
|
|
|
|
import { PAGE_INDEX } from '@constants/constant'; |
|
|
|
|
|
|
|
|
|
|
|
const api = new ApiFactory().create(); |
|
|
|
const api = new ApiFactory().create(); |
|
|
|
|
|
|
|
|
|
|
|
@model() |
|
|
|
@model() |
|
|
|
export class ListItemModel extends Model<{ |
|
|
|
export class ListItemModel extends Model<{ |
|
|
|
types : { |
|
|
|
types: { |
|
|
|
connectionSelected: AppModel['TYPE']['connectionSelected']; |
|
|
|
connectionSelected: AppModel['TYPE']['connectionSelected']; |
|
|
|
connectionSelectedOne: AppModel['TYPE']['connectionSelectedOne']; |
|
|
|
connectionSelectedOne: AppModel['TYPE']['connectionSelectedOne']; |
|
|
|
datebaseTypeSelectedOne: AppModel['TYPE']['datebaseTypeSelectedOne']; |
|
|
|
datebaseTypeSelectedOne: AppModel['TYPE']['datebaseTypeSelectedOne']; |
|
|
@ -21,7 +23,7 @@ export class ListItemModel extends Model<{ |
|
|
|
}> { |
|
|
|
}> { |
|
|
|
static xtype = 'dec.dcm.model.connection.list_item'; |
|
|
|
static xtype = 'dec.dcm.model.connection.list_item'; |
|
|
|
|
|
|
|
|
|
|
|
context = <const>['connectionSelected', 'connections', 'pageIndex', 'datebaseTypeSelectedOne', 'connectionSelectedOne', 'datebaseTypeSelected', 'isCopy']; |
|
|
|
context = <const>['connectionSelected', 'connections', 'pageIndex', 'datebaseTypeSelectedOne', 'connectionSelectedOne', 'datebaseTypeSelected', 'isCopy', 'connectionLicInfo']; |
|
|
|
|
|
|
|
|
|
|
|
state() { |
|
|
|
state() { |
|
|
|
return { |
|
|
|
return { |
|
|
@ -52,10 +54,12 @@ export class ListItemModel extends Model<{ |
|
|
|
}, |
|
|
|
}, |
|
|
|
setIsEdit: (isEdit: boolean, name: string) => { |
|
|
|
setIsEdit: (isEdit: boolean, name: string) => { |
|
|
|
if (isEdit) { |
|
|
|
if (isEdit) { |
|
|
|
api.getConnectionStatus(name).then(re => { |
|
|
|
api.getConnectionStatus(name) |
|
|
|
|
|
|
|
.then(re => { |
|
|
|
this.model.isEdit = true; |
|
|
|
this.model.isEdit = true; |
|
|
|
}) |
|
|
|
}) |
|
|
|
.catch(() => {}); |
|
|
|
.catch(() => { |
|
|
|
|
|
|
|
}); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
api.shutdownConnectionStatus(name); |
|
|
|
api.shutdownConnectionStatus(name); |
|
|
|
this.model.isEdit = false; |
|
|
|
this.model.isEdit = false; |
|
|
@ -69,7 +73,10 @@ export class ListItemModel extends Model<{ |
|
|
|
} |
|
|
|
} |
|
|
|
if (getChartLength(newName) > NAME_MAX_LENGTH) { |
|
|
|
if (getChartLength(newName) > NAME_MAX_LENGTH) { |
|
|
|
return new Promise(resolve => { |
|
|
|
return new Promise(resolve => { |
|
|
|
resolve({ errorCode: '1', errorMsg: BI.i18nText('Dec-Dcm_Connection_Cannot_Too_Lang', NAME_MAX_LENGTH) }); |
|
|
|
resolve({ |
|
|
|
|
|
|
|
errorCode: '1', |
|
|
|
|
|
|
|
errorMsg: BI.i18nText('Dec-Dcm_Connection_Cannot_Too_Lang', NAME_MAX_LENGTH), |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
const hasNamed = this.model.connections.some(item => item.connectionName === newName); |
|
|
|
const hasNamed = this.model.connections.some(item => item.connectionName === newName); |
|
|
@ -83,7 +90,8 @@ export class ListItemModel extends Model<{ |
|
|
|
connection.connectionName = newName; |
|
|
|
connection.connectionName = newName; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return api.updateConnection(connection).then(re => { |
|
|
|
return api.updateConnection(connection) |
|
|
|
|
|
|
|
.then(re => { |
|
|
|
if (!re.errorCode) { |
|
|
|
if (!re.errorCode) { |
|
|
|
this.model.connections = this.model.connections.map(item => { |
|
|
|
this.model.connections = this.model.connections.map(item => { |
|
|
|
return { |
|
|
|
return { |
|
|
@ -100,13 +108,31 @@ export class ListItemModel extends Model<{ |
|
|
|
return re; |
|
|
|
return re; |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
copyConnection(connectionName) { |
|
|
|
|
|
|
|
if (this.model.connectionLicInfo.currentConnectionNum >= this.model.connectionLicInfo.maxConnectionNum) { |
|
|
|
|
|
|
|
BI.Services.getService('dec.service.component.icon_text.msg').alert({ |
|
|
|
|
|
|
|
text: BI.i18nText('Dec-Connection_Lic_Limit_Approach_Prevent_Tip', this.model.connectionLicInfo.maxConnectionNum), |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.setConnectionSelected(connectionName); |
|
|
|
|
|
|
|
this.setIsCopy(true); |
|
|
|
|
|
|
|
this.setPageIndex(PAGE_INDEX.MAINTAIN); |
|
|
|
|
|
|
|
}, |
|
|
|
setIsCopy: (isCopy: boolean) => { |
|
|
|
setIsCopy: (isCopy: boolean) => { |
|
|
|
this.model.isCopy = isCopy; |
|
|
|
this.model.isCopy = isCopy; |
|
|
|
}, |
|
|
|
}, |
|
|
|
isDriverError: (errorCode: string) => api.isDriverError(errorCode), |
|
|
|
isDriverError: (errorCode: string) => api.isDriverError(errorCode), |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
removeConnection(name: string) { |
|
|
|
removeConnection(name: string) { |
|
|
|
api.deleteConnection(name).then(re => api.getConnectionlist()) |
|
|
|
api.deleteConnection(name) |
|
|
|
|
|
|
|
.then(re => { |
|
|
|
|
|
|
|
this.model.connectionLicInfo.currentConnectionNum -= 1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return api.getConnectionList(); |
|
|
|
|
|
|
|
}) |
|
|
|
.then(connections => { |
|
|
|
.then(connections => { |
|
|
|
this.model.connections = connections.data; |
|
|
|
this.model.connections = connections.data; |
|
|
|
this.model.connections.forEach(item => { |
|
|
|
this.model.connections.forEach(item => { |
|
|
|