DrawBoardManage.jsx 29.6 KB
Newer Older
1 2 3 4
/* eslint-disable operator-assignment */
/* eslint-disable no-undef */
/* eslint-disable no-lonely-if */
/* eslint-disable prefer-template */
皮倩雯's avatar
皮倩雯 committed
5 6 7 8 9
/* eslint-disable no-shadow */
/*
 * @Description:
 * @Author: leizhe
 * @Date: 2022-04-06 11:38:46
10
 * @LastEditTime: 2022-05-23 10:49:46
皮倩雯's avatar
皮倩雯 committed
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
 * @LastEditors: leizhe
 */
import React, { useState, useEffect } from 'react';
import {
  Button,
  Descriptions,
  Input,
  Card,
  Spin,
  Divider,
  Tabs,
  Table,
  Space,
  Tooltip,
  Modal,
  Image,
  Form,
  notification,
  message,
  Pagination,
31 32
  Dropdown,
  Menu,
皮倩雯's avatar
皮倩雯 committed
33 34 35 36 37 38 39 40 41
} from 'antd';
import {
  typeList,
  modelManageList,
  deleteByModel,
  DelModelType,
  DownLoadModelType,
  GetBasicInfo,
  DownLoadModelTypeSingle,
42
  Export,
皮倩雯's avatar
皮倩雯 committed
43 44 45 46 47 48 49 50 51
} from '@/services/drawBoardManage/api';
import {
  FormOutlined,
  DeleteOutlined,
  PlusOutlined,
  DownloadOutlined,
  UploadOutlined,
  SyncOutlined,
  PlusSquareFilled,
52 53
  ShareAltOutlined,
  DownOutlined,
皮倩雯's avatar
皮倩雯 committed
54 55 56 57 58 59 60 61 62 63
} from '@ant-design/icons';
import classnames from 'classnames';
import zhCN from 'antd/es/locale/zh_CN';
import styles from './DrawBoardManage.less';
import AddModal from './AddModal';
import EditModal from './EditModal';
import AddTemplate from './AddTemplate';
import ChildAddTemplate from './ChildAddTemplate';
import EditTemplate from './EditTemplate';
import ImportModal from './ImportModal';
64
import AssociationModel from './AssociationModel';
皮倩雯's avatar
皮倩雯 committed
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88

const { TabPane } = Tabs;

const DrawBoardManage = () => {
  const [searchWord, setSearchWord] = useState(''); // 关键字
  const [tableLoading, setTableLoading] = useState(false);
  const [treeLoading, setTreeLoading] = useState(false);
  const [tableData, setTableData] = useState([]);
  const [selectColor, setSelectColor] = useState({}); // 当前选中颜色,操作时设置
  const [treeData, setTreeData] = useState([]);
  const [pickItem, setPickItem] = useState('');
  const [rember1, setRember1] = useState();
  const [hoverItemIndex, setHoverItemIndex] = useState(0); // hover流程索引
  const [addModalVisible, setAddModalVisible] = useState(false);
  const [editModalVisible, setEditModalVisible] = useState(false);
  const [deleteModalVisible, setDeleteModalVisible] = useState(false);
  const [selectGroup, setSelectGroup] = useState([]);
  const [addTemplateVisible, setAddTemplateVisible] = useState(false);
  const [childAddTemplateVisible, setChildAddTemplateVisible] = useState(false);
  const [checkStrictly, setCheckStrictly] = useState(false);
  const [showSearchStyle, setShowSearchStyle] = useState(false); // 是否显示模糊查询样式
  const [selectedRowKeys, setSelectedRowKeys] = useState([]); // 已选字段配置数,机构改变时重置
  const [deleteVisible, setDeleteVisible] = useState(false);
  const [editVisible, setEditVisible] = useState(false);
89
  const [associationVisible, setAssociationVisible] = useState(false);
皮倩雯's avatar
皮倩雯 committed
90 91 92 93 94 95
  const [multDeleteVisible, setMultDeleteVisible] = useState(false);
  const [changeObj, setChangeObj] = useState('');
  const [obj, setObj] = useState('');
  const [importVisible, setImportVisible] = useState(false);
  const { Search } = Input;
  const [keepId, setKeepId] = useState('');
96
  const [totalData, setTotal] = useState('');
97
  const [page, setPage] = useState(1);
98 99 100 101
  const [multiOperate, setMultiOperate] = useState(true); // 是否禁用用户批量操作
  const [multiOperateButtonType, setMultiOperateButtonType] = useState(''); // 更改批量操作按钮样式
  const [keepRow, setKeepRow] = useState([]);
  const setRowClassName = record => (record.ID === selectColor.ID ? styles.clickRowStyle : '');
皮倩雯's avatar
皮倩雯 committed
102 103

  useEffect(() => {
104
    setMultiOperate(true);
皮倩雯's avatar
皮倩雯 committed
105 106 107
    if (pickItem) {
      updateTableData(pickItem.name, searchWord);
    }
108
    setPage(1);
皮倩雯's avatar
皮倩雯 committed
109 110 111 112 113 114 115 116 117 118
  }, [pickItem]);

  useEffect(() => {
    updateTrees();
    GetBasicInfo().then(res => {
      setKeepId(res.data);
    });
  }, []);

  // 获取Tree数据
119
  const updateTrees = e => {
皮倩雯's avatar
皮倩雯 committed
120
    setTreeLoading(true);
121 122
    typeList().then(res => {
      if (res.code === 0) {
皮倩雯's avatar
皮倩雯 committed
123
        setTreeLoading(false);
124 125 126 127 128
        if (e) {
          let aa = res.data.find(i => i.name === e);
          setPickItem(aa);
          updateTableData(e, searchWord);
        } else {
129
          console.log(pickItem);
130 131 132 133 134
          if (!pickItem) {
            updateTableData('', searchWord);
          } else {
            updateTableData(pickItem.name, searchWord);
          }
皮倩雯's avatar
皮倩雯 committed
135
        }
136
        setTreeData(res.data);
皮倩雯's avatar
皮倩雯 committed
137 138 139 140
      }
    });
  };

141 142 143 144 145 146 147 148 149 150
  const addBack = props => {
    console.log(props);
    updateTrees(props);
  };

  const editBack = props => {
    console.log(props);
    updateTrees(props);
  };

皮倩雯's avatar
皮倩雯 committed
151 152 153 154 155
  // 获取表格数据
  const updateTableData = (e, searchWord) => {
    setTableLoading(true);
    setSelectedRowKeys([]);
    modelManageList({
156 157
      modelName: searchWord,
      modelType: e,
皮倩雯's avatar
皮倩雯 committed
158 159
    }).then(res => {
      setTableLoading(false);
160
      if (res.code === 0) {
皮倩雯's avatar
皮倩雯 committed
161 162 163 164 165
        if (searchWord != '') {
          setShowSearchStyle(true);
        } else {
          setShowSearchStyle(false);
        }
166
        if (res.data.length > 0) {
皮倩雯's avatar
皮倩雯 committed
167
          if (!pickItem) {
168 169 170 171 172 173 174
            let aa = res.data;
            // res.data.map(i => {
            //   i.list.map(j => {
            //     aa.push(j);
            //   });
            // });
            // 一级数据
皮倩雯's avatar
皮倩雯 committed
175
            let bb = aa;
176
            let len = bb.length;
皮倩雯's avatar
皮倩雯 committed
177 178 179
            if (bb.length > 0) {
              bb.map(i => {
                if (i.children.length > 0) {
180
                  len = len + i.children.length;
皮倩雯's avatar
皮倩雯 committed
181 182 183 184 185 186 187 188
                  i.children.map(j => {
                    delete j.children;
                  });
                } else {
                  delete i.children;
                }
              });
            }
189
            setTotal(len);
皮倩雯's avatar
皮倩雯 committed
190 191 192
            setTableData(bb);
            setSelectGroup(bb);
          } else {
193 194
            let aa = res.data;
            let len = aa.length;
皮倩雯's avatar
皮倩雯 committed
195 196 197
            if (aa.length > 0) {
              aa.map(i => {
                if (i.children.length > 0) {
198
                  len = len + i.children.length;
皮倩雯's avatar
皮倩雯 committed
199 200 201 202 203 204 205 206
                  i.children.map(j => {
                    delete j.children;
                  });
                } else {
                  delete i.children;
                }
              });
            }
207
            setTotal(len);
皮倩雯's avatar
皮倩雯 committed
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
            setTableData(aa);
            setSelectGroup(aa);
          }
        } else {
          setTotal(0);
          setTableData([]);
        }
      }
    });
  };

  // 获取表格数据
  const updateTableDataAll = (e, searchWord) => {
    setTableLoading(true);
    setSelectedRowKeys([]);
    modelManageList({
224 225
      modelName: searchWord,
      modelType: e,
皮倩雯's avatar
皮倩雯 committed
226 227
    }).then(res => {
      setTableLoading(false);
228
      if (res.code === 0) {
皮倩雯's avatar
皮倩雯 committed
229 230 231 232 233
        if (searchWord != '') {
          setShowSearchStyle(true);
        } else {
          setShowSearchStyle(false);
        }
234 235 236 237 238 239 240
        if (res.data.length > 0) {
          let aa = res.data;
          // res.getMe.map(i => {
          //   i.list.map(j => {
          //     aa.push(j);
          //   });
          // });
皮倩雯's avatar
皮倩雯 committed
241
          let bb = aa;
242
          let len = bb.length;
皮倩雯's avatar
皮倩雯 committed
243 244 245
          if (bb.length > 0) {
            bb.map(i => {
              if (i.children.length > 0) {
246
                len = len + i.children.length;
皮倩雯's avatar
皮倩雯 committed
247 248 249 250 251 252 253 254
                i.children.map(j => {
                  delete j.children;
                });
              } else {
                delete i.children;
              }
            });
          }
255
          setTotal(len);
皮倩雯's avatar
皮倩雯 committed
256 257 258 259 260 261 262 263 264 265 266 267 268 269
          setTableData(bb);
          setSelectGroup(bb);
        } else {
          setTotal(0);
          setTableData([]);
        }
      }
    });
  };

  const columns = [
    {
      title: '模型类型',
      align: 'center',
270 271
      dataIndex: 'ModelTypeName',
      key: 'ModelTypeName',
皮倩雯's avatar
皮倩雯 committed
272
      render: (text, record) => {
273
        // console.log(record);
皮倩雯's avatar
皮倩雯 committed
274
        if (record.children) {
275
          // console.log(record.children.length);
皮倩雯's avatar
皮倩雯 committed
276 277 278
        }

        const obj = {
279
          children: <>{record.RelModel == 0 ? <span size="middle">{text}</span> : <span />}</>,
皮倩雯's avatar
皮倩雯 committed
280 281 282 283 284 285 286 287 288
          props: {},
        };
        obj.props.colSpan = 1;
        return obj;
      },
    },
    {
      title: '模型名称',
      align: 'center',
289 290
      dataIndex: 'ModelName',
      key: 'ModelName',
皮倩雯's avatar
皮倩雯 committed
291 292 293 294 295 296 297 298 299 300 301 302
      render: (text, record) => {
        const obj = {
          children: <span>{searchStyle(text)} </span>,
          props: {},
        };
        obj.props.colSpan = 1;
        return obj;
      },
    },
    {
      title: '图像',
      align: 'center',
303 304
      dataIndex: 'Path',
      key: 'Path',
皮倩雯's avatar
皮倩雯 committed
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339
      render: (text, record) => {
        let time = new Date();
        let timestamp = Date.parse(time);
        const obj = {
          children: (
            <Image
              src={
                window.location.origin +
                `/Publish/Web/File/ModelManage/ModelFilePreview/${encodeURIComponent(text)}?
                ${timestamp}`
              }
              height="50px"
            />
          ),
          props: {},
        };
        obj.props.colSpan = 1;
        return obj;
      },
    },
    // {
    //   title: '模型属性',
    //   align: 'center',
    //   width: 200,
    //   dataIndex: 'property',
    //   key: 'property',
    //   render: (text, record) => {
    //     const obj = {
    //       children: <span>{text} </span>,
    //       props: {},
    //     };
    //     obj.props.colSpan = 1;
    //     return obj;
    //   },
    // },
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354
    // {
    //   title: '设计者',
    //   align: 'center',
    //   dataIndex: 'people',
    //   width: 80,
    //   key: 'people',
    //   render: (text, record) => {
    //     const obj = {
    //       children: <span>{text} </span>,
    //       props: {},
    //     };
    //     obj.props.colSpan = 1;
    //     return obj;
    //   },
    // },
皮倩雯's avatar
皮倩雯 committed
355 356 357
    {
      title: '创建日期',
      align: 'center',
358
      width: 150,
皮倩雯's avatar
皮倩雯 committed
359 360 361 362 363 364 365 366 367 368 369 370 371 372
      dataIndex: 'createTime',
      key: 'createTime',
      render: (text, record) => {
        const obj = {
          children: <span>{text} </span>,
          props: {},
        };
        obj.props.colSpan = 1;
        return obj;
      },
    },
    {
      title: '操作',
      align: 'center',
373
      width: 150,
皮倩雯's avatar
皮倩雯 committed
374 375
      key: 'action',
      render: record => {
376
        // console.log(record);
皮倩雯's avatar
皮倩雯 committed
377 378 379 380 381 382 383 384 385 386 387 388 389 390
        let aa = (
          <Space size="middle">
            <Tooltip title="编辑">
              <FormOutlined
                onClick={() => onedit(record)}
                style={{ fontSize: '16px', color: '#1890FF' }}
              />
            </Tooltip>
            <Tooltip title="导出">
              <DownloadOutlined
                onClick={() => ExportSingle(record)}
                style={{ fontSize: '16px', color: '#1890FF' }}
              />
            </Tooltip>
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412
            {record.children ? (
              <Space size="middle">
                <Tooltip title="关联父模型">
                  <ShareAltOutlined
                    onClick={() => {
                      message.warning('该模型存在子模型不能关联父模型');
                    }}
                    style={{ fontSize: '16px', color: 'rgb(199 194 194)' }}
                  />
                </Tooltip>
              </Space>
            ) : (
              <Space size="middle">
                <Tooltip title="关联父模型">
                  <ShareAltOutlined
                    onClick={() => associationModel(record)}
                    style={{ fontSize: '16px', color: '#1890FF' }}
                  />
                </Tooltip>
              </Space>
            )}

皮倩雯's avatar
皮倩雯 committed
413 414 415
            <Tooltip title="删除">
              <DeleteOutlined
                onClick={() => ondelete(record)}
416
                style={{ fontSize: '16px', color: '#e86060' }}
皮倩雯's avatar
皮倩雯 committed
417 418 419 420 421 422 423 424
              />
            </Tooltip>
          </Space>
        );
        const obj = {
          children: aa,
          props: {},
        };
425
        obj.props.colSpan = record.RelModel == 0 ? 1 : 1;
皮倩雯's avatar
皮倩雯 committed
426 427 428 429 430 431 432
        return obj;
      },
    },
    {
      title: '添加子模型',
      align: 'center',
      dataIndex: 'stateModel',
433
      width: 100,
皮倩雯's avatar
皮倩雯 committed
434 435 436 437 438
      key: 'stateModel',
      render: (text, record) => {
        const obj = {
          children: (
            <>
439
              {record.RelModel == 0 ? (
皮倩雯's avatar
皮倩雯 committed
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454
                <Space size="middle">
                  <Tooltip title="新增">
                    <PlusOutlined
                      onClick={() => onadd(record)}
                      style={{ fontSize: '16px', color: '#1890FF' }}
                    />
                  </Tooltip>
                </Space>
              ) : (
                <Space size="middle" />
              )}
            </>
          ),
          props: {},
        };
455
        obj.props.colSpan = record.RelModel == 0 ? 1 : 1;
皮倩雯's avatar
皮倩雯 committed
456 457 458 459 460 461 462 463 464 465 466 467 468 469 470
        return obj;
      },
    },
  ];

  const onadd = e => {
    setObj(e);
    setChildAddTemplateVisible(true);
  };

  const onedit = e => {
    setObj(e);
    setEditVisible(true);
  };

471 472 473 474 475
  const associationModel = e => {
    setObj(e);
    setAssociationVisible(true);
  };

皮倩雯's avatar
皮倩雯 committed
476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498
  const onexport = e => {
    console.log(e);
    setObj(e);
    let a = document.createElement('a');
    a.href = `${e.imgUrl}${encodeURIComponent(e.modelPath)}?_site=null`;
    console.log(a);
    let sufStr = e.modelPath.split('.').pop();
    a.download = `${e.name}.${sufStr}`;
    a.click();
    a.remove();
  };

  const ondelete = e => {
    setObj(e);
    setDeleteVisible(true);
  };

  const submitSearchUser = () => {
    updateTableData(pickItem.name, searchWord);
  };

  const handleSearch = e => {
    setSearchWord(e.target.value);
499
    // updateTableData(pickItem.name, e.target.value);
皮倩雯's avatar
皮倩雯 committed
500 501 502 503 504 505 506 507
  };

  const addModal = () => {
    setAddModalVisible(true);
  };

  const rowSelection = {
    selectedRowKeys,
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
    onChange: (selectedRow, selectedRows) => {
      if (selectedRow.length < selectedRowKeys.length) {
        let aa;
        // 找到取消勾选一级模形id
        selectedRowKeys.map(i => {
          if (selectedRow.indexOf(i) == -1) {
            aa = i;
          }
        });
        // 从已选数组中删除取消勾选一级模型的二级模型id
        keepRow.map(j => {
          if (j.ID == aa) {
            // 判断是否存在二级模型
            if (j.children) {
              j.children.map(ii => {
                selectedRow.splice(selectedRow.findIndex(item => item.ID === ii.ID), 1);
              });
            }
          }
        });
        setSelectedRowKeys(selectedRow);
      } else {
        let aa = selectedRow;
        // 找到勾选一级模型的二级模型id存入已勾选列表
        selectedRows.map(i => {
          // 判断是否存在二级模型
          if (i.children) {
            i.children.map(i => {
              aa.push(i.ID);
            });
          }
        });
        setSelectedRowKeys(Array.from(new Set(aa)));
      }
      setKeepRow(selectedRows);
      // 控制批量操作模型按钮样式
      if (selectedRow.length > 0) {
        setSelectColor({});
        setMultiOperate(false);
        setMultiOperateButtonType('primary');
      } else {
        setMultiOperate(true);
        setMultiOperateButtonType('default');
      }
皮倩雯's avatar
皮倩雯 committed
552 553
    },
    renderCell: (checked, record, index, originNode) => {
554
      if (record.RelModel != 0) {
皮倩雯's avatar
皮倩雯 committed
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 585 586 587 588 589 590 591
        return null;
      }
      return originNode;
    },
  };

  const onUnfold = (expanded, record) => {
    if (record.children) {
      const data = [...selectGroup];
      let index = data.indexOf(record);
      // let index = selectGroup.find(i => i.type || i.name == record.name);
      if (expanded) {
        data.push(record);
        setSelectGroup(data);
      } else {
        data.splice(index, 1);
        setSelectGroup(data);
      }
    }
  };

  // 模糊查询匹配的样式
  const searchStyle = val => {
    let n;
    if (showSearchStyle) {
      n = val.replace(new RegExp(searchWord, 'g'), `<span style='color:red'>${searchWord}</span>`);
    } else {
      n = val;
    }
    return <div dangerouslySetInnerHTML={{ __html: n }} />;
  };

  const addTemplate = () => {
    setAddTemplateVisible(true);
  };

  const deleteModalData = () => {
592 593
    console.log(changeObj);
    DelModelType({ id: changeObj.ID, modelTypeName: changeObj.name }).then(res => {
皮倩雯's avatar
皮倩雯 committed
594 595 596 597 598 599 600 601 602
      if (res.code === 0) {
        setDeleteModalVisible(false);
        notification.success({
          message: '删除成功',
          duration: 2,
        });
        if (pickItem.name == changeObj.name) {
          setPickItem('');
          setChangeObj('');
603 604 605 606 607 608 609 610 611 612
          setTreeLoading(true);
          typeList().then(res => {
            setTreeLoading(false);
            if (res.code === 0) {
              updateTableDataAll('', searchWord);
              setTreeData(res.data);
            }
          });
        } else {
          updateTrees();
皮倩雯's avatar
皮倩雯 committed
613 614 615 616 617 618 619 620 621 622 623 624
        }
      } else {
        notification.error({
          message: '删除失败',
          description: res.msg,
        });
      }
    });
  };

  const deleteData = () => {
    setTableLoading(true);
625
    deleteByModel({ ids: obj.ID }).then(res => {
皮倩雯's avatar
皮倩雯 committed
626
      setTableLoading(false);
627
      if (res.code === 0) {
皮倩雯's avatar
皮倩雯 committed
628 629 630 631 632 633 634 635 636
        setDeleteVisible(false);
        notification.success({
          message: '删除成功',
          duration: 2,
        });
        updateTableData(pickItem.name, searchWord);
      } else {
        notification.error({
          message: '删除失败',
637
          description: res.msg,
皮倩雯's avatar
皮倩雯 committed
638 639 640 641 642 643 644 645 646 647 648 649 650
        });
      }
    });
  };

  const multDeleteData = () => {
    setMultDeleteVisible(true);
  };

  const multDelete = () => {
    setTableLoading(true);
    deleteByModel({ ids: selectedRowKeys.toString() }).then(res => {
      setTableLoading(false);
651
      if (res.code === 0) {
皮倩雯's avatar
皮倩雯 committed
652 653 654 655 656 657 658 659 660
        setMultDeleteVisible(false);
        notification.success({
          message: '删除成功',
          duration: 2,
        });
        updateTableData(pickItem.name, searchWord);
      } else {
        notification.error({
          message: '删除失败',
661
          description: res.msg,
皮倩雯's avatar
皮倩雯 committed
662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682
        });
      }
    });
  };

  const onAddTemplateSubmit = () => {
    setAddTemplateVisible(false);
    updateTableData(pickItem.name, searchWord);
  };

  const onChildAddTemplateSubmit = () => {
    setChildAddTemplateVisible(false);
    updateTableData(pickItem.name, searchWord);
  };

  const onEditTemplateSubmit = () => {
    setEditVisible(false);
    updateTableData(pickItem.name, searchWord);
  };

  const onImportSubmit = () => {
683
    setPickItem('');
皮倩雯's avatar
皮倩雯 committed
684
    setImportVisible(false);
685 686 687 688 689 690 691 692 693 694 695 696
    setTreeLoading(true);
    typeList().then(res => {
      if (res.code === 0) {
        setTreeLoading(false);
        updateTableData('', searchWord);
        setTreeData(res.data);
      }
    });
    // updateTableData(pickItem.name, searchWord);
  };

  const onAssociationSubmit = () => {
皮倩雯's avatar
皮倩雯 committed
697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720
    updateTableData(pickItem.name, searchWord);
  };

  const oneditlist = (e, item) => {
    e.stopPropagation();
    setChangeObj(item);
    setEditModalVisible(true);
  };

  const ondeletelist = (e, item) => {
    e.stopPropagation();
    setChangeObj(item);
    setDeleteModalVisible(true);
  };

  const importFile = () => {
    setImportVisible(true);
  };

  const ExportData = () => {
    if (selectedRowKeys.length == 0) {
      message.warning('请先选择导出的数据');
    } else {
      window.location.href = DownLoadModelType({ modelList: selectedRowKeys.toString() });
721
      // window.location.href = Export({ Ids: selectedRowKeys.toString() });
皮倩雯's avatar
皮倩雯 committed
722 723 724
    }
  };

725 726 727 728 729
  const ExportDataAll = () => {
    window.location.href = DownLoadModelType({ modelList: 'all' });
    // window.location.href = Export({ Ids: selectedRowKeys.toString() });
  };

皮倩雯's avatar
皮倩雯 committed
730 731
  const ExportSingle = e => {
    console.log(e);
732
    window.location.href = DownLoadModelTypeSingle({ modeId: e.ID });
皮倩雯's avatar
皮倩雯 committed
733 734 735 736
  };

  const choose = () => {
    setPickItem('');
皮倩雯's avatar
皮倩雯 committed
737 738
    setSearchWord('');
    updateTableDataAll('', '');
皮倩雯's avatar
皮倩雯 committed
739 740
  };

741 742 743 744 745 746 747 748 749 750 751 752 753 754 755
  // 用户批量操作
  const userButtonMenu = (
    <Menu>
      {/* <Menu.Item key="1" onClick={importFile} icon={<UploadOutlined />}>
        批量导入模型
      </Menu.Item> */}
      <Menu.Item key="1" onClick={ExportData} icon={<DownloadOutlined />}>
        批量导出模型
      </Menu.Item>
      <Menu.Item key="2" onClick={multDeleteData} icon={<DeleteOutlined />}>
        批量删除模型
      </Menu.Item>
    </Menu>
  );

皮倩雯's avatar
皮倩雯 committed
756 757 758 759 760
  return (
    <div className={styles.base_container}>
      <Card style={{ width: '100%', height: 'calc(100vh - 130px)' }}>
        <div style={{ display: 'flex', justifyContent: 'space-around', width: '100%' }}>
          {/* 左侧类型树 */}
761
          <div style={{ minWidth: '250px' }}>
皮倩雯's avatar
皮倩雯 committed
762 763 764 765 766 767 768 769 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
            <Spin spinning={treeLoading} tip="loading...">
              <div
                style={{ display: 'flex', justifyContent: 'space-between', alignContent: 'center' }}
              >
                <span
                  style={{
                    fontSize: '15px ',
                    fontWeight: 'bold',
                  }}
                >
                  模型类型
                </span>
                <Tooltip title="添加模型类型">
                  <PlusSquareFilled
                    onClick={() => addModal()}
                    style={{
                      color: '#1890FF',
                      fontSize: '25px',
                      marginTop: '3px',
                    }}
                  />
                </Tooltip>
              </div>
              <hr style={{ width: '100%', color: '#eeecec' }} />
              <div
                style={{
                  height: 'calc(100vh - 250px)',
                  overflowY: 'scroll',
                }}
              >
                <div
                  onClick={choose}
                  className={classnames({
                    [styles.allItem]: true,
                    [styles.pickItem]: pickItem === '',
                  })}
                >
                  <span style={{ marginLeft: '14px', lineHeight: '36px' }}>全部类型</span>
                </div>
                {treeData.length > 0 &&
                  treeData.map((item, index) => (
                    <div
                      className={classnames({
                        [styles.listItem]: true,
806
                        [styles.pickItem]: item.ID === pickItem.ID,
皮倩雯's avatar
皮倩雯 committed
807 808 809 810 811
                        [styles.listHover]: item !== pickItem && item === hoverItemIndex,
                      })}
                      onClick={e => {
                        setPickItem(item);
                        setRember1(item);
皮倩雯's avatar
皮倩雯 committed
812
                        setSearchWord('');
皮倩雯's avatar
皮倩雯 committed
813 814 815 816 817 818 819
                      }}
                      onMouseEnter={() => {
                        setHoverItemIndex(item);
                      }}
                      onMouseLeave={() => {
                        setHoverItemIndex('');
                      }}
820
                      key={item.ID}
皮倩雯's avatar
皮倩雯 committed
821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845
                    >
                      <div className={styles.title}>
                        <span>{item.name}</span>
                        <span className={styles.tip}>
                          <span>
                            <FormOutlined
                              onClick={e => oneditlist(e, item)}
                              style={{ color: '#1890FF', fontSize: '16px' }}
                            />
                          </span>
                          <span style={{ marginLeft: '10px' }}>
                            <DeleteOutlined
                              onClick={e => ondeletelist(e, item)}
                              style={{ color: '#e86060', fontSize: '16px' }}
                            />
                          </span>
                        </span>
                      </div>
                    </div>
                  ))}
              </div>
            </Spin>
          </div>

          {/* 右侧表格 */}
846
          <div style={{ marginLeft: '20px', marginTop: '-10px', overflow: 'scroll' }}>
皮倩雯's avatar
皮倩雯 committed
847 848 849 850 851 852 853 854 855 856
            <div
              style={{
                height: '41px',
                display: 'flex',
                justifyContent: 'space-between',
                alignItems: 'center',
              }}
            >
              <div>
                <span style={{ width: '200px', display: 'inline-block' }}>
857
                  {pickItem ? pickItem.name : '全部类型'}(已选{selectedRowKeys.length}条)
皮倩雯's avatar
皮倩雯 committed
858 859 860 861 862 863
                </span>
                <span style={{ lineHeight: '32px' }}>模型检索:</span>
                <Search
                  style={{ width: 260 }}
                  placeholder="请输入关键词"
                  onChange={e => handleSearch(e)}
864
                  onSearch={submitSearchUser}
皮倩雯's avatar
皮倩雯 committed
865 866 867
                  enterButton
                  value={searchWord}
                />
868 869
              </div>
              <div>
皮倩雯's avatar
皮倩雯 committed
870 871 872 873
                <Button
                  type="primary"
                  icon={<PlusOutlined />}
                  onClick={addTemplate}
874
                  style={{ marginRight: '20px' }}
皮倩雯's avatar
皮倩雯 committed
875 876 877
                >
                  新增
                </Button>
878
                <Button
皮倩雯's avatar
皮倩雯 committed
879 880 881
                  type="primary"
                  icon={<UploadOutlined />}
                  onClick={importFile}
882
                  style={{ marginRight: '20px' }}
皮倩雯's avatar
皮倩雯 committed
883 884 885 886 887 888
                >
                  导入
                </Button>
                <Button
                  type="primary"
                  icon={<DownloadOutlined />}
889 890 891 892 893 894 895 896 897
                  onClick={ExportDataAll}
                  style={{ marginRight: '20px' }}
                >
                  导出全部
                </Button>
                {/* <Button
                  type="primary"
                  icon={<DeleteOutlined />}
                  onClick={multDeleteData}
皮倩雯's avatar
皮倩雯 committed
898 899
                  style={{ marginLeft: '20px' }}
                >
900
                  删除
901
                </Button>
902 903 904 905 906 907 908 909 910 911 912
               
                 */}
                <Dropdown
                  overlay={userButtonMenu}
                  disabled={multiOperate}
                  style={{ marginRight: '20px' }}
                >
                  <Button type={multiOperateButtonType}>
                    模型批量操作 <DownOutlined />
                  </Button>
                </Dropdown>
皮倩雯's avatar
皮倩雯 committed
913 914 915 916 917 918 919 920
              </div>
            </div>
            <Table
              rowSelection={{ ...rowSelection, selectedRowKeys }}
              rowClassName={setRowClassName}
              size="small"
              expandIconAsCell={false}
              expandIconColumnIndex={-1}
921
              rowKey={record => record.ID}
皮倩雯's avatar
皮倩雯 committed
922 923
              locale={zhCN}
              bordered
924
              expandedRowKeys={selectGroup.map(item => item.ID)}
皮倩雯's avatar
皮倩雯 committed
925 926 927 928
              // expandRowByClick
              columns={columns}
              dataSource={tableData}
              loading={tableLoading}
929 930
              style={{ minWidth: '100%' }}
              scroll={{ y: 'calc(100vh - 262px)', x: '800px' }}
皮倩雯's avatar
皮倩雯 committed
931 932
              onExpand={onUnfold}
              onRow={record => ({
933 934 935 936
                onDoubleClick: event => {
                  event.stopPropagation();
                  onedit(record);
                }, // 双击
皮倩雯's avatar
皮倩雯 committed
937 938 939 940 941
                onClick: e => {
                  setSelectColor(record);
                },
              })}
              pagination={{
942 943 944 945
                showTotal: (total, range) => {
                  // console.log(range);
                  return `共 ${totalData} 条`;
                },
皮倩雯's avatar
皮倩雯 committed
946 947 948 949
                pageSizeOptions: [10, 20, 50, 100],
                defaultPageSize: 10,
                showQuickJumper: true,
                showSizeChanger: true,
950 951 952 953
                current: page,
                onChange: (page, pageSize) => {
                  setPage(page);
                },
皮倩雯's avatar
皮倩雯 committed
954 955 956 957 958 959 960 961 962
              }}
            />
          </div>
        </div>
      </Card>
      {/* 新增模板类型 */}
      <AddModal
        visible={addModalVisible}
        onCancel={() => setAddModalVisible(false)}
963
        callBackSubmit={addBack}
皮倩雯's avatar
皮倩雯 committed
964 965 966 967 968
      />
      <EditModal
        visible={editModalVisible}
        onCancel={() => setEditModalVisible(false)}
        changeObj={changeObj}
969
        callBackSubmit={editBack}
皮倩雯's avatar
皮倩雯 committed
970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016
      />
      <AddTemplate
        visible={addTemplateVisible}
        onClose={() => setAddTemplateVisible(false)}
        treeData={treeData}
        placement="right"
        pickItem={pickItem}
        callBackSubmit={onAddTemplateSubmit}
      />
      <ChildAddTemplate
        visible={childAddTemplateVisible}
        onClose={() => setChildAddTemplateVisible(false)}
        treeData={treeData}
        placement="right"
        pickItem={pickItem}
        obj={obj}
        callBackSubmit={onChildAddTemplateSubmit}
      />
      <EditTemplate
        visible={editVisible}
        onClose={() => setEditVisible(false)}
        treeData={treeData}
        placement="right"
        pickItem={pickItem}
        obj={obj}
        callBackSubmit={onEditTemplateSubmit}
      />
      <Modal
        visible={deleteModalVisible}
        onCancel={() => setDeleteModalVisible(false)}
        title="删除模型类型"
        okText="确认"
        cancelText="取消"
        onOk={deleteModalData}
      >
        <span>
          是否删除<span style={{ color: 'red' }}>{changeObj.name}</span>
        </span>
      </Modal>
      <Modal
        visible={deleteVisible}
        onCancel={() => setDeleteVisible(false)}
        title="删除"
        okText="确认"
        cancelText="取消"
        onOk={deleteData}
      >
1017
        <span>是否删除该模型</span>
皮倩雯's avatar
皮倩雯 committed
1018 1019 1020 1021 1022 1023 1024 1025 1026
      </Modal>
      <Modal
        visible={multDeleteVisible}
        onCancel={() => setMultDeleteVisible(false)}
        title="批量删除"
        okText="确认"
        cancelText="取消"
        onOk={multDelete}
      >
1027
        <span>是否批量删除所选模型</span>
皮倩雯's avatar
皮倩雯 committed
1028 1029 1030 1031 1032 1033
      </Modal>
      <ImportModal
        visible={importVisible}
        onCancel={() => setImportVisible(false)}
        callBackSubmit={onImportSubmit}
      />
1034 1035 1036 1037 1038 1039
      <AssociationModel
        visible={associationVisible}
        obj={obj}
        onCancel={() => setAssociationVisible(false)}
        callBackSubmit={onAssociationSubmit}
      />
皮倩雯's avatar
皮倩雯 committed
1040 1041 1042 1043
    </div>
  );
};
export default DrawBoardManage;