.then((res)=>{ if(res.Type==1){ loaderHandler.hideLoader(); ToastAndroid.show("退出成功",ToastAndroid.SHORT); }else{ loaderHandler.hideLoader(); ToastAndroid.show(res.Data,ToastAndroid.SHORT); } })
.then((resData)=>{ loaderHandler.hideLoader(); if(resData.Type==1){ this.setState({isFetch:true}); this.setState({ reportDetail:resData.Data, imageData:resData.Data.Attachments }); var tasteruser = this.state.reportDetail.Auditor && this.state.reportDetail.Auditor.map((item, index)=> { return ( item.Name ) }); var ccUser = this.state.reportDetail.CC && this.state.reportDetail.CC.map((item, index)=> { return ( item.Name )}); var imgurlTemp=resData.Data && resData.Data.Attachments&&resData.Data.Attachments.filter((imgitem)=> { if(imgitem.Name.indexOf(".jpg")!=-1||imgitem.Name.indexOf(".png")!=-1||imgitem.Name.indexOf(".jpeg")!=-1){return imgitem} }); var imgurls=resData.Data&&imgurlTemp&&imgurlTemp.length>0&&imgurlTemp.map((urlItem)=>{ return urlItem.DownloadUrl; }); this.setState({ tasteruser:tasteruser, ccUser:ccUser, imgUrls:imgurls }) }else{ this.setState({isFetch:false}); } })
.then((res)=>{ loaderHandler.hideLoader(); if(res.Type==1){ this.setState({isFetch:true}); this.setState({fetchSuccess:true}); this.getFileIcon(res.Data); str=res.Data.FileName.substring(0,res.Data.FileName.lastIndexOf(".")); if (res.Data && res.Data.FavorUsers.length > 0) { this.setState({FavorUsers: res.Data.FavorUsers}) } var isFavored = res.Data &&res.Data.IsFavorite; this.setState({isFavored: isFavored}); var commentConfig = { creatActivityUser: res.Data.Creator, activityId: res.Data.Id, TenantType:"Attachment", autoFocus: false }; if(res.Data&&res.Data.DownloadUrl.length!=0){ this.state.imgUrls.push(res.Data.DownloadUrl); } this.refs.commentInput.startIn(commentConfig, 1); this.setState({ resData:res.Data, commentConfig: commentConfig, historyData:res.Data.AttachmentHistory }); } else{ //获取详情失败 this.setState({fetchSuccess:false}); } })
.then((res)=>{ loaderHandler.hideLoader(); ToastAndroid.show(res.Data,ToastAndroid.SHORT); if(res.Type==1){ this.refs.projectDescribe.blur(); this.setState({isEdit:false}); } })
.then((res)=>{ if(res.Type==1){ this.setList("delete"); }else{ loaderHandler.hideLoader(); ToastAndroid.show(res.Data,ToastAndroid.SHORT); } })
.then((res)=>{ loaderHandler.hideLoader(); if(res.Type==1){ if(selectArr.Id!=this.props.stagetId){ this.setList("delete"); this.props.reloadMoveList(selectArr.Id); } }else{ ToastAndroid.show(res.Data,ToastAndroid.SHORT); } })
.then((res)=>{ ToastAndroid.show((res.Data==undefined||res.Data==null)?"未知错误":res.Data,ToastAndroid.SHORT); loaderHandler.hideLoader(); if(res.Type==1){ var newName=fileName; this.props.updateFileName(newName,this.state.resData.Id); this.props.nav.pop(); } else{ ToastAndroid.show((res.Data==undefined||res.Data==null)?"未知错误":res.Data,ToastAndroid.SHORT); } }).catch((err)=>{ToastAndroid.show('出现未知错误',ToastAndroid.SHORT);});
.then((resData)=>{ loaderHandler.hideLoader(); if(resData.Type==1){ if(resData.Data!=""){ this.setState({ activityData:this.state.activityData.cloneWithRows(resData.Data), nodata:false }); //处理投票以及回执 var actItem=resData.Data.item; var tempObj=actItem && actItem.Items&&actItem.Items.filter((tempitem)=> { if(tempitem.TenantType=='Receipt'||tempitem.TenantType=='Vote'){return tempitem} }); if(tempObj&&tempObj.length>0&&tempObj[0].hasOwnProperty('TenantType')&&tempObj[0].TenantType=="Vote"){ this.setState({itemText:"投票:"+tempObj[0].Title}) } if(tempObj&&tempObj.length>0&&tempObj[0].hasOwnProperty('TenantType')&&tempObj[0].TenantType=="Receipt"){ if(tempObj[0].HasVoted){ this.setState({itemText:'已回执'}) } else if(tempObj[0].hasOwnProperty('WasCreator')&&tempObj[0].WasCreator){ if(tempObj[0].hasOwnProperty('Options')&&tempObj[0].Options.length>0){ var isReceiptednums=0; for(var i=0;i<tempObj[0].Options.length;i++){ isReceiptednums+=tempObj[0].Options[i].Count } } var isReceiptnums=0; if(tempObj[0].hasOwnProperty('UnreceiptedUsers')&&tempObj[0].UnreceiptedUsers.length>0){ isReceiptnums=tempObj[0].UnreceiptedUsers.length } this.setState({itemText:'已回执'+isReceiptednums+'人'+'/'+'未回执'+isReceiptnums+'人'}) } else{ this.setState({itemText:'未回执'}) } } this.setState({tempObj:tempObj}) } else{ this.setState({ nodata:true }); } }else{ this.setState({ nodata:true }); } })
.then((res)=>{ loaderHandler.hideLoader(); if(res.Type==1){ if(res.Data.length!=0){ this.setState({hasTaskData:true,projectList:listViewData.cloneWithRows(res.Data)}); }else{ this.setState({hasTaskData:false}) } }else{ ToastAndroid.show("获取数据失败",ToastAndroid.SHORT); this.setState({hasTaskData:false}) } })
.then((res)=>{ loaderHandler.hideLoader(); if(res.Type==1){ res.Data.subordinate.splice(0, 0, cancleUserArr); res.Data.deps.splice(0, 0, cancleDepArr); this.setState({ fetchSuccess:true, users:res.Data.subordinate?res.Data.subordinate:[], deps:res.Data.deps?res.Data.deps:[] }); }else{ ToastAndroid.show("数据获取失败",ToastAndroid.SHORT); } });
.then((resData)=> { loaderHandler.hideLoader(); if (resData.Type == 1) { this.setState({ isFetch: true, data: resData.Data }); } else { this.setState({ isFetch: false }); } })
.then((resData)=>{ loaderHandler.hideLoader(); if(resData.Type==1){ if (resData.Data && resData.Data.length == 0 && firstLoad) { //第一次加载,且没有数据的时候 this.setState({hasTaskData: false}); } if (this.state.AllData.length == 0 && firstLoad) { //第一次加载有数据 this.state.AllData = resData.Data; } if (this.state.AllData.length > 0 && this.state.AllData.length < 5) { //数据小于等于5条 this.setState({ishavedata: false,hasMore: false, page: 1}); } if (resData.Data && resData.Data.length != 0) { //有数据 this.setState({hasTaskData: true}) } if (!firstLoad) { //不是第一次加载,concat数组组成新的数据 var oldDataLen = this.state.AllData.length; this.state.AllData = this.state.AllData.concat(resData.Data); if (this.state.AllData.length == oldDataLen) { ToastAndroid.show("没有数据咯",ToastAndroid.SHORT); this.setState({ ishavedata: false, isRefreshControl: false, hasMore: false, taskList: listViewData.cloneWithRows(this.state.AllData) }); return; } } this.setState({ ishavedata: false, isRefreshControl: false, taskList: listViewData.cloneWithRows(this.state.AllData) }); if (this.refs.list && this.state.AllData.length > 0 && this.state.AllData.length <= 5) { this.refs.list.scrollTo({x: 0, y: 0, animated: false}); } }else{ this.setState({ isRefreshControl: false }); } })
.then((res)=>{ //下载完直接打开 loaderHandler.hideLoader(); if(res.statusCode==200){ Linking.canOpenURL("file://"+option.toFile).then(supported => { if (!supported) { ToastAndroid.show('没有对应的应用程序!',ToastAndroid.SHORT); } else { return Linking.openURL("file://"+option.toFile); } }).catch(err => ToastAndroid.show('打开失败!',ToastAndroid.SHORT)); } else{ ToastAndroid.show("下载失败,请重试",ToastAndroid.SHORT); } })
.then((res)=>{ loaderHandler.hideLoader(); if(res.Type==1){ if(res.Data!=null){ let newData = this.creatData(res.Data); this.setState({ hasTaskData:true, taskData:res.Data, isRefreshControl: false, allList: dataSource.cloneWithRowsAndSections(newData.blobData, newData.sectionIds, newData.rowIds), }); }else{ this.setState({hasTaskData:false, isRefreshControl: false}); } }else{ this.setState({hasTaskData:false, isRefreshControl: false}); ToastAndroid.show(res.Data,ToastAndroid.SHORT); } })
setList(typeName,status){ var currentData = this.state.AllData; loaderHandler.hideLoader(); let tempIds = _.pluck(currentData, 'Id'); let _index = tempIds.indexOf(cellItem['Id']); if (_index > -1) { switch (typeName) { case "restart": case "finish": currentData[_index].Status = status; break; case "delete": currentData.splice(_index, 1); break; } this.setState({ taskList: listViewData.cloneWithRows(currentData) }); } }
.then((res)=>{ loaderHandler.hideLoader(); this.setState({isFetch:true}); this.setState({fetchSuccess:true}); if(res.Type==1){ str=res.Data.FileName; if (res.Data && res.Data.FavorUsers.length > 0) { this.setState({FavorUsers: res.Data.FavorUsers}) } var isFavored = res.Data &&res.Data.IsFavorite; this.setState({isFavored: isFavored}); var commentConfig = { creatActivityUser: res.Data.UserCreated, activityId: res.Data.Id, TenantType:"Article", autoFocus: false }; this.refs.commentInput.startIn(commentConfig, 1); this.setState({ resData:res.Data, commentConfig: commentConfig, historyData:res.Data.ArticleHistory }); AsyncStorage.getItem(this.props.kbId.toString()) .then((resHeight)=>{ //读取本地缓存数据 if(resHeight!="0"&&resHeight!=""){ this.setState({ height:parseInt(resHeight) }); } }).catch((err)=>{this.wbReload();}) } else{ //获取详情失败 this.setState({fetchSuccess:false}); } });
setTimeout(()=>{ ToastAndroid.show("创建成功",ToastAndroid.SHORT); this.props.nav.pop(); this.props.reloadList(); loaderHandler.hideLoader(); },1000);
loadingList(isload){ if(isload==1){ loaderHandler.hideLoader(); this.setState({fetchSuccess:true}) } }
.finally(() => { loaderHandler.hideLoader(); });