Commit 7a48cc3d authored by 皮倩雯's avatar 皮倩雯

fix: '修复数据库链接失败bug‘

parent e3a5d5a9
Pipeline #81866 passed with stages
...@@ -253,8 +253,10 @@ const InitDataBase = props => { ...@@ -253,8 +253,10 @@ const InitDataBase = props => {
const onFinish = values => { const onFinish = values => {
setCardLoading(true); setCardLoading(true);
const obj = values; const obj = values;
console.log(chooseDb.current, 'obj'); let pwd =
let pwd = Decrypt(obj.password) === '' ? Encrypt(obj.password) : obj.password; Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1
? Encrypt(obj.password)
: obj.password;
saveConnectionNew({ saveConnectionNew({
ip: obj.ip, ip: obj.ip,
dbName: obj.dbName, dbName: obj.dbName,
...@@ -296,7 +298,10 @@ const InitDataBase = props => { ...@@ -296,7 +298,10 @@ const InitDataBase = props => {
const onCheck = e => { const onCheck = e => {
setCardLoading(true); setCardLoading(true);
const obj = form.getFieldsValue(); const obj = form.getFieldsValue();
let pwd = Decrypt(obj.password) === '' ? Encrypt(obj.password) : obj.password; let pwd =
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1
? Encrypt(obj.password)
: obj.password;
connectionTest({ connectionTest({
ip: obj.ip, ip: obj.ip,
dbName: obj.dbName, dbName: obj.dbName,
...@@ -327,7 +332,10 @@ const InitDataBase = props => { ...@@ -327,7 +332,10 @@ const InitDataBase = props => {
// 获取数据库列表 // 获取数据库列表
const selectFocus = e => { const selectFocus = e => {
let params = form.getFieldsValue(); let params = form.getFieldsValue();
let pwd = Decrypt(params.password) === '' ? Encrypt(params.password) : params.password; let pwd =
Decrypt(params.password) === '' || Decrypt(params.password).indexOf('\u0004') !== -1
? Encrypt(params.password)
: params.password;
getDataBaseList({ getDataBaseList({
userName: params.userName || '', userName: params.userName || '',
password: pwd || '', password: pwd || '',
......
...@@ -96,7 +96,10 @@ const AppendModal = props => { ...@@ -96,7 +96,10 @@ const AppendModal = props => {
const getProduct = () => { const getProduct = () => {
setLoading(true); setLoading(true);
let pwd = Decrypt(value.password) === '' ? Encrypt(value.password) : value.password; let pwd =
Decrypt(value.password) === '' || Decrypt(value.password).indexOf('\u0004') !== -1
? Encrypt(value.password)
: value.password;
GetLicenseDifference({ ...value, password: pwd }).then(res => { GetLicenseDifference({ ...value, password: pwd }).then(res => {
setLoading(false); setLoading(false);
if (res.code === 0) { if (res.code === 0) {
......
...@@ -452,7 +452,10 @@ const DatabaseInitialization = props => { ...@@ -452,7 +452,10 @@ const DatabaseInitialization = props => {
const GetDbChangeFirst = kk => { const GetDbChangeFirst = kk => {
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
let pwd = Decrypt(obj.password) === '' ? Encrypt(obj.password) : obj.password; let pwd =
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1
? Encrypt(obj.password)
: obj.password;
GetDbProduct({ ...obj, password: pwd }).then(res => { GetDbProduct({ ...obj, password: pwd }).then(res => {
setCardLoading(false); setCardLoading(false);
if (res.code === 0) { if (res.code === 0) {
...@@ -503,7 +506,10 @@ const DatabaseInitialization = props => { ...@@ -503,7 +506,10 @@ const DatabaseInitialization = props => {
const GetDbChange = e => { const GetDbChange = e => {
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
let pwd = Decrypt(obj.password) === '' ? Encrypt(obj.password) : obj.password; let pwd =
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1
? Encrypt(obj.password)
: obj.password;
GetDbProduct({ ...obj, password: pwd }).then(res => { GetDbProduct({ ...obj, password: pwd }).then(res => {
setCardLoading(false); setCardLoading(false);
if (res.code === 0) { if (res.code === 0) {
...@@ -619,7 +625,10 @@ const DatabaseInitialization = props => { ...@@ -619,7 +625,10 @@ const DatabaseInitialization = props => {
const GetDbChangeAppend = () => { const GetDbChangeAppend = () => {
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
let pwd = Decrypt(obj.password) === '' ? Encrypt(obj.password) : obj.password; let pwd =
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1
? Encrypt(obj.password)
: obj.password;
GetDbProduct({ ...obj, password: pwd }).then(res => { GetDbProduct({ ...obj, password: pwd }).then(res => {
setCardLoading(false); setCardLoading(false);
if (res.code === 0) { if (res.code === 0) {
...@@ -704,7 +713,10 @@ const DatabaseInitialization = props => { ...@@ -704,7 +713,10 @@ const DatabaseInitialization = props => {
handleShowModal('initVisible', false); handleShowModal('initVisible', false);
setInitVisible(true); setInitVisible(true);
doInitLog(); doInitLog();
let pwd = Decrypt(obj.password) === '' ? Encrypt(obj.password) : obj.password; let pwd =
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1
? Encrypt(obj.password)
: obj.password;
NewInitAddDataBase({ ...obj, productSetting, password: pwd }).then(res => { NewInitAddDataBase({ ...obj, productSetting, password: pwd }).then(res => {
if (res.code === 0) { if (res.code === 0) {
GetDbChangeAppend(); // 刷星已初始化的产品勾选 GetDbChangeAppend(); // 刷星已初始化的产品勾选
...@@ -760,7 +772,10 @@ const DatabaseInitialization = props => { ...@@ -760,7 +772,10 @@ const DatabaseInitialization = props => {
setInitVisible(true); setInitVisible(true);
doInitLog(); doInitLog();
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
let pwd = Decrypt(obj.password) === '' ? Encrypt(obj.password) : obj.password; let pwd =
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1
? Encrypt(obj.password)
: obj.password;
InitEditDataBase({ InitEditDataBase({
...obj, ...obj,
password: pwd, password: pwd,
...@@ -857,7 +872,10 @@ const DatabaseInitialization = props => { ...@@ -857,7 +872,10 @@ const DatabaseInitialization = props => {
// setKeepValue([]); // setKeepValue([]);
setProduct([]); setProduct([]);
setCardLoading(true); setCardLoading(true);
let pwd = Decrypt(obj.password) === '' ? Encrypt(obj.password) : obj.password; let pwd =
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1
? Encrypt(obj.password)
: obj.password;
GetProductList({ ...obj, password: pwd }).then(res => { GetProductList({ ...obj, password: pwd }).then(res => {
if (res.code === 0) { if (res.code === 0) {
console.log(res.data); console.log(res.data);
...@@ -890,7 +908,10 @@ const DatabaseInitialization = props => { ...@@ -890,7 +908,10 @@ const DatabaseInitialization = props => {
// 非授权模式下环境检查 // 非授权模式下环境检查
const checkUnLicense = () => { const checkUnLicense = () => {
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
let pwd = Decrypt(obj.password) === '' ? Encrypt(obj.password) : obj.password; let pwd =
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1
? Encrypt(obj.password)
: obj.password;
CheckDatabaseIsExist({ ...obj, password: pwd }).then(res => { CheckDatabaseIsExist({ ...obj, password: pwd }).then(res => {
setCardLoading(false); setCardLoading(false);
if (res.code !== 0) { if (res.code !== 0) {
...@@ -904,7 +925,10 @@ const DatabaseInitialization = props => { ...@@ -904,7 +925,10 @@ const DatabaseInitialization = props => {
const onCheckLaster = aa => { const onCheckLaster = aa => {
// 此时有授权码才能进入 // 此时有授权码才能进入
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
let pwd = Decrypt(obj.password) === '' ? Encrypt(obj.password) : obj.password; let pwd =
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1
? Encrypt(obj.password)
: obj.password;
CheckDatabaseIsExist({ ...obj, password: pwd }).then(res => { CheckDatabaseIsExist({ ...obj, password: pwd }).then(res => {
setCardLoading(false); setCardLoading(false);
if (res.code == 0) { if (res.code == 0) {
...@@ -953,7 +977,10 @@ const DatabaseInitialization = props => { ...@@ -953,7 +977,10 @@ const DatabaseInitialization = props => {
setAppendType('no'); setAppendType('no');
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
if (obj.ip && obj.userName && obj.password && obj.dbName) { if (obj.ip && obj.userName && obj.password && obj.dbName) {
let pwd = Decrypt(obj.password) === '' ? Encrypt(obj.password) : obj.password; let pwd =
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1
? Encrypt(obj.password)
: obj.password;
GetProductList({ ...obj, password: pwd }).then(res => { GetProductList({ ...obj, password: pwd }).then(res => {
setCardLoading(false); setCardLoading(false);
if (res.code === 0) { if (res.code === 0) {
...@@ -983,7 +1010,10 @@ const DatabaseInitialization = props => { ...@@ -983,7 +1010,10 @@ const DatabaseInitialization = props => {
const findCheck = aa => { const findCheck = aa => {
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
let pwd = Decrypt(obj.password) === '' ? Encrypt(obj.password) : obj.password; let pwd =
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1
? Encrypt(obj.password)
: obj.password;
CheckDatabaseIsExist({ ...obj, password: pwd }).then(res => { CheckDatabaseIsExist({ ...obj, password: pwd }).then(res => {
setCardLoading(false); setCardLoading(false);
if (res.code === 0) { if (res.code === 0) {
...@@ -1039,7 +1069,10 @@ const DatabaseInitialization = props => { ...@@ -1039,7 +1069,10 @@ const DatabaseInitialization = props => {
const findCheck1 = aa => { const findCheck1 = aa => {
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
let pwd = Decrypt(obj.password) === '' ? Encrypt(obj.password) : obj.password; let pwd =
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1
? Encrypt(obj.password)
: obj.password;
CheckDatabaseIsExist({ ...obj, password: pwd }).then(res => { CheckDatabaseIsExist({ ...obj, password: pwd }).then(res => {
setCardLoading(false); setCardLoading(false);
if (res.code === 0) { if (res.code === 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment