Commit 0e9bfe4b authored by 邓超's avatar 邓超

fix: 添加外部字段模块,修改表返回位置问题

parent 5946c5ef
......@@ -85,7 +85,7 @@ const FlowNode = () => {
// 控制表格的展开跟收起
const onUnfold = (expanded, record) => {
const data = [...expandedRowKeys];
let index = data.indexOf(record);
let index = data.indexOf(record.GroupName);
if (expanded) {
data.push(record.GroupName);
} else {
......
......@@ -113,7 +113,16 @@
margin-bottom: 10px;
font-weight: 700;
color: #15428b;
line-height: 100%;
border-top-color: #99bbe8;
.groupName {
display: inline-block;
margin-right: 10px;
max-width: 200px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
}
......
......@@ -100,19 +100,36 @@ const NodeEdit = props => {
loadEventFields({ eventTableName: value.TableName }).then(res => {
if (res.code === 0) {
let defaultCheckedList = value[val] ? value[val].split(',') : [];
let allFields = []; // 所有得字段用来判断是否为外部字段
// 处理树形结构
let checkList = res.data.map(item => {
let plainOptions = [];
// 存入没个组得字段
item.root.forEach(ele => {
plainOptions = [...plainOptions, ele.fieldName];
});
// 存所有得字段
allFields = [...allFields, ...plainOptions];
return {
groupName: item.groupName,
plainOptions,
defaultCheckedList: [],
};
});
let externalFields = {
groupName: '外部字段',
indeterminate: false,
checkAll: true,
plainOptions: [],
defaultCheckedList: [],
}; // 外部字段
defaultCheckedList.forEach(item => {
// 添加外部字段
let isExternal = allFields.some(checkName => checkName === item);
if (!isExternal) {
externalFields.plainOptions.push(item);
externalFields.defaultCheckedList.push(item);
}
checkList.forEach(element => {
// 当前得模块是否有当前字段
let indeterminate = element.plainOptions.some(
......@@ -140,7 +157,10 @@ const NodeEdit = props => {
}
});
});
console.log(checkList, 'checkList');
// 添加外部字段
if (externalFields.plainOptions.length > 0) {
checkList.push(externalFields);
}
setFieldList(checkList);
setTimeout(() => {
setShowField(true);
......
......@@ -98,9 +98,7 @@ const Fieldselection = props => {
<div className={styles.cardBox} key={index}>
<div className={styles.title}>
<Divider orientation="left" className={styles.cardDivider}>
<span style={{ marginRight: '10px' }}>
{item.groupName}
</span>
<span className={styles.groupName}>{item.groupName}</span>
<Checkbox
indeterminate={item.indeterminate}
onChange={e => onCheckAllChange(e, index)}
......
......@@ -358,11 +358,13 @@ const AddModal = props => {
};
// 返回上一级
const back = () => {
console.log(props)
let template = props.location.state.template;
let { template, tableScroll } = props.location.state;
history.push({
pathname: '/platformCenter/bsmanger/tablemanger',
state: { template },
query: {
template,
tableScroll,
},
});
};
const onUnfold = (expanded, record) => {
......
/* eslint-disable guard-for-in */
/* eslint-disable no-restricted-syntax */
import React, { useState, useEffect } from 'react';
import {
Form,
......@@ -64,6 +66,7 @@ const AddModal = props => {
const [Type, setType] = useState('');
const [characterValue, setCharacterValue] = useState('');
const [standingType, setStandingType] = useState(['台账', '反馈', '设备']);
const [allFileds, setAllFileds] = useState([]); // 当前表所有的字段
const [form] = Form.useForm();
const { Item } = Form;
// 提交
......@@ -166,14 +169,18 @@ const AddModal = props => {
if (!name) {
return '请传入对象属性';
}
//先获取一下这个数组中有多少个"name"
// 先获取一下这个数组中有多少个"name"
let nameArr = [];
let allFile = [];
for (let i in initialArr) {
allFile.push(initialArr[i].fieldName);
if (nameArr.indexOf(initialArr[i][`${name}`]) === -1) {
nameArr.push(initialArr[i][`${name}`]);
}
}
//新建一个包含多个list的结果对象
// 保存所有的字段用来比较是否有外部字段
setAllFileds(allFile);
// 新建一个包含多个list的结果对象
let tempObj = {};
// 根据不同的"name"生成多个数组
console.log(initialArr);
......@@ -204,9 +211,26 @@ const AddModal = props => {
setInputVaule(inputText);
};
const pickFiled = fileds => {
// 添加外部字段
let fil = { ...filed };
fil['外部字段'] = [];
let isExternal;
inputValue[fileds].split(',').forEach(item => {
isExternal = allFileds.some(val => val === item);
if (!isExternal && item !== '') {
fil['外部字段'].push(item);
}
});
if (fil['外部字段'].length === 0) {
delete fil['外部字段'];
}
setFiled(fil);
setTypes('add');
setCharacterValue(inputValue[fileds]);
setCheckedList(inputValue[fileds].split(','));
setPickItem(fileds);
setIsVisible(true);
};
......
......@@ -69,6 +69,7 @@ export const defaultWebConfigObj = {
mapPlan: '',
qrcode: '',
loginTemplate: 'Default.html',
alarmWays: notificationTypes.MQTT,
};
export const getDefaultGetWebconfig = ({
......
......@@ -25,11 +25,11 @@ export const loadUnattachedTables = () =>
//7.附加表
export const addTables = (param) =>
get(`${PUBLISH_SERVICE}/CaseManage/AddTables`, param);
post(`${PUBLISH_SERVICE}/CaseManage/AddTables`, param);
//8.添加表字段
export const addFields = (param) =>
get(`${PUBLISH_SERVICE}/CaseManage/AddFields`, param);
post(`${PUBLISH_SERVICE}/CaseManage/AddFields`, param);
//9.获取表信息
......
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