Commit 69ac8b6b authored by 皮倩雯's avatar 皮倩雯

数据库初始化追加

parent 5fb162e4
Pipeline #58925 passed with stages
......@@ -37,10 +37,6 @@ import ChangeAdd from './ChangeAdd';
const { Option } = Select;
const AddModal = props => {
const [inputValue, setInputValue] = useState({
feedbackName: '',
doRole: '',
});
const { callBackSubmit = () => {}, visible, type, formObj, keepTableData } = props;
const [Type1, setType1] = useState('');
......@@ -74,13 +70,11 @@ const AddModal = props => {
form.setFieldsValue({ isSubmit: '否', docycle: '一周一次' });
setType1('');
setType2('');
setInputValue({ feedbackName: '', doRole: '' });
setFiled1({});
} else if (type === 'edit') {
CM_XWBPlan_DataList({ id: formObj.id }).then(res => {
let data = res.data[0];
data && form.setFieldsValue({ ...data });
setInputValue({ ...data });
console.log(data.businessTypee);
setType1(data.businessType);
setType2(data.accountName);
......@@ -113,8 +107,6 @@ const AddModal = props => {
form.validateFields().then(validate => {
if (validate) {
let obj = form.getFieldsValue();
// obj.feedbackName = inputValue.feedbackName;
// obj.doRole = inputValue.doRole;
if (type == 'add') {
CM_XWBPlan_DataEditORAdd(obj).then(res => {
if (res.msg == '') {
......@@ -167,26 +159,34 @@ const AddModal = props => {
setType2(e.target.value);
form.setFieldsValue({ accountName: e.target.value });
};
const changeText = (e, type) => {
let inputText = { ...inputValue };
inputText[type] = e.target.value;
setInputValue(inputText);
};
const pickFiled = fileds => {
setTypes('add');
setCharacterValue(inputValue[fileds]);
setCheckedList1(inputValue[fileds].split(','));
setPickItem(fileds);
setIsVisible(true);
if (form.getFieldValue(fileds)) {
setTypes('add');
setCharacterValue(form.getFieldValue(fileds));
setCheckedList1(form.getFieldValue(fileds).split(','));
setPickItem(fileds);
setIsVisible(true);
} else {
setTypes('add');
setCharacterValue(form.getFieldValue(fileds));
setCheckedList1([]);
setPickItem(fileds);
setIsVisible(true);
}
};
const pickFiled1 = fileds => {
setTypes('app');
setCharacterValue(inputValue[fileds]);
setCheckedList1(inputValue[fileds].split(','));
console.log(inputValue[fileds]);
console.log(inputValue[fileds].split(','));
setPickItem(fileds);
setIsVisibleRoles(true);
if (form.getFieldValue(fileds)) {
setTypes('app');
setCheckedList1(form.getFieldValue(fileds).split(','));
setPickItem(fileds);
setIsVisibleRoles(true);
} else {
setTypes('app');
setCheckedList1([]);
setPickItem(fileds);
setIsVisibleRoles(true);
}
};
const getRole = () => {
CM_Event_LoadDepartmentAndRoles().then(res => {
......@@ -258,7 +258,7 @@ const AddModal = props => {
if (!name) {
return '请传入对象属性';
}
//先获取一下这个数组中有多少个"name"
// 先获取一下这个数组中有多少个"name"
let nameArr = [];
a3.map(i => {
if (nameArr.indexOf(i.group) === -1) {
......@@ -266,7 +266,7 @@ const AddModal = props => {
}
});
console.log(nameArr);
//新建一个包含多个list的结果对象
// 新建一个包含多个list的结果对象
let tempObj = {};
// 根据不同的"name"生成多个数组
for (let k in nameArr) {
......@@ -295,20 +295,23 @@ const AddModal = props => {
setSelectValue1(value);
};
const onOK = prop => {
console.log(prop.isType);
setIsVisibleRoles(false);
let inputText = {};
inputText[prop.pickItem] = prop.str;
setCheckedList1(prop.stt);
form.setFieldsValue(inputText);
};
const onOK1 = prop => {
console.log(prop);
setIsVisible(false);
console.log(props);
let inputText = { ...inputValue };
let inputText = {};
inputText[prop.pickItem] = prop.str;
setCheckedList1(prop.checkedList);
setInputValue(inputText);
setCheckedList1(prop.stt);
form.setFieldsValue(inputText);
};
// const title = <ModalDrag title="巡维保计划配置" />
const inputType = value => {
console.log(value);
if (value) {
form.setFieldsValue({ businessType: value });
}
......@@ -345,7 +348,8 @@ const AddModal = props => {
let aa = form.getFieldValue().businessName;
if (type === 'add' && keepTableData.indexOf(aa) != -1) {
return Promise.reject('业务名称已存在');
} else if (
}
if (
type === 'edit' &&
keepTableData.indexOf(aa) != -1 &&
aa != formObj.businessName
......@@ -556,7 +560,7 @@ const AddModal = props => {
<ChangeAdd
visible={isVisible}
onCancel={() => setIsVisible(false)}
callBackSubmit={onOK}
callBackSubmit={onOK1}
newCheckedList={checkedList1}
isType={types}
filed={filed}
......
......@@ -95,7 +95,7 @@ const ChangeAdd = props => {
setCheckedList(checkArr);
setIndeterminate(!!checkArr.length && checkArr.length < filed.length);
setCheckAll(checkArr.length === filed.length && filed.length != 0);
let newArr = characterValue.length ? characterValue.split(',') : [];
let newArr = characterValue ? characterValue.split(',') : [];
setSelectData(newArr);
}
}
......
......@@ -329,7 +329,7 @@ const maintenance = () => {
marginTop: '10px',
}}
>
<span style={{ marginTop: '-3px' }}>新增</span>
<span style={{ marginTop: '-2px' }}>新增</span>
</Button>
<Button
icon={<OrderedListOutlined className={styles.icon} />}
......@@ -340,7 +340,7 @@ const maintenance = () => {
marginTop: '10px',
}}
>
<span style={{ marginTop: '-3px' }}>调序</span>
<span style={{ marginTop: '-2px' }}>调序</span>
</Button>
</span>
</div>
......
......@@ -306,8 +306,11 @@ const AddModal = props => {
};
const onOK = prop => {
console.log(prop);
setIsVisibleRoles(false);
let inputText = {};
console.log(inputText);
console.log(inputText[prop.pickItem]);
inputText[prop.pickItem] = prop.str;
setCheckedList1(prop.stt);
form.setFieldsValue(inputText);
......
......@@ -229,7 +229,7 @@ const patrolFeedback = () => {
marginTop: '10px',
}}
>
<span style={{ marginTop: '-3px' }}>新增</span>
<span style={{ marginTop: '-2px' }}>新增</span>
</Button>
<Button
icon={<OrderedListOutlined className={styles.icon} />}
......@@ -240,7 +240,7 @@ const patrolFeedback = () => {
marginTop: '10px',
}}
>
<span style={{ marginTop: '-3px' }}>调序</span>
<span style={{ marginTop: '-2px' }}>调序</span>
</Button>
<Button
icon={<DeleteOutlined className={styles.icon} />}
......@@ -252,7 +252,7 @@ const patrolFeedback = () => {
onClick={de}
disabled={!hasSelected}
>
<span style={{ marginTop: '-3px' }}>批量删除</span>
<span style={{ marginTop: '-2px' }}>批量删除</span>
</Button>
</span>
</div>
......
......@@ -626,7 +626,7 @@ const AddModal = props => {
setOrder(res.data.root.Order);
form.setFieldsValue({ ...res.data.root });
if (res.data.root.ImageExpression) {
setImageUrl(window.location.origin + `/civweb4/${res.data.root.ImageExpression}`);
setImageUrl(`${window.location.origin }/civweb4/${res.data.root.ImageExpression}`);
setIm(res.data.root.ImageExpression);
} else {
form.setFieldsValue({
......@@ -1302,7 +1302,7 @@ const AddModal = props => {
const onOk = props => {
if (props) {
setImageUrl(window.location.origin + `/civweb4/${props}`);
setImageUrl(`${window.location.origin }/civweb4/${props}`);
setIm(props);
setKeepImgeUrl(props);
form.setFieldsValue({ ImageExpression: `${props}` });
......@@ -1853,12 +1853,12 @@ const AddModal = props => {
form.setFieldsValue({ ImageExpression: '' });
}}
style={{
position: 'relative',
position: 'absolute',
fontSize: '18px',
left: '34px',
top: '10px',
left: '44px',
top: '45px',
color: 'white',
zIndex:'2'
zIndex:'999'
}}
/>
</>
......
......@@ -272,13 +272,14 @@
}
}
.imgg {
position: absolute;
top: 0;
left: 0;
position: relative;
top: -33px;
left: -9px;
height: 104px;
width: 104px;
background: rgba(0, 0, 0, 0.5);
border-radius: 2px;
z-index:1;
}
.imgg :hover {
opacity: 0.7;
......
/* eslint-disable guard-for-in */
/* eslint-disable no-restricted-syntax */
import React, { useEffect, useState } from 'react';
import { Button, Space, notification, Modal, Popconfirm, Empty, Spin } from 'antd';
import styles from './DatabaseInitialization.less';
import { GetLicenseDifference, InitEditDataBase, GetProductList } from '@/services/database/api';
const AppendModal = props => {
const { callBackSubmit = () => {}, visible, onCancel, value } = props;
const [data, setData] = useState([]);
const [allLength, setAllLength] = useState('');
const [flag, setFlag] = useState();
const [loading, setLoading] = useState(false);
useEffect(() => {
if (visible) {
getProduct();
console.log(value);
} else {
setData([]);
setFlag();
setAllLength('');
}
}, [visible]);
const getProduct = () => {
setLoading(true);
GetLicenseDifference(value).then(res => {
setLoading(false);
if (res.code === 0) {
let arr = formateArrDataA(res.data, 'productName');
let aa = Object.keys(arr);
aa.map(i => {
let list = [];
arr[i].map(j => {
list.push(j.name);
});
arr[i] = list;
});
setData(arr);
if (res.data.length == 0) {
setFlag(1);
} else {
setFlag(0);
}
setAllLength(res.data.length);
} else {
notification.error({
message: '提示',
duration: 3,
description: res.msg,
});
}
});
};
const formateArrDataA = (initialArr, name) => {
// 判定传参是否符合规则
if (!(initialArr instanceof Array)) {
return '请传入正确格式的数组';
}
if (!name) {
return '请传入对象属性';
}
// 先获取一下这个数组中有多少个"name"
let nameArr = [];
for (let i in initialArr) {
if (nameArr.indexOf(initialArr[i][`${name}`]) === -1) {
nameArr.push(initialArr[i][`${name}`]);
}
}
// 新建一个包含多个list的结果对象
let tempObj = {};
// 根据不同的"name"生成多个数组
for (let k in nameArr) {
for (let j in initialArr) {
if (initialArr[j][`${name}`] == nameArr[k]) {
// 每次外循环时新建一个对应"name"的数组, 内循环时当前数组不变
tempObj[nameArr[k]] = tempObj[nameArr[k]] || [];
tempObj[nameArr[k]].push(initialArr[j]);
}
}
}
for (let keys in tempObj) {
let arr = [];
tempObj[keys].map((item, index) => {
tempObj[keys] = arr;
item.key = index;
arr.push(item);
});
}
return tempObj;
};
const Submit = () => {
callBackSubmit();
};
return (
<Modal
title="产品追加"
width="800px"
visible={visible}
onCancel={onCancel}
destroyOnClose
maskClosable={false}
bodyStyle={{
height: '500px',
overflowY: 'scroll',
}}
footer={
<Space>
<Button onClick={onCancel}>取消</Button>
<Popconfirm
placement="topLeft"
title={<span style={{ color: 'rgb(24 144 255)' }}>是否确认追加!</span>}
okText="确认"
cancelText="取消"
onConfirm={() => {
Submit();
}}
>
<Button type="primary">追加</Button>
</Popconfirm>
</Space>
}
>
<Spin spinning={loading}>
{flag == 1 ? (
<Empty
image={Empty.PRESENTED_IMAGE_SIMPLE}
description={<span>当前授权码下产品已全部初始化,无需再次追加</span>}
/>
) : (
<>
{allLength > 0 && (
<div style={{ marginBottom: '26px' }}>
<strong>
追加产品列表(共<span style={{ color: 'rgb(24 144 255)' }}>{allLength}</span>个)
</strong>
</div>
)}
{data &&
Object.keys(data).map((i, j) => (
<div
style={{
border: '2px solid #c2cdfd',
borderRadius: '5px',
marginBottom: '20px',
position: 'relative',
paddingTop: '30px',
}}
>
<div
style={{
position: 'absolute',
left: '13px',
top: '-12px',
backgroundColor: 'white',
paddingLeft: '10px',
paddingRight: '10px',
}}
>
<>
<span>{i}</span>
<span>
(共<span style={{ color: 'rgb(24, 144, 255)' }}>{data[i].length}</span>个)
</span>
</>
</div>
{data[i].map(j => (
<span
style={{
width: '150px',
marginLeft: '24px',
display: 'inline-block',
marginBottom: '20px',
}}
>
{j}
</span>
))}
</div>
))}
</>
)}
</Spin>
</Modal>
);
};
export default AppendModal;
/* eslint-disable guard-for-in */
/* eslint-disable no-restricted-syntax */
/* eslint-disable no-lonely-if */
/* eslint-disable prefer-promise-reject-errors */
/* eslint-disable no-else-return */
......@@ -22,25 +24,14 @@ import {
import PageContainer from '@/components/BasePageContainer';
import { connect } from 'react-redux';
import {
setTableSQLDirName,
deleteConnNew,
initDBv4new,
getInitDBLogNew,
getConnRecordNew,
getDataBaseConfigNew,
saveConnectionNew,
getDataBaseList,
updateConnDescNew,
deleteInitDBLogNew,
connectionTest,
GetProductList, // 获取产品列表
GetDbProduct, // 获取产品方案配置
InitAddDataBase, // 数据库初始化
InitEditDataBase, // 二次初始化
CheckConnection,
SetAdminMenuToRole,
CheckDatabaseIsExist,
NewInitAddDataBase,
InitEditDataBase,
} from '@/services/database/api';
import {
CloseCircleOutlined,
......@@ -53,6 +44,7 @@ import {
} from '@ant-design/icons';
import styles from './DatabaseInitialization.less';
import styles1 from '../InitDataBase/InitDataBase.less';
import AppendModal from './AppendModal';
const CheckboxGroup = Checkbox.Group;
const formLables = {
......@@ -76,7 +68,6 @@ const DatabaseInitialization = props => {
const [cardLoading, setCardLoading] = useState(false); // 初始化card Loading
const [finish, setFinish] = useState(false);
const [initLoading, setInitLoading] = useState(false);
const [dbExists, setDbExists] = useState(false); // 数据库是否存在
const [keepDb, setKeepDb] = useState([]);
const [keepProduct, setKeepProduct] = useState([]);
const scroll = useRef(null);
......@@ -85,7 +76,6 @@ const DatabaseInitialization = props => {
const [title, setTitle] = useState([]);
const [keepCode, setKeepCode] = useState([]);
const [keepData, setKeepData] = useState([]);
const [checkboxFlag, setCheckboxFlag] = useState(0);
const [keepValue, setKeepValue] = useState([]);
const [value, setValue] = useState([]);
const [product, setProduct] = useState([]);
......@@ -116,6 +106,9 @@ const DatabaseInitialization = props => {
const [licen, setLicen] = useState('');
const [showDetali, setShowDetali] = useState(false);
const [keepLast, setKeepLast] = useState('');
const [appendVisible, setAppendVisible] = useState(false);
const [append, setAppend] = useState('不需要追加');
const [dataValue, setDataValue] = useState();
// 获取数据库配置信息
useEffect(() => {
......@@ -128,7 +121,6 @@ const DatabaseInitialization = props => {
GetProductList().then(res => {
setCardLoading(false);
if (res.code === 0) {
console.log(res.data);
GetDb(res.data);
setKeepData(res.data);
let arr = formateArrDataA(res.data, 'productName');
......@@ -141,8 +133,6 @@ const DatabaseInitialization = props => {
arr[i] = list;
});
setAllLength(res.data.length);
console.log(arr);
console.log(aa);
setTitle(aa);
setData(arr);
}
......@@ -295,6 +285,7 @@ const DatabaseInitialization = props => {
};
const GetDb = kk => {
console.log(121212);
GetDbProduct().then(res => {
if (res.code === 0) {
if (res.data.DbInfo.ip == '127.0.0.1' || !res.data.DbInfo.ip) {
......@@ -314,9 +305,9 @@ const DatabaseInitialization = props => {
setkeepNa('');
setkeepCo('');
}
if (!res.data.IsAuthorize) {
form.setFieldsValue(res.data.DbInfo);
}
form.setFieldsValue(res.data.DbInfo);
GetDbChangeFirst(kk);
// 有License的情况下首次进入展示数据
// if (res.data.IsAuthorize) {
if (res.data.Product) {
......@@ -324,11 +315,6 @@ const DatabaseInitialization = props => {
res.data.Product.map(i => {
aa.push(i.name);
});
if (res.data.IsAuthorize) {
setCheckboxFlag(1);
} else {
setCheckboxFlag(0);
}
if (aa.length > 0) {
let dd = [];
aa.map(i => {
......@@ -352,15 +338,97 @@ const DatabaseInitialization = props => {
setKeepValue(arr);
}
let newArr = Array.from(new Set(aa));
console.log(newArr);
setKeepProduct(newArr);
setKeepCode(newArr);
setValue(newArr);
}
setDbExists(res.data.DBExists);
setKeepDb(res.data);
setIsAuthorize(res.data.IsAuthorize);
if (res.data.IsAuthorize) {
setMsg('');
// if (res.data.IsAppend) {
// setMsg('当前环境需要追加产品');
// setAppend('');
// } else {
// setMsg('');
// setAppend('没有追加的产品');
// }
} else {
// if (res.data.IsAppend) {
// setbeforeColor('green');
// setResult('检测到License,当前环境需要追加产品');
// setMsg('检测到License,当前环境需要追加产品');
// setAppend('');
// setAppendVisible(true);
// } else {
// setAppend('没有追加的产品');
if (res.data.Project && res.data.Project[0]) {
setbeforeColor('red');
setResult('检测到License已被使用');
setMsg('检测到License已被使用');
} else {
setbeforeColor('red');
setResult('未检测到License');
setMsg('未检测到License');
}
// }
}
} else {
notification.error({
message: '提示',
duration: 3,
description: res.msg,
});
}
});
};
const GetDbChangeFirst = kk => {
console.log(123);
let obj = form.getFieldsValue();
GetDbProduct({ ...obj }).then(res => {
setCardLoading(false);
if (res.code === 0) {
if (res.data.Product) {
let aa = [];
res.data.Product.map(i => {
aa.push(i.name);
});
if (aa.length > 0) {
let dd = [];
aa.map(i => {
kk.map(j => {
if (j.name === i) {
dd.push(j);
}
});
});
let Arr = Array.from(new Set(dd));
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;
});
setProduct(arr);
setKeepValue(arr);
}
let newArr = Array.from(new Set(aa));
console.log(newArr);
setKeepProduct(newArr);
setKeepCode(newArr);
setValue(newArr);
}
if (res.data.IsAuthorize) {
if (kk) {
findCheck(res.data.IsAppend);
} else {
onCheckLaster(res.data.IsAppend);
}
} else {
if (res.data.Project && res.data.Project[0]) {
setbeforeColor('red');
......@@ -372,31 +440,6 @@ const DatabaseInitialization = props => {
setMsg('未检测到License');
}
}
// if (res.data.DBExists) {
// setCheckboxFlag(1);
// setMsg('当前数据库已存在不可初始化');
// notification.error({
// message: '提示',
// duration: 3,
// description: '当前数据库已存在不可初始化',
// });
// } else if (!res.data.DBExists && !res.data.Project[0]) {
// setCheckboxFlag(0);
// setMsg('');
// notification.warning({
// message: '提示',
// duration: 3,
// description: '未检测到License,自主选择产品进行数据库初始化',
// });
// } else if (!res.data.DBExists && res.data.Project[0]) {
// setCheckboxFlag(1);
// notification.success({
// message: '提示',
// duration: 3,
// description: '已检测到License,需初始化数据库',
// });
// setMsg('');
// }
} else {
notification.error({
message: '提示',
......@@ -409,15 +452,16 @@ const DatabaseInitialization = props => {
const GetDbChange = e => {
let obj = form.getFieldsValue();
console.log(2222);
GetDbProduct({ ...obj }).then(res => {
setCardLoading(false);
if (res.code === 0) {
if (res.data.IsAuthorize) {
// setMsg('');
if (e) {
findCheck();
findCheck(res.data.IsAppend);
} else {
onCheckLaster();
onCheckLaster(res.data.IsAppend);
}
} else {
if (res.data.Project && res.data.Project[0]) {
......@@ -446,13 +490,6 @@ const DatabaseInitialization = props => {
res.data.Product.map(i => {
aa.push(i.name);
});
console.log(aa);
// if (res.data.IsAuthorize || res.data.DBExists) {
// setCheckboxFlag(1);
// } else {
// setCheckboxFlag(0);
// }
// console.log(aa);
if (aa.length > 0) {
let dd = [];
aa.map(i => {
......@@ -462,13 +499,9 @@ const DatabaseInitialization = props => {
}
});
});
console.log(dd);
let Arr = Array.from(new Set(dd));
console.log(Arr);
let arr = formateArrDataA(Arr, 'productName');
console.log(arr);
let a = Object.keys(arr);
console.log(a);
a.map(i => {
let list = [];
arr[i].map(j => {
......@@ -481,18 +514,81 @@ const DatabaseInitialization = props => {
setKeepValue(arr);
}
let newArr = Array.from(new Set(aa));
console.log(aa);
// 当前数据库已存在和上一个已存在数据库值重新赋值
if (newArr.length > 0 || dbExists) {
if (newArr.length > 0) {
setKeepProduct(newArr);
setKeepCode(newArr);
setValue(newArr);
} else {
setKeepProduct([]);
setKeepCode([]);
setValue([]);
}
if (res.data.Product.length == 0) {
console.log(1212);
setKeepValue([]);
}
}
setKeepDb(res.data);
setIsAuthorize(res.data.IsAuthorize);
} else {
notification.error({
message: '提示',
duration: 3,
description: res.msg,
});
}
});
};
const GetDbChangeAppend = () => {
let obj = form.getFieldsValue();
console.log(5555);
GetDbProduct({ ...obj }).then(res => {
setCardLoading(false);
if (res.code === 0) {
if (res.data.Product) {
let aa = [];
res.data.Product.map(i => {
aa.push(i.name);
});
if (aa.length > 0) {
let dd = [];
aa.map(i => {
keepData.map(j => {
if (j.name === i) {
dd.push(j);
}
});
});
let Arr = Array.from(new Set(dd));
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;
});
setProduct(arr);
setKeepValue(arr);
}
let newArr = Array.from(new Set(aa));
// 当前数据库已存在和上一个已存在数据库值重新赋值
if (newArr.length > 0) {
setKeepProduct(newArr);
setKeepCode(newArr);
setValue(newArr);
} else {
setKeepProduct([]);
setKeepCode([]);
setValue([]);
}
if (res.data.Product.length == 0) {
setKeepValue([]);
}
}
setDbExists(res.data.DBExists);
setKeepDb(res.data);
setIsAuthorize(res.data.IsAuthorize);
} else {
......@@ -517,45 +613,12 @@ const DatabaseInitialization = props => {
handleShowModal('initVisible', false);
setInitVisible(true);
doInitLog();
// if (dbExists) {
// InitEditDataBase({ ...obj, productSetting, license: j }).then(res => {
// setInitLoading(false);
// if (res.code === 0) {
// setfirstColor('green');
// setsecordColor('green');
// SetAdminMenuToRole().then(resdata => {
// if (resdata.code === 0) {
// setLastColor('green');
// }
// });
// notification.success({
// message: '提示',
// duration: 5,
// description: '数据库初始化成功',
// });
// } else {
// setfirstColor('red');
// setsecordColor('gray');
// setLastColor('gray');
// notification.error({
// message: '提示',
// duration: 5,
// description: res.msg,
// });
// }
// });
// return;
// }
NewInitAddDataBase({ ...obj, productSetting }).then(res => {
if (res.code === 0) {
if (value.length > 0) {
setKeepProduct(value);
}
// setbeforeColor('red');
// setResult('检测到License已被使用');
setMsg('检测到License已被使用');
setCheckboxFlag(1);
setfirstColor('green');
setDataResult('成功');
......@@ -564,13 +627,64 @@ const DatabaseInitialization = props => {
duration: 3,
description: '数据库初始化成功',
});
setDbExists(true);
if (keepNumber != '') {
setkeepNumber('已使用');
}
// setkeepNa('');
// setkeepMsg('');
// setkeepCo('');
if (res.data.productPackageCount == 0) {
setProductResult('产品授权不包含已初始化的产品');
setsecordColor('#eda625');
} else {
setsecordColor('green');
}
setTotalProduct(res.data.productPackageSumCount);
setSimpleProduct(res.data.productPackageCount);
SetAdminMenuToRole().then(resdata => {
if (resdata.code === 0) {
setLastColor('green');
setKeepLast('');
} else {
setLastColor('red');
setKeepLast(res.data.msg);
}
});
} else {
setDataResult(res.msg);
setFinish(true);
setfirstColor('red');
setsecordColor('gray');
setLastColor('gray');
notification.error({
message: '提示',
duration: 3,
description: res.msg,
});
}
});
};
// 数据库初始化追加
const initDatabaseProAppend = () => {
// 数据库存在调用编辑接口否则调用新增接口
handleShowModal('initVisible', false);
setInitVisible(true);
doInitLog();
let obj = form.getFieldsValue();
InitEditDataBase(obj).then(res => {
if (res.code === 0) {
// if (value.length > 0) {
// setKeepProduct(value);
// }
setMsg('检测到License已被使用');
setfirstColor('green');
setDataResult('成功');
notification.success({
message: '提示',
duration: 3,
description: '数据库初始化追加成功',
});
if (keepNumber != '') {
setkeepNumber('已使用');
}
if (res.data.productPackageCount == 0) {
setProductResult('产品授权不包含已初始化的产品');
setsecordColor('#eda625');
......@@ -685,8 +799,6 @@ const DatabaseInitialization = props => {
arr[i] = list;
});
setAllLength(res.data.length);
console.log(arr);
console.log(aa);
setTitle(aa);
setData(arr);
} else {
......@@ -699,44 +811,44 @@ const DatabaseInitialization = props => {
setbeforeColor('red');
setResult('请输入完整数据库信息');
setMsg('请输入完整数据库信息');
setCheckboxFlag(1);
}
};
const onCheckLaster = () => {
const onCheckLaster = aa => {
// 此时有授权码才能进入
let obj = form.getFieldsValue();
CheckDatabaseIsExist({ ...obj }).then(res => {
setCardLoading(false);
if (res.code == 0) {
setDataValue(form.getFieldsValue());
// 数据库不存在
if (res.data === false) {
setbeforeColor('green');
setResult('通过');
// 有授权码
console.log(keepNumber);
setAppend('无需追加');
setMsg('');
if (keepNumber && keepNumber != '已使用') {
setCheckboxFlag(1);
// setDbExists(false);
setMsg('');
} else {
setCheckboxFlag(0);
// setDbExists(false);
setMsg('');
}
// setValue([]);
// setKeepProduct([]);
console.log(value);
} else {
setbeforeColor('red');
setResult('当前数据库已存在');
setCheckboxFlag(1);
setMsg('当前数据库已存在');
if (aa) {
setbeforeColor('green');
setResult('检测到License,当前环境需要追加产品');
setMsg('检测到License,当前环境需要追加产品');
setAppend('');
setAppendVisible(true);
console.log(form.getFieldsValue());
setDataValue(form.getFieldsValue());
} else {
setbeforeColor('red');
setResult('无法追加,该数据库为非授权初始化数据库,请直接升级数据库!');
setMsg('无法追加,该数据库为非授权初始化数据库,请直接升级数据库!');
setAppend('无需追加');
}
}
} else {
setbeforeColor('red');
setResult(`${res.msg}`);
setMsg(res.msg);
setCheckboxFlag(1);
}
});
};
......@@ -747,7 +859,6 @@ const DatabaseInitialization = props => {
GetProductList({ ...obj }).then(res => {
setCardLoading(false);
if (res.code === 0) {
console.log(res.data);
GetDbChange(1);
setKeepData(res.data);
let arr = formateArrDataA(res.data, 'productName');
......@@ -760,8 +871,6 @@ const DatabaseInitialization = props => {
arr[i] = list;
});
setAllLength(res.data.length);
console.log(arr);
console.log(aa);
setTitle(aa);
setData(arr);
}
......@@ -772,64 +881,52 @@ const DatabaseInitialization = props => {
setbeforeColor('red');
setResult('请输入完整数据库信息');
setMsg('请输入完整数据库信息');
setCheckboxFlag(1);
}
};
const findCheck = () => {
const findCheck = aa => {
let obj = form.getFieldsValue();
CheckDatabaseIsExist({ ...obj }).then(res => {
setCardLoading(false);
if (res.code === 0) {
setDataValue(form.getFieldsValue());
if (res.data === true) {
setbeforeColor('red');
setPassword(false);
setResult('当前数据库已存在 ');
setMsg('当前数据库已存在');
deleteInitDBLogNew();
setCheckboxFlag(1);
if (aa) {
setbeforeColor('green');
setResult('检测到License,当前环境需要追加产品');
setMsg('检测到License,当前环境需要追加产品');
setAppend('');
setAppendVisible(true);
setDataValue(form.getFieldsValue());
} else {
setbeforeColor('red');
setPassword(false);
setResult('无法追加,该数据库为非授权初始化数据库,请直接升级数据库! ');
setMsg('无法追加,该数据库为非授权初始化数据库,请直接升级数据库!');
setAppend('无需追加');
deleteInitDBLogNew();
}
} else {
setPassword(true);
setbeforeColor('green');
setResult('通过');
// setDbExists(false);
setMsg('');
if (checkboxFlag == 0 && value.length == 0) {
notification.warning({
message: '提示',
duration: 3,
description: '请勾选产品',
});
} else if (checkboxFlag == 1 && keepProduct.length == 0) {
notification.warning({
message: '提示',
duration: 3,
description: '请勾选产品',
});
} else {
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);
}
});
setAppend('无需追加');
let arr = [];
keepData.map(i => {
if (keepCode.indexOf(i.name) != -1) {
arr.push(i);
}
onOK(arr);
}
});
onOK(arr);
}
} else {
setbeforeColor('red');
setResult(`${res.msg}`);
setMsg(res.msg);
setCheckboxFlag(1);
}
});
};
......@@ -871,6 +968,11 @@ const DatabaseInitialization = props => {
return aa;
};
const onOk = () => {
setAppendVisible(false);
initDatabaseProAppend();
GetDbChangeAppend();
};
return (
<>
<PageContainer className={styles.InitDataBaseContainer}>
......@@ -899,7 +1001,6 @@ const DatabaseInitialization = props => {
if (!regCn.test(form.getFieldValue().ip)) {
return Promise.reject('ip格式不正确');
}
setbeforeColor('gray');
setfirstColor('gray');
setsecordColor('gray');
......@@ -923,7 +1024,6 @@ const DatabaseInitialization = props => {
if (form.getFieldValue().userName == '') {
return Promise.reject('用户名称必填');
}
setbeforeColor('gray');
setfirstColor('gray');
setsecordColor('gray');
......@@ -944,7 +1044,6 @@ const DatabaseInitialization = props => {
rules={[
{
validator: (rule, value) => {
console.log(form.getFieldValue().password);
if (form.getFieldValue().password == '') {
return Promise.reject('用户密码必填');
}
......@@ -969,7 +1068,6 @@ const DatabaseInitialization = props => {
rules={[
{
validator: (rule, value) => {
console.log(form.getFieldValue().dbName);
if (
form.getFieldValue().dbName == '' ||
form.getFieldValue().dbName == undefined
......@@ -1050,6 +1148,17 @@ const DatabaseInitialization = props => {
return (
<CheckCircleOutlined style={{ color: 'green', marginLeft: '10px' }} />
);
case '检测到License,当前环境需要追加产品':
return (
<>
<CheckCircleOutlined
style={{ color: 'green', marginLeft: '10px' }}
/>
<span style={{ color: 'rgb(24 144 255)', marginLeft: '5px' }}>
{result}
</span>
</>
);
default:
return (
<>
......@@ -1207,18 +1316,11 @@ const DatabaseInitialization = props => {
{keepCo ? <>{keepCo}</> : '-'}
</div>
<div style={{ display: 'inline-block', backgroundColor: 'aliceblue' }}>
{checkboxFlag == 0 ? (
<div style={{ float: 'right' }}>
(已选<span style={{ color: 'rgb(24 144 255)' }}>{value.length}</span>/
<span style={{ color: 'rgb(24 144 255)' }}>{allLength}</span>个产品)
</div>
) : (
<div style={{ float: 'right' }}>
(已选
<span style={{ color: 'rgb(24 144 255)' }}>{keepProduct.length}</span>/
<span style={{ color: 'rgb(24 144 255)' }}>{allLength}</span>个产品)
</div>
)}
<div style={{ float: 'right' }}>
(已选
<span style={{ color: 'rgb(24 144 255)' }}>{keepProduct.length}</span>/
<span style={{ color: 'rgb(24 144 255)' }}>{allLength}</span>个产品)
</div>
</div>
</div>
<Spin tip="loading..." spinning={cardLoading}>
......@@ -1236,18 +1338,10 @@ const DatabaseInitialization = props => {
>
{`${item}(${simple(item)}/${total(item)})`}
</Divider>
{/* {checkboxFlag == 0 ? (
<CheckboxGroup
options={data[item]}
value={value}
onChange={e => onChange1(e, item)}
/>
) : (
<> */}
{data[item] &&
data[item].map((i, j) => {
if (keepProduct.indexOf(i) != -1) {
return <Checkbox checked={true}>{i}</Checkbox>;
return <Checkbox checked>{i}</Checkbox>;
} else {
return (
<Checkbox checked={false} disabled>
......@@ -1256,17 +1350,20 @@ const DatabaseInitialization = props => {
);
}
})}
{/* </>
)} */}
</div>
))}
</div>
</Spin>
<div>
<Space size="large" className={styles.btnBox}>
{/* {append == '' ? (
<Button onClick={() => setAppendVisible(true)}>追加</Button>
) : (
<></>
)} */}
<Popconfirm
placement="topLeft"
disabled={msg == '' ? false : true}
disabled={msg != ''}
title={<span style={{ color: 'rgb(24 144 255)' }}>是否确认初始化!</span>}
okText="确认"
cancelText="取消"
......@@ -1275,7 +1372,7 @@ const DatabaseInitialization = props => {
deleteInitDBLogNew();
}}
>
<Button type="primary" disabled={msg == '' ? false : true}>
<Button type="primary" disabled={msg != ''}>
初始化
</Button>
{/* <Button type="primary" disabled={isAuthorize && msg == '' ? false : true}>
......@@ -1380,6 +1477,14 @@ const DatabaseInitialization = props => {
{keepInitContent}
</div>
</Modal>
<AppendModal
visible={appendVisible}
onCancel={() => {
setAppendVisible(false);
}}
value={dataValue}
callBackSubmit={onOk}
/>
<Modal
title="初始化数据库详细日志"
visible={initVisibledetail}
......
......@@ -23,6 +23,9 @@ InitDataBaseContainer {
padding-bottom: 0px !important;
}
}
.ant-modal-footer {
padding: 10px 25px 10px 40px;
}
.cardContainer {
margin-top: 10px;
......
......@@ -228,3 +228,7 @@ export const SetAdminMenuToRole = params =>
export const NewInitAddDataBase = params =>
post(`${PUBLISH_SERVICE}/DBManager/NewInitAddDataBase`, params);
// 获取追加产品
export const GetLicenseDifference = params =>
post(`${PUBLISH_SERVICE}/DBManager/GetLicenseDifference`, params);
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