2018-01-19旧版production-order添加字段

2018-01-19  本文已影响0人  NOTEBOOK2

1 原来

const createProductionOrder = (data, storeId) => (dispatch) => {
  dispatch({ type: actionTypes.SUBMIT_PRODUCTION_ORDER_OVERVIEW_REQUEST });
  return dispatch(create(data, storeId))
    .then(resp => {
      const { data, error } = resp;
      if (!error) {
        let { id } = data;
        routeHelper.goProductionOrders(storeId, id);
      } else {
        alert(error.message);
        dispatch({ type: actionTypes.SUBMIT_PRODUCTION_ORDER_OVERVIEW_FAILURE, error });
      }
    });
};
production_order_item_materials_attributes

更改上传的参数

  update(data, id, storeId) {
    let path = `v2/stores/${storeId}/production_orders/${id}`;
    return super.put(path, data, config.gateway);
  }

  create(data, storeId) {
    let path = `v2/stores/${storeId}/production_orders`;
    return super.post(path, data, config.gateway);
  }
const createProductionOrder = (data, storeId) => (dispatch) => {
  dispatch({ type: actionTypes.SUBMIT_PRODUCTION_ORDER_OVERVIEW_REQUEST });

  dispatch(startFetch());
  dispatch(getListingBillOfMaterialCollection(
    data.productionOrderItemsAttributes[0].listingId, storeId))
    .then(resp => {
      dispatch(stopFetch());
      const { data } = resp;
      const billOfMaterialsData = data;
      // Object.assign({}, )
      console.log(billOfMaterialsData)
      return dispatch(create(data, storeId)).then(resp => {
        const { data, error } = resp;
        if (!error) {
          let { id } = data;
          routeHelper.goProductionOrders(storeId, id);
        } else {
          alert(error.message);
          dispatch({ type: actionTypes.SUBMIT_PRODUCTION_ORDER_OVERVIEW_FAILURE, error });
        }
      });
    })
};
屏幕快照 2018-01-19 16.46.28.png
const createProductionOrder = (data, storeId) => (dispatch) => {
  dispatch({ type: actionTypes.SUBMIT_PRODUCTION_ORDER_OVERVIEW_REQUEST });

  dispatch(startFetch());
  // data.productionOrderItemsAttributes[0].listingId = 358708
  dispatch(getListingBillOfMaterialCollection(358708, storeId))
    .then(resp => {
      dispatch(stopFetch());
      const billOfMaterialsData = resp.data;
      Object.assign(data, {productionOrderItemMaterialsAttributes: billOfMaterialsData} )
      return dispatch(create(data, storeId)).then(resp => {
        const { data, error } = resp;
        if (!error) {
          let { id } = data;
          routeHelper.goProductionOrders(storeId, id);
        } else {
          alert(error.message);
          dispatch({ type: actionTypes.SUBMIT_PRODUCTION_ORDER_OVERVIEW_FAILURE, error });
        }
      });
    })
};
上一篇下一篇

猜你喜欢

热点阅读