Commit f4678f7f authored by 皮倩雯's avatar 皮倩雯

fix: '巡检反馈异常联动兼容老数据回显'

parent baf8a075
Pipeline #76584 passed with stages
......@@ -43,13 +43,13 @@ import ChangeRoles from './ChangeRoles';
import ChangeFields from './ChangeFields';
import logo from '@/assets/images/icons/值映射.png';
import lodash from 'lodash';
import { reloadTableFields } from '@/services/tablemanager/tablemanager';
import RuleConfig from '@/components/RuleConfig';
const { Option } = Select;
const AddModal = props => {
const { callBackSubmit = () => {}, visible, type, formObj, keepTableData } = props;
const { callBackSubmit = () => {}, visible, type, formObj, keepTableData, onClose } = props;
const [filed, setFiled] = useState({}); // 传给子组件列表数据
const [filed1, setFiled1] = useState({}); // 传给子组件列表数据
......@@ -67,7 +67,7 @@ const AddModal = props => {
const [keepFiled, setKeepFiled] = useState([]);
const [eventData, setEventData] = useState([]);
const [keepData, setKeepData] = useState('');
const [keep, setKeep] = useState([]); // 保存初始完整任务同步事件字段
const keep = useRef([]); // 保存初始完整任务同步事件字段
const [keepAllData, setKeepAllData] = useState([]); // 保存所有关联事件类型数据
const [keepTree, setKeepTree] = useState([]);
const [keepAll, setKeepAll] = useState([]); // 保存所选关联事件下完整的字段值
......@@ -86,7 +86,6 @@ const AddModal = props => {
getGisPatrolObject();
if (visible) {
if (type === 'edit') {
onChangeTableName(formObj.tableName, '');
CM_Feedback_QueryPatrolFeedback({ id: formObj.id }).then(res => {
form.setFieldsValue({ ...res.data });
console.log(res.data);
......@@ -105,13 +104,13 @@ const AddModal = props => {
: res.data.gisLayer,
});
}
let aa = JSON.parse(res.data.mappingFields);
getGetTaskSyncField(aa); // 获取字段名数据
onChangeEvent(res.data.relationEvent, aa); // 改变关联事件类型
getFeedbackTable();
getRoles();
getFields(res.data.tableName);
let aa = JSON.parse(res.data.mappingFields);
onChangeTableName(formObj.tableName, aa);
});
} else {
form.setFieldsValue({ businessGroup: '区域巡检', feedbackRule: '' });
......@@ -124,46 +123,33 @@ const AddModal = props => {
form.resetFields();
setKeepTree([]);
setKeepData('');
setKeep([]);
keep.current = [];
setKeepAll([]);
}
}, [visible]);
// 获取字段名数据
const getGetTaskSyncField = (e, newKeep) => {
let dataList = newKeep ? newKeep : keep;
if (e) {
// 编辑时
let datalist = [...e];
let aa = e;
let from = [];
aa.forEach(i => {
if (i && i.fromField) {
from.push(`${i.fromField}%${i.fromTable}`);
}
});
let lastFrom = [];
dataList.forEach(j => {
if (from.indexOf(j) === -1) {
lastFrom.push(j);
}
});
// let bb = detailData(dataList, from);
// setKeepData(lastFrom);
// setKeep(lastFrom);
let str = newKeep && newKeep[0].TableName;
let arr = [];
datalist.forEach(i => {
if (i.fromTable) {
arr.push({ fromField: `${i.fromField}%${i.fromTable}`, toField: i.toField });
} else {
arr.push({ fromField: i.fromField, toField: i.toField });
arr.push({
fromField: `${i.fromField}%${str ? str : ''}`,
toField: i.toField,
});
}
});
setTimeout(() => {
formAdd.setFieldsValue({ parmars: arr }); // 处理数据让下拉框回显title值
}, 0);
} else {
setKeepData(dataList);
setKeepData([]);
}
};
......@@ -356,8 +342,8 @@ const AddModal = props => {
if (validate1) {
form.validateFields().then(validate => {
if (validate) {
let obj = form.getFieldsValue();
let mappingFields = formAdd.getFieldValue('parmars');
let obj = lodash.cloneDeep(form.getFieldsValue());
let mappingFields = lodash.cloneDeep(formAdd.getFieldValue('parmars'));
mappingFields &&
mappingFields.forEach(i => {
let data = i.fromField.split('%');
......@@ -378,7 +364,8 @@ const AddModal = props => {
gisServerName: groupNameSever,
mappingFields: mappingFields && JSON.stringify(mappingFields),
}).then(res => {
if (res.msg == '') {
if (res.code === 0) {
onClose();
callBackSubmit();
notification.success({
message: '提示',
......@@ -400,7 +387,8 @@ const AddModal = props => {
id: formObj.id,
mappingFields: mappingFields && JSON.stringify(mappingFields),
}).then(res => {
if (res.msg == '') {
if (res.code === 0) {
onClose();
callBackSubmit();
notification.success({
message: '提示',
......@@ -478,7 +466,7 @@ const AddModal = props => {
}
};
const onChangeTableName = (e, flag, str) => {
const onChangeTableName = (e, flag) => {
getFields(e);
GetGisFeedbackTableFields({ feedbackTableName: e }).then(res => {
if (res.code === 0) {
......@@ -488,12 +476,12 @@ const AddModal = props => {
newData.push(i);
});
setKeepData(newData);
setKeep(newData);
}
});
keep.current = newData;
if (flag) {
formAdd.setFieldsValue({ parmars: [] });
getGetTaskSyncField(flag, newData); // 获取字段名数据
}
}
});
};
const formateArrDataA = (initialArr, name) => {
......@@ -558,7 +546,7 @@ const AddModal = props => {
// 改变关联事件类型
const onChangeEvent = (e, i) => {
if (!i || !e) {
setKeepData(keep);
setKeepData(keep.current);
formAdd.resetFields();
}
let aa = keepAllData.find(i => i.name === e);
......@@ -594,7 +582,7 @@ const AddModal = props => {
let lastFrom = [];
let lastTo = [];
keep.map(j => {
keep.current.map(j => {
if (from.indexOf(j.key) == -1) {
lastFrom.push(j);
}
......
......@@ -212,7 +212,6 @@ const patrolFeedback = () => {
CM_Feedback_LoadPatrolFeedbacks({ pageIndex: 0, pageSize: 0 }).then(res => {
setTreeLoading(false);
if (res.code === 0) {
console.log(res.data.list);
let data = {};
if (res.data.list.length > 0) {
let area = [];
......@@ -242,9 +241,6 @@ const patrolFeedback = () => {
setGroupName(['区域巡检', 'DMA巡检']);
}
}
console.log(data);
console.log(data['区域巡检']);
console.log(data.区域巡检);
setTableData(data);
let list = [];
res.data.list.map(i => {
......@@ -282,10 +278,6 @@ const patrolFeedback = () => {
}
});
};
const onSubmit = () => {
setAddVisible(false);
setFlag(flag + 1);
};
const onOK = () => {
setFlag(flag + 1);
......@@ -483,7 +475,7 @@ const patrolFeedback = () => {
visible={addVisible}
type={type}
onClose={() => setAddVisible(false)}
callBackSubmit={onSubmit}
callBackSubmit={onOK}
formObj={formObj}
keepTableData={keepTableData}
placement="right"
......
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