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

数据库初始化追加

parent 5fb162e4
Pipeline #58925 passed with stages
...@@ -37,10 +37,6 @@ import ChangeAdd from './ChangeAdd'; ...@@ -37,10 +37,6 @@ import ChangeAdd from './ChangeAdd';
const { Option } = Select; const { Option } = Select;
const AddModal = props => { const AddModal = props => {
const [inputValue, setInputValue] = useState({
feedbackName: '',
doRole: '',
});
const { callBackSubmit = () => {}, visible, type, formObj, keepTableData } = props; const { callBackSubmit = () => {}, visible, type, formObj, keepTableData } = props;
const [Type1, setType1] = useState(''); const [Type1, setType1] = useState('');
...@@ -74,13 +70,11 @@ const AddModal = props => { ...@@ -74,13 +70,11 @@ const AddModal = props => {
form.setFieldsValue({ isSubmit: '否', docycle: '一周一次' }); form.setFieldsValue({ isSubmit: '否', docycle: '一周一次' });
setType1(''); setType1('');
setType2(''); setType2('');
setInputValue({ feedbackName: '', doRole: '' });
setFiled1({}); setFiled1({});
} else if (type === 'edit') { } else if (type === 'edit') {
CM_XWBPlan_DataList({ id: formObj.id }).then(res => { CM_XWBPlan_DataList({ id: formObj.id }).then(res => {
let data = res.data[0]; let data = res.data[0];
data && form.setFieldsValue({ ...data }); data && form.setFieldsValue({ ...data });
setInputValue({ ...data });
console.log(data.businessTypee); console.log(data.businessTypee);
setType1(data.businessType); setType1(data.businessType);
setType2(data.accountName); setType2(data.accountName);
...@@ -113,8 +107,6 @@ const AddModal = props => { ...@@ -113,8 +107,6 @@ const AddModal = props => {
form.validateFields().then(validate => { form.validateFields().then(validate => {
if (validate) { if (validate) {
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
// obj.feedbackName = inputValue.feedbackName;
// obj.doRole = inputValue.doRole;
if (type == 'add') { if (type == 'add') {
CM_XWBPlan_DataEditORAdd(obj).then(res => { CM_XWBPlan_DataEditORAdd(obj).then(res => {
if (res.msg == '') { if (res.msg == '') {
...@@ -167,26 +159,34 @@ const AddModal = props => { ...@@ -167,26 +159,34 @@ const AddModal = props => {
setType2(e.target.value); setType2(e.target.value);
form.setFieldsValue({ accountName: 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 => { const pickFiled = fileds => {
setTypes('add'); if (form.getFieldValue(fileds)) {
setCharacterValue(inputValue[fileds]); setTypes('add');
setCheckedList1(inputValue[fileds].split(',')); setCharacterValue(form.getFieldValue(fileds));
setPickItem(fileds); setCheckedList1(form.getFieldValue(fileds).split(','));
setIsVisible(true); setPickItem(fileds);
setIsVisible(true);
} else {
setTypes('add');
setCharacterValue(form.getFieldValue(fileds));
setCheckedList1([]);
setPickItem(fileds);
setIsVisible(true);
}
}; };
const pickFiled1 = fileds => { const pickFiled1 = fileds => {
setTypes('app'); if (form.getFieldValue(fileds)) {
setCharacterValue(inputValue[fileds]); setTypes('app');
setCheckedList1(inputValue[fileds].split(',')); setCheckedList1(form.getFieldValue(fileds).split(','));
console.log(inputValue[fileds]); setPickItem(fileds);
console.log(inputValue[fileds].split(',')); setIsVisibleRoles(true);
setPickItem(fileds); } else {
setIsVisibleRoles(true); setTypes('app');
setCheckedList1([]);
setPickItem(fileds);
setIsVisibleRoles(true);
}
}; };
const getRole = () => { const getRole = () => {
CM_Event_LoadDepartmentAndRoles().then(res => { CM_Event_LoadDepartmentAndRoles().then(res => {
...@@ -258,7 +258,7 @@ const AddModal = props => { ...@@ -258,7 +258,7 @@ const AddModal = props => {
if (!name) { if (!name) {
return '请传入对象属性'; return '请传入对象属性';
} }
//先获取一下这个数组中有多少个"name" // 先获取一下这个数组中有多少个"name"
let nameArr = []; let nameArr = [];
a3.map(i => { a3.map(i => {
if (nameArr.indexOf(i.group) === -1) { if (nameArr.indexOf(i.group) === -1) {
...@@ -266,7 +266,7 @@ const AddModal = props => { ...@@ -266,7 +266,7 @@ const AddModal = props => {
} }
}); });
console.log(nameArr); console.log(nameArr);
//新建一个包含多个list的结果对象 // 新建一个包含多个list的结果对象
let tempObj = {}; let tempObj = {};
// 根据不同的"name"生成多个数组 // 根据不同的"name"生成多个数组
for (let k in nameArr) { for (let k in nameArr) {
...@@ -295,20 +295,23 @@ const AddModal = props => { ...@@ -295,20 +295,23 @@ const AddModal = props => {
setSelectValue1(value); setSelectValue1(value);
}; };
const onOK = prop => { const onOK = prop => {
console.log(prop.isType);
setIsVisibleRoles(false); setIsVisibleRoles(false);
let inputText = {};
inputText[prop.pickItem] = prop.str;
setCheckedList1(prop.stt);
form.setFieldsValue(inputText);
};
const onOK1 = prop => {
console.log(prop);
setIsVisible(false); setIsVisible(false);
console.log(props); let inputText = {};
let inputText = { ...inputValue };
inputText[prop.pickItem] = prop.str; inputText[prop.pickItem] = prop.str;
setCheckedList1(prop.checkedList); setCheckedList1(prop.stt);
setInputValue(inputText);
form.setFieldsValue(inputText); form.setFieldsValue(inputText);
}; };
// const title = <ModalDrag title="巡维保计划配置" />
const inputType = value => { const inputType = value => {
console.log(value);
if (value) { if (value) {
form.setFieldsValue({ businessType: value }); form.setFieldsValue({ businessType: value });
} }
...@@ -345,7 +348,8 @@ const AddModal = props => { ...@@ -345,7 +348,8 @@ const AddModal = props => {
let aa = form.getFieldValue().businessName; let aa = form.getFieldValue().businessName;
if (type === 'add' && keepTableData.indexOf(aa) != -1) { if (type === 'add' && keepTableData.indexOf(aa) != -1) {
return Promise.reject('业务名称已存在'); return Promise.reject('业务名称已存在');
} else if ( }
if (
type === 'edit' && type === 'edit' &&
keepTableData.indexOf(aa) != -1 && keepTableData.indexOf(aa) != -1 &&
aa != formObj.businessName aa != formObj.businessName
...@@ -556,7 +560,7 @@ const AddModal = props => { ...@@ -556,7 +560,7 @@ const AddModal = props => {
<ChangeAdd <ChangeAdd
visible={isVisible} visible={isVisible}
onCancel={() => setIsVisible(false)} onCancel={() => setIsVisible(false)}
callBackSubmit={onOK} callBackSubmit={onOK1}
newCheckedList={checkedList1} newCheckedList={checkedList1}
isType={types} isType={types}
filed={filed} filed={filed}
......
...@@ -95,7 +95,7 @@ const ChangeAdd = props => { ...@@ -95,7 +95,7 @@ const ChangeAdd = props => {
setCheckedList(checkArr); setCheckedList(checkArr);
setIndeterminate(!!checkArr.length && checkArr.length < filed.length); setIndeterminate(!!checkArr.length && checkArr.length < filed.length);
setCheckAll(checkArr.length === filed.length && filed.length != 0); setCheckAll(checkArr.length === filed.length && filed.length != 0);
let newArr = characterValue.length ? characterValue.split(',') : []; let newArr = characterValue ? characterValue.split(',') : [];
setSelectData(newArr); setSelectData(newArr);
} }
} }
......
...@@ -329,7 +329,7 @@ const maintenance = () => { ...@@ -329,7 +329,7 @@ const maintenance = () => {
marginTop: '10px', marginTop: '10px',
}} }}
> >
<span style={{ marginTop: '-3px' }}>新增</span> <span style={{ marginTop: '-2px' }}>新增</span>
</Button> </Button>
<Button <Button
icon={<OrderedListOutlined className={styles.icon} />} icon={<OrderedListOutlined className={styles.icon} />}
...@@ -340,7 +340,7 @@ const maintenance = () => { ...@@ -340,7 +340,7 @@ const maintenance = () => {
marginTop: '10px', marginTop: '10px',
}} }}
> >
<span style={{ marginTop: '-3px' }}>调序</span> <span style={{ marginTop: '-2px' }}>调序</span>
</Button> </Button>
</span> </span>
</div> </div>
......
...@@ -306,8 +306,11 @@ const AddModal = props => { ...@@ -306,8 +306,11 @@ const AddModal = props => {
}; };
const onOK = prop => { const onOK = prop => {
console.log(prop);
setIsVisibleRoles(false); setIsVisibleRoles(false);
let inputText = {}; let inputText = {};
console.log(inputText);
console.log(inputText[prop.pickItem]);
inputText[prop.pickItem] = prop.str; inputText[prop.pickItem] = prop.str;
setCheckedList1(prop.stt); setCheckedList1(prop.stt);
form.setFieldsValue(inputText); form.setFieldsValue(inputText);
......
...@@ -229,7 +229,7 @@ const patrolFeedback = () => { ...@@ -229,7 +229,7 @@ const patrolFeedback = () => {
marginTop: '10px', marginTop: '10px',
}} }}
> >
<span style={{ marginTop: '-3px' }}>新增</span> <span style={{ marginTop: '-2px' }}>新增</span>
</Button> </Button>
<Button <Button
icon={<OrderedListOutlined className={styles.icon} />} icon={<OrderedListOutlined className={styles.icon} />}
...@@ -240,7 +240,7 @@ const patrolFeedback = () => { ...@@ -240,7 +240,7 @@ const patrolFeedback = () => {
marginTop: '10px', marginTop: '10px',
}} }}
> >
<span style={{ marginTop: '-3px' }}>调序</span> <span style={{ marginTop: '-2px' }}>调序</span>
</Button> </Button>
<Button <Button
icon={<DeleteOutlined className={styles.icon} />} icon={<DeleteOutlined className={styles.icon} />}
...@@ -252,7 +252,7 @@ const patrolFeedback = () => { ...@@ -252,7 +252,7 @@ const patrolFeedback = () => {
onClick={de} onClick={de}
disabled={!hasSelected} disabled={!hasSelected}
> >
<span style={{ marginTop: '-3px' }}>批量删除</span> <span style={{ marginTop: '-2px' }}>批量删除</span>
</Button> </Button>
</span> </span>
</div> </div>
......
...@@ -626,7 +626,7 @@ const AddModal = props => { ...@@ -626,7 +626,7 @@ const AddModal = props => {
setOrder(res.data.root.Order); setOrder(res.data.root.Order);
form.setFieldsValue({ ...res.data.root }); form.setFieldsValue({ ...res.data.root });
if (res.data.root.ImageExpression) { 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); setIm(res.data.root.ImageExpression);
} else { } else {
form.setFieldsValue({ form.setFieldsValue({
...@@ -1302,7 +1302,7 @@ const AddModal = props => { ...@@ -1302,7 +1302,7 @@ const AddModal = props => {
const onOk = props => { const onOk = props => {
if (props) { if (props) {
setImageUrl(window.location.origin + `/civweb4/${props}`); setImageUrl(`${window.location.origin }/civweb4/${props}`);
setIm(props); setIm(props);
setKeepImgeUrl(props); setKeepImgeUrl(props);
form.setFieldsValue({ ImageExpression: `${props}` }); form.setFieldsValue({ ImageExpression: `${props}` });
...@@ -1853,12 +1853,12 @@ const AddModal = props => { ...@@ -1853,12 +1853,12 @@ const AddModal = props => {
form.setFieldsValue({ ImageExpression: '' }); form.setFieldsValue({ ImageExpression: '' });
}} }}
style={{ style={{
position: 'relative', position: 'absolute',
fontSize: '18px', fontSize: '18px',
left: '34px', left: '44px',
top: '10px', top: '45px',
color: 'white', color: 'white',
zIndex:'2' zIndex:'999'
}} }}
/> />
</> </>
......
...@@ -272,13 +272,14 @@ ...@@ -272,13 +272,14 @@
} }
} }
.imgg { .imgg {
position: absolute; position: relative;
top: 0; top: -33px;
left: 0; left: -9px;
height: 104px; height: 104px;
width: 104px; width: 104px;
background: rgba(0, 0, 0, 0.5); background: rgba(0, 0, 0, 0.5);
border-radius: 2px; border-radius: 2px;
z-index:1;
} }
.imgg :hover { .imgg :hover {
opacity: 0.7; 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 { ...@@ -23,6 +23,9 @@ InitDataBaseContainer {
padding-bottom: 0px !important; padding-bottom: 0px !important;
} }
} }
.ant-modal-footer {
padding: 10px 25px 10px 40px;
}
.cardContainer { .cardContainer {
margin-top: 10px; margin-top: 10px;
......
...@@ -228,3 +228,7 @@ export const SetAdminMenuToRole = params => ...@@ -228,3 +228,7 @@ export const SetAdminMenuToRole = params =>
export const NewInitAddDataBase = params => export const NewInitAddDataBase = params =>
post(`${PUBLISH_SERVICE}/DBManager/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