AuditPage.js 3.2 KB
Newer Older
王绍森's avatar
王绍森 committed
1 2 3 4 5 6
import pageSetting from './pageSetting';
import React, { Component, Fragment } from 'react';
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
import List from '../ApplyPage/List';
import ListTab from './ListTab';
import { deepCopy } from '@/baseComponent/utils';
7
import { getApplyPage, getHandledPage, getWaitPage } from '../publicApiService';
8 9 10
import AuditModal from '@/webPublic/FormInsertDiy/AuditPage/BatchAudit/AuditModal';
import { ModalInfo } from '@/baseComponent/Modal';
import ButtonDiy from '@/baseComponent/ButtonDiy';
王绍森's avatar
王绍森 committed
11 12 13 14

export default class AuditPage extends Component {
  constructor(props) {
    super(props);
15
    this.state = {};
王绍森's avatar
王绍森 committed
16 17
  }

18 19
  componentDidMount() {}

王绍森's avatar
王绍森 committed
20 21 22 23
  handleButtonSet = () => {
    const { addFields, workId } = this.props;
    return {
      tab1: [
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
        {
          type: 'audit',
          component: 'RenderComponent',
          render: ({ selectRows, getPage }) => {
            const disabled = !selectRows || !Array.isArray(selectRows) || !selectRows.length;
            function handleClick(onShow) {
              const taskName = selectRows[0].taskName;
              const differentTask = selectRows.slice(1).find(i => i.taskName !== taskName);
              if (differentTask) {
                return ModalInfo((
                  <div>
                    <strong style={{color: "red"}}> {differentTask.taskName} </strong>
                    <strong> {taskName} </strong>不能一起审核。<br />
                  请将分开操作。
                  </div>
                ));
              }
              onShow();
            }
            return (
              <AuditModal selectRows={selectRows} getPage={getPage}>
                {({ onShow }) => (
                  <ButtonDiy
                    name="批量审核"
                    handleClick={() => handleClick(onShow)}
                    disabled={disabled}
                  />
                )}
              </AuditModal>
            );
          },
        },
王绍森's avatar
王绍森 committed
56 57 58 59 60 61
      ],
      tab2: [],
    };
  };

  handleSearchSet = () => {
62 63
    const { columns, searchCondition } = this.props;
    const tab1 = {
王绍森's avatar
王绍森 committed
64
      search: {
65
        field: {},
王绍森's avatar
王绍森 committed
66
        getPageService: getWaitPage,
67
        responseCallBack: response => {
王绍森's avatar
王绍森 committed
68 69 70 71 72 73 74 75 76 77 78
          return response;
        },
        condition: searchCondition,
        nameSpan: { big: 8, small: 9 },
        fileSpan: { big: 4, small: 4 },
      },
      tableRowKey: 'id',
      columns,
    };
    const tab2 = {
      search: {
79
        field: {},
王绍森's avatar
王绍森 committed
80
        getPageService: getHandledPage,
81
        responseCallBack: response => {
王绍森's avatar
王绍森 committed
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
          return response;
        },
        condition: searchCondition,
        nameSpan: { big: 8, small: 9 },
        fileSpan: { big: 4, small: 4 },
      },
      tableRowKey: 'id',
      columns,
    };
    return {
      tab1,
      tab2,
    };
  };

  render() {
    const { workId, dataBaseId, addFields } = this.props;

    return (
      <PageHeaderWrapper title="">
102 103 104 105 106 107 108 109
        <ListTab
          tabList={pageSetting.tabList}
          pageButton={this.handleButtonSet({})}
          workId={workId}
          dataBaseId={dataBaseId}
          addFields={addFields}
          pageSearch={this.handleSearchSet({})}
        />
王绍森's avatar
王绍森 committed
110 111 112 113
      </PageHeaderWrapper>
    );
  }
}