index.jsx 71.1 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-02-16 17:23:15
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 16 17 18 19 20 21 22 23 24 25 26
import {
  message,
  Dropdown,
  Menu,
  Layout,
  Button,
  Image,
  Space,
  Divider,
  Tabs,
  Tooltip,
} from 'antd';
TZW's avatar
TZW committed
27
import TreeRender from '@/components/TreeRender';
TZW's avatar
TZW committed
28
import { ProDescriptions } from '@ant-design/pro-components';
TZW's avatar
TZW committed
29
import InitForm from '@/components/InitForm';
TZW's avatar
TZW committed
30
import ExtendField from '@/components/ExtendField';
TZW's avatar
TZW committed
31
import dayjs from 'dayjs';
wuhao's avatar
wuhao committed
32

TZW's avatar
TZW committed
33
const { Sider, Content } = Layout;
TZW's avatar
TZW committed
34

TZW's avatar
TZW committed
35
function Model(props) {
TZW's avatar
TZW committed
36 37 38 39
  const disabledDateOfDay = (current) => {
    // Can not select days before today and today
    return current && current > dayjs().endOf('day');
  };
TZW's avatar
TZW committed
40
  const [activeTab, setactiveTab] = useState(1);
TZW's avatar
TZW committed
41
  let actionRef = useRef(),
TZW's avatar
TZW committed
42 43 44 45
    formRef = useRef(),
    [drawer, setDrawer] = useState({
      visible: false,
    }),
TZW's avatar
TZW committed
46
    [extraparams, setextraparams] = useState({}),
TZW's avatar
TZW committed
47 48 49
    [currDrawer, setCurrDrawer] = useState({
      visible: false,
    }),
TZW's avatar
TZW committed
50
    [resumeTab, setresumeTab] = useState(null),
TZW's avatar
TZW committed
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
    currfields = {
      1: [
        {
          title: '操作人',
          dataIndex: 'updateUserName',
          key: 'updateUserName',
        },
        {
          title: '操作时间',
          dataIndex: 'updateTime',
          key: 'updateTime',
        },
        {
          title: '改造日期',
          dataIndex: 'reformDate',
          key: 'reformDate',
          valueType: 'date',
TZW's avatar
TZW committed
68

TZW's avatar
TZW committed
69 70 71 72 73 74 75 76 77 78
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
        {
          title: '改造承包商',
          dataIndex: 'supplierId',
          key: 'supplierId',
          valueType: 'select',
          options: {
            path: '/asset/equipmentSupplier/query/selection',
            params: {},
wuhao's avatar
wuhao committed
79
          },
TZW's avatar
TZW committed
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
          formItemProps: {
            rules: [
              {
                required: true,
                message: '此项为必填项',
              },
            ],
          },
        },
        {
          title: '改造内容',
          dataIndex: 'reformContent',
          key: 'reformContent',
          valueType: 'textarea',
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
        {
TZW's avatar
TZW committed
97
          title: '上传文件',
TZW's avatar
TZW committed
98
          key: 'urlIds',
TZW's avatar
TZW committed
99
          valueType: 'uploadDragger',
TZW's avatar
TZW committed
100 101
          // column: { xs: 1, sm: 2, md: 3 },
          span: '3',
TZW's avatar
TZW committed
102
          fieldProps: {
TZW's avatar
TZW committed
103
            maxCount: 5,
TZW's avatar
TZW committed
104 105 106 107 108 109 110 111 112 113
          },
          formItemProps: {
            rules: [
              {
                required: true,
                message: '此项为必填项',
              },
            ],
          },
          render: (text, row) => {
TZW's avatar
TZW committed
114 115 116 117 118
            return (
              <div>
                {row?.urlIds.map((it) => (
                  // eslint-disable-next-line react/jsx-key
                  <div style={{ marginBottom: '8px' }}>
TZW's avatar
TZW committed
119 120 121
                    <a href={it?.url} download target="_blank" rel="noopener noreferrer">
                      {it?.name}
                    </a>
TZW's avatar
TZW committed
122 123 124 125
                  </div>
                ))}
              </div>
            );
TZW's avatar
TZW committed
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
          },
        },
      ],
      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
155
          title: '上传文件',
TZW's avatar
TZW committed
156
          key: 'urlIds',
TZW's avatar
TZW committed
157
          valueType: 'uploadDragger',
TZW's avatar
TZW committed
158
          span: '3',
TZW's avatar
TZW committed
159 160 161
          formItemProps: {
            rules: [
              {
TZW's avatar
TZW committed
162
                required: false,
TZW's avatar
TZW committed
163 164 165 166 167
                message: '此项为必填项',
              },
            ],
          },
          fieldProps: {
TZW's avatar
TZW committed
168
            maxCount: 5,
TZW's avatar
TZW committed
169 170
          },
          render: (text, row) => {
TZW's avatar
TZW committed
171 172 173 174 175
            return (
              <div>
                {row?.urlIds.map((it) => (
                  // eslint-disable-next-line react/jsx-key
                  <div style={{ marginBottom: '8px' }}>
TZW's avatar
TZW committed
176 177 178
                    <a href={it?.url} download target="_blank" rel="noopener noreferrer">
                      {it?.name}
                    </a>
TZW's avatar
TZW committed
179 180 181 182
                  </div>
                ))}
              </div>
            );
TZW's avatar
TZW committed
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
          },
        },
      ],
      3: [
        {
          title: '操作人',
          dataIndex: 'updateUserName',
          key: 'updateUserName',
        },
        {
          title: '操作时间',
          dataIndex: 'updateTime',
          key: 'updateTime',
        },
        {
          title: '调入公司',
TZW's avatar
TZW committed
199
          dataIndex: 'toOrganizationName',
TZW's avatar
TZW committed
200 201 202 203 204 205 206
          key: 'toOrganizationId',
          valueType: 'select',
          options: { path: '/auth/sysDepartment/query/organization/selectbox', params: {} },
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
        {
          title: '调入部门',
TZW's avatar
TZW committed
207 208
          valueType: 'treeSelect',
          dataIndex: 'toDepartmentName',
TZW's avatar
TZW committed
209 210
          key: 'toDepartmentId',
          options: {
TZW's avatar
TZW committed
211
            path: '/auth/sysDepartment/query/children/tree',
TZW's avatar
TZW committed
212 213 214 215 216 217 218
            linkParams: {
              toOrganizationId: 'parentId',
            },
          },
        },
        {
          title: '调入工厂',
TZW's avatar
TZW committed
219
          dataIndex: 'toFactoryName',
TZW's avatar
TZW committed
220 221 222 223 224 225 226
          key: 'toFactoryId',
          valueType: 'select',
          options: { path: '/auth/sysFactory/getAllFactorySelection', params: {} },
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
        {
          title: '调入车间',
TZW's avatar
TZW committed
227
          dataIndex: 'toShopName',
TZW's avatar
TZW committed
228 229 230 231 232 233 234 235 236 237 238 239
          valueType: 'select',
          options: {
            path: '/auth/sysShop/getShopSelectionByFactory',
            linkParams: {
              toFactoryId: 'factoryId',
            },
          },
          key: 'toShopId',
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
        {
          title: '调入工段',
TZW's avatar
TZW committed
240
          dataIndex: 'toSectionName',
TZW's avatar
TZW committed
241 242 243 244 245 246 247 248 249 250 251
          key: 'toSectionId',
          valueType: 'select',
          options: {
            path: '/auth/sysSection/getAllSectionSelectionByShop',
            linkParams: {
              toShopId: 'shopId',
            },
          },
        },
        {
          title: '调入产线',
TZW's avatar
TZW committed
252
          dataIndex: 'toProductLineName',
TZW's avatar
TZW committed
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295
          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
296 297
          dataIndex: 'toOrganizationName',
          key: 'toOrganizationName',
TZW's avatar
TZW committed
298 299 300
        },
        {
          title: '借用部门',
TZW's avatar
TZW committed
301
          valueType: 'treeSelect',
TZW's avatar
TZW committed
302 303
          dataIndex: 'toDepartmentName',
          key: 'toDepartmentName',
TZW's avatar
TZW committed
304 305 306
        },
        {
          title: '借用工厂',
TZW's avatar
TZW committed
307 308
          dataIndex: 'toFactoryName',
          key: 'toFactoryName',
TZW's avatar
TZW committed
309 310 311
        },
        {
          title: '借用车间',
TZW's avatar
TZW committed
312
          dataIndex: 'toShopName',
TZW's avatar
TZW committed
313
          valueType: 'select',
TZW's avatar
TZW committed
314
          key: 'toShopName',
TZW's avatar
TZW committed
315 316 317
        },
        {
          title: '借用工段',
TZW's avatar
TZW committed
318 319
          dataIndex: 'toSectionName',
          key: 'toSectionName',
TZW's avatar
TZW committed
320 321 322
        },
        {
          title: '借用产线',
TZW's avatar
TZW committed
323 324
          dataIndex: 'toProductLineName',
          key: 'toProductLineName',
TZW's avatar
TZW committed
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366
        },
        {
          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
367 368
          dataIndex: 'returnOrganizationName',
          key: 'returnOrganizationName',
TZW's avatar
TZW committed
369 370 371 372 373 374
          valueType: 'select',
          options: { path: '/auth/sysDepartment/query/organization/selectbox', params: {} },
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
        {
          title: '接收部门',
TZW's avatar
TZW committed
375
          valueType: 'treeSelect',
TZW's avatar
TZW committed
376 377
          dataIndex: 'returnDepartmentName',
          key: 'returnDepartmentName',
TZW's avatar
TZW committed
378
          options: {
TZW's avatar
TZW committed
379
            path: '/auth/sysDepartment/query/children/tree',
TZW's avatar
TZW committed
380 381 382 383 384 385 386
            linkParams: {
              returnOrganizationId: 'parentId',
            },
          },
        },
        {
          title: '接收工厂',
TZW's avatar
TZW committed
387 388
          dataIndex: 'returnFactoryName',
          key: 'returnFactoryName',
TZW's avatar
TZW committed
389 390 391 392 393 394
          valueType: 'select',
          options: { path: '/auth/sysFactory/getAllFactorySelection', params: {} },
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
        {
          title: '接收车间',
TZW's avatar
TZW committed
395
          dataIndex: 'returnShopName',
TZW's avatar
TZW committed
396 397 398 399 400 401 402 403 404 405 406 407
          valueType: 'select',
          options: {
            path: '/auth/sysShop/getShopSelectionByFactory',
            linkParams: {
              returnFactoryId: 'factoryId',
            },
          },
          key: 'returnShopId',
          formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
        },
        {
          title: '接收工段',
TZW's avatar
TZW committed
408
          dataIndex: 'returnSectionName',
TZW's avatar
TZW committed
409 410 411 412 413 414 415 416 417 418 419
          key: 'returnSectionId',
          valueType: 'select',
          options: {
            path: '/auth/sysSection/getAllSectionSelectionByShop',
            linkParams: {
              returnShopId: 'shopId',
            },
          },
        },
        {
          title: '接收产线',
TZW's avatar
TZW committed
420
          dataIndex: 'returnProductLineName',
TZW's avatar
TZW committed
421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471
          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
472

TZW's avatar
TZW committed
473 474 475 476 477 478 479 480 481 482 483 484 485 486
  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
487 488 489 490 491 492
  const edit = (text, row, _, action) => {
    return (
      <PremButton
        btn={{
          size: 'small',
          onClick: () => {
TZW's avatar
TZW committed
493
            setDrawer((s) => ({
wuhao's avatar
wuhao committed
494 495 496
              ...s,
              visible: true,
              title: '编辑',
TZW's avatar
TZW committed
497
              val: 'only',
TZW's avatar
TZW committed
498
              type: 'edit',
TZW's avatar
TZW committed
499
              item: row,
wuhao's avatar
wuhao committed
500 501 502 503 504 505 506 507 508 509 510 511 512
            }));
          },
        }}
      >
        编辑
      </PremButton>
    );
  };

  const remove = (text, row, _, action) => {
    return (
      <PremButton
        pop={{
TZW's avatar
TZW committed
513
          title: '是否删除该设备?',
wuhao's avatar
wuhao committed
514 515
          okText: '确认',
          cancelText: '取消',
TZW's avatar
TZW committed
516 517 518 519 520 521 522 523 524 525
          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
526 527 528 529 530 531 532 533 534 535 536 537
          },
        }}
        btn={{
          size: 'small',
          type: 'danger',
        }}
      >
        删除
      </PremButton>
    );
  };

TZW's avatar
TZW committed
538 539 540 541 542 543 544 545 546 547 548
  const more = (text, row, _, action) => {
    const menu = (
      <Menu
        items={[
          {
            label: (
              <a
                onClick={() => {
                  setDrawer((s) => ({
                    ...s,
                    visible: true,
TZW's avatar
TZW committed
549 550 551 552
                    type: 'editChildEquipment',
                    item: {
                      id: row.id,
                    },
TZW's avatar
TZW committed
553 554 555 556 557 558 559 560 561 562 563
                    val: 'only',
                    title: '编辑子设备',
                  }));
                }}
              >
                编辑子设备
              </a>
            ),
            key: '0',
          },
          {
TZW's avatar
TZW committed
564 565
            label: (
              <a
TZW's avatar
TZW committed
566 567
                onClick={async () => {
                  let res = await doFetch({
TZW's avatar
TZW committed
568 569
                    url: '/asset/equipmentLog/getAllResumeType',
                    params: { equipmentId: row?.id },
TZW's avatar
TZW committed
570
                  });
TZW's avatar
TZW committed
571 572
                  await setresumeTab(res?.data?.dataList);
                  await setDrawer((s) => ({
TZW's avatar
TZW committed
573 574 575 576 577
                    ...s,
                    visible: true,
                    type: 'resume',
                    item: {
                      id: row.id,
TZW's avatar
TZW committed
578 579
                      reformDate: formatDate(new Date()),
                      scrapDate: formatDate(new Date()),
TZW's avatar
TZW committed
580 581 582
                      transferDate: formatDate(new Date()),
                      borrowDate: formatDate(new Date()),
                      realReturnDate: formatDate(new Date()),
TZW's avatar
TZW committed
583 584 585 586 587 588 589 590 591
                    },
                    val: 'only',
                    title: '履历登记',
                  }));
                }}
              >
                履历登记
              </a>
            ),
TZW's avatar
TZW committed
592 593
            key: '1',
          },
TZW's avatar
TZW committed
594 595 596 597 598 599 600 601
          // {
          //   label: <a>关联备件(暂缓)</a>,
          //   key: '2',
          // },
          // {
          //   label: <a>寿命件台账(暂缓)</a>,
          //   key: '3',
          // },
TZW's avatar
TZW committed
602 603 604 605
        ]}
      />
    );
    return (
TZW's avatar
TZW committed
606 607 608 609
      <Dropdown
        overlay={menu}
        trigger={['click']}
        arrow={true}
TZW's avatar
TZW committed
610
        getPopupContainer={() => containderef.current}
TZW's avatar
TZW committed
611 612 613 614 615 616 617 618 619 620
      >
        <Button size="small">更多</Button>
      </Dropdown>
    );
  };

  //设备详情
  const Detail = () => {
    // 基础信息
    const BaseInfo = () => {
TZW's avatar
TZW committed
621
      const columns1 = [
TZW's avatar
TZW committed
622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641
        {
          title: '设备编号',
          dataIndex: 'equipmentNo',
          key: 'equipmentNo',
        },
        {
          title: '设备名称',
          dataIndex: 'equipmentName',
          key: 'equipmentName',
        },
        {
          title: '位置号',
          dataIndex: 'positionNo',
          key: 'positionNo',
        },
        {
          title: '设备类型',
          dataIndex: 'equipmentTypeName',
          key: 'equipmentTypeId',
        },
TZW's avatar
TZW committed
642 643 644 645 646
        {
          title: '设备型号',
          dataIndex: 'equipmentModelName',
          key: 'equipmentModelName',
        },
TZW's avatar
TZW committed
647 648 649 650 651 652
        {
          title: '状态',
          dataIndex: 'statusName',
          key: 'statusName',
          span: 2,
        },
TZW's avatar
TZW committed
653 654
      ];
      const columns2 = [
TZW's avatar
TZW committed
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
        {
          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',
        },
TZW's avatar
TZW committed
685 686
      ];
      const columns3 = [
TZW's avatar
TZW committed
687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740
        {
          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
741
      const [request, setrequest] = useState();
TZW's avatar
TZW committed
742 743
      useEffect(() => {
        const fn = async () => {
TZW's avatar
TZW committed
744 745 746 747
            let res = await doFetch({
              url: '/base/paFormField/queryList',
              params: {
                formId: '2',
TZW's avatar
TZW committed
748
              },
TZW's avatar
TZW committed
749 750 751
            });
            if (res?.data?.dataList) {
              let column = [];
wuhao's avatar
wuhao committed
752
              res?.data?.dataList?.forEach?.((el) => {
TZW's avatar
TZW committed
753 754 755 756 757 758
                column.push({
                  ...selectValueType(el.fieldChar, el.valueList),
                  title: el.fieldName,
                  dataIndex: el.id,
                  key: el.id,
                });
TZW's avatar
TZW committed
759
              });
TZW's avatar
TZW committed
760 761 762 763 764 765 766
              setnewfieldscolumns(column);
            }
          },
          fn2 = async () => {
            const res = await doFetch({
              url: urlParams.detail,
              params: { id: drawer?.item?.id },
TZW's avatar
TZW committed
767
            });
TZW's avatar
TZW committed
768
            let obj = {};
wuhao's avatar
wuhao committed
769
            res?.data?.data['equipmentCharList']?.forEach?.((it) => {
TZW's avatar
TZW committed
770
              obj[it?.fieldId] = it?.fieldRealValue;
TZW's avatar
TZW committed
771 772 773 774 775 776 777 778 779 780 781 782
            });
            console.log('drawerpro:', {
              ...(res?.data?.data ?? {}),
              ...obj,
            });
            setrequest(
              {
                ...(res?.data?.data ?? {}),
                ...obj,
              } ?? {},
            );
          };
TZW's avatar
TZW committed
783
        fn();
TZW's avatar
TZW committed
784
        fn2();
TZW's avatar
TZW committed
785
      }, []);
TZW's avatar
TZW committed
786 787
      return (
        <>
TZW's avatar
TZW committed
788 789 790 791 792 793
          <ProDescriptions dataSource={request} columns={columns1} />
          <Divider style={{ marginTop: 0 }} />
          <ProDescriptions dataSource={request} columns={columns2} />
          <Divider style={{ marginTop: 0 }} />
          <ProDescriptions dataSource={request} columns={columns3} />
          <h3 className="page-title" style={{ marginBottom: 24 }}>
TZW's avatar
TZW committed
794 795 796
            扩展字段
          </h3>
          <ProDescriptions dataSource={request} columns={newfieldscolumns} />
TZW's avatar
TZW committed
797 798 799 800 801 802 803 804 805 806 807 808 809 810
        </>
      );
    };
    // 相关设备
    const Correlation = () => {
      return (
        <>
          <AutoTable
            pagetitle="子设备"
            columns={[
              {
                title: '设备编号',
                dataIndex: 'equipmentNo',
                key: 'equipmentNo',
TZW's avatar
TZW committed
811
                search: false,
wuhao's avatar
wuhao committed
812

TZW's avatar
TZW committed
813 814 815 816 817 818
                width: 120,
                formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
              },
              {
                title: '设备名称',
                dataIndex: 'equipmentName',
TZW's avatar
TZW committed
819
                search: false,
wuhao's avatar
wuhao committed
820

TZW's avatar
TZW committed
821 822 823 824 825 826
                width: 120,
                key: 'equipmentName',
                formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
              },
              {
                title: '公司名称',
wuhao's avatar
wuhao committed
827

TZW's avatar
TZW committed
828
                search: false,
TZW's avatar
TZW committed
829 830 831 832 833 834 835 836 837 838
                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
839
                search: false,
wuhao's avatar
wuhao committed
840

TZW's avatar
TZW committed
841
                valueType: 'treeSelect',
TZW's avatar
TZW committed
842 843 844
                dataIndex: 'departmentName',
                key: 'departmentId',
                options: {
TZW's avatar
TZW committed
845
                  path: '/auth/sysDepartment/query/children/tree',
TZW's avatar
TZW committed
846 847 848 849 850 851 852 853
                  linkParams: {
                    organizationId: 'parentId',
                  },
                },
              },
              {
                title: '工厂名称',
                dataIndex: 'factoryName',
TZW's avatar
TZW committed
854
                search: false,
TZW's avatar
TZW committed
855 856
                key: 'factoryId',
                width: 120,
wuhao's avatar
wuhao committed
857

TZW's avatar
TZW committed
858 859 860 861 862 863 864
                valueType: 'select',
                options: { path: '/auth/sysFactory/getAllFactorySelection', params: {} },
                formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
              },
              {
                title: '车间名称',
                dataIndex: 'shopName',
wuhao's avatar
wuhao committed
865

TZW's avatar
TZW committed
866
                search: false,
TZW's avatar
TZW committed
867 868 869 870 871 872 873 874 875 876 877 878 879
                width: 120,
                valueType: 'select',
                options: {
                  path: '/auth/sysShop/getShopSelectionByFactory',
                  linkParams: {
                    factoryId: '',
                  },
                },
                key: 'shopId',
                formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
              },
              {
                title: '工段名称',
TZW's avatar
TZW committed
880
                search: false,
TZW's avatar
TZW committed
881 882
                width: 120,
                dataIndex: 'sectionName',
wuhao's avatar
wuhao committed
883

TZW's avatar
TZW committed
884 885 886 887 888 889 890 891 892 893 894
                key: 'sectionId',
                valueType: 'select',
                options: {
                  path: '/auth/sysSection/getAllSectionSelectionByShop',
                  linkParams: {
                    shopId: '',
                  },
                },
              },
              {
                title: '产线名称',
TZW's avatar
TZW committed
895
                search: false,
TZW's avatar
TZW committed
896 897 898 899
                width: 120,
                dataIndex: 'productLineName',
                valueType: 'select',
                key: 'productLineName',
wuhao's avatar
wuhao committed
900

TZW's avatar
TZW committed
901
                options: {
TZW's avatar
TZW committed
902
                  path: '/auth/sysProductionLine/getAllProductLineSelectionByShop',
TZW's avatar
TZW committed
903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919
                  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
920
                search: false,
TZW's avatar
TZW committed
921
                key: 'equipmentNo',
wuhao's avatar
wuhao committed
922

TZW's avatar
TZW committed
923 924 925 926 927 928
                width: 120,
                formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
              },
              {
                title: '设备名称',
                dataIndex: 'equipmentName',
TZW's avatar
TZW committed
929
                search: false,
wuhao's avatar
wuhao committed
930

TZW's avatar
TZW committed
931 932 933 934 935 936
                width: 120,
                key: 'equipmentName',
                formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
              },
              {
                title: '公司名称',
wuhao's avatar
wuhao committed
937

TZW's avatar
TZW committed
938 939 940
                dataIndex: 'organizationName',
                width: 120,
                key: 'organizationId',
TZW's avatar
TZW committed
941
                search: false,
TZW's avatar
TZW committed
942 943 944 945 946 947 948
                valueType: 'select',
                options: { path: '/auth/sysDepartment/query/organization/selectbox', params: {} },
                formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
              },
              {
                title: '部门名称',
                width: 120,
wuhao's avatar
wuhao committed
949

TZW's avatar
TZW committed
950
                search: false,
TZW's avatar
TZW committed
951
                valueType: 'treeSelect',
TZW's avatar
TZW committed
952 953 954
                dataIndex: 'departmentName',
                key: 'departmentId',
                options: {
TZW's avatar
TZW committed
955
                  path: '/auth/sysDepartment/query/children/tree',
TZW's avatar
TZW committed
956 957 958 959 960 961 962
                  linkParams: {
                    organizationId: 'parentId',
                  },
                },
              },
              {
                title: '工厂名称',
TZW's avatar
TZW committed
963
                search: false,
TZW's avatar
TZW committed
964 965 966
                dataIndex: 'factoryName',
                key: 'factoryId',
                width: 120,
wuhao's avatar
wuhao committed
967

TZW's avatar
TZW committed
968 969 970 971 972 973 974
                valueType: 'select',
                options: { path: '/auth/sysFactory/getAllFactorySelection', params: {} },
                formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
              },
              {
                title: '车间名称',
                dataIndex: 'shopName',
TZW's avatar
TZW committed
975
                search: false,
wuhao's avatar
wuhao committed
976

TZW's avatar
TZW committed
977 978 979 980 981 982 983 984 985 986 987 988 989 990 991
                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
992

TZW's avatar
TZW committed
993
                key: 'sectionId',
TZW's avatar
TZW committed
994
                search: false,
TZW's avatar
TZW committed
995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007
                valueType: 'select',
                options: {
                  path: '/auth/sysSection/getAllSectionSelectionByShop',
                  linkParams: {
                    shopId: '',
                  },
                },
              },
              {
                title: '产线名称',
                width: 120,
                dataIndex: 'productLineName',
                valueType: 'select',
TZW's avatar
TZW committed
1008
                search: false,
TZW's avatar
TZW committed
1009
                key: 'productLineName',
wuhao's avatar
wuhao committed
1010

TZW's avatar
TZW committed
1011
                options: {
TZW's avatar
TZW committed
1012
                  path: '/auth/sysProductionLine/getAllProductLineSelectionByShop',
TZW's avatar
TZW committed
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 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097
                  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
1098
                key: 'operateTimeList',
TZW's avatar
TZW committed
1099
                width: 120,
TZW's avatar
TZW committed
1100
                searchValueType: 'dateRange',
TZW's avatar
TZW committed
1101 1102 1103 1104 1105 1106
                formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
              },
              {
                title: '履历类型',
                dataIndex: 'logTypeName',
                width: 120,
TZW's avatar
TZW committed
1107
                key: 'logType',
TZW's avatar
TZW committed
1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130
                valueType: 'select',
                options: [
                  {
                    label: '改造',
                    value: '1',
                  },
                  {
                    label: '报废',
                    value: '2',
                  },
                  {
                    label: '调拨',
                    value: '3',
                  },
                  {
                    label: '借用',
                    value: '4',
                  },
                  {
                    label: '归还',
                    value: '5',
                  },
                ],
TZW's avatar
TZW committed
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 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189
                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
1190 1191 1192
    );
  };

TZW's avatar
TZW committed
1193
  // 子设备
TZW's avatar
TZW committed
1194 1195 1196 1197 1198 1199 1200 1201
  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
1202
        // //console.log(result);
TZW's avatar
TZW committed
1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213
        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
1214
        search: false,
wuhao's avatar
wuhao committed
1215

TZW's avatar
TZW committed
1216 1217 1218 1219 1220 1221
        width: 120,
        formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
      },
      {
        title: '设备名称',
        dataIndex: 'equipmentName',
wuhao's avatar
wuhao committed
1222

TZW's avatar
TZW committed
1223 1224 1225 1226 1227 1228
        width: 120,
        key: 'equipmentName',
        formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
      },
      {
        title: '公司名称',
wuhao's avatar
wuhao committed
1229

TZW's avatar
TZW committed
1230 1231 1232
        dataIndex: 'organizationName',
        width: 120,
        key: 'organizationId',
TZW's avatar
TZW committed
1233 1234 1235 1236
        fieldProps: {
          placeholder: '请选择',
          showSearch: true,
        },
TZW's avatar
TZW committed
1237 1238 1239 1240 1241 1242 1243
        valueType: 'select',
        options: { path: '/auth/sysDepartment/query/organization/selectbox', params: {} },
        formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
      },
      {
        title: '部门名称',
        width: 120,
wuhao's avatar
wuhao committed
1244

TZW's avatar
TZW committed
1245
        valueType: 'treeSelect',
TZW's avatar
TZW committed
1246
        dataIndex: 'departmentName',
TZW's avatar
TZW committed
1247 1248 1249 1250
        fieldProps: {
          placeholder: '请选择',
          showSearch: true,
        },
TZW's avatar
TZW committed
1251 1252
        key: 'departmentId',
        options: {
TZW's avatar
TZW committed
1253
          path: '/auth/sysDepartment/query/children/tree',
TZW's avatar
TZW committed
1254 1255 1256 1257 1258 1259 1260 1261 1262 1263
          linkParams: {
            organizationId: 'parentId',
          },
        },
      },
      {
        title: '工厂名称',
        dataIndex: 'factoryName',
        key: 'factoryId',
        width: 120,
TZW's avatar
TZW committed
1264 1265 1266 1267
        fieldProps: {
          placeholder: '请选择',
          showSearch: true,
        },
TZW's avatar
TZW committed
1268 1269 1270 1271 1272 1273 1274
        valueType: 'select',
        options: { path: '/auth/sysFactory/getAllFactorySelection', params: {} },
        formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
      },
      {
        title: '车间名称',
        dataIndex: 'shopName',
wuhao's avatar
wuhao committed
1275

TZW's avatar
TZW committed
1276
        width: 120,
TZW's avatar
TZW committed
1277 1278 1279 1280
        fieldProps: {
          placeholder: '请选择',
          showSearch: true,
        },
TZW's avatar
TZW committed
1281 1282 1283 1284 1285 1286 1287
        valueType: 'select',
        options: {
          path: '/auth/sysShop/getShopSelectionByFactory',
          linkParams: {
            factoryId: '',
          },
        },
TZW's avatar
TZW committed
1288
        search: false,
TZW's avatar
TZW committed
1289 1290 1291
        key: 'shopId',
        formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
      },
TZW's avatar
TZW committed
1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302
      {
        title: '车间名称',
        dataIndex: 'shopName',
        width: 120,
        valueType: 'select',
        fieldProps: {
          placeholder: '请选择',
          showSearch: true,
        },
        options: {
          path: '/auth/sysShop/getAllShopSelection',
TZW's avatar
TZW committed
1303
          params: {},
TZW's avatar
TZW committed
1304 1305 1306 1307 1308
        },
        key: 'shopId',
        hideInForm: true,
        hideInTable: true,
      },
TZW's avatar
TZW committed
1309 1310 1311 1312
      {
        title: '工段名称',
        width: 120,
        dataIndex: 'sectionName',
wuhao's avatar
wuhao committed
1313

TZW's avatar
TZW committed
1314
        key: 'sectionId',
TZW's avatar
TZW committed
1315 1316 1317 1318
        fieldProps: {
          placeholder: '请选择',
          showSearch: true,
        },
TZW's avatar
TZW committed
1319 1320 1321 1322 1323 1324 1325
        valueType: 'select',
        options: {
          path: '/auth/sysSection/getAllSectionSelectionByShop',
          linkParams: {
            shopId: '',
          },
        },
TZW's avatar
TZW committed
1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340
        search: false,
      },

      {
        title: '工段名称',
        width: 120,
        dataIndex: 'sectionName',
        key: 'sectionId',
        fieldProps: {
          placeholder: '请选择',
          showSearch: true,
        },
        valueType: 'select',
        options: {
          path: '/auth/sysSection/getAllSectionSelection',
TZW's avatar
TZW committed
1341
          params: {},
TZW's avatar
TZW committed
1342 1343 1344
        },
        hideInForm: true,
        hideInTable: true,
TZW's avatar
TZW committed
1345 1346 1347 1348 1349 1350 1351
      },
      {
        title: '产线名称',
        width: 120,
        dataIndex: 'productLineName',
        valueType: 'select',
        key: 'productLineName',
TZW's avatar
TZW committed
1352 1353 1354 1355
        fieldProps: {
          placeholder: '请选择',
          showSearch: true,
        },
wuhao's avatar
wuhao committed
1356

TZW's avatar
TZW committed
1357
        options: {
TZW's avatar
TZW committed
1358
          path: '/auth/sysProductionLine/getAllProductLineSelectionByShop',
TZW's avatar
TZW committed
1359 1360 1361 1362
          linkParams: {
            shopId: '',
          },
        },
TZW's avatar
TZW committed
1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376
        search: false,
      },
      {
        title: '产线名称',
        width: 120,
        dataIndex: 'productLineName',
        valueType: 'select',
        fieldProps: {
          placeholder: '请选择',
          showSearch: true,
        },
        key: 'productLineId',
        options: {
          path: '/auth/sysProductionLine/getAllProductLineSelection',
TZW's avatar
TZW committed
1377
          params: {},
TZW's avatar
TZW committed
1378 1379 1380
        },
        hideInForm: true,
        hideInTable: true,
TZW's avatar
TZW committed
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 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454
      },
    ];
    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
1455
              //console.log('selectedRowKeys changed: ', record, selected, selectedRows);
TZW's avatar
TZW committed
1456 1457 1458 1459 1460
              setSelectArr(() => {
                return selectedRows.map((it) => it.id);
              });
            },
            onSelectAll: (selected, selectedRows, changeRows) => {
TZW's avatar
TZW committed
1461
              //console.log(selected, selectedRows, changeRows);
TZW's avatar
TZW committed
1462 1463 1464 1465 1466 1467 1468 1469
              if (selected) {
                let arr = selectArr.concat(changeRows.map((it) => it.id));
                setSelectArr(arr);
              } else {
                setSelectArr([]);
              }
            },
            onSelectNone: () => {
TZW's avatar
TZW committed
1470
              //console.log(11);
TZW's avatar
TZW committed
1471 1472 1473 1474 1475 1476 1477
              setSelectArr([]);
            },
          }}
        />
        <Space style={{ marginTop: 16 }}>
          <Button
            onClick={() => {
TZW's avatar
TZW committed
1478
              //console.log(drawer);
TZW's avatar
TZW committed
1479 1480 1481 1482 1483 1484
              setDrawer((s) => ({
                ...s,
                visible: false,
                item: null,
                detailpath: null,
                params: null,
TZW's avatar
TZW committed
1485 1486
                val: null,
                onFinish: null,
TZW's avatar
TZW committed
1487 1488 1489 1490 1491 1492 1493 1494 1495
              }));
              setSelectArr([]);
            }}
          >
            取消
          </Button>
          <Button
            type="primary"
            onClick={async () => {
TZW's avatar
TZW committed
1496
              //console.log(selectArr);
TZW's avatar
TZW committed
1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522
              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
1523 1524 1525 1526 1527 1528 1529 1530 1531 1532
  // 履历登记
  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
1533
        // //console.log(result);
TZW's avatar
TZW committed
1534 1535 1536 1537 1538
        if (!result?.data?.dataList.length == 0) {
          setSelectArr(result?.data?.dataList.map((it) => it.id));
        }
      };
      fun();
TZW's avatar
TZW committed
1539
      let dis = resumeTab?.filter((it) => it?.disabled);
TZW's avatar
TZW committed
1540
      if (dis?.length > 0 && dis[0].key == 1) {
TZW's avatar
TZW committed
1541 1542 1543 1544 1545 1546
        setactiveTab(
          menulist?.filter((it) => !dis?.map((item) => item.key).includes(it?.key))[0]?.key,
        );
      } else {
        setactiveTab(1);
      }
TZW's avatar
TZW committed
1547 1548
    }, []);

TZW's avatar
TZW committed
1549 1550 1551 1552 1553 1554 1555 1556 1557
    const menulist = useMemo(() => {
      console.log(activeTab);
      const fields = {
        1: [
          {
            title: '改造日期',
            dataIndex: 'reformDate',
            key: 'reformDate',
            valueType: 'date',
TZW's avatar
TZW committed
1558 1559 1560
            fieldProps: {
              disabledDate: disabledDateOfDay,
            },
TZW's avatar
TZW committed
1561
            formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
TZW's avatar
TZW committed
1562
          },
TZW's avatar
TZW committed
1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579
          {
            title: '改造承包商',
            dataIndex: 'supplierId',
            key: 'supplierId',
            valueType: 'select',
            options: {
              path: '/asset/equipmentSupplier/query/selection',
              params: {},
            },
            formItemProps: {
              rules: [
                {
                  required: true,
                  message: '此项为必填项',
                },
              ],
            },
TZW's avatar
TZW committed
1580
          },
TZW's avatar
TZW committed
1581 1582 1583 1584 1585 1586
          {
            title: '改造内容',
            dataIndex: 'reformContent',
            key: 'reformContent',
            valueType: 'textarea',
            formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
TZW's avatar
TZW committed
1587
          },
TZW's avatar
TZW committed
1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604
          {
            title: '上传文件(上限为5个)',
            key: 'urlIds',
            valueType: 'UploadDragger',
            // colProps: { span: 24 },
            fieldProps: {
              maxCount: 5,
              name: 'file',
            },
            formItemProps: {
              rules: [
                {
                  required: false,
                  message: '此项为必填项',
                },
              ],
            },
TZW's avatar
TZW committed
1605
          },
TZW's avatar
TZW committed
1606 1607 1608 1609 1610 1611
        ],
        2: [
          {
            title: '报废日期',
            dataIndex: 'scrapDate',
            key: 'scrapDate',
TZW's avatar
TZW committed
1612 1613 1614
            fieldProps: {
              disabledDate: disabledDateOfDay,
            },
TZW's avatar
TZW committed
1615 1616
            valueType: 'date',
            formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
TZW's avatar
TZW committed
1617
          },
TZW's avatar
TZW committed
1618 1619 1620 1621 1622 1623
          {
            title: '报废原因',
            dataIndex: 'scrapReason',
            key: 'scrapReason',
            valueType: 'textarea',
            formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
TZW's avatar
TZW committed
1624
          },
TZW's avatar
TZW committed
1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639
          {
            title: '上传文件(上限为5个)',
            key: 'urlIds',
            valueType: 'UploadDragger',
            formItemProps: {
              rules: [
                {
                  required: false,
                  message: '此项为必填项',
                },
              ],
            },
            fieldProps: {
              name: 'file',
              maxCount: 5,
TZW's avatar
TZW committed
1640 1641
            },
          },
TZW's avatar
TZW committed
1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661
        ],
        3: [
          {
            title: '调入公司',
            dataIndex: 'organizationName',
            key: 'toOrganizationId',
            valueType: 'select',
            options: { path: '/auth/sysDepartment/query/organization/selectbox', params: {} },
            formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
          },
          {
            title: '调入部门',
            valueType: 'treeSelect',
            dataIndex: 'departmentName',
            key: 'toDepartmentId',
            options: {
              path: '/auth/sysDepartment/query/children/tree',
              linkParams: {
                toOrganizationId: 'parentId',
              },
TZW's avatar
TZW committed
1662 1663
            },
          },
TZW's avatar
TZW committed
1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680
          {
            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',
              },
TZW's avatar
TZW committed
1681
            },
TZW's avatar
TZW committed
1682 1683
            key: 'toShopId',
            formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
TZW's avatar
TZW committed
1684
          },
TZW's avatar
TZW committed
1685 1686 1687 1688 1689 1690 1691 1692 1693 1694
          {
            title: '调入工段',
            dataIndex: 'sectionName',
            key: 'toSectionId',
            valueType: 'select',
            options: {
              path: '/auth/sysSection/getAllSectionSelectionByShop',
              linkParams: {
                toShopId: 'shopId',
              },
TZW's avatar
TZW committed
1695 1696
            },
          },
TZW's avatar
TZW committed
1697 1698 1699 1700 1701 1702 1703 1704 1705 1706
          {
            title: '调入产线',
            dataIndex: 'productionLines',
            valueType: 'select',
            key: 'toProductLineId',
            options: {
              path: '/auth/sysProductionLine/getAllProductLineSelectionByShop',
              linkParams: {
                toShopId: 'shopId',
              },
TZW's avatar
TZW committed
1707 1708
            },
          },
TZW's avatar
TZW committed
1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719
          {
            title: '调入位置号',
            dataIndex: 'toPositionNo',
            valueType: 'input',
            key: 'toPositionNo',
          },
          {
            title: '调拨日期',
            dataIndex: 'transferDate',
            key: 'transferDate',
            valueType: 'date',
TZW's avatar
TZW committed
1720 1721 1722
            fieldProps: {
              disabledDate: disabledDateOfDay,
            },
TZW's avatar
TZW committed
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
            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: '借用部门',
            valueType: 'treeSelect',
            dataIndex: 'departmentName',
            key: 'toDepartmentId',
            options: {
              path: '/auth/sysDepartment/query/children/tree',
              linkParams: {
                toOrganizationId: 'parentId',
              },
TZW's avatar
TZW committed
1752 1753
            },
          },
TZW's avatar
TZW committed
1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770
          {
            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',
              },
TZW's avatar
TZW committed
1771
            },
TZW's avatar
TZW committed
1772 1773
            key: 'toShopId',
            formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
TZW's avatar
TZW committed
1774
          },
TZW's avatar
TZW committed
1775 1776 1777 1778 1779 1780 1781 1782 1783 1784
          {
            title: '借用工段',
            dataIndex: 'sectionName',
            key: 'toSectionId',
            valueType: 'select',
            options: {
              path: '/auth/sysSection/getAllSectionSelectionByShop',
              linkParams: {
                toShopId: 'shopId',
              },
TZW's avatar
TZW committed
1785 1786
            },
          },
TZW's avatar
TZW committed
1787 1788 1789 1790 1791 1792 1793 1794 1795 1796
          {
            title: '借用产线',
            dataIndex: 'productionLines',
            valueType: 'select',
            key: 'toProductLineId',
            options: {
              path: '/auth/sysProductionLine/getAllProductLineSelectionByShop',
              linkParams: {
                toShopId: 'shopId',
              },
TZW's avatar
TZW committed
1797 1798
            },
          },
TZW's avatar
TZW committed
1799 1800 1801 1802 1803 1804 1805 1806 1807 1808
          {
            title: '借用位置号',
            dataIndex: 'toPositionNo',
            valueType: 'input',
            key: 'toPositionNo',
          },
          {
            title: '借用日期',
            dataIndex: 'borrowDate',
            key: 'borrowDate',
TZW's avatar
TZW committed
1809 1810 1811
            fieldProps: {
              disabledDate: disabledDateOfDay,
            },
TZW's avatar
TZW committed
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
            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: 'returnOrganizationId',
            key: 'returnOrganizationId',
            valueType: 'select',
            options: { path: '/auth/sysDepartment/query/organization/selectbox', params: {} },
            formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
          },
          {
            title: '接收部门',
            valueType: 'treeSelect',
            dataIndex: 'returnDepartmentId',
            key: 'returnDepartmentId',
            options: {
              path: '/auth/sysDepartment/query/children/tree',
              linkParams: {
                returnOrganizationId: 'parentId',
              },
TZW's avatar
TZW committed
1849 1850
            },
          },
TZW's avatar
TZW committed
1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867
          {
            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',
              },
TZW's avatar
TZW committed
1868
            },
TZW's avatar
TZW committed
1869 1870
            key: 'returnShopId',
            formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
TZW's avatar
TZW committed
1871
          },
TZW's avatar
TZW committed
1872 1873 1874 1875 1876 1877 1878 1879 1880 1881
          {
            title: '接收工段',
            dataIndex: 'returnSectionId',
            key: 'returnSectionId',
            valueType: 'select',
            options: {
              path: '/auth/sysSection/getAllSectionSelectionByShop',
              linkParams: {
                returnShopId: 'shopId',
              },
TZW's avatar
TZW committed
1882 1883
            },
          },
TZW's avatar
TZW committed
1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906
          {
            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',
TZW's avatar
TZW committed
1907 1908 1909
            fieldProps: {
              disabledDate: disabledDateOfDay,
            },
TZW's avatar
TZW committed
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 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049
            formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
          },
          {
            title: '备注',
            dataIndex: 'remark',
            key: 'remark',
            valueType: 'textarea',
            formItemProps: { rules: [{ required: false, message: '此项为必填项' }] },
          },
        ],
      };
      let arr = [
        {
          label: '改造',
          key: 1,
          children: activeTab == 1 && (
            <InitForm
              fields={fields[activeTab]}
              defaultFormValue={drawer?.item}
              onFinish={async (vals) => {
                //console.log(vals);
                let res = await doFetch({
                  url: urlParams_resume.save,
                  params: { ...vals, type: '1', equipmentId: drawer?.item?.id },
                });
                if (res.code === '0000') {
                  message.success('登记成功!');
                  await setDrawer((s) => ({
                    ...s,
                    visible: false,
                    item: null,
                  }));
                  actionRef.current.reload();
                }
              }}
            />
          ),
        }, // remember to pass the key prop
        {
          label: '报废',
          key: 2,
          children: activeTab == 2 && (
            <InitForm
              fields={fields[activeTab]}
              defaultFormValue={drawer?.item}
              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('登记成功!');
                  await setDrawer((s) => ({
                    ...s,
                    visible: false,
                    item: null,
                  }));
                  actionRef.current.reload();
                }
              }}
            />
          ),
        },
        {
          label: '调拨',
          key: 3,
          children: activeTab == 3 && (
            <InitForm
              fields={fields[activeTab]}
              defaultFormValue={drawer?.item}
              onFinish={async (vals) => {
                //console.log(vals);
                let res = await doFetch({
                  url: urlParams_resume.save,
                  params: { ...vals, type: '3', equipmentId: drawer?.item?.id },
                });
                if (res.code === '0000') {
                  message.success('登记成功!');
                  await setDrawer((s) => ({
                    ...s,
                    visible: false,
                    item: null,
                  }));
                  actionRef.current.reload();
                }
              }}
            />
          ),
        },
        {
          label: '借用',
          key: 4,
          children: activeTab == 4 && (
            <InitForm
              defaultFormValue={drawer?.item}
              fields={fields[activeTab]}
              onFinish={async (vals) => {
                //console.log(vals);
                let res = await doFetch({
                  url: urlParams_resume.save,
                  params: { ...vals, type: '4', equipmentId: drawer?.item?.id },
                });
                if (res.code === '0000') {
                  message.success('登记成功!');
                  await setDrawer((s) => ({
                    ...s,
                    visible: false,
                    item: null,
                  }));
                  actionRef.current.reload();
                }
              }}
            />
          ),
        },
        {
          label: '归还',
          key: 5,
          children: activeTab == 5 && (
            <InitForm
              fields={fields[activeTab]}
              defaultFormValue={drawer?.item}
              onFinish={async (vals) => {
                //console.log(vals);
                let res = await doFetch({
                  url: urlParams_resume.save,
                  params: { ...vals, type: '5', equipmentId: drawer?.item?.id },
                });
                if (res.code === '0000') {
                  message.success('登记成功!');
                  await setDrawer((s) => ({
                    ...s,
                    visible: false,
                    item: null,
                  }));
                  actionRef.current.reload();
                }
              }}
            />
          ),
TZW's avatar
TZW committed
2050
        },
TZW's avatar
TZW committed
2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067
      ];
      let dis = resumeTab?.filter((it) => it?.disabled);
      arr.forEach((item) => {
        dis?.forEach((it) => {
          if (item?.key == it?.key) {
            let string = item.label;
            item.disabled = true;
            item.label = (
              <Tooltip placement="topLeft" title={it.disabledReason}>
                <span>{string}</span>
              </Tooltip>
            );
          }
        });
      });
      return arr;
    }, [activeTab]);
TZW's avatar
TZW committed
2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140

    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 />
TZW's avatar
TZW committed
2141
        <Tabs activeKey={activeTab} onChange={setactiveTab} items={menulist} />
TZW's avatar
TZW committed
2142 2143 2144 2145
      </>
    );
  };

wuhao's avatar
wuhao committed
2146
  const columns = useMemo(() => {
TZW's avatar
TZW committed
2147
    let defcolumn = getcolumns(setDrawer);
TZW's avatar
TZW committed
2148 2149 2150 2151 2152 2153 2154
    defcolumn[1].render = (text, row) => {
      return (
        <a
          onClick={() => {
            setDrawer((s) => ({
              ...s,
              visible: true,
TZW's avatar
TZW committed
2155 2156 2157
              type: 'detail',
              item: row,
              val: 'only',
TZW's avatar
TZW committed
2158 2159 2160 2161 2162 2163 2164 2165
              title: row.equipmentName + '的详细信息',
            }));
          }}
        >
          {row.equipmentName}
        </a>
      );
    };
wuhao's avatar
wuhao committed
2166 2167 2168
    return defcolumn.concat({
      title: '操作',
      valueType: 'option',
TZW's avatar
TZW committed
2169 2170 2171 2172 2173 2174 2175
      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
2176 2177 2178
    });
  }, []);

TZW's avatar
TZW committed
2179 2180 2181 2182 2183
  const onselecteTree = async (selectedKeys, e, alldata) => {
    let params = {
      treeNodeType: e.node.type,
      treeNodeKey: e.node.key,
    };
TZW's avatar
TZW committed
2184
    setextraparams(params);
TZW's avatar
TZW committed
2185 2186 2187 2188 2189 2190 2191 2192
  };

  const selectMoreDrawerType = (type) => {
    switch (type) {
      case 'editChildEquipment':
        return <EditChildEquipment />;
      case 'resume':
        return <Resume />;
TZW's avatar
TZW committed
2193 2194
      case 'detail':
        return <Detail />;
TZW's avatar
TZW committed
2195 2196 2197 2198 2199 2200 2201
      case 'add':
        return (
          <ExtendField
            setDrawer={setDrawer}
            drawer={drawer}
            actionRef={actionRef}
            columns={columns}
TZW's avatar
TZW committed
2202
            // urlParams={urlParams}
TZW's avatar
TZW committed
2203 2204 2205 2206 2207 2208
            formId={'2'}
            onFinish={async (vals) => {
              let equipmentCharReqList = [];
              for (let i in vals) {
                if (!isNaN(Number(i))) {
                  equipmentCharReqList.push({
TZW's avatar
TZW committed
2209
                    fieldId: i,
TZW's avatar
TZW committed
2210
                    fieldRealValue: vals[i],
TZW's avatar
TZW committed
2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253
                  });
                  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
2254
                    fieldId: i,
TZW's avatar
TZW committed
2255
                    fieldRealValue: vals[i],
TZW's avatar
TZW committed
2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283
                  });
                  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
2284 2285
      default:
        return null;
TZW's avatar
TZW committed
2286 2287 2288
    }
  };

TZW's avatar
TZW committed
2289
  const containderef = useRef();
wuhao's avatar
wuhao committed
2290 2291
  return (
    <div style={{ position: 'relative' }}>
TZW's avatar
TZW committed
2292
      <div className="ant-card-head" style={{ backgroundColor: 'white' }}>
TZW's avatar
TZW committed
2293 2294 2295 2296 2297 2298
        <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
2299
      <Layout style={{ height: '100%' }} ref={containderef}>
TZW's avatar
TZW committed
2300
        <Sider theme="light" width={300}>
TZW's avatar
TZW committed
2301
          <TreeRender url="/auth/sysFactory/getTree" onselected={onselecteTree} noaction={true} />
TZW's avatar
TZW committed
2302 2303 2304 2305 2306
        </Sider>
        <Content>
          <AutoTable
            pagetitle={<h3 style={{ marginBottom: 0, fontWeight: 400 }}>设备台账</h3>}
            columns={columns}
TZW's avatar
TZW committed
2307
            path={urlParams.list}
TZW's avatar
TZW committed
2308 2309
            actionRef={actionRef}
            pageextra={'add'}
TZW's avatar
TZW committed
2310
            resizeable={false}
TZW's avatar
TZW committed
2311 2312 2313 2314 2315 2316
            addconfig={{
              // access: 'sysDepartment_save',
              btn: {
                disabled: false,
                type: 'primary',
                onClick: () => {
TZW's avatar
TZW committed
2317
                  setDrawer((s) => ({
TZW's avatar
TZW committed
2318 2319 2320 2321
                    ...s,
                    visible: true,
                    item: null,
                    title: '新增',
TZW's avatar
TZW committed
2322 2323 2324
                    val: 'only',
                    type: 'add',
                    // onFinish: async (vals) => {
TZW's avatar
TZW committed
2325
                    //   //console.log(vals);
TZW's avatar
TZW committed
2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341
                    //   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
2342 2343 2344 2345
                  }));
                },
              },
            }}
TZW's avatar
TZW committed
2346
            x={1500}
TZW's avatar
TZW committed
2347
            extraparams={extraparams}
TZW's avatar
TZW committed
2348 2349 2350
          />
        </Content>
      </Layout>
wuhao's avatar
wuhao committed
2351 2352 2353 2354 2355
      <DrawerPro
        fields={columns}
        formRef={formRef}
        placement="right"
        onClose={() => {
TZW's avatar
TZW committed
2356
          setDrawer((s) => ({
wuhao's avatar
wuhao committed
2357 2358 2359 2360 2361
            ...s,
            visible: false,
          }));
        }}
        {...drawer}
wuhao's avatar
wuhao committed
2362 2363 2364
        colProps={{
          span: 8,
        }}
TZW's avatar
TZW committed
2365
      >
wuhao's avatar
wuhao committed
2366
        {drawer?.visible && selectMoreDrawerType(drawer?.type)}
TZW's avatar
TZW committed
2367
      </DrawerPro>
TZW's avatar
TZW committed
2368 2369 2370

      <DrawerPro
        placement="right"
TZW's avatar
TZW committed
2371 2372 2373
        onClose={async () => {
          await setactiveTab(3);
          await setCurrDrawer((s) => ({
TZW's avatar
TZW committed
2374 2375 2376 2377 2378 2379
            ...s,
            visible: false,
            item: null,
          }));
        }}
        {...currDrawer}
wuhao's avatar
wuhao committed
2380 2381 2382
        colProps={{
          span: 8,
        }}
TZW's avatar
TZW committed
2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447
      >
        <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
2448
          column={2}
TZW's avatar
TZW committed
2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461
          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
2462 2463 2464 2465
    </div>
  );
}

TZW's avatar
TZW committed
2466
export default Model;