diff --git a/src/modules/app.service.ts b/src/modules/app.service.ts index 194feb5..a9df67a 100644 --- a/src/modules/app.service.ts +++ b/src/modules/app.service.ts @@ -78,6 +78,17 @@ export function resolveUrlInfo (url: string) { }; } +// 拼接url +export function splitUrl(host: string, port: string, database: string, baseUrl: string) { + if (baseUrl.startsWith('jdbc:sqlserver')) { + return baseUrl.replace('hostname', host).replace(':port', port ? `:${port}` : '') + .replace('=database', `=${database}`); + } + + return baseUrl.replace('hostname', host).replace(':port', port ? `:${port}` : '') + .replace('database', database); +} + export function connectionCanEdit(connection: Connection) { if (connection && connection.privilegeDetailBeanList) { // privilegeType === 4 代表编辑权限,privilegeValue === 2 代表有权限 diff --git a/src/modules/pages/maintain/forms/components/form.jdbc.ts b/src/modules/pages/maintain/forms/components/form.jdbc.ts index c4a7dc9..a343545 100644 --- a/src/modules/pages/maintain/forms/components/form.jdbc.ts +++ b/src/modules/pages/maintain/forms/components/form.jdbc.ts @@ -5,7 +5,7 @@ import { FormItemXtype } from '../../components/form_item/form_item'; import { Connection, ConnectionJDBC, ConnectionPoolJDBC } from 'src/modules/crud/crud.typings'; import { connectionType } from '@constants/env'; import { CONNECT_CHARSET } from '@constants/constant'; -import { getAllDatabaseTypes, getJdbcDatabaseType, resolveUrlInfo } from '../../../../app.service'; +import { getAllDatabaseTypes, getJdbcDatabaseType, resolveUrlInfo, splitUrl } from '../../../../app.service'; export const FormJdbcXtype = 'dec.dcm.maintain.form.jdbc'; @shortcut(FormJdbcXtype) @@ -652,8 +652,7 @@ export class FormJdbc extends BI.Widget { const host = this.form.host.getValue(); const port = this.form.port.getValue(); const database = this.form.database.getValue(); - this.form.url.setValue(url.replace('hostname', host).replace(':port', port ? `:${port}` : '') - .replace('database', database)); + this.form.url.setValue(splitUrl(host, port, database, url)); } public setSchemas(schemas: string[]) {