|
@@ -98,7 +98,7 @@
|
|
|
:title="connDialogTitle"
|
|
|
width="500px"
|
|
|
center
|
|
|
- :before-close="handleClose"
|
|
|
+ :before-close="handleCloseByConn"
|
|
|
:visible.sync="connDialogVisible"
|
|
|
:close-on-click-modal="false"
|
|
|
:append-to-body="true">
|
|
@@ -407,57 +407,70 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- /** 连接事件:type 1 测试连接 2 确定 3 保存 */
|
|
|
- handleConnect(type) {
|
|
|
- // 已有链接编辑:未改变点击保存直接关闭弹出层
|
|
|
- if (this.chooseConnServer) {
|
|
|
- this.chooseConnServer = null
|
|
|
- this.handleCancel()
|
|
|
- return
|
|
|
+ checkDataSourceParam(type) {
|
|
|
+ // 已有链接编辑且数据未改变
|
|
|
+ if (type == 3 && this.chooseConnServer && !this.$refs['connForm']) {
|
|
|
+ this.connForm = JSON.parse(JSON.stringify(this.chooseConnServer))
|
|
|
+ this.connForm.connType = {
|
|
|
+ 'type' : this.chooseConnServer.dataSourceTypeKey,
|
|
|
+ 'id': this.chooseConnServer.typeId
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 判断驱动类型
|
|
|
+ if (this.connForm.connType.type == 'opc_da_real') {
|
|
|
+ if (!this.connForm.clsId) {
|
|
|
+ this.$message({
|
|
|
+ message: '请选择驱动!',
|
|
|
+ type: 'warning'
|
|
|
+ })
|
|
|
+ return false
|
|
|
+ }
|
|
|
}
|
|
|
- // 未配置服务连接信息
|
|
|
- if (!this.$refs['connForm']) {
|
|
|
+ // 判断基础数据
|
|
|
+ if (!this.connForm.ipAddress) {
|
|
|
this.$message({
|
|
|
message: '请检查配置信息!',
|
|
|
type: 'warning'
|
|
|
})
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ return true
|
|
|
+ },
|
|
|
+ /** 连接事件:type 1 测试连接 2 确定 3 保存 */
|
|
|
+ handleConnect(type) {
|
|
|
+ if (!this.checkDataSourceParam(type)) {
|
|
|
return
|
|
|
}
|
|
|
- this.$refs['connForm'].validate(valid => {
|
|
|
- if (valid) {
|
|
|
- // 参数封装
|
|
|
- let params = JSON.parse(JSON.stringify(this.connForm))
|
|
|
- params.dataSourceName = this.datasourceForm.datasourceName
|
|
|
- params.dataSourceDescribe = this.datasourceForm.desc
|
|
|
- if (params.isAnonymous == 1) {
|
|
|
- params.ipPassword = ''
|
|
|
- params.ipUserName = ''
|
|
|
- } else {
|
|
|
- if (!this.chooseConnServer || (this.chooseConnServer
|
|
|
- && this.connForm.ipPassword != this.chooseConnServer.ipPassword)) {
|
|
|
- params.ipPassword = encrypt(this.connForm.ipPassword, getPubKey())
|
|
|
- }
|
|
|
- }
|
|
|
- if (this.chooseConnServer) {
|
|
|
- params.typeId = this.chooseConnServer.typeId
|
|
|
- } else if (this.chooseServerType) {
|
|
|
- params.typeId = this.chooseServerType.id
|
|
|
- }
|
|
|
- // 接口请求
|
|
|
- if (type == 1) {
|
|
|
- this.testConnect(params)
|
|
|
- } else if (type == 3) {
|
|
|
- this.saveConnect(params)
|
|
|
- } else {
|
|
|
- this.connDialogVisible = false
|
|
|
- }
|
|
|
- } else {
|
|
|
- this.$message({
|
|
|
- message: '请检查配置信息!',
|
|
|
- type: 'warning'
|
|
|
- })
|
|
|
+ this.handleWithConnect(type)
|
|
|
+ },
|
|
|
+ /** 处理连接 */
|
|
|
+ handleWithConnect(type) {
|
|
|
+ // 参数封装
|
|
|
+ let params = JSON.parse(JSON.stringify(this.connForm))
|
|
|
+ params.dataSourceName = this.datasourceForm.datasourceName
|
|
|
+ params.dataSourceDescribe = this.datasourceForm.desc
|
|
|
+ if (params.isAnonymous == 1) {
|
|
|
+ params.ipPassword = ''
|
|
|
+ params.ipUserName = ''
|
|
|
+ } else {
|
|
|
+ if (!this.chooseConnServer || (this.chooseConnServer
|
|
|
+ && this.connForm.ipPassword != this.chooseConnServer.ipPassword)) {
|
|
|
+ params.ipPassword = encrypt(this.connForm.ipPassword, getPubKey())
|
|
|
}
|
|
|
- })
|
|
|
+ }
|
|
|
+ if (this.chooseConnServer) {
|
|
|
+ params.typeId = this.chooseConnServer.typeId
|
|
|
+ } else if (this.chooseServerType) {
|
|
|
+ params.typeId = this.chooseServerType.id
|
|
|
+ }
|
|
|
+ // 接口请求
|
|
|
+ if (type == 1) {
|
|
|
+ this.testConnect(params)
|
|
|
+ } else if (type == 3) {
|
|
|
+ this.saveConnect(params)
|
|
|
+ } else {
|
|
|
+ this.connDialogVisible = false
|
|
|
+ }
|
|
|
},
|
|
|
/** 测试连接 */
|
|
|
testConnect(params) {
|
|
@@ -496,8 +509,7 @@ export default {
|
|
|
confirmButtonText: '确定',
|
|
|
callback: action => {
|
|
|
this.handleCancel()
|
|
|
- // 刷新右侧数据源类型列表
|
|
|
- this.getMyDatasourceList()
|
|
|
+ this.initConfigForm()
|
|
|
}
|
|
|
})
|
|
|
return
|
|
@@ -555,9 +567,10 @@ export default {
|
|
|
}).catch((e) => {
|
|
|
loading.close()
|
|
|
console.error(e)
|
|
|
- this.$message({
|
|
|
- message: '驱动获取失败!',
|
|
|
- type: 'warning'
|
|
|
+ this.$alert(e, '驱动获取失败!', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ callback: action => {
|
|
|
+ }
|
|
|
})
|
|
|
})
|
|
|
}
|
|
@@ -588,12 +601,18 @@ export default {
|
|
|
this.clearDatasourceBg()
|
|
|
if (this.$refs['connForm']) this.$refs['connForm'].resetFields()
|
|
|
this.$refs['datasourceForm'].resetFields()
|
|
|
+ this.chooseConnServer = null
|
|
|
+ this.chooseServerType = null
|
|
|
this.connDialogVisible = false
|
|
|
this.datasourceDialogVisible = false
|
|
|
break
|
|
|
}
|
|
|
},
|
|
|
/** 弹出层关闭事件 */
|
|
|
+ handleCloseByConn(done) {
|
|
|
+ this.handleCancel("conn")
|
|
|
+ },
|
|
|
+ /** 弹出层关闭事件 */
|
|
|
handleClose(done) {
|
|
|
this.$refs['datasourceForm'].resetFields()
|
|
|
done()
|