美文网首页
2018-01-19旧版production-order添加字段

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

作者: NOTEBOOK2 | 来源:发表于2018-01-19 16:45 被阅读0次

    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 });
            }
          });
        })
    };
    

    相关文章

      网友评论

          本文标题:2018-01-19旧版production-order添加字段

          本文链接:https://www.haomeiwen.com/subject/macooxtx.html