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;
......@@ -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