lodash#divide JavaScript Examples

The following examples show how to use lodash#divide. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.js    From hzero-front with Apache License 2.0 6 votes vote down vote up
/**
   * @function handleAdd - 更新汇率定义
   * @param {object} record - 更新的数据
   */
  @Bind()
  handleAdd(fieldsValue) {
    const { dispatch } = this.props;
    const { rateFormData } = this.state;
    const params = {
      ...rateFormData,
      ...fieldsValue,
      enabledFlag: fieldsValue.enabledFlag ? 1 : 0,
      startDate: moment(fieldsValue.startDate).format(DATETIME_MIN),
      endDate: moment(fieldsValue.endDate).format(DATETIME_MIN),
      rate: round(divide(fieldsValue.exchangeNumber, fieldsValue.currencyNumber), 8),
    };
    dispatch({
      type: `rate/${rateFormData.exchangeRateId ? 'updateRate' : 'createRate'}`,
      payload: params,
    }).then((response) => {
      if (Array.isArray(response) && response.length > 0) {
        notification.warning({
          message: intl
            .get('hpfm.rate.view.validation.repeatData', {
              date: response.join('、'),
            })
            .d(`所选日期区间存在重复数据:${response.join('、')}`),
        });
      } else {
        // eslint-disable-next-line
        if (response) {
          notification.success();
          this.hideModal();
          this.fetchRateData();
        }
      }
    });
  }