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); fetch(url,{ credentials : 'include', method : 'GET', mode : 'cors', headers: { 'content-type':'application/json;charset=UTF-8', }, }).then((response) => response.json()) .then( (json)=>{ //处理数据如果 if(json.meta.success){ dispatch(getReportDamageListSuccess(json.data)) }else{ dispatch(throwError(json.meta.message)) } }).catch(e=>{} ) } } export function deleteDamageItem(postaData) { return (dispatch) => { let url = String(domain+'machine_pad/delete_invetory_loss_by_saas'); 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=>{} ) /* dispatch(initSuccess(fakeJsonData.data))*/ } } function getReportDamageListSuccess(data) { return{ type:actionTypes.INIT_GETDAMGELIST_SUCCESS, data } } function deleteDamageListSuccess(data) { return{ type:actionTypes.DELET_DAMAGEITEM_SUCCESS, data } } function throwError(data) { return{ type:actionTypes_error.ADDERRORINFO, errMsg:data } }