Browse Source

fix: DEC-10010 补充缺失的表单,修改表单提交bug

qufenxi
alan 5 years ago
parent
commit
ce94dcb9b6
  1. 1
      i18n/zh_cn.properties
  2. 1
      private/i18n.ts
  3. 5
      src/modules/pages/connection/connection_jdbc/connection_jdbc.ts
  4. 41
      src/modules/pages/maintain/forms/components/form.jdbc.ts
  5. 3
      src/modules/pages/maintain/forms/form.model.ts
  6. 3
      src/modules/pages/maintain/forms/form.ts

1
i18n/zh_cn.properties

@ -75,6 +75,7 @@ Dec-Dcm_Connection_Form_Database_Advanced_Setting= 高级设置
Dec-Dcm_Connection_Form_Database_Initial_Size= 初始化连接数
Dec-Dcm_Connection_Form_Database_Max_Active= 最大活动连接数
Dec-Dcm_Connection_Form_Database_Max_Idle= 最大空闲连接数
Dec-Dcm_Connection_Form_Database_Min_Idle= 最小空闲连接数
Dec-Dcm_Connection_Form_Database_Max_Wait= 最大等待时间
Dec-Dcm_Connection_Form_Database_Validation_Query= SQL验证查询
Dec-Dcm_Connection_Form_Database_Test_On_Borrow= 获取连接前检验

1
private/i18n.ts

@ -74,6 +74,7 @@ export default {
'Dec-Dcm_Connection_Form_Database_Initial_Size': '初始化连接数',
'Dec-Dcm_Connection_Form_Database_Max_Active': '最大活动连接数',
'Dec-Dcm_Connection_Form_Database_Max_Idle': '最大空闲连接数',
'Dec-Dcm_Connection_Form_Database_Min_Idle': '最小空闲连接数',
'Dec-Dcm_Connection_Form_Database_Max_Wait': '最大等待时间',
'Dec-Dcm_Connection_Form_Database_Validation_Query': 'SQL验证查询',
'Dec-Dcm_Connection_Form_Database_Test_On_Borrow': '获取连接前检验',

5
src/modules/pages/connection/connection_jdbc/connection_jdbc.ts

@ -117,6 +117,11 @@ export class ConnectionJdbc extends BI.Widget {
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Max_Idle'),
value: connectionPoolAttr.maxIdle,
},
{
type: FormItemXtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Min_Idle'),
value: connectionPoolAttr.minIdle,
},
{
type: FormItemXtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Max_Wait'),

41
src/modules/pages/maintain/forms/components/form.jdbc.ts

@ -38,7 +38,7 @@ export class FormJdbc extends BI.Widget {
authType: null,
principal: null,
keyPath: null,
newCharsetName: null,
originalCharsetName: null,
schema: null,
url: null,
initialSize: null,
@ -51,14 +51,14 @@ export class FormJdbc extends BI.Widget {
testWhileIdle: null,
timeBetweenEvictionRunsMillis: null,
numTestsPerEvictionRun: null,
minIdle: null,
minEvictableIdleTimeMillis: null,
};
render() {
const { connectionName, connectionData } = this.options.formData;
const { driver, user, password, newCharsetName, schema, url, connectionPoolAttr, database, authType, principal, keyPath } = connectionData as ConnectionJDBC;
// minIdle 暂未使用
const { initialSize, maxActive, maxIdle, maxWait, validationQuery, testOnBorrow, testOnReturn, testWhileIdle, timeBetweenEvictionRunsMillis, numTestsPerEvictionRun, minEvictableIdleTimeMillis } = connectionPoolAttr as ConnectionPoolJDBC;
const { driver, user, password, originalCharsetName, schema, url, connectionPoolAttr, database, authType, principal, keyPath } = connectionData as ConnectionJDBC;
const { initialSize, maxActive, maxIdle, maxWait, validationQuery, testOnBorrow, testOnReturn, testWhileIdle, timeBetweenEvictionRunsMillis, numTestsPerEvictionRun, minIdle, minEvictableIdleTimeMillis } = connectionPoolAttr as ConnectionPoolJDBC;
const databaseType = getJdbcDatabaseType(database, driver);
this.oldPassword = password;
const { host, port, databaseName } = resolveUrlInfo(url);
@ -316,10 +316,10 @@ export class FormJdbc extends BI.Widget {
forms: [{
type: TextValueCombo,
width: 300,
value: newCharsetName ? newCharsetName : '',
value: originalCharsetName ? originalCharsetName : '',
items: CONNECT_CHARSET,
ref: (_ref: any) => {
this.form.newCharsetName = _ref;
this.form.originalCharsetName = _ref;
},
}],
},
@ -449,6 +449,22 @@ export class FormJdbc extends BI.Widget {
},
}],
},
{
type: FormItemXtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Min_Idle'),
forms: [{
type: TextEditor,
width: 300,
allowBlank: true,
value: minIdle,
watermark: BI.i18nText('Dec-Dcm_Connection_Form_Database_Min_Idle'),
errorText: BI.i18nText('Dec-Dcm_Connection_Check_Integer'),
validationChecker: (value: string) => this.checkInteger(value),
ref: (_ref: any) => {
this.form.minIdle = _ref;
},
}],
},
{
type: FormItemXtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Max_Wait'),
@ -675,6 +691,8 @@ export class FormJdbc extends BI.Widget {
public getSubmitValue():Connection {
const connectionData = this.options.formData.connectionData as ConnectionJDBC;
const connectionPoolAttr = connectionData.connectionPoolAttr;
const originalCharsetName = this.form.originalCharsetName.getValue()[0] || '';
// TODO 获取表单数据这里待优化
return {
connectionType: connectionType.JDBC,
@ -688,8 +706,8 @@ export class FormJdbc extends BI.Widget {
user: this.form.user.getValue(),
password: this.oldPassword === this.form.password.getValue() ? this.oldPassword : BI.encode(this.form.password.getValue()),
queryType: '',
newCharsetName: this.form.newCharsetName.getValue()[0] || '',
originalCharsetName: this.form.newCharsetName.getValue()[0] || '',
newCharsetName: originalCharsetName ? 'gbk' : '', // 后台要求,originalCharsetName不为空时,newCharsetName为gbk
originalCharsetName,
schema: this.form.schema.getValue()[0],
host: this.form.host.getValue(),
authType: this.form.authType.getValue()[0] || '',
@ -700,11 +718,12 @@ export class FormJdbc extends BI.Widget {
initialSize: this.form.initialSize.getValue(),
maxActive: this.form.maxActive.getValue(),
maxIdle: this.form.maxIdle.getValue(),
minIdle: this.form.minIdle.getValue(),
maxWait: this.form.maxWait.getValue(),
validationQuery: this.form.validationQuery.getValue(),
testOnBorrow: this.form.testOnBorrow.getValue()[0] || connectionPoolAttr.testOnBorrow,
testOnReturn: this.form.testOnReturn.getValue()[0] || connectionPoolAttr.testOnReturn,
testWhileIdle: this.form.testWhileIdle.getValue()[0] || connectionPoolAttr.testWhileIdle,
testOnBorrow: BI.size(this.form.testOnBorrow.getValue()) > 0 ? this.form.testOnBorrow.getValue()[0] : connectionPoolAttr.testOnBorrow,
testOnReturn: BI.size(this.form.testOnReturn.getValue()) > 0 ? this.form.testOnReturn.getValue()[0] : connectionPoolAttr.testOnReturn,
testWhileIdle: BI.size(this.form.testOnReturn.getValue()) > 0 ? this.form.testWhileIdle.getValue()[0] : connectionPoolAttr.testWhileIdle,
timeBetweenEvictionRunsMillis: this.form.timeBetweenEvictionRunsMillis.getValue(),
numTestsPerEvictionRun: this.form.numTestsPerEvictionRun.getValue(),
minEvictableIdleTimeMillis: this.form.minEvictableIdleTimeMillis.getValue(),

3
src/modules/pages/maintain/forms/form.model.ts

@ -3,6 +3,7 @@ import { AppModel } from 'src/modules/app.model';
import { Connection } from 'src/modules/crud/crud.typings';
import { ApiFactory } from 'src/modules/crud/apiFactory';
import { PAGE_INDEX } from '@constants/constant';
import { testConnection } from './form.server';
const api = new ApiFactory().create();
export const MaintainFormModelXtype = 'dec.dcm.model.maintain_form';
@model(MaintainFormModelXtype)
@ -40,7 +41,7 @@ export class MaintainFormModel extends Model<{
this.model.pageIndex = PAGE_INDEX.CONNECTION;
});
},
testConnection: (connection: Connection) => api.testConnection(connection),
testConnection: (connection: Connection) => testConnection(connection),
setIsCopy(isCopy: boolean) {
this.model.isCopy = isCopy;
},

3
src/modules/pages/maintain/forms/form.ts

@ -7,7 +7,6 @@ import { connectionType } from '@constants/env';
import { ConnectionJDBC, Connection } from 'src/modules/crud/crud.typings';
import { DEFAULT_JNDI_DATA, DEFAULT_JDBC_POOL, DATEBASE_FILTER_TYPE } from '@constants/constant';
import { getJdbcDatabaseType } from 'src/modules/app.service';
import { testConnection } from './form.server';
export const MaintainFormXtype = 'dec.dcm.maintain.form';
@shortcut(MaintainFormXtype)
@store(MaintainFormModelXtype)
@ -198,7 +197,7 @@ export class MaintainForm extends BI.Widget {
if (this.isEdit || this.model.isCopy) {
formValue.connectionId = this.connectionName;
}
testConnection(formValue).then(re => {
this.store.testConnection(formValue).then(re => {
this.form.setSchemas(re);
});
}

Loading…
Cancel
Save