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

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

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