import fetch from 'isomorphic-fetch'; import * as actionTypes from '../actiontype/reportDamage'; import actionTypes_error from "../actiontype/error"; let domain = ENV.domain; export function getReportDamageList (postData) { return (dispatch) => { let url = String(domain+'machine_pad/list_all_dealed_invetory_loss/'+postData.taskId+'/'+postData.storeId); console.log(url) fetch(url,{ credentials : 'include', method : 'GET', mode : 'cors', headers: { 'content-type':'application/json;charset=UTF-8', }, body : {} }).then((response) => response.json()) .then( (json)=>{ //处理数据如果 if(json.meta.success){ dispatch(getReportDamageListSuccess(json.data)) }else{ dispatch(throwError(json.meta.message)) } }).catch(e=>{console.error(e)} ) } } export function deleteDamageItem(postaData) { return (dispatch) => { let url = String(domain+'machine_pad/delete_invetory_loss_by_saas'); console.log(url) fetch(url,{ credentials : 'include', method : 'POST', mode : 'cors', headers: { 'content-type':'application/json;charset=UTF-8', }, body : JSON.stringify({inventoryLossId:postaData.inventoryLossId}) }).then((response) => response.json()) .then( (json)=>{ //处理数据如果 let success = json.meta.success; if(success){ dispatch(getReportDamageList({"taskId":postaData.taskId,"storeId":postaData.storeId})) }else{ dispatch(throwError(json.meta.message)) } } ).catch(e=>{console.error(e)} ) /* dispatch(initSuccess(fakeJsonData.data))*/ } } function getReportDamageListSuccess(data) { console.log("========================") return{ type:actionTypes.INIT_GETDAMGELIST_SUCCESS, data } } function deleteDamageListSuccess(data) { console.log("=======================delete===========") return{ type:actionTypes.DELET_DAMAGEITEM_SUCCESS, data } } function throwError(data) { return{ type:actionTypes_error.ADDERRORINFO, errMsg:data } }