GJLZJXJApply.js 1.7 KB
Newer Older
王绍森's avatar
王绍森 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 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
/**
 * 国家励志奖学金
 * 钟是志
 * 2019年11月28日
 * 因业务复杂只能特殊开发
 * */
import React, { Component } from 'react';
import ApplyPage from '../index';
import { getDefaultValues } from '../../destruction';
import { message } from 'antd';

const getIndex = (arr, name) => {
  return arr.findIndex((x) => {
    return x.name === name;
  });
};


const GJLZJXJApply = WrappedComponent => class extends Component {

  diyFunction = () => {
    this.instanceComponent.handleButtonSet = () => {
      let that = this.instanceComponent;
      const { addFields, workId, tableInfo } = that.state;
      const bankNumIndex = getIndex(addFields, '工商银行卡号');
      const defaultValues = getDefaultValues(addFields, tableInfo);
      const beforeSubmit = (data, ModalFormComponent) => {
        const bankKey = addFields[bankNumIndex].key;
        if(data[bankKey] && data[bankKey].replace(/\s/g,"").length !== 19){
          message.warning('请输入正确的19位工商银行卡卡号');
          return false;
        }
        return data;
      };
      return [
        {
          type: 'add',
          name: '申请',
          component: 'ModalForm',
          workId,
          fields: addFields,
          modalWidth: 800,
          values: {
            ...defaultValues,
          },
          beforeSubmit,
          nameSpan: { big: 6, small: 6 },
          fileSpan: { big: 1, small: 1 },
        },
      ];
    };
  };


  componentDidMount() {
    console.log(this.instanceComponent);
    this.diyFunction();
  }

  render() {
    return (
      <WrappedComponent
        ref={instanceComponent => this.instanceComponent = instanceComponent}
      />
    );
  }
};
export default KNXSRDApply(ApplyPage); // 高阶组件