diff --git a/client/actions/getTroubles.js b/client/actions/getTroubles.js index 10e234f..2ec20dd 100644 --- a/client/actions/getTroubles.js +++ b/client/actions/getTroubles.js @@ -33,7 +33,7 @@ let json = { }, { "id": 1, - "errorCode": null, + "errorCode": 12123, "type": "OP", "files": [], "parentProblemName": "机械故障", diff --git a/client/actions/refreshImg.js b/client/actions/refreshImg.js new file mode 100644 index 0000000..3944a7e --- /dev/null +++ b/client/actions/refreshImg.js @@ -0,0 +1,61 @@ +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} + diff --git a/client/actiontype/refreshImg.js b/client/actiontype/refreshImg.js new file mode 100644 index 0000000..f13ea42 --- /dev/null +++ b/client/actiontype/refreshImg.js @@ -0,0 +1,4 @@ +const actionTypes = { + REFRESHIMG : 'REFRESHIMG' +} +export default actionTypes \ No newline at end of file diff --git a/client/components/TroubleComponent/TroubleItemComponent/TroubleItemComponent.jsx b/client/components/TroubleComponent/TroubleItemComponent/TroubleItemComponent.jsx index de9f82c..ed0ab62 100644 --- a/client/components/TroubleComponent/TroubleItemComponent/TroubleItemComponent.jsx +++ b/client/components/TroubleComponent/TroubleItemComponent/TroubleItemComponent.jsx @@ -66,7 +66,7 @@ export default class TroubleItemComponent extends React.Component{ <div className={"plusImg controlBox "} onClick={()=>props.showQrcode(item.errorCode)}> <img src={UTILPATH.localImg.plusIcon} alt=""/> </div> - <div className={"refreshImg controlBox "}> + <div className={"refreshImg controlBox "} onClick={()=>props.getRefreshImg(item.id,item.type)}> <img src={UTILPATH.localImg.refreshIcon} alt=""/> </div> </div> diff --git a/client/containers/PageContainer/PageContainer.jsx b/client/containers/PageContainer/PageContainer.jsx index 9878f7d..bf0349e 100755 --- a/client/containers/PageContainer/PageContainer.jsx +++ b/client/containers/PageContainer/PageContainer.jsx @@ -5,17 +5,16 @@ import { connect } from 'react-redux'; import {getStoreInfo} from "../../actions/getStore"; import {getTroubleList} from "../../actions/getTroubles"; import {intGetOtherProblem} from "../../actions/otherQuestion" +import {getRefreshImg} from "../../actions/refreshImg" import PopupComponent from '../../components/CommonComponent/PopupComponent/PopupComponent' import TroubleContainer from '../TroubleContainer/TroubleContainer' -import TextAreaContainer from '../TextAreaContainer/TextAreaContainer' import ScanBarCodeContainer from '../ScanBarCodeContainer/ScanBarCodeContaienr' import ReportDamagesListContainer from '../ReportDamagesListContainer/ReportDamagesListContainer' import OtherQuestionContainer from '../OtherQuestionContainer/OtherQuestionContainer' import HomeContainer from '../HomeContainer/HomeContainer' import FinishAskContainer from '../FinishAskContainer/FinishAskContainer' import ChooseTaskContainer from '../ChooseTaskContainer/ChooseTaskContainer' -import Qrcode from '../Qrcode/Qrcode' require('./index.css') @@ -131,12 +130,14 @@ class PageContainer extends React.Component { case showPage[1]: pages = <TroubleContainer troubleList={state.troubleList} + refreshImg = {state.refreshImg} storeInfo={state.storeInfo} userInfo={state.userInfo} initTroubleList={()=>dispatch(getTroubleList())} showTextArea={(text)=>this.showTextArea(text)} showPopup={(info)=>this.showPopup(info)} hidePopup={()=>this.hidePopup()} + getRefreshImg={(errorId,type)=>dispatch(getRefreshImg(errorId,type))} />; break; case showPage[2]: @@ -151,9 +152,6 @@ class PageContainer extends React.Component { state = {state} />; break; - case showPage[6]: - pages = <Qrcode />; - break; case showPage[7]: pages = <HomeContainer />; break; diff --git a/client/containers/TroubleContainer/TroubleContainer.jsx b/client/containers/TroubleContainer/TroubleContainer.jsx index 20340d2..bcf9a94 100644 --- a/client/containers/TroubleContainer/TroubleContainer.jsx +++ b/client/containers/TroubleContainer/TroubleContainer.jsx @@ -32,31 +32,7 @@ export default class TroubleContainer extends React.Component{ this.getDefaultDom = this.getDefaultDom.bind(this); this.getTextAreaDom = this.getTextAreaDom.bind(this); this.getQrcodeDom = this.getQrcodeDom.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 - }) - } + this.updateImg = this.updateImg.bind(this); } @@ -68,8 +44,8 @@ export default class TroubleContainer extends React.Component{ componentWillReceiveProps(nextProps){ let troubleList = nextProps.troubleList; let nowTroubleList = this.state.troubleList; - 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 troubleErrorCodeList = Array.isArray(troubleList.details) ? troubleList.details.map(i=>i.errorCode) : []; + let nowtroubleErrorCodeList = Array.isArray(nowTroubleList.details) ? nowTroubleList.details.map(i=>i.errorCode) : []; //上一次和这一次不一样 let troubleErrorCodeListStr = troubleErrorCodeList.join(","); @@ -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){ @@ -126,13 +121,12 @@ export default class TroubleContainer extends React.Component{ this.goBack() }) } + saveText(text){ let errcode = this.state.currentErrorCode; this.setItem(errcode,'explanation',text); - } - goBack(){ this.setState({ currentErrorCode : 0, @@ -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(){ - let {userInfo,storeInfo} = this.props; + let {userInfo,storeInfo,getRefreshImg} = this.props; let troubleList = this.state.troubleList; let showTrouble = Array.isArray(troubleList.details) && troubleList.details.length > 0; let details = Array.isArray(troubleList.details) ? troubleList.details : []; 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 = { width : 1396, @@ -192,8 +213,7 @@ export default class TroubleContainer extends React.Component{ return <TextArea text={this.state.tmpText} goBack={this.goBack} - saveText={this.saveText} - ></TextArea> + saveText={this.saveText}/> } getQrcodeDom(){ diff --git a/client/image/breakImg.png b/client/image/breakImg.png new file mode 100644 index 0000000..8813a15 Binary files /dev/null and b/client/image/breakImg.png differ diff --git a/client/reducers/index.js b/client/reducers/index.js index 10664aa..efd810a 100755 --- a/client/reducers/index.js +++ b/client/reducers/index.js @@ -4,13 +4,14 @@ import storeInfo from './store' import scanBarCodeContainer from './scanBarCodeContainer' import otherQuestion from './otherQuestion' import userInfo from './user' +import refreshImg from './refreshImg' export default combineReducers({ troubleList, storeInfo, scanBarCodeContainer, otherQuestion, - userInfo - + userInfo, + refreshImg }) diff --git a/client/reducers/refreshImg.js b/client/reducers/refreshImg.js new file mode 100644 index 0000000..8d8c712 --- /dev/null +++ b/client/reducers/refreshImg.js @@ -0,0 +1,14 @@ +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 diff --git a/client/util/image.js b/client/util/image.js index cdf03f3..732ea19 100644 --- a/client/util/image.js +++ b/client/util/image.js @@ -4,6 +4,7 @@ import addIcon from '../image/addIcon.png'; import refreshIcon from '../image/refresh.png'; import plusIcon from '../image/plusIcon.png'; import clockIcon from '../image/clock.png'; +import breakImg from '../image/breakImg.png'; const localHost = 'http://localhost:7788'; const devHost = 'http://test.mjitech.com'; @@ -77,6 +78,6 @@ const handleImgLoad = (ref)=>{ 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}; \ No newline at end of file