import fetch from 'isomorphic-fetch'
import tokeActionType from '../actiontype/TokeStokeContainer'
console.log(tokeActionType,'dhakjshdjhasjhdjshj')
let domain1 = ENV.domain;
let domain = 'http://192.168.10.128:8080/web/'
//点击提交后台核对商品数量
const checkProductQuantity = (data)=>{
      let {commonInfo,tokeProductInfo}=data;
      let storeId=commonInfo.storeInfo.id;
      let {taskId,area}=commonInfo.taskInfo;
      let employeeId=commonInfo.userInfo.id;
      let {quantity,skuPassId,workListId}=tokeProductInfo;
      let bodyData={storeId,taskId,area,quantity,skuPassId,workListId,employeeId}
      let url=domain+`flat/work/ck`;
      return (dispatch)=>{
                fetch(url,{
                    credentials : 'include',
                    method : 'POST',
                    mode : 'cors',
                    headers: {
                        'content-type':'application/json;charset=UTF-8',
                    },
                    body:JSON.stringify(bodyData)
                }).then(response=>response.json())
                .then((json)=>{
                    dispatch(checkQuantity({type:json.data}))
                }).catch(e=>{console.log('err'+e)})

      }
}
const checkQuantity = (data)=>{
      return{
          type:tokeActionType.SUBMIT_NUM,
          data
      }
  }

  export {checkProductQuantity}