Commit 4c35b702 by Zhang Xin

刷新图片获取最新图片

parent 81c73473
...@@ -33,7 +33,7 @@ let json = { ...@@ -33,7 +33,7 @@ let json = {
}, },
{ {
"id": 1, "id": 1,
"errorCode": null, "errorCode": 12123,
"type": "OP", "type": "OP",
"files": [], "files": [],
"parentProblemName": "机械故障", "parentProblemName": "机械故障",
......
import fetch from 'isomorphic-fetch';
import actionTypes from '../actiontype/refreshImg'
const domain = ENV.domain;
let json = {
"meta": {
"code": "200",
"message": "成功",
"success": true
},
"data": [
{
"id": 17,
"filePath": "http://static.mjitech.com/static/sku/0/0/427/1471329704482.jpg"
},
{
"id": 18,
"filePath": "http://static.mjitech.com/static/sku/0/0/427/1471329704482.jpg"
},
{
"id": 19,
"filePath": "http://static.mjitech.com/static/sku/0/0/427/1471329704482.jpg"
}
]
}
const refreshImg = (data)=>{
return{
type:actionTypes.REFRESHIMG,
data
}
};
const getRefreshImg = (errorId,type)=>{
console.log(errorId,type)
return(dispatch)=>{
// fetch(domain + '/web/flush_image.action',{
// credentials : 'include',
// method : 'POST',
// mode : 'cors',
// body : {}
//
// }).then((response)=>response.json())
// .then(json=>{
// console.log(json);
// }).catch(e=>{console.error(e)})
if(json.meta.success && json.data){
let data = {
errorId,
type,
files : json.data
};
dispatch(refreshImg(data))
}
}
}
export {getRefreshImg}
const actionTypes = {
REFRESHIMG : 'REFRESHIMG'
}
export default actionTypes
\ No newline at end of file
...@@ -66,7 +66,7 @@ export default class TroubleItemComponent extends React.Component{ ...@@ -66,7 +66,7 @@ export default class TroubleItemComponent extends React.Component{
<div className={"plusImg controlBox "} onClick={()=>props.showQrcode(item.errorCode)}> <div className={"plusImg controlBox "} onClick={()=>props.showQrcode(item.errorCode)}>
<img src={UTILPATH.localImg.plusIcon} alt=""/> <img src={UTILPATH.localImg.plusIcon} alt=""/>
</div> </div>
<div className={"refreshImg controlBox "}> <div className={"refreshImg controlBox "} onClick={()=>props.getRefreshImg(item.id,item.type)}>
<img src={UTILPATH.localImg.refreshIcon} alt=""/> <img src={UTILPATH.localImg.refreshIcon} alt=""/>
</div> </div>
</div> </div>
......
...@@ -5,17 +5,16 @@ import { connect } from 'react-redux'; ...@@ -5,17 +5,16 @@ import { connect } from 'react-redux';
import {getStoreInfo} from "../../actions/getStore"; import {getStoreInfo} from "../../actions/getStore";
import {getTroubleList} from "../../actions/getTroubles"; import {getTroubleList} from "../../actions/getTroubles";
import {intGetOtherProblem} from "../../actions/otherQuestion" import {intGetOtherProblem} from "../../actions/otherQuestion"
import {getRefreshImg} from "../../actions/refreshImg"
import PopupComponent from '../../components/CommonComponent/PopupComponent/PopupComponent' import PopupComponent from '../../components/CommonComponent/PopupComponent/PopupComponent'
import TroubleContainer from '../TroubleContainer/TroubleContainer' import TroubleContainer from '../TroubleContainer/TroubleContainer'
import TextAreaContainer from '../TextAreaContainer/TextAreaContainer'
import ScanBarCodeContainer from '../ScanBarCodeContainer/ScanBarCodeContaienr' import ScanBarCodeContainer from '../ScanBarCodeContainer/ScanBarCodeContaienr'
import ReportDamagesListContainer from '../ReportDamagesListContainer/ReportDamagesListContainer' import ReportDamagesListContainer from '../ReportDamagesListContainer/ReportDamagesListContainer'
import OtherQuestionContainer from '../OtherQuestionContainer/OtherQuestionContainer' import OtherQuestionContainer from '../OtherQuestionContainer/OtherQuestionContainer'
import HomeContainer from '../HomeContainer/HomeContainer' import HomeContainer from '../HomeContainer/HomeContainer'
import FinishAskContainer from '../FinishAskContainer/FinishAskContainer' import FinishAskContainer from '../FinishAskContainer/FinishAskContainer'
import ChooseTaskContainer from '../ChooseTaskContainer/ChooseTaskContainer' import ChooseTaskContainer from '../ChooseTaskContainer/ChooseTaskContainer'
import Qrcode from '../Qrcode/Qrcode'
require('./index.css') require('./index.css')
...@@ -131,12 +130,14 @@ class PageContainer extends React.Component { ...@@ -131,12 +130,14 @@ class PageContainer extends React.Component {
case showPage[1]: case showPage[1]:
pages = <TroubleContainer pages = <TroubleContainer
troubleList={state.troubleList} troubleList={state.troubleList}
refreshImg = {state.refreshImg}
storeInfo={state.storeInfo} storeInfo={state.storeInfo}
userInfo={state.userInfo} userInfo={state.userInfo}
initTroubleList={()=>dispatch(getTroubleList())} initTroubleList={()=>dispatch(getTroubleList())}
showTextArea={(text)=>this.showTextArea(text)} showTextArea={(text)=>this.showTextArea(text)}
showPopup={(info)=>this.showPopup(info)} showPopup={(info)=>this.showPopup(info)}
hidePopup={()=>this.hidePopup()} hidePopup={()=>this.hidePopup()}
getRefreshImg={(errorId,type)=>dispatch(getRefreshImg(errorId,type))}
/>; />;
break; break;
case showPage[2]: case showPage[2]:
...@@ -151,9 +152,6 @@ class PageContainer extends React.Component { ...@@ -151,9 +152,6 @@ class PageContainer extends React.Component {
state = {state} state = {state}
/>; />;
break; break;
case showPage[6]:
pages = <Qrcode />;
break;
case showPage[7]: case showPage[7]:
pages = <HomeContainer />; pages = <HomeContainer />;
break; break;
......
...@@ -32,31 +32,7 @@ export default class TroubleContainer extends React.Component{ ...@@ -32,31 +32,7 @@ export default class TroubleContainer extends React.Component{
this.getDefaultDom = this.getDefaultDom.bind(this); this.getDefaultDom = this.getDefaultDom.bind(this);
this.getTextAreaDom = this.getTextAreaDom.bind(this); this.getTextAreaDom = this.getTextAreaDom.bind(this);
this.getQrcodeDom = this.getQrcodeDom.bind(this); this.getQrcodeDom = this.getQrcodeDom.bind(this);
} this.updateImg = this.updateImg.bind(this);
dealTrouble(){
let {showPopup,hidePopup} = this.props;
let troubleList = this.state.troubleList;
let details = troubleList.details;
let arr = details.filter(d=>{
return ! d.isExistProblem || ! d.explanation
});
if(arr && arr.length > 0){
showPopup({
popupText:'请完成所有需要处理的故障的必填项',
popupButtons:[{text : '关闭',option:hidePopup}]
})
}else{
details.forEach((d)=>{
d.imagesFileId = d.files.map(f=>f.id).join(',');
});
this.setState({
showTrouble : false
})
}
} }
...@@ -68,8 +44,8 @@ export default class TroubleContainer extends React.Component{ ...@@ -68,8 +44,8 @@ export default class TroubleContainer extends React.Component{
componentWillReceiveProps(nextProps){ componentWillReceiveProps(nextProps){
let troubleList = nextProps.troubleList; let troubleList = nextProps.troubleList;
let nowTroubleList = this.state.troubleList; let nowTroubleList = this.state.troubleList;
let troubleErrorCodeList = Array.isArray(troubleList.details) ? troubleList.details.map(i=>i.errorCode) : [] let troubleErrorCodeList = Array.isArray(troubleList.details) ? troubleList.details.map(i=>i.errorCode) : [];
let nowtroubleErrorCodeList = Array.isArray(nowTroubleList.details) ? nowTroubleList.details.map(i=>i.errorCode) : [] let nowtroubleErrorCodeList = Array.isArray(nowTroubleList.details) ? nowTroubleList.details.map(i=>i.errorCode) : [];
//上一次和这一次不一样 //上一次和这一次不一样
let troubleErrorCodeListStr = troubleErrorCodeList.join(","); let troubleErrorCodeListStr = troubleErrorCodeList.join(",");
...@@ -83,6 +59,25 @@ export default class TroubleContainer extends React.Component{ ...@@ -83,6 +59,25 @@ export default class TroubleContainer extends React.Component{
}) })
} }
let refreshImg = nextProps.refreshImg;
let nowRefreshImg = this.state.refreshImg;
if(refreshImg && refreshImg.errorId && refreshImg.type && refreshImg.files){
this.updateImg(refreshImg);
}
}
updateImg(info){
let id = info.errorId;
let type = info.type;
let files = info.files;
let troubleList = this.state.troubleList;
let details = troubleList.details;
let indexInfo = details.find(d=>d.id === id && d.type === type);
if(indexInfo && indexInfo.id){
this.setItem(indexInfo.errorCode,"files",files);
}
} }
showText(errcode){ showText(errcode){
...@@ -126,13 +121,12 @@ export default class TroubleContainer extends React.Component{ ...@@ -126,13 +121,12 @@ export default class TroubleContainer extends React.Component{
this.goBack() this.goBack()
}) })
} }
saveText(text){ saveText(text){
let errcode = this.state.currentErrorCode; let errcode = this.state.currentErrorCode;
this.setItem(errcode,'explanation',text); this.setItem(errcode,'explanation',text);
} }
goBack(){ goBack(){
this.setState({ this.setState({
currentErrorCode : 0, currentErrorCode : 0,
...@@ -142,13 +136,40 @@ export default class TroubleContainer extends React.Component{ ...@@ -142,13 +136,40 @@ export default class TroubleContainer extends React.Component{
}) })
} }
dealTrouble(){
let {showPopup,hidePopup} = this.props;
let troubleList = this.state.troubleList;
let details = troubleList.details;
let arr = details.filter(d=>{
return !d.isExistProblem || ( d.isExistProblem === 1 && ! d.explanation)
});
if(arr && arr.length > 0){
showPopup({
popupText:'请完成所有需要处理的故障的必填项',
popupButtons:[{text : '关闭',option:hidePopup}]
})
}else{
details.forEach((d)=>{
d.imagesFileId = d.files.map(f=>f.id).join(',');
});
console.log(details);
// this.setState({
// showTrouble : false
// })
}
}
getDefaultDom(){ getDefaultDom(){
let {userInfo,storeInfo} = this.props; let {userInfo,storeInfo,getRefreshImg} = this.props;
let troubleList = this.state.troubleList; let troubleList = this.state.troubleList;
let showTrouble = Array.isArray(troubleList.details) && troubleList.details.length > 0; let showTrouble = Array.isArray(troubleList.details) && troubleList.details.length > 0;
let details = Array.isArray(troubleList.details) ? troubleList.details : []; let details = Array.isArray(troubleList.details) ? troubleList.details : [];
let dom = details.map((i,k)=>{ let dom = details.map((i,k)=>{
return <TroubleItem key={k} item={i} num={k+1} setItem={this.setItem} showText={this.showText} showQrcode={this.showQrcode}/>; return <TroubleItem key={k} item={i} num={k+1} setItem={this.setItem}
showText={this.showText} showQrcode={this.showQrcode}
getRefreshImg={getRefreshImg}
/>;
}); });
let swiperOptions = { let swiperOptions = {
width : 1396, width : 1396,
...@@ -192,8 +213,7 @@ export default class TroubleContainer extends React.Component{ ...@@ -192,8 +213,7 @@ export default class TroubleContainer extends React.Component{
return <TextArea return <TextArea
text={this.state.tmpText} text={this.state.tmpText}
goBack={this.goBack} goBack={this.goBack}
saveText={this.saveText} saveText={this.saveText}/>
></TextArea>
} }
getQrcodeDom(){ getQrcodeDom(){
......
...@@ -4,13 +4,14 @@ import storeInfo from './store' ...@@ -4,13 +4,14 @@ import storeInfo from './store'
import scanBarCodeContainer from './scanBarCodeContainer' import scanBarCodeContainer from './scanBarCodeContainer'
import otherQuestion from './otherQuestion' import otherQuestion from './otherQuestion'
import userInfo from './user' import userInfo from './user'
import refreshImg from './refreshImg'
export default combineReducers({ export default combineReducers({
troubleList, troubleList,
storeInfo, storeInfo,
scanBarCodeContainer, scanBarCodeContainer,
otherQuestion, otherQuestion,
userInfo userInfo,
refreshImg
}) })
import actionTypes from '../actiontype/refreshImg';
const refreshImg = (content,data)=>{
return Object.assign({},content,data);
}
export default function(state={}, action) {
switch (action.type) {
case actionTypes.REFRESHIMG:
return refreshImg(state,action.data)
default:
return state;
}
}
\ No newline at end of file
...@@ -4,6 +4,7 @@ import addIcon from '../image/addIcon.png'; ...@@ -4,6 +4,7 @@ import addIcon from '../image/addIcon.png';
import refreshIcon from '../image/refresh.png'; import refreshIcon from '../image/refresh.png';
import plusIcon from '../image/plusIcon.png'; import plusIcon from '../image/plusIcon.png';
import clockIcon from '../image/clock.png'; import clockIcon from '../image/clock.png';
import breakImg from '../image/breakImg.png';
const localHost = 'http://localhost:7788'; const localHost = 'http://localhost:7788';
const devHost = 'http://test.mjitech.com'; const devHost = 'http://test.mjitech.com';
...@@ -77,6 +78,6 @@ const handleImgLoad = (ref)=>{ ...@@ -77,6 +78,6 @@ const handleImgLoad = (ref)=>{
return style; return style;
} }
const localImg = {headlogo,defaultImg,addIcon,refreshIcon,plusIcon,clockIcon} const localImg = {headlogo,defaultImg,addIcon,refreshIcon,plusIcon,clockIcon,breakImg}
module.exports = {localHost,devHost,masterHost,getPic,handleImgError,handleImgLoad,localImg}; module.exports = {localHost,devHost,masterHost,getPic,handleImgError,handleImgLoad,localImg};
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment