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

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

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