import fetch from 'isomorphic-fetch'
import tokeActionType from '../actiontype/TokeStokeContainer'
import {getTaskList} from './common'
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)=>{
                    if(json.data===1){
                        console.log("执行了 json.data===1 的拉取工单的操作")
                        dispatch(getTaskList(commonInfo))
                    }
                    dispatch(checkQuantity({type:json.data}))
                }).catch(e=>{console.log('err'+e)})

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

  export {checkProductQuantity}