index.js 2.0 KB
import React, { useState } from 'react';
import PageTypeMatching from '@/highOrderComponent/PageTypeMatching';
import getInfoGenerator from '@/webPublic/FormInsertDiy/getInfoGenerator';
import AuditModal from './AuditModal';
import { findValueByKey } from '../../../../pages/zydtw/Cxcy/utils';
import withGoBack from '@/highOrderComponent/withGoBack';

const defaultNameSpan = { big: 9, small: 9 };
const defaultFieldSpan = { big: 4, small: 4 };

const defaultPageSetting = {
  selectRows: true,
  paging: true,
  searchArea: true,
  buttonArea: true,
};

export default withGoBack(function BatchAudit({
  appId,
  flowNode,
  getInfo,
  condition,
  nameSpan,
  fieldSpan,
  tableRowKey,
  columns,
  pageButton,
  pageSetting,
}) {
  const [code, setCode] = useState(null);
  const pageSearch = {
    search: {
      searchType: 'cascadeSearchNew',
      getInfo: getInfo || getInfoGenerator(condition),
      url: '/common/assigneeTasks',
      field: {
        appId: {
          required: true,
          defaultValue: appId,
        },
        flowNode: {
          required: true,
          defaultValue: flowNode,
        },
      },
      condition: condition || [],
      nameSpan: nameSpan || defaultNameSpan,
      fileSpan: fieldSpan || defaultFieldSpan,
      responseCallBack: res => {
        if (res && res.rows && res.rows[0]) {
          setCode(findValueByKey(res.rows[0], 'code'));
        }
        return res;
      },
    },
    tableRowKey: tableRowKey || 'buzinessId',
    columns: columns || [],
  };

  const defaultPageButton = [
    {
      type: 'create',
      name: '批量审核',
      component: 'RenderComponent',
      render: ({ selectRows, getPage }) => {
        return <AuditModal selectRows={selectRows} getPage={getPage} code={code} />;
      },
    },
  ];

  return (
    <PageTypeMatching
      tabsShellStyle={{ marginTop: 0 }}
      pageSetting={{ type: 'list', listConfig: { ...defaultPageSetting, ...pageSetting } }}
      pageButton={pageButton || defaultPageButton}
      pageSearch={pageSearch}
    />
  );
});