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

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

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