index.jsx 68.6 KB
Newer Older
TZW's avatar
TZW committed
1 2 3 4
/* 设备台账
 * @Author: Li Hanlin
 * @Date: 2022-11-10 09:39:56
 * @Last Modified by: Li Hanlin
TZW's avatar
TZW committed
5
 * @Last Modified time: 2023-01-11 16:49:41
TZW's avatar
TZW committed
6 7
 */

wuhao's avatar
wuhao committed
8
import * as React from 'react';
TZW's avatar
TZW committed
9
import { useState, useMemo, useRef, useEffect } from 'react';
wuhao's avatar
wuhao committed
10 11 12 13
import DrawerPro from '@/components/DrawerPro';
import AutoTable from '@/components/AutoTable';
import PremButton from '@/components/PremButton';
import getcolumns from './columns';
TZW's avatar
TZW committed
14
import { doFetch } from '@/utils/doFetch';
TZW's avatar
TZW committed
15
import { message, Dropdown, Menu, Layout, Button, Image, Space, Divider, Tabs } from 'antd';
TZW's avatar
TZW committed
16
import TreeRender from '@/components/TreeRender';
TZW's avatar
TZW committed
17
import { ProDescriptions } from '@ant-design/pro-components';
TZW's avatar
TZW committed
18
import InitForm from '@/components/InitForm';
TZW's avatar
TZW committed
19
import ExtendField from '@/components/ExtendField';
wuhao's avatar
wuhao committed
20

TZW's avatar
TZW committed
21
const { Sider, Content } = Layout;
TZW's avatar
TZW committed
22

TZW's avatar
TZW committed
23
function Model(props) {
wuhao's avatar
wuhao committed
24
  const actionRef = useRef(),
TZW's avatar
TZW committed
25 26 27 28
    formRef = useRef(),
    [drawer, setDrawer] = useState({
      visible: false,
    }),
TZW's avatar
TZW committed
29
    [extraparams, setextraparams] = useState({}),
TZW's avatar
TZW committed
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
    [currDrawer, setCurrDrawer] = useState({
      visible: false,
    }),
    currfields = {
      1: [
        {
          title: '操作人',
          dataIndex: 'updateUserName',
          key: 'updateUserName',
        },
        {
          title: '操作时间',
          dataIndex: 'updateTime',
          key: 'updateTime',
        },
        {
          title: '改造日期',
          dataIndex: 'reformDate',
          key: 'reformDate',
          valueType: 'date',
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
        {
          title: '改造承包商',
          dataIndex: 'supplierId',
          key: 'supplierId',
          valueType: 'select',
          options: {
            path: '/asset/equipmentSupplier/query/selection',
            params: {},
wuhao's avatar
wuhao committed
60
          },
TZW's avatar
TZW committed
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
          formItemProps: {
            rules: [
              {
                required: true,
                message: '此项为必填项',
              },
            ],
          },
        },
        {
          title: '改造内容',
          dataIndex: 'reformContent',
          key: 'reformContent',
          valueType: 'textarea',
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
        {
TZW's avatar
TZW committed
78
          title: '上传文件',
TZW's avatar
TZW committed
79
          key: 'urlIds',
TZW's avatar
TZW committed
80
          valueType: 'uploadDragger',
TZW's avatar
TZW committed
81 82
          // column: { xs: 1, sm: 2, md: 3 },
          span: '3',
TZW's avatar
TZW committed
83
          fieldProps: {
TZW's avatar
TZW committed
84
            maxCount: 5,
TZW's avatar
TZW committed
85 86 87 88 89 90 91 92 93 94
          },
          formItemProps: {
            rules: [
              {
                required: true,
                message: '此项为必填项',
              },
            ],
          },
          render: (text, row) => {
TZW's avatar
TZW committed
95 96 97 98 99
            return (
              <div>
                {row?.urlIds.map((it) => (
                  // eslint-disable-next-line react/jsx-key
                  <div style={{ marginBottom: '8px' }}>
TZW's avatar
TZW committed
100 101 102
                    <a href={it?.url} download target="_blank" rel="noopener noreferrer">
                      {it?.name}
                    </a>
TZW's avatar
TZW committed
103 104 105 106
                  </div>
                ))}
              </div>
            );
TZW's avatar
TZW committed
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
          },
        },
      ],
      2: [
        {
          title: '操作人',
          dataIndex: 'updateUserName',
          key: 'updateUserName',
        },
        {
          title: '操作时间',
          dataIndex: 'updateTime',
          key: 'updateTime',
        },
        {
          title: '报废日期',
          dataIndex: 'scrapDate',
          key: 'scrapDate',
          valueType: 'date',
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
        {
          title: '报废原因',
          dataIndex: 'scrapReason',
          key: 'scrapReason',
          valueType: 'textarea',
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
        {
TZW's avatar
TZW committed
136
          title: '上传文件',
TZW's avatar
TZW committed
137
          key: 'urlIds',
TZW's avatar
TZW committed
138
          valueType: 'uploadDragger',
TZW's avatar
TZW committed
139
          span: '3',
TZW's avatar
TZW committed
140 141 142
          formItemProps: {
            rules: [
              {
TZW's avatar
TZW committed
143
                required: false,
TZW's avatar
TZW committed
144 145 146 147 148
                message: '此项为必填项',
              },
            ],
          },
          fieldProps: {
TZW's avatar
TZW committed
149
            maxCount: 5,
TZW's avatar
TZW committed
150 151
          },
          render: (text, row) => {
TZW's avatar
TZW committed
152 153 154 155 156
            return (
              <div>
                {row?.urlIds.map((it) => (
                  // eslint-disable-next-line react/jsx-key
                  <div style={{ marginBottom: '8px' }}>
TZW's avatar
TZW committed
157 158 159
                    <a href={it?.url} download target="_blank" rel="noopener noreferrer">
                      {it?.name}
                    </a>
TZW's avatar
TZW committed
160 161 162 163
                  </div>
                ))}
              </div>
            );
TZW's avatar
TZW committed
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
          },
        },
      ],
      3: [
        {
          title: '操作人',
          dataIndex: 'updateUserName',
          key: 'updateUserName',
        },
        {
          title: '操作时间',
          dataIndex: 'updateTime',
          key: 'updateTime',
        },
        {
          title: '调入公司',
TZW's avatar
TZW committed
180
          dataIndex: 'toOrganizationName',
TZW's avatar
TZW committed
181 182 183 184 185 186 187
          key: 'toOrganizationId',
          valueType: 'select',
          options: { path: '/auth/sysDepartment/query/organization/selectbox', params: {} },
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
        {
          title: '调入部门',
TZW's avatar
TZW committed
188 189
          valueType: 'treeSelect',
          dataIndex: 'toDepartmentName',
TZW's avatar
TZW committed
190 191
          key: 'toDepartmentId',
          options: {
TZW's avatar
TZW committed
192
            path: '/auth/sysDepartment/query/children/tree',
TZW's avatar
TZW committed
193 194 195 196 197 198 199
            linkParams: {
              toOrganizationId: 'parentId',
            },
          },
        },
        {
          title: '调入工厂',
TZW's avatar
TZW committed
200
          dataIndex: 'toFactoryName',
TZW's avatar
TZW committed
201 202 203 204 205 206 207
          key: 'toFactoryId',
          valueType: 'select',
          options: { path: '/auth/sysFactory/getAllFactorySelection', params: {} },
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
        {
          title: '调入车间',
TZW's avatar
TZW committed
208
          dataIndex: 'toShopName',
TZW's avatar
TZW committed
209 210 211 212 213 214 215 216 217 218 219 220
          valueType: 'select',
          options: {
            path: '/auth/sysShop/getShopSelectionByFactory',
            linkParams: {
              toFactoryId: 'factoryId',
            },
          },
          key: 'toShopId',
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
        {
          title: '调入工段',
TZW's avatar
TZW committed
221
          dataIndex: 'toSectionName',
TZW's avatar
TZW committed
222 223 224 225 226 227 228 229 230 231 232
          key: 'toSectionId',
          valueType: 'select',
          options: {
            path: '/auth/sysSection/getAllSectionSelectionByShop',
            linkParams: {
              toShopId: 'shopId',
            },
          },
        },
        {
          title: '调入产线',
TZW's avatar
TZW committed
233
          dataIndex: 'toProductLineName',
TZW's avatar
TZW committed
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 271 272 273 274 275 276
          valueType: 'select',
          key: 'toProductLineId',
          options: {
            path: '/auth/sysProductionLine/getAllProductLineSelectionByShop',
            linkParams: {
              toShopId: 'shopId',
            },
          },
        },
        {
          title: '调入位置号',
          dataIndex: 'toPositionNo',
          valueType: 'input',
          key: 'toPositionNo',
        },
        {
          title: '调拨日期',
          dataIndex: 'transferDate',
          key: 'transferDate',
          valueType: 'date',
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
        {
          title: '调拨原因',
          dataIndex: 'transferReason',
          key: 'transferReason',
          valueType: 'textarea',
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
      ],
      4: [
        {
          title: '操作人',
          dataIndex: 'updateUserName',
          key: 'updateUserName',
        },
        {
          title: '操作时间',
          dataIndex: 'updateTime',
          key: 'updateTime',
        },
        {
          title: '借用公司',
TZW's avatar
TZW committed
277 278
          dataIndex: 'toOrganizationName',
          key: 'toOrganizationName',
TZW's avatar
TZW committed
279 280 281
        },
        {
          title: '借用部门',
TZW's avatar
TZW committed
282
          valueType: 'treeSelect',
TZW's avatar
TZW committed
283 284
          dataIndex: 'toDepartmentName',
          key: 'toDepartmentName',
TZW's avatar
TZW committed
285 286 287
        },
        {
          title: '借用工厂',
TZW's avatar
TZW committed
288 289
          dataIndex: 'toFactoryName',
          key: 'toFactoryName',
TZW's avatar
TZW committed
290 291 292
        },
        {
          title: '借用车间',
TZW's avatar
TZW committed
293
          dataIndex: 'toShopName',
TZW's avatar
TZW committed
294
          valueType: 'select',
TZW's avatar
TZW committed
295
          key: 'toShopName',
TZW's avatar
TZW committed
296 297 298
        },
        {
          title: '借用工段',
TZW's avatar
TZW committed
299 300
          dataIndex: 'toSectionName',
          key: 'toSectionName',
TZW's avatar
TZW committed
301 302 303
        },
        {
          title: '借用产线',
TZW's avatar
TZW committed
304 305
          dataIndex: 'toProductLineName',
          key: 'toProductLineName',
TZW's avatar
TZW committed
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 340 341 342 343 344 345 346 347
        },
        {
          title: '借用位置号',
          dataIndex: 'toPositionNo',
          valueType: 'input',
          key: 'toPositionNo',
        },
        {
          title: '借用日期',
          dataIndex: 'borrowDate',
          key: 'borrowDate',
          valueType: 'date',
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
        {
          title: '预计归还日期',
          dataIndex: 'planReturnDate',
          key: 'planReturnDate',
          valueType: 'date',
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
        {
          title: '借用原因',
          dataIndex: 'borrowReason',
          key: 'borrowReason',
          valueType: 'textarea',
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
      ],
      5: [
        {
          title: '操作人',
          dataIndex: 'updateUserName',
          key: 'updateUserName',
        },
        {
          title: '操作时间',
          dataIndex: 'updateTime',
          key: 'updateTime',
        },
        {
          title: '接收公司',
TZW's avatar
TZW committed
348 349
          dataIndex: 'returnOrganizationName',
          key: 'returnOrganizationName',
TZW's avatar
TZW committed
350 351 352 353 354 355
          valueType: 'select',
          options: { path: '/auth/sysDepartment/query/organization/selectbox', params: {} },
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
        {
          title: '接收部门',
TZW's avatar
TZW committed
356
          valueType: 'treeSelect',
TZW's avatar
TZW committed
357 358
          dataIndex: 'returnDepartmentName',
          key: 'returnDepartmentName',
TZW's avatar
TZW committed
359
          options: {
TZW's avatar
TZW committed
360
            path: '/auth/sysDepartment/query/children/tree',
TZW's avatar
TZW committed
361 362 363 364 365 366 367
            linkParams: {
              returnOrganizationId: 'parentId',
            },
          },
        },
        {
          title: '接收工厂',
TZW's avatar
TZW committed
368 369
          dataIndex: 'returnFactoryName',
          key: 'returnFactoryName',
TZW's avatar
TZW committed
370 371 372 373 374 375
          valueType: 'select',
          options: { path: '/auth/sysFactory/getAllFactorySelection', params: {} },
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
        {
          title: '接收车间',
TZW's avatar
TZW committed
376
          dataIndex: 'returnShopName',
TZW's avatar
TZW committed
377 378 379 380 381 382 383 384 385 386 387 388
          valueType: 'select',
          options: {
            path: '/auth/sysShop/getShopSelectionByFactory',
            linkParams: {
              returnFactoryId: 'factoryId',
            },
          },
          key: 'returnShopId',
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
        {
          title: '接收工段',
TZW's avatar
TZW committed
389
          dataIndex: 'returnSectionName',
TZW's avatar
TZW committed
390 391 392 393 394 395 396 397 398 399 400
          key: 'returnSectionId',
          valueType: 'select',
          options: {
            path: '/auth/sysSection/getAllSectionSelectionByShop',
            linkParams: {
              returnShopId: 'shopId',
            },
          },
        },
        {
          title: '接收产线',
TZW's avatar
TZW committed
401
          dataIndex: 'returnProductLineName',
TZW's avatar
TZW committed
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 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
          valueType: 'select',
          key: 'returnProductLineId',
          options: {
            path: '/auth/sysProductionLine/getAllProductLineSelectionByShop',
            linkParams: {
              returnShopId: 'shopId',
            },
          },
        },
        {
          title: '接收位置号',
          dataIndex: 'returnPositionNo',
          valueType: 'input',
          key: 'returnPositionNo',
        },
        {
          title: '实际归还日期',
          dataIndex: 'realReturnDate',
          key: 'realReturnDate',
          valueType: 'date',
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
        {
          title: '备注',
          dataIndex: 'remark',
          key: 'remark',
          valueType: 'textarea',
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
      ],
    },
    urlParams = {
      save: '/asset/equipment/save',
      remove: '/asset/equipment/deleteById',
      list: '/asset/equipment/queryList',
      detail: '/asset/equipment/detail',
    },
    urlParams_childEquipment = {
      list: '/asset/equipment/children/queryList',
      checked: '/asset/equipment/children/selected/queryList',
      save: '/asset/equipmentChildren/save',
    },
    urlParams_resume = {
      save: '/asset/equipmentLog/save',
      list: '/asset/equipmentLog/queryEquipmentLogPage',
      detail: '/asset/equipmentLog/query/resumeDetail',
    },
    urlParams_correlation = {
      zsb: '/asset/equipment/detail/children/page',
      fsb: '/asset/equipment/detail/parent/page',
    };
wuhao's avatar
wuhao committed
453

TZW's avatar
TZW committed
454 455 456 457 458 459 460 461 462 463 464 465 466 467
  function formatDate(date) {
    var myyear = date.getFullYear();
    var mymonth = date.getMonth() + 1;
    var myweekday = date.getDate();

    if (mymonth < 10) {
      mymonth = '0' + mymonth;
    }
    if (myweekday < 10) {
      myweekday = '0' + myweekday;
    }
    return myyear + '-' + mymonth + '-' + myweekday; //想要什么格式都可以随便自己拼
  }

wuhao's avatar
wuhao committed
468 469 470 471 472 473
  const edit = (text, row, _, action) => {
    return (
      <PremButton
        btn={{
          size: 'small',
          onClick: () => {
TZW's avatar
TZW committed
474
            setDrawer((s) => ({
wuhao's avatar
wuhao committed
475 476 477
              ...s,
              visible: true,
              title: '编辑',
TZW's avatar
TZW committed
478
              val: 'only',
TZW's avatar
TZW committed
479
              type: 'edit',
TZW's avatar
TZW committed
480
              item: row,
wuhao's avatar
wuhao committed
481 482 483 484 485 486 487 488 489 490 491 492 493
            }));
          },
        }}
      >
        编辑
      </PremButton>
    );
  };

  const remove = (text, row, _, action) => {
    return (
      <PremButton
        pop={{
TZW's avatar
TZW committed
494
          title: '是否删除该设备?',
wuhao's avatar
wuhao committed
495 496
          okText: '确认',
          cancelText: '取消',
TZW's avatar
TZW committed
497 498 499 500 501 502 503 504 505 506
          onConfirm: async () => {
            let res = await doFetch({ url: urlParams.remove, params: { id: row.id } });
            if (res.code === '0000') {
              message.success('删除成功!');
              setDrawer((s) => ({
                ...s,
                visible: false,
              }));
              actionRef.current.reload();
            }
wuhao's avatar
wuhao committed
507 508 509 510 511 512 513 514 515 516 517 518
          },
        }}
        btn={{
          size: 'small',
          type: 'danger',
        }}
      >
        删除
      </PremButton>
    );
  };

TZW's avatar
TZW committed
519 520 521 522 523 524 525 526 527 528 529
  const more = (text, row, _, action) => {
    const menu = (
      <Menu
        items={[
          {
            label: (
              <a
                onClick={() => {
                  setDrawer((s) => ({
                    ...s,
                    visible: true,
TZW's avatar
TZW committed
530 531 532 533
                    type: 'editChildEquipment',
                    item: {
                      id: row.id,
                    },
TZW's avatar
TZW committed
534 535 536 537 538 539 540 541 542 543 544
                    val: 'only',
                    title: '编辑子设备',
                  }));
                }}
              >
                编辑子设备
              </a>
            ),
            key: '0',
          },
          {
TZW's avatar
TZW committed
545 546 547 548 549 550 551 552 553
            label: (
              <a
                onClick={() => {
                  setDrawer((s) => ({
                    ...s,
                    visible: true,
                    type: 'resume',
                    item: {
                      id: row.id,
TZW's avatar
TZW committed
554 555
                      reformDate: formatDate(new Date()),
                      scrapDate: formatDate(new Date()),
TZW's avatar
TZW committed
556 557 558
                      transferDate: formatDate(new Date()),
                      borrowDate: formatDate(new Date()),
                      realReturnDate: formatDate(new Date()),
TZW's avatar
TZW committed
559 560 561 562 563 564 565 566 567
                    },
                    val: 'only',
                    title: '履历登记',
                  }));
                }}
              >
                履历登记
              </a>
            ),
TZW's avatar
TZW committed
568 569 570 571 572 573 574 575 576 577 578 579 580 581
            key: '1',
          },
          {
            label: <a>关联备件(暂缓)</a>,
            key: '2',
          },
          {
            label: <a>寿命件台账(暂缓)</a>,
            key: '3',
          },
        ]}
      />
    );
    return (
TZW's avatar
TZW committed
582 583 584 585
      <Dropdown
        overlay={menu}
        trigger={['click']}
        arrow={true}
TZW's avatar
TZW committed
586
        getPopupContainer={() => containderef.current}
TZW's avatar
TZW committed
587 588 589 590 591 592 593 594 595 596 597
      >
        <Button size="small">更多</Button>
      </Dropdown>
    );
  };

  //设备详情
  const Detail = () => {
    const [activeTab, setactiveTab] = useState(1);
    // 基础信息
    const BaseInfo = () => {
TZW's avatar
TZW committed
598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708
      const columns = [
        {
          title: '设备编号',
          dataIndex: 'equipmentNo',
          key: 'equipmentNo',
        },
        {
          title: '设备名称',
          dataIndex: 'equipmentName',
          key: 'equipmentName',
        },
        {
          title: '位置号',
          dataIndex: 'positionNo',
          key: 'positionNo',
        },
        {
          title: '设备类型',
          dataIndex: 'equipmentTypeName',
          key: 'equipmentTypeId',
        },
        {
          title: '状态',
          dataIndex: 'statusName',
          key: 'statusName',
          span: 2,
        },
        {
          title: '公司名称',
          dataIndex: 'organizationName',
          key: 'organizationId',
        },
        {
          title: '部门名称',
          dataIndex: 'departmentName',
          key: 'departmentId',
        },
        {
          title: '工厂名称',
          dataIndex: 'factoryName',
          key: 'factoryId',
        },
        {
          title: '车间名称',
          dataIndex: 'shopName',
          key: 'shopId',
        },
        {
          title: '工段名称',
          dataIndex: 'sectionName',
          key: 'sectionId',
        },
        {
          title: '产线名称',
          dataIndex: 'productLineName',
          key: 'productLineName',
        },
        {
          title: '供应商',
          dataIndex: 'supplierName',
          key: 'supplierId',
        },
        {
          title: '设备原值',
          dataIndex: 'equipmentWorth',
          key: 'equipmentWorth',
        },
        {
          title: '安装投产日期',
          dataIndex: 'productDate',
          key: 'productDate',
        },
        {
          title: '图片',
          dataIndex: 'pictureUrl',
          key: 'pictureUrl',
          render: (text, row) => <Image width={70} src={row.pictureUrl} />,
        },
        {
          title: '二维码',
          dataIndex: 'qrCodeUrl',
          key: 'qrCodeUrl',
          render: (text, row) => <Image width={70} src={row.qrCodeUrl} />,
        },
      ];
      const [newfieldscolumns, setnewfieldscolumns] = useState(columns);
      const selectValueType = (type, options) => {
        switch (type) {
          case 1:
            return {
              valueType: 'input',
            };
          case 2:
            return {
              valueType: 'select',
              options,
            };
          case 3:
            return {
              valueType: 'radio',
              options,
            };
          case 4:
            return {
              valueType: 'select',
              options,
            };
          default:
            break;
        }
      };
TZW's avatar
TZW committed
709
      const [request, setrequest] = useState();
TZW's avatar
TZW committed
710 711
      useEffect(() => {
        const fn = async () => {
TZW's avatar
TZW committed
712 713
            console.log('d');

TZW's avatar
TZW committed
714 715 716 717
            let res = await doFetch({
              url: '/base/paFormField/queryList',
              params: {
                formId: '2',
TZW's avatar
TZW committed
718
              },
TZW's avatar
TZW committed
719 720 721
            });
            if (res?.data?.dataList) {
              let column = [];
wuhao's avatar
wuhao committed
722
              res?.data?.dataList?.forEach?.((el) => {
TZW's avatar
TZW committed
723 724 725 726 727 728
                column.push({
                  ...selectValueType(el.fieldChar, el.valueList),
                  title: el.fieldName,
                  dataIndex: el.id,
                  key: el.id,
                });
TZW's avatar
TZW committed
729
              });
TZW's avatar
TZW committed
730 731 732 733 734 735 736
              setnewfieldscolumns(column);
            }
          },
          fn2 = async () => {
            const res = await doFetch({
              url: urlParams.detail,
              params: { id: drawer?.item?.id },
TZW's avatar
TZW committed
737
            });
TZW's avatar
TZW committed
738
            let obj = {};
wuhao's avatar
wuhao committed
739
            res?.data?.data['equipmentCharList']?.forEach?.((it) => {
TZW's avatar
TZW committed
740
              obj[it?.fieldId] = it?.fieldRealValue;
TZW's avatar
TZW committed
741 742 743 744 745 746 747 748 749 750 751 752
            });
            console.log('drawerpro:', {
              ...(res?.data?.data ?? {}),
              ...obj,
            });
            setrequest(
              {
                ...(res?.data?.data ?? {}),
                ...obj,
              } ?? {},
            );
          };
TZW's avatar
TZW committed
753
        fn();
TZW's avatar
TZW committed
754
        fn2();
TZW's avatar
TZW committed
755
      }, []);
TZW's avatar
TZW committed
756 757
      return (
        <>
TZW's avatar
TZW committed
758
          <ProDescriptions dataSource={request} columns={columns} />
TZW's avatar
TZW committed
759
          <Divider />
TZW's avatar
TZW committed
760 761 762 763
          <h3 className="page-title" style={{ marginBottom: 16 }}>
            扩展字段
          </h3>
          <ProDescriptions dataSource={request} columns={newfieldscolumns} />
TZW's avatar
TZW committed
764 765 766 767 768 769 770 771 772 773 774 775 776 777
        </>
      );
    };
    // 相关设备
    const Correlation = () => {
      return (
        <>
          <AutoTable
            pagetitle="子设备"
            columns={[
              {
                title: '设备编号',
                dataIndex: 'equipmentNo',
                key: 'equipmentNo',
TZW's avatar
TZW committed
778
                search: false,
wuhao's avatar
wuhao committed
779

TZW's avatar
TZW committed
780 781 782 783 784 785
                width: 120,
                formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
              },
              {
                title: '设备名称',
                dataIndex: 'equipmentName',
TZW's avatar
TZW committed
786
                search: false,
wuhao's avatar
wuhao committed
787

TZW's avatar
TZW committed
788 789 790 791 792 793
                width: 120,
                key: 'equipmentName',
                formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
              },
              {
                title: '公司名称',
wuhao's avatar
wuhao committed
794

TZW's avatar
TZW committed
795
                search: false,
TZW's avatar
TZW committed
796 797 798 799 800 801 802 803 804 805
                dataIndex: 'organizationName',
                width: 120,
                key: 'organizationId',
                valueType: 'select',
                options: { path: '/auth/sysDepartment/query/organization/selectbox', params: {} },
                formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
              },
              {
                title: '部门名称',
                width: 120,
TZW's avatar
TZW committed
806
                search: false,
wuhao's avatar
wuhao committed
807

TZW's avatar
TZW committed
808
                valueType: 'treeSelect',
TZW's avatar
TZW committed
809 810 811
                dataIndex: 'departmentName',
                key: 'departmentId',
                options: {
TZW's avatar
TZW committed
812
                  path: '/auth/sysDepartment/query/children/tree',
TZW's avatar
TZW committed
813 814 815 816 817 818 819 820
                  linkParams: {
                    organizationId: 'parentId',
                  },
                },
              },
              {
                title: '工厂名称',
                dataIndex: 'factoryName',
TZW's avatar
TZW committed
821
                search: false,
TZW's avatar
TZW committed
822 823
                key: 'factoryId',
                width: 120,
wuhao's avatar
wuhao committed
824

TZW's avatar
TZW committed
825 826 827 828 829 830 831
                valueType: 'select',
                options: { path: '/auth/sysFactory/getAllFactorySelection', params: {} },
                formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
              },
              {
                title: '车间名称',
                dataIndex: 'shopName',
wuhao's avatar
wuhao committed
832

TZW's avatar
TZW committed
833
                search: false,
TZW's avatar
TZW committed
834 835 836 837 838 839 840 841 842 843 844 845 846
                width: 120,
                valueType: 'select',
                options: {
                  path: '/auth/sysShop/getShopSelectionByFactory',
                  linkParams: {
                    factoryId: '',
                  },
                },
                key: 'shopId',
                formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
              },
              {
                title: '工段名称',
TZW's avatar
TZW committed
847
                search: false,
TZW's avatar
TZW committed
848 849
                width: 120,
                dataIndex: 'sectionName',
wuhao's avatar
wuhao committed
850

TZW's avatar
TZW committed
851 852 853 854 855 856 857 858 859 860 861
                key: 'sectionId',
                valueType: 'select',
                options: {
                  path: '/auth/sysSection/getAllSectionSelectionByShop',
                  linkParams: {
                    shopId: '',
                  },
                },
              },
              {
                title: '产线名称',
TZW's avatar
TZW committed
862
                search: false,
TZW's avatar
TZW committed
863 864 865 866
                width: 120,
                dataIndex: 'productLineName',
                valueType: 'select',
                key: 'productLineName',
wuhao's avatar
wuhao committed
867

TZW's avatar
TZW committed
868
                options: {
TZW's avatar
TZW committed
869
                  path: '/auth/sysProductionLine/getAllProductLineSelectionByShop',
TZW's avatar
TZW committed
870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886
                  linkParams: {
                    shopId: '',
                  },
                },
              },
            ]}
            path={urlParams_correlation.zsb}
            params={{ id: drawer?.item?.id }}
            resizeable={false}
          />
          <Divider />
          <AutoTable
            pagetitle="父设备"
            columns={[
              {
                title: '设备编号',
                dataIndex: 'equipmentNo',
TZW's avatar
TZW committed
887
                search: false,
TZW's avatar
TZW committed
888
                key: 'equipmentNo',
wuhao's avatar
wuhao committed
889

TZW's avatar
TZW committed
890 891 892 893 894 895
                width: 120,
                formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
              },
              {
                title: '设备名称',
                dataIndex: 'equipmentName',
TZW's avatar
TZW committed
896
                search: false,
wuhao's avatar
wuhao committed
897

TZW's avatar
TZW committed
898 899 900 901 902 903
                width: 120,
                key: 'equipmentName',
                formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
              },
              {
                title: '公司名称',
wuhao's avatar
wuhao committed
904

TZW's avatar
TZW committed
905 906 907
                dataIndex: 'organizationName',
                width: 120,
                key: 'organizationId',
TZW's avatar
TZW committed
908
                search: false,
TZW's avatar
TZW committed
909 910 911 912 913 914 915
                valueType: 'select',
                options: { path: '/auth/sysDepartment/query/organization/selectbox', params: {} },
                formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
              },
              {
                title: '部门名称',
                width: 120,
wuhao's avatar
wuhao committed
916

TZW's avatar
TZW committed
917
                search: false,
TZW's avatar
TZW committed
918
                valueType: 'treeSelect',
TZW's avatar
TZW committed
919 920 921
                dataIndex: 'departmentName',
                key: 'departmentId',
                options: {
TZW's avatar
TZW committed
922
                  path: '/auth/sysDepartment/query/children/tree',
TZW's avatar
TZW committed
923 924 925 926 927 928 929
                  linkParams: {
                    organizationId: 'parentId',
                  },
                },
              },
              {
                title: '工厂名称',
TZW's avatar
TZW committed
930
                search: false,
TZW's avatar
TZW committed
931 932 933
                dataIndex: 'factoryName',
                key: 'factoryId',
                width: 120,
wuhao's avatar
wuhao committed
934

TZW's avatar
TZW committed
935 936 937 938 939 940 941
                valueType: 'select',
                options: { path: '/auth/sysFactory/getAllFactorySelection', params: {} },
                formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
              },
              {
                title: '车间名称',
                dataIndex: 'shopName',
TZW's avatar
TZW committed
942
                search: false,
wuhao's avatar
wuhao committed
943

TZW's avatar
TZW committed
944 945 946 947 948 949 950 951 952 953 954 955 956 957 958
                width: 120,
                valueType: 'select',
                options: {
                  path: '/auth/sysShop/getShopSelectionByFactory',
                  linkParams: {
                    factoryId: '',
                  },
                },
                key: 'shopId',
                formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
              },
              {
                title: '工段名称',
                width: 120,
                dataIndex: 'sectionName',
wuhao's avatar
wuhao committed
959

TZW's avatar
TZW committed
960
                key: 'sectionId',
TZW's avatar
TZW committed
961
                search: false,
TZW's avatar
TZW committed
962 963 964 965 966 967 968 969 970 971 972 973 974
                valueType: 'select',
                options: {
                  path: '/auth/sysSection/getAllSectionSelectionByShop',
                  linkParams: {
                    shopId: '',
                  },
                },
              },
              {
                title: '产线名称',
                width: 120,
                dataIndex: 'productLineName',
                valueType: 'select',
TZW's avatar
TZW committed
975
                search: false,
TZW's avatar
TZW committed
976
                key: 'productLineName',
wuhao's avatar
wuhao committed
977

TZW's avatar
TZW committed
978
                options: {
TZW's avatar
TZW committed
979
                  path: '/auth/sysProductionLine/getAllProductLineSelectionByShop',
TZW's avatar
TZW committed
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 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064
                  linkParams: {
                    shopId: '',
                  },
                },
              },
            ]}
            path={urlParams_correlation.fsb}
            params={{ id: drawer?.item?.id }}
            resizeable={false}
          />
        </>
      );
    };
    //履历查询
    const Curritae = () => {
      return (
        <>
          <ProDescriptions
            title="设备信息"
            request={async () => {
              const { data } = await doFetch({
                url: urlParams.detail,
                params: { id: drawer?.item?.id },
              });
              return {
                success: true,
                data: data?.data,
              };
            }}
            columns={[
              {
                title: '设备编号',
                dataIndex: 'equipmentNo',
                key: 'equipmentNo',
              },
              {
                title: '设备名称',
                dataIndex: 'equipmentName',
                key: 'equipmentName',
              },
              {
                title: '位置号',
                dataIndex: 'positionNo',
                key: 'positionNo',
              },

              {
                title: '公司名称',
                dataIndex: 'organizationName',
                key: 'organizationId',
              },
              {
                title: '部门名称',
                dataIndex: 'departmentName',
                key: 'departmentId',
              },
              {
                title: '工厂名称',
                dataIndex: 'factoryName',
                key: 'factoryId',
              },
              {
                title: '车间名称',
                dataIndex: 'shopName',
                key: 'shopId',
              },
              {
                title: '工段名称',
                dataIndex: 'sectionName',
                key: 'sectionId',
              },
              {
                title: '产线名称',
                dataIndex: 'productLineName',
                key: 'productLineName',
              },
            ]}
          />
          <Divider />
          <AutoTable
            pagetitle="履历详情"
            columns={[
              {
                title: '操作时间',
                dataIndex: 'createTime',
TZW's avatar
TZW committed
1065
                key: 'operateTimeList',
TZW's avatar
TZW committed
1066
                width: 120,
TZW's avatar
TZW committed
1067
                searchValueType: 'dateRange',
TZW's avatar
TZW committed
1068 1069 1070 1071 1072 1073
                formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
              },
              {
                title: '履历类型',
                dataIndex: 'logTypeName',
                width: 120,
TZW's avatar
TZW committed
1074
                key: 'logType',
TZW's avatar
TZW committed
1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097
                valueType: 'select',
                options: [
                  {
                    label: '改造',
                    value: '1',
                  },
                  {
                    label: '报废',
                    value: '2',
                  },
                  {
                    label: '调拨',
                    value: '3',
                  },
                  {
                    label: '借用',
                    value: '4',
                  },
                  {
                    label: '归还',
                    value: '5',
                  },
                ],
TZW's avatar
TZW committed
1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156
                formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
              },
              {
                title: '相关单号',
                dataIndex: 'relateNo',
                width: 120,
                key: 'relateNo',
                formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
                render: (text, row) => {
                  return (
                    <a
                      onClick={() => {
                        setCurrDrawer((s) => ({
                          ...s,
                          visible: true,
                          item: row,
                          val: 'only',
                          title: `${row.logTypeName}详情`,
                        }));
                      }}
                    >
                      {row.relateNo}
                    </a>
                  );
                },
              },
            ]}
            path={urlParams_resume.list}
            params={{ equipmentId: drawer?.item?.id }}
            resizeable={false}
          />
        </>
      );
    };

    return (
      <>
        <Tabs
          activeKey={activeTab}
          onChange={setactiveTab}
          items={[
            {
              label: '基础信息',
              key: 1,
              children: <BaseInfo />,
            },
            {
              label: '相关设备',
              key: 2,
              children: <Correlation />,
            },
            {
              label: '履历查询',
              key: 3,
              children: <Curritae />,
            },
          ]}
        />
      </>
TZW's avatar
TZW committed
1157 1158 1159
    );
  };

TZW's avatar
TZW committed
1160
  // 子设备
TZW's avatar
TZW committed
1161 1162 1163 1164 1165 1166 1167 1168
  const EditChildEquipment = () => {
    const [selectArr, setSelectArr] = useState([]);
    useEffect(() => {
      const fun = async () => {
        const result = await doFetch({
          url: '/asset/equipment/children/selected/queryList',
          params: { id: drawer?.item?.id },
        });
TZW's avatar
TZW committed
1169
        // //console.log(result);
TZW's avatar
TZW committed
1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180
        if (!result?.data?.dataList.length == 0) {
          setSelectArr(result?.data?.dataList.map((it) => it.id));
        }
      };
      fun();
    }, []);
    const columns = [
      {
        title: '设备编号',
        dataIndex: 'equipmentNo',
        key: 'equipmentNo',
TZW's avatar
TZW committed
1181
        search: false,
wuhao's avatar
wuhao committed
1182

TZW's avatar
TZW committed
1183 1184 1185 1186 1187 1188
        width: 120,
        formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
      },
      {
        title: '设备名称',
        dataIndex: 'equipmentName',
wuhao's avatar
wuhao committed
1189

TZW's avatar
TZW committed
1190 1191 1192 1193 1194 1195
        width: 120,
        key: 'equipmentName',
        formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
      },
      {
        title: '公司名称',
wuhao's avatar
wuhao committed
1196

TZW's avatar
TZW committed
1197 1198 1199
        dataIndex: 'organizationName',
        width: 120,
        key: 'organizationId',
TZW's avatar
TZW committed
1200 1201 1202 1203
        fieldProps: {
          placeholder: '请选择',
          showSearch: true,
        },
TZW's avatar
TZW committed
1204 1205 1206 1207 1208 1209 1210
        valueType: 'select',
        options: { path: '/auth/sysDepartment/query/organization/selectbox', params: {} },
        formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
      },
      {
        title: '部门名称',
        width: 120,
wuhao's avatar
wuhao committed
1211

TZW's avatar
TZW committed
1212
        valueType: 'treeSelect',
TZW's avatar
TZW committed
1213
        dataIndex: 'departmentName',
TZW's avatar
TZW committed
1214 1215 1216 1217
        fieldProps: {
          placeholder: '请选择',
          showSearch: true,
        },
TZW's avatar
TZW committed
1218 1219
        key: 'departmentId',
        options: {
TZW's avatar
TZW committed
1220
          path: '/auth/sysDepartment/query/children/tree',
TZW's avatar
TZW committed
1221 1222 1223 1224 1225 1226 1227 1228 1229 1230
          linkParams: {
            organizationId: 'parentId',
          },
        },
      },
      {
        title: '工厂名称',
        dataIndex: 'factoryName',
        key: 'factoryId',
        width: 120,
TZW's avatar
TZW committed
1231 1232 1233 1234
        fieldProps: {
          placeholder: '请选择',
          showSearch: true,
        },
TZW's avatar
TZW committed
1235 1236 1237 1238 1239 1240 1241
        valueType: 'select',
        options: { path: '/auth/sysFactory/getAllFactorySelection', params: {} },
        formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
      },
      {
        title: '车间名称',
        dataIndex: 'shopName',
wuhao's avatar
wuhao committed
1242

TZW's avatar
TZW committed
1243
        width: 120,
TZW's avatar
TZW committed
1244 1245 1246 1247
        fieldProps: {
          placeholder: '请选择',
          showSearch: true,
        },
TZW's avatar
TZW committed
1248 1249 1250 1251 1252 1253 1254
        valueType: 'select',
        options: {
          path: '/auth/sysShop/getShopSelectionByFactory',
          linkParams: {
            factoryId: '',
          },
        },
TZW's avatar
TZW committed
1255
        search: false,
TZW's avatar
TZW committed
1256 1257 1258
        key: 'shopId',
        formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
      },
TZW's avatar
TZW committed
1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274
      {
        title: '车间名称',
        dataIndex: 'shopName',
        width: 120,
        valueType: 'select',
        fieldProps: {
          placeholder: '请选择',
          showSearch: true,
        },
        options: {
          path: '/auth/sysShop/getAllShopSelection',
        },
        key: 'shopId',
        hideInForm: true,
        hideInTable: true,
      },
TZW's avatar
TZW committed
1275 1276 1277 1278
      {
        title: '工段名称',
        width: 120,
        dataIndex: 'sectionName',
wuhao's avatar
wuhao committed
1279

TZW's avatar
TZW committed
1280
        key: 'sectionId',
TZW's avatar
TZW committed
1281 1282 1283 1284
        fieldProps: {
          placeholder: '请选择',
          showSearch: true,
        },
TZW's avatar
TZW committed
1285 1286 1287 1288 1289 1290 1291
        valueType: 'select',
        options: {
          path: '/auth/sysSection/getAllSectionSelectionByShop',
          linkParams: {
            shopId: '',
          },
        },
TZW's avatar
TZW committed
1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309
        search: false,
      },

      {
        title: '工段名称',
        width: 120,
        dataIndex: 'sectionName',
        key: 'sectionId',
        fieldProps: {
          placeholder: '请选择',
          showSearch: true,
        },
        valueType: 'select',
        options: {
          path: '/auth/sysSection/getAllSectionSelection',
        },
        hideInForm: true,
        hideInTable: true,
TZW's avatar
TZW committed
1310 1311 1312 1313 1314 1315 1316
      },
      {
        title: '产线名称',
        width: 120,
        dataIndex: 'productLineName',
        valueType: 'select',
        key: 'productLineName',
TZW's avatar
TZW committed
1317 1318 1319 1320
        fieldProps: {
          placeholder: '请选择',
          showSearch: true,
        },
wuhao's avatar
wuhao committed
1321

TZW's avatar
TZW committed
1322
        options: {
TZW's avatar
TZW committed
1323
          path: '/auth/sysProductionLine/getAllProductLineSelectionByShop',
TZW's avatar
TZW committed
1324 1325 1326 1327
          linkParams: {
            shopId: '',
          },
        },
TZW's avatar
TZW committed
1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344
        search: false,
      },
      {
        title: '产线名称',
        width: 120,
        dataIndex: 'productLineName',
        valueType: 'select',
        fieldProps: {
          placeholder: '请选择',
          showSearch: true,
        },
        key: 'productLineId',
        options: {
          path: '/auth/sysProductionLine/getAllProductLineSelection',
        },
        hideInForm: true,
        hideInTable: true,
TZW's avatar
TZW committed
1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418
      },
    ];
    return (
      <>
        <ProDescriptions
          request={async () => {
            const { data } = await doFetch({
              url: urlParams.detail,
              params: { id: drawer.item.id },
            });
            return {
              success: true,
              data: data.data,
            };
          }}
          columns={[
            {
              title: '设备编号',
              dataIndex: 'equipmentNo',
              key: 'equipmentNo',
            },
            {
              title: '设备名称',
              dataIndex: 'equipmentName',
              key: 'equipmentName',
            },
            {
              title: '位置号',
              dataIndex: 'positionNo',
              key: 'positionNo',
            },
            {
              title: '公司名称',
              dataIndex: 'organizationName',
              key: 'organizationId',
            },
            {
              title: '部门名称',
              dataIndex: 'departmentName',
              key: 'departmentId',
            },
            {
              title: '工厂名称',
              dataIndex: 'factoryName',
              key: 'factoryId',
            },
            {
              title: '车间名称',
              dataIndex: 'shopName',
              key: 'shopId',
            },
            {
              title: '工段名称',
              dataIndex: 'sectionName',
              key: 'sectionId',
            },
            {
              title: '产线名称',
              dataIndex: 'productLineName',
              key: 'productLineName',
            },
          ]}
        />
        <AutoTable
          pagetitle="选择子设备"
          columns={columns}
          path={urlParams_childEquipment.list}
          params={{ id: drawer?.item?.id }}
          resizeable={false}
          rowSelection={{
            type: 'checkbox',
            selectedRowKeys: selectArr,
            // defaultSelectedRowKeys: ,
            onSelect: (record, selected, selectedRows, nativeEvent) => {
TZW's avatar
TZW committed
1419
              //console.log('selectedRowKeys changed: ', record, selected, selectedRows);
TZW's avatar
TZW committed
1420 1421 1422 1423 1424
              setSelectArr(() => {
                return selectedRows.map((it) => it.id);
              });
            },
            onSelectAll: (selected, selectedRows, changeRows) => {
TZW's avatar
TZW committed
1425
              //console.log(selected, selectedRows, changeRows);
TZW's avatar
TZW committed
1426 1427 1428 1429 1430 1431 1432 1433
              if (selected) {
                let arr = selectArr.concat(changeRows.map((it) => it.id));
                setSelectArr(arr);
              } else {
                setSelectArr([]);
              }
            },
            onSelectNone: () => {
TZW's avatar
TZW committed
1434
              //console.log(11);
TZW's avatar
TZW committed
1435 1436 1437 1438 1439 1440 1441
              setSelectArr([]);
            },
          }}
        />
        <Space style={{ marginTop: 16 }}>
          <Button
            onClick={() => {
TZW's avatar
TZW committed
1442
              //console.log(drawer);
TZW's avatar
TZW committed
1443 1444 1445 1446 1447 1448
              setDrawer((s) => ({
                ...s,
                visible: false,
                item: null,
                detailpath: null,
                params: null,
TZW's avatar
TZW committed
1449 1450
                val: null,
                onFinish: null,
TZW's avatar
TZW committed
1451 1452 1453 1454 1455 1456 1457 1458 1459
              }));
              setSelectArr([]);
            }}
          >
            取消
          </Button>
          <Button
            type="primary"
            onClick={async () => {
TZW's avatar
TZW committed
1460
              //console.log(selectArr);
TZW's avatar
TZW committed
1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486
              let res = await doFetch({
                url: urlParams_childEquipment.save,
                params: {
                  equipmentId: drawer?.item?.id,
                  childrenIdList: selectArr,
                },
              });
              if (res.code === '0000') {
                message.success('新增成功!');
                setDrawer((s) => ({
                  ...s,
                  visible: false,
                  item: null,
                }));
                setSelectArr([]);
                actionRef.current.reload();
              }
            }}
          >
            提交
          </Button>
        </Space>
      </>
    );
  };

TZW's avatar
TZW committed
1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497
  // 履历登记
  const Resume = () => {
    const [selectArr, setSelectArr] = useState([]);
    const [activeTab, setactiveTab] = useState(1);

    useEffect(() => {
      const fun = async () => {
        const result = await doFetch({
          url: '/asset/equipment/children/selected/queryList',
          params: { id: drawer?.item?.id },
        });
TZW's avatar
TZW committed
1498
        // //console.log(result);
TZW's avatar
TZW committed
1499 1500 1501 1502 1503 1504 1505 1506 1507 1508
        if (!result?.data?.dataList.length == 0) {
          setSelectArr(result?.data?.dataList.map((it) => it.id));
        }
      };
      fun();
    }, []);

    const fields = {
      1: [
        {
TZW's avatar
TZW committed
1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540
          title: '改造日期',
          dataIndex: 'reformDate',
          key: 'reformDate',
          valueType: 'date',
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
        {
          title: '改造承包商',
          dataIndex: 'supplierId',
          key: 'supplierId',
          valueType: 'select',
          options: {
            path: '/asset/equipmentSupplier/query/selection',
            params: {},
          },
          formItemProps: {
            rules: [
              {
                required: true,
                message: '此项为必填项',
              },
            ],
          },
        },
        {
          title: '改造内容',
          dataIndex: 'reformContent',
          key: 'reformContent',
          valueType: 'textarea',
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
        {
TZW's avatar
TZW committed
1541
          title: '上传文件(上限为5个)',
TZW's avatar
TZW committed
1542
          key: 'urlIds',
TZW's avatar
1  
TZW committed
1543
          valueType: 'UploadDragger',
TZW's avatar
TZW committed
1544
          // colProps: { span: 24 },
TZW's avatar
TZW committed
1545
          fieldProps: {
TZW's avatar
TZW committed
1546
            maxCount: 5,
TZW's avatar
1  
TZW committed
1547
            name: 'file',
TZW's avatar
TZW committed
1548
          },
TZW's avatar
TZW committed
1549 1550 1551
          formItemProps: {
            rules: [
              {
TZW's avatar
TZW committed
1552
                required: false,
TZW's avatar
TZW committed
1553 1554 1555 1556
                message: '此项为必填项',
              },
            ],
          },
TZW's avatar
TZW committed
1557 1558 1559
        },
      ],
      2: [
TZW's avatar
TZW committed
1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574
        {
          title: '报废日期',
          dataIndex: 'scrapDate',
          key: 'scrapDate',
          valueType: 'date',
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
        {
          title: '报废原因',
          dataIndex: 'scrapReason',
          key: 'scrapReason',
          valueType: 'textarea',
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
        {
TZW's avatar
TZW committed
1575
          title: '上传文件(上限为5个)',
TZW's avatar
TZW committed
1576
          key: 'urlIds',
TZW's avatar
1  
TZW committed
1577
          valueType: 'UploadDragger',
TZW's avatar
TZW committed
1578 1579 1580
          formItemProps: {
            rules: [
              {
TZW's avatar
TZW committed
1581
                required: false,
TZW's avatar
TZW committed
1582 1583 1584 1585
                message: '此项为必填项',
              },
            ],
          },
TZW's avatar
TZW committed
1586
          fieldProps: {
TZW's avatar
1  
TZW committed
1587
            name: 'file',
TZW's avatar
TZW committed
1588
            maxCount: 5,
TZW's avatar
TZW committed
1589
          },
TZW's avatar
TZW committed
1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602
        },
      ],
      3: [
        {
          title: '调入公司',
          dataIndex: 'organizationName',
          key: 'toOrganizationId',
          valueType: 'select',
          options: { path: '/auth/sysDepartment/query/organization/selectbox', params: {} },
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
        {
          title: '调入部门',
TZW's avatar
TZW committed
1603
          valueType: 'treeSelect',
TZW's avatar
TZW committed
1604 1605 1606
          dataIndex: 'departmentName',
          key: 'toDepartmentId',
          options: {
TZW's avatar
TZW committed
1607
            path: '/auth/sysDepartment/query/children/tree',
TZW's avatar
TZW committed
1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689
            linkParams: {
              toOrganizationId: 'parentId',
            },
          },
        },
        {
          title: '调入工厂',
          dataIndex: 'factoryName',
          key: 'toFactoryId',
          valueType: 'select',
          options: { path: '/auth/sysFactory/getAllFactorySelection', params: {} },
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
        {
          title: '调入车间',
          dataIndex: 'shopName',
          valueType: 'select',
          options: {
            path: '/auth/sysShop/getShopSelectionByFactory',
            linkParams: {
              toFactoryId: 'factoryId',
            },
          },
          key: 'toShopId',
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
        {
          title: '调入工段',
          dataIndex: 'sectionName',
          key: 'toSectionId',
          valueType: 'select',
          options: {
            path: '/auth/sysSection/getAllSectionSelectionByShop',
            linkParams: {
              toShopId: 'shopId',
            },
          },
        },
        {
          title: '调入产线',
          dataIndex: 'productionLines',
          valueType: 'select',
          key: 'toProductLineId',
          options: {
            path: '/auth/sysProductionLine/getAllProductLineSelectionByShop',
            linkParams: {
              toShopId: 'shopId',
            },
          },
        },
        {
          title: '调入位置号',
          dataIndex: 'toPositionNo',
          valueType: 'input',
          key: 'toPositionNo',
        },
        {
          title: '调拨日期',
          dataIndex: 'transferDate',
          key: 'transferDate',
          valueType: 'date',
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
        {
          title: '调拨原因',
          dataIndex: 'transferReason',
          key: 'transferReason',
          valueType: 'textarea',
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
      ],
      4: [
        {
          title: '借用公司',
          dataIndex: 'organizationName',
          key: 'toOrganizationId',
          valueType: 'select',
          options: { path: '/auth/sysDepartment/query/organization/selectbox', params: {} },
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
        {
          title: '借用部门',
TZW's avatar
TZW committed
1690
          valueType: 'treeSelect',
TZW's avatar
TZW committed
1691 1692 1693
          dataIndex: 'departmentName',
          key: 'toDepartmentId',
          options: {
TZW's avatar
TZW committed
1694
            path: '/auth/sysDepartment/query/children/tree',
TZW's avatar
TZW committed
1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773
            linkParams: {
              toOrganizationId: 'parentId',
            },
          },
        },
        {
          title: '借用工厂',
          dataIndex: 'factoryName',
          key: 'toFactoryId',
          valueType: 'select',
          options: { path: '/auth/sysFactory/getAllFactorySelection', params: {} },
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
        {
          title: '借用车间',
          dataIndex: 'shopName',
          valueType: 'select',
          options: {
            path: '/auth/sysShop/getShopSelectionByFactory',
            linkParams: {
              toFactoryId: 'factoryId',
            },
          },
          key: 'toShopId',
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
        {
          title: '借用工段',
          dataIndex: 'sectionName',
          key: 'toSectionId',
          valueType: 'select',
          options: {
            path: '/auth/sysSection/getAllSectionSelectionByShop',
            linkParams: {
              toShopId: 'shopId',
            },
          },
        },
        {
          title: '借用产线',
          dataIndex: 'productionLines',
          valueType: 'select',
          key: 'toProductLineId',
          options: {
            path: '/auth/sysProductionLine/getAllProductLineSelectionByShop',
            linkParams: {
              toShopId: 'shopId',
            },
          },
        },
        {
          title: '借用位置号',
          dataIndex: 'toPositionNo',
          valueType: 'input',
          key: 'toPositionNo',
        },
        {
          title: '借用日期',
          dataIndex: 'borrowDate',
          key: 'borrowDate',
          valueType: 'date',
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
        {
          title: '预计归还日期',
          dataIndex: 'planReturnDate',
          key: 'planReturnDate',
          valueType: 'date',
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
        {
          title: '借用原因',
          dataIndex: 'borrowReason',
          key: 'borrowReason',
          valueType: 'textarea',
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
      ],
      5: [
TZW's avatar
TZW committed
1774
        {
TZW's avatar
TZW committed
1775 1776 1777 1778 1779 1780 1781 1782 1783
          title: '接收公司',
          dataIndex: 'returnOrganizationId',
          key: 'returnOrganizationId',
          valueType: 'select',
          options: { path: '/auth/sysDepartment/query/organization/selectbox', params: {} },
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
        {
          title: '接收部门',
TZW's avatar
TZW committed
1784
          valueType: 'treeSelect',
TZW's avatar
TZW committed
1785 1786 1787
          dataIndex: 'returnDepartmentId',
          key: 'returnDepartmentId',
          options: {
TZW's avatar
TZW committed
1788
            path: '/auth/sysDepartment/query/children/tree',
TZW's avatar
TZW committed
1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856
            linkParams: {
              returnOrganizationId: 'parentId',
            },
          },
        },
        {
          title: '接收工厂',
          dataIndex: 'returnFactoryId',
          key: 'returnFactoryId',
          valueType: 'select',
          options: { path: '/auth/sysFactory/getAllFactorySelection', params: {} },
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
        {
          title: '接收车间',
          dataIndex: 'returnShopId',
          valueType: 'select',
          options: {
            path: '/auth/sysShop/getShopSelectionByFactory',
            linkParams: {
              returnFactoryId: 'factoryId',
            },
          },
          key: 'returnShopId',
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
        {
          title: '接收工段',
          dataIndex: 'returnSectionId',
          key: 'returnSectionId',
          valueType: 'select',
          options: {
            path: '/auth/sysSection/getAllSectionSelectionByShop',
            linkParams: {
              returnShopId: 'shopId',
            },
          },
        },
        {
          title: '接收产线',
          dataIndex: 'returnProductLineId',
          valueType: 'select',
          key: 'returnProductLineId',
          options: {
            path: '/auth/sysProductionLine/getAllProductLineSelectionByShop',
            linkParams: {
              returnShopId: 'shopId',
            },
          },
        },
        {
          title: '接收位置号',
          dataIndex: 'returnPositionNo',
          valueType: 'input',
          key: 'returnPositionNo',
        },
        {
          title: '实际归还日期',
          dataIndex: 'realReturnDate',
          key: 'realReturnDate',
          valueType: 'date',
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
        {
          title: '备注',
          dataIndex: 'remark',
          key: 'remark',
          valueType: 'textarea',
TZW's avatar
TZW committed
1857
          formItemProps: { rules: [{ required: false, message: '此项为必填项' }] },
TZW's avatar
TZW committed
1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940
        },
      ],
    };

    return (
      <>
        <ProDescriptions
          request={async () => {
            const { data } = await doFetch({
              url: urlParams.detail,
              params: { id: drawer?.item?.id },
            });
            return {
              success: true,
              data: data?.data,
            };
          }}
          columns={[
            {
              title: '设备编号',
              dataIndex: 'equipmentNo',
              key: 'equipmentNo',
            },
            {
              title: '设备名称',
              dataIndex: 'equipmentName',
              key: 'equipmentName',
            },
            {
              title: '位置号',
              dataIndex: 'positionNo',
              key: 'positionNo',
            },
            {
              title: '公司名称',
              dataIndex: 'organizationName',
              key: 'organizationId',
            },
            {
              title: '部门名称',
              dataIndex: 'departmentName',
              key: 'departmentId',
            },
            {
              title: '工厂名称',
              dataIndex: 'factoryName',
              key: 'factoryId',
            },
            {
              title: '车间名称',
              dataIndex: 'shopName',
              key: 'shopId',
            },
            {
              title: '工段名称',
              dataIndex: 'sectionName',
              key: 'sectionId',
            },
            {
              title: '产线名称',
              dataIndex: 'productLineName',
              key: 'productLineName',
            },
            {
              title: '供应商',
              dataIndex: 'supplierName',
              key: 'supplierId',
            },
            {
              title: '安装投产日期',
              dataIndex: 'productDate',
              key: 'productDate',
            },
          ]}
        />
        <Divider />
        <Tabs
          activeKey={activeTab}
          onChange={setactiveTab}
          items={[
            {
              label: '改造',
              key: 1,
TZW's avatar
TZW committed
1941 1942 1943
              children: activeTab == 1 && (
                <InitForm
                  fields={fields[activeTab]}
TZW's avatar
TZW committed
1944
                  defaultFormValue={drawer?.item}
TZW's avatar
TZW committed
1945
                  onFinish={async (vals) => {
TZW's avatar
TZW committed
1946
                    //console.log(vals);
TZW's avatar
TZW committed
1947 1948 1949 1950 1951 1952
                    let res = await doFetch({
                      url: urlParams_resume.save,
                      params: { ...vals, type: '1', equipmentId: drawer?.item?.id },
                    });
                    if (res.code === '0000') {
                      message.success('登记成功!');
wuhao's avatar
wuhao committed
1953
                      await setDrawer((s) => ({
TZW's avatar
TZW committed
1954 1955 1956 1957 1958 1959 1960 1961 1962
                        ...s,
                        visible: false,
                        item: null,
                      }));
                      actionRef.current.reload();
                    }
                  }}
                />
              ),
TZW's avatar
TZW committed
1963 1964
            }, // remember to pass the key prop
            {
TZW's avatar
TZW committed
1965
              label: '报废',
TZW's avatar
TZW committed
1966
              key: 2,
TZW's avatar
TZW committed
1967 1968 1969
              children: activeTab == 2 && (
                <InitForm
                  fields={fields[activeTab]}
TZW's avatar
TZW committed
1970
                  defaultFormValue={drawer?.item}
TZW's avatar
TZW committed
1971 1972 1973 1974 1975 1976 1977
                  onFinish={async (vals) => {
                    let res = await doFetch({
                      url: urlParams_resume.save,
                      params: { ...vals, type: '2', equipmentId: drawer?.item?.id },
                    });
                    if (res.code === '0000') {
                      message.success('登记成功!');
wuhao's avatar
wuhao committed
1978
                      await setDrawer((s) => ({
TZW's avatar
TZW committed
1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994
                        ...s,
                        visible: false,
                        item: null,
                      }));
                      actionRef.current.reload();
                    }
                  }}
                />
              ),
            },
            {
              label: '调拨',
              key: 3,
              children: activeTab == 3 && (
                <InitForm
                  fields={fields[activeTab]}
TZW's avatar
TZW committed
1995
                  defaultFormValue={drawer?.item}
TZW's avatar
TZW committed
1996
                  onFinish={async (vals) => {
TZW's avatar
TZW committed
1997
                    //console.log(vals);
TZW's avatar
TZW committed
1998 1999 2000 2001 2002 2003
                    let res = await doFetch({
                      url: urlParams_resume.save,
                      params: { ...vals, type: '3', equipmentId: drawer?.item?.id },
                    });
                    if (res.code === '0000') {
                      message.success('登记成功!');
wuhao's avatar
wuhao committed
2004
                      await setDrawer((s) => ({
TZW's avatar
TZW committed
2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019
                        ...s,
                        visible: false,
                        item: null,
                      }));
                      actionRef.current.reload();
                    }
                  }}
                />
              ),
            },
            {
              label: '借用',
              key: 4,
              children: activeTab == 4 && (
                <InitForm
TZW's avatar
TZW committed
2020
                  defaultFormValue={drawer?.item}
TZW's avatar
TZW committed
2021 2022
                  fields={fields[activeTab]}
                  onFinish={async (vals) => {
TZW's avatar
TZW committed
2023
                    //console.log(vals);
TZW's avatar
TZW committed
2024 2025 2026 2027 2028 2029
                    let res = await doFetch({
                      url: urlParams_resume.save,
                      params: { ...vals, type: '4', equipmentId: drawer?.item?.id },
                    });
                    if (res.code === '0000') {
                      message.success('登记成功!');
wuhao's avatar
wuhao committed
2030
                      await setDrawer((s) => ({
TZW's avatar
TZW committed
2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043
                        ...s,
                        visible: false,
                        item: null,
                      }));
                      actionRef.current.reload();
                    }
                  }}
                />
              ),
            },
            {
              label: '归还',
              key: 5,
TZW's avatar
TZW committed
2044 2045 2046
              children: activeTab == 5 && (
                <InitForm
                  fields={fields[activeTab]}
TZW's avatar
TZW committed
2047
                  defaultFormValue={drawer?.item}
TZW's avatar
TZW committed
2048
                  onFinish={async (vals) => {
TZW's avatar
TZW committed
2049
                    //console.log(vals);
TZW's avatar
TZW committed
2050 2051 2052 2053 2054 2055
                    let res = await doFetch({
                      url: urlParams_resume.save,
                      params: { ...vals, type: '5', equipmentId: drawer?.item?.id },
                    });
                    if (res.code === '0000') {
                      message.success('登记成功!');
wuhao's avatar
wuhao committed
2056
                      await setDrawer((s) => ({
TZW's avatar
TZW committed
2057 2058 2059 2060 2061 2062 2063 2064 2065
                        ...s,
                        visible: false,
                        item: null,
                      }));
                      actionRef.current.reload();
                    }
                  }}
                />
              ),
TZW's avatar
TZW committed
2066 2067 2068 2069 2070 2071 2072
            },
          ]}
        />
      </>
    );
  };

wuhao's avatar
wuhao committed
2073
  const columns = useMemo(() => {
TZW's avatar
TZW committed
2074
    let defcolumn = getcolumns(setDrawer);
TZW's avatar
TZW committed
2075 2076 2077 2078 2079 2080 2081
    defcolumn[1].render = (text, row) => {
      return (
        <a
          onClick={() => {
            setDrawer((s) => ({
              ...s,
              visible: true,
TZW's avatar
TZW committed
2082 2083 2084
              type: 'detail',
              item: row,
              val: 'only',
TZW's avatar
TZW committed
2085 2086 2087 2088 2089 2090 2091 2092
              title: row.equipmentName + '的详细信息',
            }));
          }}
        >
          {row.equipmentName}
        </a>
      );
    };
wuhao's avatar
wuhao committed
2093 2094 2095
    return defcolumn.concat({
      title: '操作',
      valueType: 'option',
TZW's avatar
TZW committed
2096 2097 2098 2099 2100 2101 2102
      fixed: 'right',
      width: 200,
      render: (text, row, _, action) => [
        edit(text, row, _, action),
        remove(text, row, _, action),
        more(text, row, _, action),
      ],
wuhao's avatar
wuhao committed
2103 2104 2105
    });
  }, []);

TZW's avatar
TZW committed
2106 2107 2108 2109 2110
  const onselecteTree = async (selectedKeys, e, alldata) => {
    let params = {
      treeNodeType: e.node.type,
      treeNodeKey: e.node.key,
    };
TZW's avatar
TZW committed
2111
    setextraparams(params);
TZW's avatar
TZW committed
2112 2113 2114 2115 2116 2117 2118 2119
  };

  const selectMoreDrawerType = (type) => {
    switch (type) {
      case 'editChildEquipment':
        return <EditChildEquipment />;
      case 'resume':
        return <Resume />;
TZW's avatar
TZW committed
2120 2121
      case 'detail':
        return <Detail />;
TZW's avatar
TZW committed
2122 2123 2124 2125 2126 2127 2128
      case 'add':
        return (
          <ExtendField
            setDrawer={setDrawer}
            drawer={drawer}
            actionRef={actionRef}
            columns={columns}
TZW's avatar
TZW committed
2129
            // urlParams={urlParams}
TZW's avatar
TZW committed
2130 2131 2132 2133 2134 2135
            formId={'2'}
            onFinish={async (vals) => {
              let equipmentCharReqList = [];
              for (let i in vals) {
                if (!isNaN(Number(i))) {
                  equipmentCharReqList.push({
TZW's avatar
TZW committed
2136
                    fieldId: i,
TZW's avatar
TZW committed
2137
                    fieldRealValue: vals[i],
TZW's avatar
TZW committed
2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180
                  });
                  delete vals[i];
                }
              }
              let params = {
                ...vals,
                id: drawer?.title == '编辑' ? drawer?.item?.id : '',
                equipmentCharReqList,
              };
              //console.log(params, '!!!!');
              let res = await doFetch({
                url: urlParams.save,
                params,
              });
              if (res.code === '0000') {
                if (drawer?.title == '编辑') {
                  message.success('编辑成功!');
                } else {
                  message.success('新增成功!');
                }
                setDrawer((s) => ({
                  ...s,
                  visible: false,
                }));
                actionRef.current.reload();
              }
            }}
          />
        );
      case 'edit':
        return (
          <ExtendField
            setDrawer={setDrawer}
            drawer={drawer}
            actionRef={actionRef}
            columns={columns}
            urlParams={urlParams}
            formId={'2'}
            onFinish={async (vals) => {
              let equipmentCharReqList = [];
              for (let i in vals) {
                if (!isNaN(Number(i))) {
                  equipmentCharReqList.push({
TZW's avatar
TZW committed
2181
                    fieldId: i,
TZW's avatar
TZW committed
2182
                    fieldRealValue: vals[i],
TZW's avatar
TZW committed
2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210
                  });
                  delete vals[i];
                }
              }
              let params = {
                ...vals,
                id: drawer?.title == '编辑' ? drawer?.item?.id : '',
                equipmentCharReqList,
              };
              let res = await doFetch({
                url: urlParams.save,
                params,
              });
              if (res.code === '0000') {
                if (drawer?.title == '编辑') {
                  message.success('编辑成功!');
                } else {
                  message.success('新增成功!');
                }
                setDrawer((s) => ({
                  ...s,
                  visible: false,
                }));
                actionRef.current.reload();
              }
            }}
          />
        );
TZW's avatar
TZW committed
2211 2212
      default:
        return null;
TZW's avatar
TZW committed
2213 2214 2215
    }
  };

TZW's avatar
TZW committed
2216
  const containderef = useRef();
wuhao's avatar
wuhao committed
2217 2218
  return (
    <div style={{ position: 'relative' }}>
TZW's avatar
TZW committed
2219
      <div className="ant-card-head" style={{ backgroundColor: 'white' }}>
TZW's avatar
TZW committed
2220 2221 2222 2223 2224 2225
        <div className="ant-card-head-wrapper">
          <div className="ant-card-head-title">
            <h3 className="page-title">设备台账</h3>
          </div>
        </div>
      </div>
TZW's avatar
TZW committed
2226
      <Layout style={{ height: '100%' }} ref={containderef}>
TZW's avatar
TZW committed
2227
        <Sider theme="light" width={300}>
TZW's avatar
TZW committed
2228
          <TreeRender url="/auth/sysFactory/getTree" onselected={onselecteTree} noaction={true} />
TZW's avatar
TZW committed
2229 2230 2231 2232 2233
        </Sider>
        <Content>
          <AutoTable
            pagetitle={<h3 style={{ marginBottom: 0, fontWeight: 400 }}>设备台账</h3>}
            columns={columns}
TZW's avatar
TZW committed
2234
            path={urlParams.list}
TZW's avatar
TZW committed
2235 2236
            actionRef={actionRef}
            pageextra={'add'}
TZW's avatar
TZW committed
2237
            resizeable={false}
TZW's avatar
TZW committed
2238 2239 2240 2241 2242 2243
            addconfig={{
              // access: 'sysDepartment_save',
              btn: {
                disabled: false,
                type: 'primary',
                onClick: () => {
TZW's avatar
TZW committed
2244
                  setDrawer((s) => ({
TZW's avatar
TZW committed
2245 2246 2247 2248
                    ...s,
                    visible: true,
                    item: null,
                    title: '新增',
TZW's avatar
TZW committed
2249 2250 2251
                    val: 'only',
                    type: 'add',
                    // onFinish: async (vals) => {
TZW's avatar
TZW committed
2252
                    //   //console.log(vals);
TZW's avatar
TZW committed
2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268
                    //   let params = {
                    //     ...vals,
                    //   };
                    //   let res = await doFetch({
                    //     url: urlParams.save,
                    //     params,
                    //   });
                    //   if (res.code === '0000') {
                    //     message.success('新增成功!');
                    //     setDrawer((s) => ({
                    //       ...s,
                    //       visible: false,
                    //     }));
                    //     actionRef.current.reload();
                    //   }
                    // },
TZW's avatar
TZW committed
2269 2270 2271 2272
                  }));
                },
              },
            }}
TZW's avatar
TZW committed
2273
            x={1500}
TZW's avatar
TZW committed
2274
            extraparams={extraparams}
TZW's avatar
TZW committed
2275 2276 2277
          />
        </Content>
      </Layout>
wuhao's avatar
wuhao committed
2278 2279 2280 2281 2282
      <DrawerPro
        fields={columns}
        formRef={formRef}
        placement="right"
        onClose={() => {
TZW's avatar
TZW committed
2283
          setDrawer((s) => ({
wuhao's avatar
wuhao committed
2284 2285 2286 2287 2288
            ...s,
            visible: false,
          }));
        }}
        {...drawer}
wuhao's avatar
wuhao committed
2289 2290 2291
        colProps={{
          span: 8,
        }}
TZW's avatar
TZW committed
2292
      >
wuhao's avatar
wuhao committed
2293
        {drawer?.visible && selectMoreDrawerType(drawer?.type)}
TZW's avatar
TZW committed
2294
      </DrawerPro>
TZW's avatar
TZW committed
2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305

      <DrawerPro
        placement="right"
        onClose={() => {
          setCurrDrawer((s) => ({
            ...s,
            visible: false,
            item: null,
          }));
        }}
        {...currDrawer}
wuhao's avatar
wuhao committed
2306 2307 2308
        colProps={{
          span: 8,
        }}
TZW's avatar
TZW committed
2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373
      >
        <ProDescriptions
          title="设备信息"
          request={async () => {
            const { data } = await doFetch({
              url: urlParams.detail,
              params: { id: drawer?.item?.id },
            });
            return {
              success: true,
              data: data?.data,
            };
          }}
          columns={[
            {
              title: '设备编号',
              dataIndex: 'equipmentNo',
              key: 'equipmentNo',
            },
            {
              title: '设备名称',
              dataIndex: 'equipmentName',
              key: 'equipmentName',
            },
            {
              title: '位置号',
              dataIndex: 'positionNo',
              key: 'positionNo',
            },

            {
              title: '公司名称',
              dataIndex: 'organizationName',
              key: 'organizationId',
            },
            {
              title: '部门名称',
              dataIndex: 'departmentName',
              key: 'departmentId',
            },
            {
              title: '工厂名称',
              dataIndex: 'factoryName',
              key: 'factoryId',
            },
            {
              title: '车间名称',
              dataIndex: 'shopName',
              key: 'shopId',
            },
            {
              title: '工段名称',
              dataIndex: 'sectionName',
              key: 'sectionId',
            },
            {
              title: '产线名称',
              dataIndex: 'productLineName',
              key: 'productLineName',
            },
          ]}
        />
        <Divider />
        <ProDescriptions
          title={currDrawer?.item?.logTypeName + '信息'}
TZW's avatar
TZW committed
2374
          column={2}
TZW's avatar
TZW committed
2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387
          request={async () => {
            const { data } = await doFetch({
              url: urlParams_resume.detail,
              params: { id: currDrawer?.item?.id },
            });
            return {
              success: true,
              data: data?.data?.resume,
            };
          }}
          columns={currfields[currDrawer?.item?.logType]}
        />
      </DrawerPro>
wuhao's avatar
wuhao committed
2388 2389 2390 2391
    </div>
  );
}

TZW's avatar
TZW committed
2392
export default Model;