Commit da6f5f6b authored by 皮倩雯's avatar 皮倩雯

fix: '数据库初始化交互优化'

parent 23602c5d
Pipeline #56579 waiting for manual action with stages
......@@ -46,6 +46,7 @@ import {
import { BarcodeOutlined, EditOutlined } from '@ant-design/icons';
import styles from './DatabaseInitialization.less';
import styles1 from '../InitDataBase/InitDataBase.less';
import { objectOf } from 'prop-types';
const CheckboxGroup = Checkbox.Group;
const { Option } = Select;
......@@ -260,14 +261,11 @@ const DatabaseInitialization = props => {
});
};
const GetDb = e => {
const GetDb = () => {
// let obj = form.getFieldsValue();
GetDbProduct().then(res => {
if (res.code === 0) {
if (!e) {
form.setFieldsValue(res.data.DbInfo);
}
form.setFieldsValue(res.data.DbInfo);
if (res.data.Project[0]) {
setkeepNumber(res.data.Project[0].license);
setkeepMsg(res.data.Project[0].projectName);
......@@ -323,46 +321,101 @@ const DatabaseInitialization = props => {
}
setDbExists(res.data.DBExists);
setKeepDb(res.data);
if (!e) {
if (res.data.DBExists) {
if (res.data.DBExists) {
setCheckboxFlag(1);
setMsg('当前数据库已存在不可初始化');
notification.warning({
message: '提示',
duration: 5,
description: '当前数据库已存在不可初始化',
});
} else if (!res.data.DBExists && !res.data.Project[0]) {
setCheckboxFlag(0);
setMsg('');
notification.warning({
message: '提示',
duration: 5,
description: '未检测到License,自主选择产品进行数据库初始化',
});
} else if (!res.data.DBExists && res.data.Project[0]) {
setCheckboxFlag(1);
notification.success({
message: '提示',
duration: 5,
description: '已检测到License,需初始化数据库',
});
setMsg('');
}
} else {
notification.warning({
message: '提示',
duration: 5,
description: res.msg,
});
}
});
};
const GetDbChange = () => {
let obj = form.getFieldsValue();
GetDbProduct({ ...obj }).then(res => {
if (res.code === 0) {
if (res.data.Project[0]) {
setkeepNumber(res.data.Project[0].license);
setkeepMsg(res.data.Project[0].projectName);
setkeepNa(res.data.Project[0].applicantName);
setkeepCo(res.data.Project[0].jobNumber);
} else {
setkeepNumber('');
setkeepMsg('');
setkeepNa('');
setkeepCo('');
}
if (res.data.Product) {
let aa = [];
res.data.Product.map(i => {
aa.push(i.name);
});
if (res.data.IsAuthorize || res.data.DBExists) {
setCheckboxFlag(1);
setMsg('当前数据库已存在不可初始化');
notification.warning({
message: '提示',
duration: 5,
description: '当前数据库已存在不可初始化',
});
} else if (!res.data.DBExists && !res.data.Project[0]) {
} else {
setCheckboxFlag(0);
setMsg('');
notification.warning({
message: '提示',
duration: 5,
description: '未检测到License,自主选择产品进行数据库初始化',
}
console.log(aa);
if (aa.length > 0) {
let dd = [];
aa.map(i => {
keepData.map(j => {
if (j.name === i) {
dd.push(j);
}
});
});
} else if (!res.data.DBExists && res.data.Project[0]) {
setCheckboxFlag(1);
notification.success({
message: '提示',
duration: 5,
description: '已检测到License,需初始化数据库',
console.log(dd);
let Arr = Array.from(new Set(dd));
console.log(Arr);
let arr = formateArrDataA(Arr, 'productName');
let a = Object.keys(arr);
a.map(i => {
let list = [];
arr[i].map(j => {
list.push(j.name);
});
arr[i] = list;
});
setMsg('');
console.log(arr);
setProduct(arr);
setKeepValue(arr);
}
console.log(newArr);
let newArr = Array.from(new Set(aa));
setKeepProduct(newArr);
setKeepCode(newArr);
setValue(newArr);
}
// if (!res.data.DBExists) {
// setMsg('');
// } else if (res.data.DBExists && res.data.Product.length > 0) {
// setMsg('');
// } else {
// setMsg('当前数据库不可初始化');
// notification.warning({
// message: '提示',
// duration: 5,
// description: '当前数据库不可初始化',
// });
// }
setDbExists(res.data.DBExists);
setKeepDb(res.data);
} else {
notification.warning({
message: '提示',
......@@ -465,13 +518,16 @@ const DatabaseInitialization = props => {
setTotalProduct('');
setValue('');
setKeepProduct([]);
// GetDb(1);
setKeepValue([]);
setProduct([]);
onCheck();
// GetDb();
// deleteInitDBLogNew();
};
const onChange1 = (e, item) => {
console.log(e);
console.log(item);
console.log(product);
if (product[item]) {
// 过滤已初始化的产品但不存在于产品列表中的数据,避免组件出错
product[item].map(i => {
......@@ -521,16 +577,15 @@ const DatabaseInitialization = props => {
};
const onCheck = () => {
console.log(99999999);
let obj = form.getFieldsValue();
GetDbChange();
deleteInitDBLogNew();
CheckDatabaseIsExist({ ...obj }).then(res => {
if (res.code == 0) {
// 数据库不存在
if (res.data === false) {
console.log(555);
// 有授权码
if (keepNumber) {
GetDb(1);
setCheckboxFlag(1);
setDbExists(false);
setMsg('');
......@@ -560,7 +615,8 @@ const DatabaseInitialization = props => {
}
} else {
setMsg(res.msg);
notification.warning({
setCheckboxFlag(1);
notification.error({
message: '提示',
duration: 5,
description: res.msg,
......@@ -573,41 +629,64 @@ const DatabaseInitialization = props => {
let obj = form.getFieldsValue();
CheckDatabaseIsExist({ ...obj }).then(res => {
if (res.code === 0) {
setDbExists(false);
setMsg('');
if (msg) {
notification.warning({
message: '提示',
duration: 5,
description: '当前数据库不可初始化',
});
} else if (obj.ip == '' || obj.userName == '' || obj.password == '' || obj.dbName == '') {
if (res.data === true) {
setCheckboxFlag(1);
setMsg('当前数据库已存在不可初始化');
notification.warning({
message: '提示',
duration: 5,
description: '请输入完整数据库信息',
description: '当前数据库已存在不可初始化',
});
} else {
console.log(value);
let arr = [];
if (checkboxFlag == 0) {
keepData.map(i => {
if (value.indexOf(i.name) != -1) {
arr.push(i);
}
setDbExists(false);
setMsg('');
if (msg) {
notification.warning({
message: '提示',
duration: 5,
description: '当前数据库不可初始化',
});
} else {
keepData.map(i => {
if (keepCode.indexOf(i.name) != -1) {
arr.push(i);
}
} else if (obj.ip == '' || obj.userName == '' || obj.password == '' || obj.dbName == '') {
notification.warning({
message: '提示',
duration: 5,
description: '请输入完整数据库信息',
});
} else if (checkboxFlag == 0 && value.length == 0) {
notification.warning({
message: '提示',
duration: 5,
description: '请勾选产品',
});
} else if (checkboxFlag == 1 && keepProduct.length == 0) {
notification.warning({
message: '提示',
duration: 5,
description: '请勾选产品',
});
} else {
console.log(value);
let arr = [];
if (checkboxFlag == 0) {
keepData.map(i => {
if (value.indexOf(i.name) != -1) {
arr.push(i);
}
});
} else {
keepData.map(i => {
if (keepCode.indexOf(i.name) != -1) {
arr.push(i);
}
});
}
console.log(arr);
onOK(arr, code);
}
console.log(arr);
onOK(arr, code);
}
} else {
setMsg(res.msg);
setCheckboxFlag(1);
notification.error({
message: '提示',
duration: 5,
......@@ -638,14 +717,12 @@ const DatabaseInitialization = props => {
<div style={{ width: '30%' }}>
<Card>
<div style={{ height: 'calc(100vh - 108px)', paddingTop: '13px' }}>
{/* <div className={styles.tableTitle}>数据库初始化</div> */}
<Form
className={styles.mgTop20}
layout="horizontal"
labelAlign="left"
labelCol={{ span: 6 }}
form={form}
// onFinish={onFinish}
onValuesChange={onValuesChange}
>
<Form.Item
......@@ -657,14 +734,6 @@ const DatabaseInitialization = props => {
if (form.getFieldValue().ip == '') {
return Promise.reject('ip必填');
}
// if (
// form.getFieldValue().ip &&
// form.getFieldValue().userName &&
// form.getFieldValue().password &&
// form.getFieldValue().dbName
// ) {
// flagChange();
// }
setfirstColor('gray');
setsecordColor('gray');
setLastColor('gray');
......@@ -684,14 +753,6 @@ const DatabaseInitialization = props => {
if (form.getFieldValue().userName == '') {
return Promise.reject('用户名称必填');
}
// if (
// form.getFieldValue().ip &&
// form.getFieldValue().userName &&
// form.getFieldValue().password &&
// form.getFieldValue().dbName
// ) {
// flagChange();
// }
setfirstColor('gray');
setsecordColor('gray');
setLastColor('gray');
......@@ -712,14 +773,6 @@ const DatabaseInitialization = props => {
if (form.getFieldValue().password == '') {
return Promise.reject('用户密码必填');
}
// if (
// form.getFieldValue().ip &&
// form.getFieldValue().userName &&
// form.getFieldValue().password &&
// form.getFieldValue().dbName
// ) {
// flagChange();
// }
setfirstColor('gray');
setsecordColor('gray');
setLastColor('gray');
......@@ -743,14 +796,6 @@ const DatabaseInitialization = props => {
) {
return Promise.reject('数据库名称必填');
}
// if (
// form.getFieldValue().ip &&
// form.getFieldValue().userName &&
// form.getFieldValue().password &&
// form.getFieldValue().dbName
// ) {
// flagChange();
// }
setfirstColor('gray');
setsecordColor('gray');
setLastColor('gray');
......@@ -760,34 +805,6 @@ const DatabaseInitialization = props => {
]}
>
<Input placeholder="请输入数据库名称" />
{/* <Select
showSearch
mode="tags"
placeholder="请选择数据库"
optionFilterProp="children"
onFocus={() => {
selectFocus();
}}
onChange={e => {
onChange(e);
}}
// eslint-disable-next-line no-shadow
filterOption={(input, option) => {
console.log(option);
return (
option.children &&
option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
);
}}
>
{option &&
option.length > 0 &&
option.map((item, index) => (
<Option value={item.value} key={item.value + index}>
{item.value}
</Option>
))}
</Select> */}
</Form.Item>
</Form>
<div style={{ float: 'right' }}>
......@@ -912,13 +929,7 @@ const DatabaseInitialization = props => {
deleteInitDBLogNew();
}}
>
<Button
type="primary"
disabled={msg == '' ? false : true}
// onClick={() => {
// onCheck();
// }}
>
<Button type="primary" disabled={msg == '' ? false : true}>
数据库初始化
</Button>
</Popconfirm>
......@@ -933,10 +944,6 @@ const DatabaseInitialization = props => {
onCancel={() => {
setInitVisible(false);
setInitContent('');
// deleteInitDBLog({
// _version: 9999,
// _dc: Date.now(),
// });
deleteInitDBLogNew();
}}
width={800}
......
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