index.js 3.0 KB
Newer Older
王绍森's avatar
王绍森 committed
1 2 3 4 5 6 7
/**
 * 事务页面。 根据一站式服务大厅的事务接口。达到增删发起事务流程
 * 2019年10月23日 09:48:13
 * 钟是志
 *
 * */

8 9
import { message } from 'antd';
import React, {  } from 'react';
王绍森's avatar
王绍森 committed
10 11 12
import * as service from '../publicApiService';
import AuditPage from './AuditPage';
import * as destructionFunc from '../destruction';
13
import { Link } from 'dva/router';
王绍森's avatar
王绍森 committed
14 15 16 17

export default class Index extends React.Component {
  constructor(props) {
    super(props);
18 19
    let pathname = this.props.location.pathname;
    const idObj = service.getId(pathname);
王绍森's avatar
王绍森 committed
20 21 22 23 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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
    if (!idObj) {
      message.error('没有配置数据id,无法使用该功能');
    }
    this.state = {
      columns: [],
      dataList: [],
      headerInfo: [],
      workId: idObj.workId,
      searchCondition: [],
      dataBaseId: idObj.dataBaseId,
      addCondition: [],
      addFields: [], // 新增时填写的字段。
      tableInfo: {}, // 表格配置属性
      allConfigSetInfo: {}, // getFormDetail 返回的数据
    };
  };

  getFormDetail = (workId) => {
    const { dataBaseId } = this.state;
    /*service.getQueryCondition(dataBaseId).then((response) => {
      this.setState({searchCondition: response})
    });*/

    service.getFormDetail(workId).then((response) => {
      if (typeof response.unifiedServicePatternModel === 'undefined') {
        return false;
      }
      destructionFunc.destructionGetDetail(response).then((x) => {
        const { addFields, tableInfo, allConfigSetInfo } = x;
        this.setState({
          addFields,
          tableInfo,
          allConfigSetInfo,
        },() => {
          this.giveDetailColumns();
        });
      });
    });
  };

  giveDetailColumns = () =>{
    const { columns, workId, dataBaseId, addFields, tableInfo } = this.state;
    columns.push(
      {
        dataIndex: 'operation',
        title: '操作',
        fixed: columns.length > 12 ? 'right' : false,
        render: (text, record) => {
          return ( <Link to={
            {
              pathname: "./Detail",
              state: {
                workId,
                dataBaseId,
                record,
                addFields,
                tableInfo
              },
            }}>
            详情
          </Link> );
        },
      },
    );
    this.setState({
      columns,
    })
  };

  componentDidMount() {
    const { workId, dataBaseId, addFields } = this.state;
    service.getColumns(workId).then((response) => {
      if (response && response.length) {
        this.setState({
          columns: response, // 表头
        },()=>{
          this.getFormDetail(workId);
        });
      }
    });
  }

  render() {
    const { workId, dataBaseId, columns, searchCondition, addFields, allConfigSetInfo, tableInfo } = this.state;
    return (
      <AuditPage
        workId={workId}
        dataBaseId={dataBaseId}
        columns={columns}
        addFields={addFields}
        tableInfo={tableInfo}
        allConfigSetInfo={allConfigSetInfo}
        searchCondition={searchCondition}
      />
    );
  }
}