AddModal.jsx 30.6 KB
Newer Older
1
/* eslint-disable prefer-destructuring */
皮倩雯's avatar
皮倩雯 committed
2 3 4 5 6 7 8
/* eslint-disable no-else-return */
/* eslint-disable prefer-promise-reject-errors */
/* eslint-disable guard-for-in */
/* eslint-disable no-restricted-syntax */
/* eslint-disable indent */
/* eslint-disable camelcase */
/* eslint-disable no-unused-expressions */
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
import React, { useState, useEffect, useRef } from 'react';
import {
  Drawer,
  Form,
  Input,
  notification,
  Row,
  Col,
  Select,
  Button,
  Space,
  TreeSelect,
  Empty,
} from 'antd';
import { PlusOutlined, SwapOutlined, MinusCircleOutlined } from '@ant-design/icons';
皮倩雯's avatar
皮倩雯 committed
24 25 26 27 28 29 30
import styles from './patrolFeedback.less';
import {
  CM_Feedback_LoadFeedbackTables,
  CM_Feedback_LoadFeedbackEvent,
  CM_Feedback_OperatePatrolFeedback,
  CM_Feedback_LoadFields,
  CM_Feedback_QueryPatrolFeedback,
31
  GetTaskSyncField,
32
  GetGisPatrolObject,
皮倩雯's avatar
皮倩雯 committed
33
} from '@/services/PatrolFeedback/api';
34 35 36 37
import {
  GetCM_Event_LoadEventTable,
  CM_Event_LoadDepartmentAndRoles,
} from '@/services/standingBook/api';
38
import RMSComponents from '@/components/RolePmSite/index';
皮倩雯's avatar
皮倩雯 committed
39 40 41 42

import ChangeRoles from './ChangeRoles';
import ChangeFields from './ChangeFields';

43 44 45 46
import logo from '@/assets/images/icons/值映射.png';

import { reloadTableFields } from '@/services/tablemanager/tablemanager';

皮倩雯's avatar
皮倩雯 committed
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
const { Option } = Select;
const AddModal = props => {
  const { callBackSubmit = () => {}, visible, type, formObj, keepTableData } = props;

  const [filed, setFiled] = useState({}); // 传给子组件列表数据
  const [filed1, setFiled1] = useState({}); // 传给子组件列表数据
  const [pickItem, setPickItem] = useState(''); // 复选框数据填入项
  const [checkedList1, setCheckedList1] = useState([]); // 最新选择数据

  const [feedbackTable, setFeedbackTable] = useState([]);
  const [feedbackEvent, setFeedbackEvent] = useState([]);
  const [isVisibleFields, setIsVisibleFields] = useState(false);
  const [isVisibleRoles, setIsVisibleRoles] = useState(false);
  const [nu, setNu] = useState([]);
  const [nu1, setNu1] = useState([]);
62 63
  const [groupName, setGroupName] = useState('角色');
  const [chooseGroupName, setChooseGroupName] = useState(['角色', '部门', '站点']);
64
  const [keepFiled, setKeepFiled] = useState([]);
65
  const [eventData, setEventData] = useState([]);
66 67 68
  const [keepData, setKeepData] = useState('');
  const [keep, setkeep] = useState([]); // 保存初始完整任务同步事件字段
  const [keepAllData, setKeepAllData] = useState([]); // 保存所有关联事件类型数据
69
  const [keepTree, setKeepTree] = useState([]);
70
  const [keepAll, setKeepAll] = useState([]); // 保存所选关联事件下完整的字段值
71 72
  const [treeSelectValue, setTreeSelectValue] = useState([]);
  const [menuWebList, setMenuWebList] = useState([]);
皮倩雯's avatar
皮倩雯 committed
73 74

  const [form] = Form.useForm();
75
  const [formAdd] = Form.useForm();
皮倩雯's avatar
皮倩雯 committed
76
  const { Item } = Form;
77
  const { TreeNode } = TreeSelect;
皮倩雯's avatar
皮倩雯 committed
78 79

  useEffect(() => {
80
    getEventData(); // 获取所有关联事件数据
81
    getGisPatrolObject();
皮倩雯's avatar
皮倩雯 committed
82 83 84 85
    if (visible) {
      if (type === 'edit') {
        CM_Feedback_QueryPatrolFeedback({ id: formObj.id }).then(res => {
          form.setFieldsValue({ ...res.data });
86 87
          console.log(res.data);
          if (!res.data.businessGroup) {
88 89 90 91 92 93
            form.setFieldsValue({
              businessGroup: '区域巡检',
              gisLayer: res.data.gisServerName
                ? `${res.data.gisServerName}&${res.data.gisLayer}`
                : res.data.gisLayer,
            });
94
          } else {
95 96 97 98 99 100
            form.setFieldsValue({
              businessGroup: res.data.businessGroup.split(','),
              gisLayer: res.data.gisServerName
                ? `${res.data.gisServerName}&${res.data.gisLayer}`
                : res.data.gisLayer,
            });
101
          }
102 103 104 105 106 107
          let aa = JSON.parse(res.data.mappingFields);
          getGetTaskSyncField(aa); // 获取字段名数据

          onChangeEvent(res.data.relationEvent, aa); // 改变关联事件类型
          getFeedbackTable();
          getRoles();
皮倩雯's avatar
皮倩雯 committed
108
        });
109
      } else {
110
        form.setFieldsValue({ businessGroup: '区域巡检' });
111 112 113
        getGetTaskSyncField();
        getFeedbackTable();
        getRoles();
皮倩雯's avatar
皮倩雯 committed
114 115
      }
    } else {
116
      formAdd.resetFields();
皮倩雯's avatar
皮倩雯 committed
117
      form.resetFields();
118
      setKeepTree([]);
119
      setKeepData('');
皮倩雯's avatar
皮倩雯 committed
120 121 122
    }
  }, [visible]);

123
  // 获取字段名数据
124 125 126
  const getGetTaskSyncField = e => {
    GetTaskSyncField().then(res => {
      if (res.code === '0') {
127
        // 编辑时处理数据为下拉框过滤调已选数据
128 129 130 131 132 133 134 135 136
        if (e) {
          let datalist = [...e];
          datalist.map(i => {
            res.data.map(j => {
              if (j.value === i.fromField) {
                i.fromField = j.key;
              }
            });
          });
137
          formAdd.setFieldsValue({ parmars: datalist }); // 处理数据让下拉框回显title值
138 139 140 141 142 143 144 145
          let aa = e;
          let from = [];
          aa.map(i => {
            if (i && i.fromField) {
              from.push(i.fromField);
            }
          });
          let lastFrom = [];
146
          res.data.map(j => {
147 148 149 150 151 152 153 154 155 156 157 158 159
            if (from.indexOf(j.key) == -1) {
              lastFrom.push(j);
            }
          });
          setKeepData(lastFrom);
        } else {
          setKeepData(res.data);
        }
        setkeep(res.data);
      }
    });
  };

160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
  const getGisPatrolObject = () => {
    GetGisPatrolObject().then(res => {
      if (res.code === '0') {
        setMenuWebList(res.data);
      } else {
        notification.error({
          message: '提示',
          duration: 3,
          description: res.msg,
        });
      }
      console.log(res);
    });
  };

175 176 177 178 179 180 181 182
  const getReloadTableField = (e, i) => {
    reloadTableFields({
      tableName: e,
    }).then(res => {
      if (res.msg === 'Ok') {
        console.log(res.data.root);
        console.log(i);
        setKeepAll(res.data.root);
183
        // 编辑时过滤下l拉框初始数据
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203
        if (i) {
          let aa = i;
          let to = [];
          aa.map(j => {
            if (j && j.toField) {
              to.push(j.toField);
            }
          });
          let lastTo = [];
          res.data.root.map(b => {
            if (to.indexOf(b.name) == -1) {
              lastTo.push(b);
            }
          });
          console.log(lastTo);
          setKeepTree(lastTo);
        } else {
          setKeepTree(res.data.root);
        }

204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224
        let arrlist = [];
        let data = {};
        let listArr = [];
        res.data.root.map(i => {
          arrlist.push(i.name);
        });
        data.TableFieldNames = arrlist;
        data.TableName = e;
        listArr.push(data);
        let arr = formateArrDataA2(res.data.root, 'group');
        let newArr = [];
        Object.keys(arr).map((item, index) => {
          newArr.push({ type: item, key: index, id: index });
        });
        let aa = [];
        let bb = [];
        Object.keys(arr).forEach((item, index) => {
          aa.push({ name: item, key: index, ID: index, children: arr[item] });
          bb.push(item);
        });
        console.log(aa, 'aaaaaaaaaaaaa');
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270
        // setKeepTree(aa);
        // setKeepAll(aa);
        // all.current = aa;
      }
    });
  };

  const formateArrDataA2 = (initialArr, name) => {
    // 判定传参是否符合规则
    if (!(initialArr instanceof Array)) {
      return '请传入正确格式的数组';
    }
    if (!name) {
      return '请传入对象属性';
    }
    // 先获取一下这个数组中有多少个"name"
    let nameArr = [];
    // eslint-disable-next-line no-restricted-syntax
    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;
  };

271 272 273 274 275
  // 获取关联事件数据
  const getEventData = () => {
    GetCM_Event_LoadEventTable().then(res => {
      if (res.code === 0) {
        let aa = [];
276
        let bb = [];
277 278 279
        res.data.map(i => {
          i.root.map(j => {
            aa.push(j.name);
280
            bb.push(j);
281 282
          });
        });
283
        setKeepAllData(bb);
284 285 286 287 288
        setEventData(aa);
      }
    });
  };

皮倩雯's avatar
皮倩雯 committed
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317
  const getFeedbackTable = () => {
    CM_Feedback_LoadFeedbackTables().then(res => {
      if (res.code === 0) {
        setFeedbackTable(res.data);
      }
    });
    CM_Feedback_LoadFeedbackEvent().then(res => {
      if (res.code === 0) {
        setFeedbackEvent(res.data);
        if (type == 'add') {
          form.setFieldsValue({ eventName: res.data[0].Name });
        }
      }
    });
  };

  const getFields = e => {
    CM_Feedback_LoadFields(e).then(res => {
      if (res.code === 0) {
        setNu(res.data);
        setFiled(formateArrDataA(res.data, 'groupName'));
      }
    });
  };

  const getRoles = () => {
    CM_Event_LoadDepartmentAndRoles().then(res => {
      if (res.code === 0) {
        setNu1(res.data);
318 319
        // setFiled1(formateArrDataA1(res.data, 'groupType'));
        setKeepFiled(groupArr(res.data, 'groupType'));
皮倩雯's avatar
皮倩雯 committed
320 321 322 323
      }
    });
  };

324 325 326 327 328 329 330 331 332 333 334 335 336 337 338
  const groupArr = (initialArr, name) => {
    let list = {};
    initialArr.data.map(i => {
      let ar = [];
      i.root.map(j => {
        let ss = {};
        ss.label = j.Name;
        ss.value = j.ID.toString();
        ar.push(ss);
      });
      list[i.groupType] = ar;
    });
    return list;
  };

皮倩雯's avatar
皮倩雯 committed
339
  const onSubmit = () => {
340 341 342 343 344 345
    formAdd.validateFields().then(validate1 => {
      if (validate1) {
        form.validateFields().then(validate => {
          if (validate) {
            let obj = form.getFieldsValue();
            let objaa = formAdd.getFieldValue('parmars');
346 347 348 349 350 351 352
            objaa &&
              objaa.map(i => {
                keep.map(j => {
                  if (j.key === i.fromField) {
                    i.fromField = j.value;
                  }
                });
353
              });
354
            obj.businessGroup = obj.businessGroup.toString();
355 356 357 358 359 360 361
            let list = [];
            let groupNameSever = '';
            if (obj.gisLayer && obj.gisLayer.indexOf('&') !== -1) {
              list = obj.gisLayer.split('&');
              obj.gisLayer = list[1];
              groupNameSever = list[0];
            }
362 363 364
            if (type == 'add') {
              CM_Feedback_OperatePatrolFeedback({
                ...obj,
365
                gisServerName: groupNameSever,
366
                mappingFields: objaa && JSON.stringify(objaa),
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382
              }).then(res => {
                if (res.msg == '') {
                  form.resetFields();
                  callBackSubmit();
                  notification.success({
                    message: '提示',
                    duration: 3,
                    description: type == 'add' ? '添加成功' : '编辑成功',
                  });
                } else {
                  notification.error({
                    message: '提示',
                    duration: 3,
                    description: res.msg,
                  });
                }
383 384
              });
            } else {
385 386
              CM_Feedback_OperatePatrolFeedback({
                ...obj,
387
                gisServerName: groupNameSever,
388
                id: formObj.id,
389
                mappingFields: objaa && JSON.stringify(objaa),
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405
              }).then(res => {
                if (res.msg == '') {
                  form.resetFields();
                  callBackSubmit();
                  notification.success({
                    message: '提示',
                    duration: 3,
                    description: type == 'add' ? '添加成功' : '编辑成功',
                  });
                } else {
                  notification.error({
                    message: '提示',
                    duration: 3,
                    description: res.msg,
                  });
                }
406 407
              });
            }
408 409
          }
        });
皮倩雯's avatar
皮倩雯 committed
410 411 412 413 414 415 416
      }
    });
  };

  const pickFiled = fileds => {
    if (form.getFieldsValue().tableName) {
      let pp = formateArrDataA(nu, 'groupName');
417
      console.log(pp);
皮倩雯's avatar
皮倩雯 committed
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584
      if (form.getFieldValue(fileds)) {
        let ab = form.getFieldValue(fileds).split(',');
        let arr = Object.keys(pp);
        let b = [];
        let a = [];
        arr.map((item, index) => {
          pp[item].map((i, j) => {
            b.push(i);
          });
        });
        ab.map((item, index) => {
          if (b.includes(item) == false) {
            if (item == '') {
              a = [];
            } else {
              a.push(item);
            }
          }
        });
        if (a.length > 0) {
          pp.外部字段 = a;
          arr.push('外部字段');
        }
        setFiled(pp);
        setCheckedList1(form.getFieldValue(fileds).split(','));
        setPickItem(fileds);
        setIsVisibleFields(true);
      } else {
        setFiled(pp);
        setCheckedList1([]);
        setPickItem(fileds);
        setIsVisibleFields(true);
      }
    } else {
      notification.warning({
        message: '提示',
        duration: 3,
        description: '请先选择反馈名称',
      });
    }
  };
  const pickFiled1 = fileds => {
    if (form.getFieldValue(fileds)) {
      setCheckedList1(form.getFieldValue(fileds).split(','));
      setPickItem(fileds);
      setIsVisibleRoles(true);
    } else {
      setCheckedList1([]);
      setPickItem(fileds);
      setIsVisibleRoles(true);
    }
  };

  const onChangeTableName = e => {
    getFields(e);
  };

  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);
      });
    }
    Object.keys(tempObj).map((i, j) => {
      tempObj[i].map((k, y) => {
        tempObj[i][y] = k.fieldName;
      });
    });
    return tempObj;
  };

  const formateArrDataA1 = (initialArr, name) => {
    let aa = [];
    let a1 = [];
    let a2;
    let a3 = [];
    initialArr.data.map(i => {
      // console.log(i.groupType)
      a2 = i.groupType;
      // console.log(a2)
      // console.log(i.root)
      a1 = i.root;
      a1.map(j => {
        j.group = a2;
        // console.log(j)
      });
      aa.push(i.root);
    });
    // console.log(aa)
    aa.map(p => {
      // console.log(p)
      p.map(o => {
        // console.log(o)
        a3.push(o);
      });
    });
    console.log(a3);

    // 判定传参是否符合规则
    if (!(a3 instanceof Array)) {
      return '请传入正确格式的数组';
    }
    if (!name) {
      return '请传入对象属性';
    }
    // 先获取一下这个数组中有多少个"name"
    let nameArr = [];
    a3.map(i => {
      if (nameArr.indexOf(i.group) === -1) {
        nameArr.push(i.group);
      }
    });
    console.log(nameArr);
    // 新建一个包含多个list的结果对象
    let tempObj = {};
    // 根据不同的"name"生成多个数组
    for (let k in nameArr) {
      for (let j in a3) {
        if (a3[j].group == nameArr[k]) {
          // 每次外循环时新建一个对应"name"的数组, 内循环时当前数组不变
          tempObj[nameArr[k]] = tempObj[nameArr[k]] || [];
          tempObj[nameArr[k]].push(a3[j]);
        }
      }
    }

    for (let key in tempObj) {
      let arr = [];
      tempObj[key].map(item => {
        tempObj[key] = arr;
        arr.push(item.Name);
      });
    }
    console.log(tempObj);
    return tempObj;
  };

  const onOK = prop => {
皮倩雯's avatar
皮倩雯 committed
585
    console.log(prop);
皮倩雯's avatar
皮倩雯 committed
586 587
    setIsVisibleRoles(false);
    let inputText = {};
皮倩雯's avatar
皮倩雯 committed
588 589
    console.log(inputText);
    console.log(inputText[prop.pickItem]);
皮倩雯's avatar
皮倩雯 committed
590 591 592 593 594 595 596 597 598 599 600 601
    inputText[prop.pickItem] = prop.str;
    setCheckedList1(prop.stt);
    form.setFieldsValue(inputText);
  };

  const onOK1 = prop => {
    setIsVisibleFields(false);
    let inputText = {};
    inputText[prop.pickItem] = prop.str;
    setCheckedList1(prop.stt);
    form.setFieldsValue(inputText);
  };
602 603 604 605 606 607 608 609 610

  const changTable = (value, e) => {
    console.log(value);
    console.log(e.key);
  };

  // 改变关联事件类型
  const onChangeEvent = (e, i) => {
    if (!i) {
611
      setKeepData(keep);
612 613 614 615 616 617 618 619
      formAdd.resetFields();
    }
    let aa = keepAllData.find(i => i.name === e);
    if (aa) {
      getReloadTableField(aa.tableName, i); // 找到关联事件对应事件表获取对应表的所有字段
    }
  };

620
  const mapTree = (org, server) => {
621
    const haveChildren = Array.isArray(org.items) && org.items.length > 0;
622
    return haveChildren ? (
623
      <TreeNode value={org.serverName} title={org.serverName} disabled>
624
        {org.items.map(item => mapTree(item, org.serverName))}
625 626
      </TreeNode>
    ) : (
627
      <TreeNode value={`${server}&${org.name}`} title={org.name} />
628 629 630 631 632 633
    );
  };

  const changeValue = () => {
    console.log(formAdd.getFieldsValue().parmars);
    let aa = formAdd.getFieldsValue().parmars;
634 635 636 637 638 639 640 641 642 643 644 645
    if (aa) {
      console.log(aa);
      let from = [];
      let to = [];
      aa.map(i => {
        if (i && i.fromField) {
          from.push(i.fromField);
        }
        if (i && i.toField) {
          to.push(i.toField);
        }
      });
646

647 648 649 650 651 652 653 654 655 656 657
      let lastFrom = [];
      let lastTo = [];
      console.log(from);
      console.log(keep);
      keep.map(j => {
        if (from.indexOf(j.key) == -1) {
          lastFrom.push(j);
        }
      });
      console.log(lastFrom);
      setKeepData(lastFrom);
658

659 660 661 662 663 664 665 666
      keepAll.map(j => {
        if (to.indexOf(j.name) == -1) {
          lastTo.push(j);
        }
      });
      console.log(lastTo);
      setKeepTree(lastTo);
    }
667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682

    // let data = keepAll;
    // data.map(k => {
    //   console.log(k);
    //   k.children.map((j, h) => {
    //     console.log(j);
    //     if (to.indexOf(j.name) != -1) {
    //       console.log(j);
    //       k.children.splice(h, 1);
    //     }
    //   });
    // });
    // console.log(data);
    // setKeepTree(data);
  };

683 684 685 686
  const treeSelectOnchange = e => {
    setTreeSelectValue(e);
  };

皮倩雯's avatar
皮倩雯 committed
687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729
  return (
    <Drawer
      title="反馈配置"
      visible={visible}
      destroyOnClose
      width="550px"
      {...props}
      footer={
        <Space>
          <Button onClick={onSubmit} type="primary">
            确定
          </Button>
        </Space>
      }
    >
      <Form form={form} labelCol={{ span: 7 }} style={{ overflowY: 'scroll' }}>
        <Row>
          <Col span={23}>
            <Item
              label="巡检对象"
              name="layerName"
              labelCol={{ span: 4 }}
              rules={[
                {
                  validator: (rule, value) => {
                    let aa = form.getFieldValue().layerName;
                    if (type === 'add' && keepTableData.indexOf(aa) != -1) {
                      return Promise.reject('巡检对象已存在');
                    } else if (
                      type === 'edit' &&
                      keepTableData.indexOf(aa) != -1 &&
                      aa != formObj.layerName
                    ) {
                      return Promise.reject('巡检对象已存在');
                    }
                    return Promise.resolve();
                  },
                },
              ]}
            >
              <Input placeholder="巡检对象名称不可重复" />
            </Item>
          </Col>
730
          <Col span={23}>
731
            <Item label="业务划分" name="businessGroup" labelCol={{ span: 4 }}>
732
              <Select placeholder="请选择业务划分" showSearch mode="multiple" allowClear>
733 734 735 736 737 738 739 740 741 742
                <Option key="区域巡检" value="区域巡检">
                  区域巡检
                </Option>
                <Option key="DMA巡检" value="DMA巡检">
                  DMA巡检
                </Option>
              </Select>
            </Item>
          </Col>
          <Col span={23}>
743 744 745 746
            <Item label="分组" name="groupType" labelCol={{ span: 4 }}>
              <Input placeholder="请输入分组名称" />
            </Item>
          </Col>
皮倩雯's avatar
皮倩雯 committed
747 748
          <Col span={23}>
            <Item label="GIS图层" name="gisLayer" labelCol={{ span: 4 }}>
749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764
              <TreeSelect
                showSearch
                value={treeSelectValue}
                dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
                placeholder="请选择映射字段名 "
                allowClear
                treeDefaultExpandAll
                showCheckedStrategy
                onChange={treeSelectOnchange}
              >
                {menuWebList ? (
                  menuWebList.map(i => mapTree(i))
                ) : (
                  <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
                )}
              </TreeSelect>
皮倩雯's avatar
皮倩雯 committed
765 766 767 768
            </Item>
          </Col>
          <Col span={23}>
            <Item label="GIS条件" name="gisFilterValue" labelCol={{ span: 4 }}>
769
              <Input placeholder="示例:设备级别 = '小区阀门'  (设备级别来自图层表字段)" />
皮倩雯's avatar
皮倩雯 committed
770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832
            </Item>
          </Col>
          <Col span={23}>
            <Item label="反馈表" name="tableName" labelCol={{ span: 4 }}>
              <Select placeholder="选择反馈表" onChange={onChangeTableName} showSearch>
                {feedbackTable
                  ? feedbackTable.map((item, index) => (
                      <Option key={index} value={item.text}>
                        {item.text}
                      </Option>
                    ))
                  : ''}
              </Select>
            </Item>
          </Col>
          <Col span={23}>
            <Item label="字段集" name="fields" labelCol={{ span: 4 }}>
              <div style={{ display: 'flex' }}>
                <Item name="fields" style={{ marginBottom: 0, width: '100%' }}>
                  <Input placeholder="请选择字段集" allowClear />
                </Item>
                <Button
                  type="dashed"
                  onClick={() => pickFiled('fields')}
                  icon={<PlusOutlined style={{ marginTop: '5px' }} />}
                  style={{ marginLeft: '10px', width: '70px' }}
                />
              </div>
            </Item>
          </Col>
          {/* <Col span={23}>
            <Item label="异常值" name="exceptionValue" labelCol={{ span: 4 }}>
              <Input placeholder="请输入异常值" />
            </Item>
          </Col> */}
          {/* <Col span={23}>
            <Item label="触发事件" name="eventName" labelCol={{ span: 4 }}>
              <Select placeholder="选择触发事件" showSearch>
                {feedbackEvent
                  ? feedbackEvent.map((item, index) => (
                      <Option key={index} value={item.Name}>
                        {item.Name}
                      </Option>
                    ))
                  : ''}
              </Select>
            </Item>
          </Col> */}
          <Col span={23}>
            <Item label="权限" name="roles" labelCol={{ span: 4 }}>
              <div style={{ display: 'flex' }}>
                <Item name="roles" style={{ marginBottom: 0, width: '100%' }}>
                  <Input placeholder="请选择字段集" allowClear />
                </Item>
                <Button
                  type="dashed"
                  onClick={() => pickFiled1('roles')}
                  icon={<PlusOutlined style={{ marginTop: '5px' }} />}
                  style={{ marginLeft: '10px', width: '70px' }}
                />
              </div>
            </Item>
          </Col>
833 834
          <Col span={23}>
            <Item label="关联事件" name="relationEvent" labelCol={{ span: 4 }}>
835
              <Select placeholder="选择关联事件类型" onChange={e => onChangeEvent(e)} showSearch>
836 837 838 839 840 841 842 843 844 845
                {eventData
                  ? eventData.map((item, index) => (
                      <Option key={index} value={item}>
                        {item}
                      </Option>
                    ))
                  : ''}
              </Select>
            </Item>
          </Col>
846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931
          <Col span={23}>
            <span style={{ fontSize: '12px', color: '#bfbcbc', marginLeft: '80px' }}>
              当配置了关联事件后,可配置字段映射规则
            </span>
            <br />
            <span style={{ fontSize: '12px', color: '#bfbcbc', marginLeft: '80px' }}>
              配置后,巡检发起的工单,可以传递该巡检任务信息
            </span>
          </Col>
          <Col span={4} />
          <Col span={19}>
            <Item style={{ marginTop: '20px' }}>
              <Form name="form" form={formAdd} onFieldsChange={changeValue}>
                <Form.List name="parmars">
                  {(fields, { add, remove }) => (
                    <>
                      {fields.map(({ key, name, fieldKey, ...restField }) => (
                        <Space
                          key={key}
                          style={{
                            display: 'flex',
                            marginBottom: '5px',
                            justifyContent: 'center',
                          }}
                          align="baseline"
                        >
                          <Form.Item
                            {...restField}
                            style={{ marginBottom: '5px' }}
                            name={[name, 'fromField']}
                            fieldKey={[fieldKey, 'key']}
                            validateTrigger={['onChange', 'onBlur']}
                            rules={[{ required: true, message: '请填写字段名' }]}
                          >
                            <Select
                              placeholder="选择字段名"
                              // onSelect={changTable}
                              // optionLabelProp="key"
                              showSearch
                              style={{ width: '159px' }}
                            >
                              {keepData
                                ? keepData.map((item, index) => (
                                    <Option key={item.key} value={item.key}>
                                      {item.key}
                                    </Option>
                                  ))
                                : ''}
                            </Select>
                          </Form.Item>
                          <img src={logo} style={{ height: '24px' }} alt="" />
                          <Form.Item
                            {...restField}
                            style={{ marginBottom: '5px' }}
                            name={[name, 'toField']}
                            fieldKey={[fieldKey, 'key']}
                            rules={[{ required: true, message: '请填写映射字段名' }]}
                          >
                            <Select
                              placeholder="选择映射字段名"
                              showSearch
                              style={{ width: '159px' }}
                            >
                              {keepTree.length > 0
                                ? keepTree.map((item, index) => (
                                    <>
                                      <Option key={item.name} value={item.name}>
                                        {item.name}
                                      </Option>
                                    </>
                                  ))
                                : ''}
                            </Select>
                          </Form.Item>
                          <MinusCircleOutlined
                            onClick={() => remove(name)}
                            style={{ marginLeft: '10px', fontSize: '20px' }}
                          />
                        </Space>
                      ))}
                      <Form.Item>
                        <Button
                          type="dashed"
                          onClick={() => add()}
                          block
                          icon={<PlusOutlined />}
皮倩雯's avatar
皮倩雯 committed
932
                          style={{ marginLeft: '-2px' }}
933
                          disabled={keepData && !(keepData.length > 0)}
934 935 936 937 938 939 940 941 942 943
                        >
                          添加映射
                        </Button>
                      </Form.Item>
                    </>
                  )}
                </Form.List>
              </Form>
            </Item>
          </Col>
皮倩雯's avatar
皮倩雯 committed
944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959
          {/* <Col span={23}>
            <Item label="分组" name="groupType" labelCol={{ span: 4 }}>
              <Input placeholder="请输入分组" />
            </Item>
          </Col> */}
        </Row>
      </Form>
      <ChangeFields
        visible={isVisibleFields}
        callBackSubmit={onOK1}
        onCancel={() => setIsVisibleFields(false)}
        newCheckedList={checkedList1}
        filed={filed}
        pickItem={pickItem}
        formObj={formObj}
      />
960
      {/* <ChangeRoles
皮倩雯's avatar
皮倩雯 committed
961 962 963 964 965 966
        visible={isVisibleRoles}
        onCancel={() => setIsVisibleRoles(false)}
        callBackSubmit={onOK}
        newCheckedList={checkedList1}
        filed11={filed1}
        pickItem={pickItem}
967 968 969 970 971 972 973 974 975
      /> */}
      <RMSComponents
        visible={isVisibleRoles}
        onCancel={() => setIsVisibleRoles(false)}
        callBackSubmit={onOK}
        newCheckedList={checkedList1} // 单选框中的值
        pickItem={pickItem}
        groupName={groupName} // 打开组件展示的分组名,用来首次获取数据
        chooseGroupName={chooseGroupName} // 可选分组名
976
        keepFiled={keepFiled}
977
        dataType="name"
皮倩雯's avatar
皮倩雯 committed
978 979 980 981 982
      />
    </Drawer>
  );
};
export default AddModal;