Commit 5ae11ffd authored by 皮倩雯's avatar 皮倩雯

fix: '产品初始化方案修改

parent f2eb8e14
Pipeline #56197 passed with stages
......@@ -440,7 +440,7 @@ const InitDataBase = props => {
aa.push(i.name);
});
console.log(aa);
setKeep(res.data.Product);
setKeep(res.data.IsAuthorize);
setKeepProduct(aa);
}
setDbExists(res.data.DBExists);
......
......@@ -7,11 +7,11 @@
* @Description:
* @Author: leizhe
* @Date: 2022-07-13 16:13:03
* @LastEditTime: 2022-07-19 17:53:15
* @LastEditTime: 2022-07-26 13:35:37
* @LastEditors: leizhe
*/
import React, { useState, useEffect } from 'react';
import { Form, Modal, Divider, Checkbox, Button, Input, notification, Row, Col } from 'antd';
import { Form, Modal, Divider, Checkbox, Button, Input, notification, Row, Col, Spin } from 'antd';
import {
GetProductList,
GetProductListByLicense,
......@@ -34,18 +34,25 @@ const InitModal = props => {
const [flag, setFlag] = useState(0);
const [mag, setMag] = useState('');
const [code, setCode] = useState('');
const [loadings, setLoadings] = useState(false);
const [checkboxFlag, setCheckboxFlag] = useState(0);
const [keepValue, setKeepValue] = useState([]);
const [value, setValue] = useState([]);
const [product, setProduct] = useState([]);
useEffect(() => {
getProductList();
console.log(keep);
console.log(keepProduct);
setFlag(0);
setCheckboxFlag(0);
setMag('');
if (visible) {
getProductList();
if (keep) {
setCheckboxFlag(1);
} else {
setCheckboxFlag(0);
}
setValue(keepProduct);
setKeepCode(keepProduct);
} else {
setCode('');
......@@ -83,7 +90,7 @@ const InitModal = props => {
});
console.log(arr);
setProduct(arr);
setValue(keepProduct);
setKeepValue(arr);
}
let arr = formateArrDataA(res.data, 'productName');
......@@ -202,16 +209,41 @@ const InitModal = props => {
};
const onSubmit = () => {
console.log(mag);
if (mag != '' && keepProduct == keepCode && checkboxFlag != 0) {
notification.error({
message: '提示',
duration: 5,
description: '请先输入激活码激活产品',
});
} else {
if (flag !== 0 || checkboxFlag == 0) {
setLoadings(true);
// console.log(mag);
// if (mag != '' && keepProduct == keepCode && checkboxFlag != 0) {
// notification.error({
// message: '提示',
// duration: 5,
// description: '请先输入激活码激活产品',
// });
// } else {
// if (flag !== 0 || checkboxFlag == 0) {
// setLoadings(true);
// 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);
// callBackSubmit(arr, code);
// onCancel();
// } else {
// notification.warning({
// message: '提示',
// duration: 5,
// description: '请先输入激活码激活产品',
// });
// }
// }
let arr = [];
if (checkboxFlag == 0) {
keepData.map(i => {
......@@ -229,36 +261,9 @@ const InitModal = props => {
console.log(arr);
callBackSubmit(arr, code);
onCancel();
} else {
notification.warning({
message: '提示',
duration: 5,
description: '请先输入激活码激活产品',
});
}
}
};
const onChange = (e, item) => {
console.log(e);
console.log(product);
console.log(keepProduct);
console.log(product[item]);
console.log(item);
console.log(data[item]);
console.log(keepValue);
// let aa = keepValue;
// aa[item] = e;
// let a = Object.keys(aa);
// let list = [];
// a.map(i => {
// aa[i].map(j => {
// list.push(j);
// });
// });
// setKeepValue(aa);
// setValue(list);
if (product[item]) {
// 过滤已初始化的产品但不存在于产品列表中的数据,避免组件出错
product[item].map(i => {
......@@ -312,7 +317,7 @@ const InitModal = props => {
forceRender
getContainer={false}
footer={[
<Button onClick={() => setListVisible(true)}>产品激活</Button>,
// <Button onClick={() => setListVisible(true)}>产品激活</Button>,
<Button type="primary" onClick={() => onSubmit()}>
确认
</Button>,
......@@ -344,7 +349,7 @@ const InitModal = props => {
<>
{data[item] &&
data[item].map((i, j) => {
if (keepCode.indexOf(i) != -1) {
if (keepProduct.indexOf(i) != -1) {
return <Checkbox checked={true}>{i}</Checkbox>;
} else {
return (
......@@ -371,7 +376,11 @@ const InitModal = props => {
<Form form={form}>
<Row span={24}>
<Col span={6}>
<Form.Item label="产品激活码" name="License1">
<Form.Item
label="产品激活码"
name="License1"
// rules={[{ required: true, message: '请输入产品激活码' }]}
>
<Input
maxLength={5}
onPaste={e => {
......@@ -521,6 +530,25 @@ const InitModal = props => {
</Form.Item>
</Col>
</Row>
<Form.Item
name="name"
label="部署人工号"
rules={[
// { required: true, message: '请输入部署人工号' },
{
validator: (rule, value) => {
let aa = /^[1-9]([0-9])*$/;
let bb = form.getFieldValue().name;
if (!aa.test(bb)) {
return Promise.reject('请正确填写工号');
}
return Promise.resolve();
},
},
]}
>
<Input placeholder="请输入部署人工号" allowClear style={{ width: '33%' }} />
</Form.Item>
</Form>
</Modal>
</Modal>
......
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