【无标题】

 componentWillReceiveProps(props) {
    const { printData, repayList } = props.cardNoChangeApply;
    const { args } = this.props;
    if (JSON.stringify(printData) !== '{}') {
      this.setState({ pdfPath: `${serviceHost()}${printData.docPdfView}`, isVisible: true });
      for (const attr of Object.keys(printData)) {
        delete printData[attr];
      }
    }
    if (args) {
      console.log(repayList);
      if (repayList.length > 0) {
        // eslint-disable-next-line max-len
        const **msg** = repayList.filter((item) => { return item.CUST_NAME === args.record.NEW_DEBIT_BY; })[0];
        this.setState({
          OLD_PHONE_BAK: args.record.ABC_PHONE,
          OLD_CERT_NO_BAK: msg.NEW_CERT_NO,
        });
      }
    }
  }

要判断repayList.length大于0的情况。
因为获取接口是异步的方法,所以当接口返回后repayList才有数据,在这之后再将返回的值设置到state中去。

save = (type) => {
    const { dispatch, form, args, cardNoChangeApply } = this.props;
    const { repayList, orderIdList = {} } = cardNoChangeApply;
    const { getFieldValue } = this.props.form;
    const selectmsg = repayList.filter((item) => { return item.CUST_NAME === getFieldValue('NEW_DEBIT_BY'); })[0];
    form.validateFieldsAndScroll((errors, values) => {
      if (errors) return;
     
      const params = { ...values };
      params.CUST_ID = **selectmsg**.CUST_ID;
      params.CUSTOMER_ROLE = **selectmsg**.CUSTOMER_ROLE;
      params.CUSTOMER_NAME = **selectmsg**.CUST_NAME;
  
      Object.assign(params, { NEW_CERT_NO: newCartNo, NEW_PHONE: newPhone });

      if (values.EXEMPT_MONEY === 0) {
        params.EXEMPT_MONEY = '0';
      }
      params.CHANGE_REASON = encodeURIComponent(values.CHANGE_REASON);
      params.subType = type;
      params.SALE_ORDER_STATUS = '0';

      **if (args) {
        params.FUNDS_REQUEST_ID = this.state.fundId;
        params.DEBIT_MODLE = args.record.DEBIT_MODLE;
        params.CARD_CHANGE_ID = args.record.CARD_CHANGE_ID;
        params.SALE_ORDER_ID = args.record.SALE_ORDER_ID;
        params.Save_CardChange = 'update';
        params.RENT_REQUEST_ID = args.record.RENT_REQUEST_ID;
        params.SALE_ORDER_STATUS = args.record.SALE_ORDER_STATUS;
        params.OLD_PHONE_BAK = this.state.OLD_PHONE_BAK;
        params.OLD_CERT_NO_BAK = this.state.OLD_CERT_NO_BAK;
        params.NEW_PHONE_BAK = values.ABC_PHONE;
        params.NEW_CERT_NO_BAK = selectmsg.NEW_CERT_NO;
      } else {
        const contractList = this.getContract();
        params.FUNDS_REQUEST_ID = contractList.FUNDS_REQUEST_ID;
        params.DEBIT_MODLE = contractList.DEBIT_MODLE;
        params.CARD_CHANGE_ID = cardNoChangeApply.primaryKey;
        params.Save_CardChange = 'add';
        params.RENT_REQUEST_ID = contractList.RENT_REQUEST_ID;
        params.OLD_PHONE_BAK = values.PHONE;
        params.OLD_CERT_NO_BAK = values.CERT_NO;
        params.NEW_PHONE_BAK = values.ABC_PHONE;
        params.NEW_CERT_NO_BAK = selectmsg.NEW_CERT_NO;
      }**
      if (JSON.stringify(orderIdList) !== '{}') {
        params.Save_CardChange = 'update';
      }

      if (type === '6') {
        if (values.CUST_NAME1 === values.NEW_DEBIT_BY &&
          values.OLD_CARD_NUM === values.NEW_CARD_NUM &&
          values.OLD_ACCOUNT_BANK === values.NEW_ACCOUNT_BANK) {
          confirm({
            title: '提示',
            content: '旧卡信息与新卡信息一致,是否确定提交?',
            onOk() {
              confirm({
                title: '提示',
                content: '请确认申请表签字上传后再提交',
                onOk() {
                  dispatch({
                    type: 'cardNoChangeApply/saveNoChange',
                    payload: params,
                  });
                },
                onCancel() { },
              });
            },
            onCancel() { },
          });
        } else {
          confirm({
            title: '提示',
            content: '请确认申请表签字上传后再提交',
            onOk() {
              dispatch({
                type: 'cardNoChangeApply/saveNoChange',
                payload: params,
              });
            },
            onCancel() { },
          });
        }
      } else {
        dispatch({
          type: 'cardNoChangeApply/saveNoChange',
          payload: params,
        });
      }
    });
  }

再在save保存的时候,通过const selectmsg = repayList.filter((item) => { return item.CUST_NAME === getFieldValue('NEW_DEBIT_BY'); })[0];
的方法的到选中的那一条数据。

通过this.state.OLD_PHONE_BAK;得到之前设置的state中的数据。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值