Commit a9edc2b1 by Zhang Xin

fix bugs

parent 510d6966
...@@ -47,18 +47,14 @@ const getStoreInfo = (storeId)=>{ ...@@ -47,18 +47,14 @@ const getStoreInfo = (storeId)=>{
}).then((response)=>response.json()) }).then((response)=>response.json())
.then(json=>{ .then(json=>{
console.log(json); console.log(json);
// if(json.meta.success && json.data.warehouse){
// dispatch(saveStoreInfo(Object.assign({},json.data.warehouse,{id:storeId})))
// }else{
// //没有店铺信息
// }
}).catch(e=>{console.error(e)})
if(json.meta.success && json.data.warehouse){ if(json.meta.success && json.data.warehouse){
dispatch(saveStoreInfo(Object.assign({},json.data.warehouse,{id:storeId}))) dispatch(saveStoreInfo(Object.assign({},json.data.warehouse,{id:storeId})))
}else{ }else{
//没有店铺信息 //没有店铺信息
} }
}).catch(e=>{console.error(e)})
} }
} }
......
...@@ -77,7 +77,7 @@ var myHeaders = new Headers({ ...@@ -77,7 +77,7 @@ var myHeaders = new Headers({
const getTroubleList = (info)=>{ const getTroubleList = (info)=>{
console.log(info); console.log("getTroubleList ",info);
//{storeId: 17, employeeId: 5, token: "966D5C0B-3CF2-420D-B9A3-313BA37DE092"} //{storeId: 17, employeeId: 5, token: "966D5C0B-3CF2-420D-B9A3-313BA37DE092"}
return(dispatch)=>{ return(dispatch)=>{
let bodyData = Object.assign({},{ let bodyData = Object.assign({},{
...@@ -92,15 +92,15 @@ const getTroubleList = (info)=>{ ...@@ -92,15 +92,15 @@ const getTroubleList = (info)=>{
body : JSON.stringify(bodyData) body : JSON.stringify(bodyData)
}).then((response)=>response.json()) }).then((response)=>response.json())
.then(json=>{ .then(json=>{
// if(json.meta.success && json.data){
// dispatch(saveHeaderInfo({taskId:json.data.taskId,sellOrderId:json.data.sellOrderId}))
// dispatch(saveTroubleList(json.data))
// }
}).catch(e=>{console.error(e)})
if(json.meta.success && json.data){ if(json.meta.success && json.data){
dispatch(saveHeaderInfo({taskId:json.data.taskId,sellOrderId:json.data.sellOrderId})) dispatch(saveHeaderInfo({taskId:json.data.taskId,sellOrderId:json.data.sellOrderId}))
dispatch(saveTroubleList(json.data)) dispatch(saveTroubleList(json.data))
} }
}).catch(e=>{console.error(e)})
// if(json.meta.success && json.data){
// dispatch(saveHeaderInfo({taskId:json.data.taskId,sellOrderId:json.data.sellOrderId}))
// dispatch(saveTroubleList(json.data))
// }
} }
}; };
......
...@@ -91,20 +91,20 @@ const getRefreshImg = (errorId,type)=>{ ...@@ -91,20 +91,20 @@ const getRefreshImg = (errorId,type)=>{
.then(json=>{ .then(json=>{
console.log(json); console.log(json);
if(json.meta.success && json.data){ if(json.meta.success && json.data){
// let data = {
// errorId,
// type,
// files : json.data.files ? json.data.files : []
// };
// dispatch(refreshImg(data))
}
}).catch(e=>{console.error(e)})
let data = { let data = {
errorId, errorId,
type, type,
files : json.data.files ? json.data.files : [] files : json.data.files ? json.data.files : []
}; };
dispatch(refreshImg(data)) dispatch(refreshImg(data))
}
}).catch(e=>{console.error(e)})
// let data = {
// errorId,
// type,
// files : json.data.files ? json.data.files : []
// };
// dispatch(refreshImg(data))
} }
}; };
...@@ -126,21 +126,21 @@ const deleteImg = (errorId,type,fileId)=>{ ...@@ -126,21 +126,21 @@ const deleteImg = (errorId,type,fileId)=>{
.then(parseJson) .then(parseJson)
.then((data) => { .then((data) => {
console.log("data :",data); console.log("data :",data);
// if(data.meta.success){ if(data.meta.success){
// dispatch(getRefreshImg(errorId,type)) dispatch(getRefreshImg(errorId,type))
// } }
}) })
.catch((err) =>{ .catch((err) =>{
console.error("Err:",err); console.error("Err:",err);
}); });
let info = json.data.files.filter(i=>i.id !== fileId); // let info = json.data.files.filter(i=>i.id !== fileId);
let data = { // let data = {
errorId, // errorId,
type, // type,
files : info // files : info
}; // };
dispatch(refreshImg(data)) // dispatch(refreshImg(data))
} }
} }
......
...@@ -11,7 +11,7 @@ let json = { ...@@ -11,7 +11,7 @@ let json = {
"success": true "success": true
}, },
"data": { "data": {
"types":'ER', "type":'ER',
"employee":{ "employee":{
"id": 5, "id": 5,
"employeeName": "机器库管员", "employeeName": "机器库管员",
...@@ -36,10 +36,11 @@ var myHeaders = new Headers({ ...@@ -36,10 +36,11 @@ var myHeaders = new Headers({
const getUserinfo = (info)=>{ const getUserinfo = (info,headerInfo)=>{
console.log("getUserinfo ",info) console.log("getUserinfo ",info)
let employeeId = info.employeeId; let employeeId = info.employeeId;
let bodyData = Object.assign({},{employeeId}) let storeId = headerInfo.storeId;
let bodyData = Object.assign({},{employeeId,storeId})
return(dispatch)=>{ return(dispatch)=>{
dispatch(saveHeaderInfo(info)); dispatch(saveHeaderInfo(info));
fetch(domain + 'machine_pad/get_alowed_task.action',{ fetch(domain + 'machine_pad/get_alowed_task.action',{
...@@ -51,19 +52,19 @@ const getUserinfo = (info)=>{ ...@@ -51,19 +52,19 @@ const getUserinfo = (info)=>{
}).then((response)=>response.json()) }).then((response)=>response.json())
.then(json=>{ .then(json=>{
console.log(json); console.log(json);
if(json.meta.success && json.data){
dispatch(saveUserinfo(json.data));
if(!json.data.type){
dispatch(addErrorInfo('没有任务需要处理'))
}
}
}).catch(e=>{console.error(e)})
// if(json.meta.success && json.data){ // if(json.meta.success && json.data){
// dispatch(saveUserinfo(json.data)); // dispatch(saveUserinfo(json.data));
// if(!json.data.types){ // if(!json.data.types){
// dispatch(addErrorInfo('没有任务需要处理')) // dispatch(addErrorInfo('没有任务需要处理'))
// } // }
// } // }
}).catch(e=>{console.error(e)})
if(json.meta.success && json.data){
dispatch(saveUserinfo(json.data));
if(!json.data.types){
dispatch(addErrorInfo('没有任务需要处理'))
}
}
} }
} }
......
...@@ -134,13 +134,14 @@ class PageContainer extends React.Component { ...@@ -134,13 +134,14 @@ class PageContainer extends React.Component {
} }
getSocketMsg(data){ getSocketMsg(data){
let {dispatch} = this.props; let {dispatch,state} = this.props;
switch (data.type){ switch (data.type){
case 'SUCCESS_OPENDOOR': case 'SUCCESS_OPENDOOR':
//执行开门 //执行开门
let info = JSON.parse(data.info); let info = data.info;
let headerInfo = state.headerInfo;
console.log("SUCCESS_OPENDOOR " ,info); console.log("SUCCESS_OPENDOOR " ,info);
dispatch(getUserinfo(info)); dispatch(getUserinfo(info,headerInfo));
this.setState({ this.setState({
successCloseDoor : false successCloseDoor : false
}); });
...@@ -174,10 +175,10 @@ class PageContainer extends React.Component { ...@@ -174,10 +175,10 @@ class PageContainer extends React.Component {
let nowUserInfo = this.props.state.userInfo; let nowUserInfo = this.props.state.userInfo;
let isNotOneUser = userinfo.employee && userinfo.employee.id && let isNotOneUser = userinfo.employee && userinfo.employee.id &&
(!nowUserInfo || !nowUserInfo.employee || (nowUserInfo.employee.id !== userinfo.employee.id)); (!nowUserInfo || !nowUserInfo.employee || (nowUserInfo.employee.id !== userinfo.employee.id));
let isNotOneTask = userinfo.types && userinfo.types !== nowUserInfo.types; let isNotOneTask = userinfo.type && userinfo.type !== nowUserInfo.type;
if(isNotOneUser && isNotOneTask){ if(isNotOneUser && isNotOneTask){
this.dealPageByType(userinfo.types); this.dealPageByType(userinfo.type);
} }
if(state.errMsg.errMsg){ if(state.errMsg.errMsg){
this.showError(state.errMsg.errMsg) this.showError(state.errMsg.errMsg)
......
...@@ -158,7 +158,7 @@ export default class TroubleContainer extends React.Component{ ...@@ -158,7 +158,7 @@ export default class TroubleContainer extends React.Component{
}) })
}else{ }else{
details.forEach((d)=>{ details.forEach((d)=>{
d.imagesFileId = d.files.map(f=>f.id).join(','); d.imagesFileId = Array.isArray(d.files) ? d.files.map(f=>f.id).join(',') : d.imagesFileId;
}); });
updateTroubleList(details); updateTroubleList(details);
this.setState({ this.setState({
......
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
*/ */
module.exports = { module.exports = {
domain: 'http://preprod.mjitech.com/web/', domain: 'http://preprod.mjitech.com/web/',
uploadImg : 'https://preprod.mjitech.com/static/uploadTrouble/' uploadImg : 'https://preprod.mjitech.com/static/uploadTrouble'
} }
\ No newline at end of file
...@@ -2,6 +2,6 @@ ...@@ -2,6 +2,6 @@
* Created by ruibing on 16/11/2. * Created by ruibing on 16/11/2.
*/ */
module.exports = { module.exports = {
domain: 'http://www.mjitech.com', domain: 'http://preprod.mjitech.com/web/',
uploadImg : "https://www.mjitech.com/static/uploadTrouble/" uploadImg : "https://preprod.mjitech.com/static/uploadTrouble"
} }
\ No newline at end of file
...@@ -2,5 +2,6 @@ ...@@ -2,5 +2,6 @@
* Created by ruibing on 16/11/2. * Created by ruibing on 16/11/2.
*/ */
module.exports = { module.exports = {
domain: 'http://test.mjitech.com' domain: 'http://test.mjitech.com',
uploadImg : 'https://preprod.mjitech.com/static/uploadTrouble'
} }
\ No newline at end of file
...@@ -29,6 +29,7 @@ function renderPage(store) { ...@@ -29,6 +29,7 @@ function renderPage(store) {
let store = activateVendor(); let store = activateVendor();
UTILPATH.socket.init(115,17); // UTILPATH.socket.init(129,17);
UTILPATH.socket.testIp(209);
renderPage(store); renderPage(store);
\ No newline at end of file
...@@ -89,11 +89,11 @@ const testIp = (ip) => { ...@@ -89,11 +89,11 @@ const testIp = (ip) => {
.then((data) => { .then((data) => {
if(data.storeId){ if(data.storeId){
window.storeId = data.storeId; window.storeId = data.storeId;
window.localIp = domainIp + i; window.localIp = domainIp + ip;
let wsUrl = 'ws://' + domainIp + i + ':7788/notify?from=plant&storeId='+data.storeId; let wsUrl = 'ws://' + domainIp + ip + ':7788/notify?from=plant&storeId='+data.storeId;
currentIpIndex = i; currentIpIndex = ip;
init(i,data.storeId); init(ip,data.storeId);
} }
}) })
.catch((err) =>{ .catch((err) =>{
...@@ -197,4 +197,4 @@ const closeSocket = ()=>{ ...@@ -197,4 +197,4 @@ const closeSocket = ()=>{
} }
} }
module.exports = {getIp,sendMsg,init}; module.exports = {getIp,sendMsg,init,testIp};
\ No newline at end of file \ No newline at end of file
...@@ -8,7 +8,8 @@ ...@@ -8,7 +8,8 @@
"test": "echo \"Error: no test specified\" && exit 1", "test": "echo \"Error: no test specified\" && exit 1",
"clean": "rm -rf static/*", "clean": "rm -rf static/*",
"start": "set NODE_ENV=development && webpack-dev-server --env=dev -d --history-api-fallback --hot --inline --progress --colors --port 80 --host 0.0.0.0", "start": "set NODE_ENV=development && webpack-dev-server --env=dev -d --history-api-fallback --hot --inline --progress --colors --port 80 --host 0.0.0.0",
"build": "set NODE_ENV=production && webpack --env=build --progress --color" "build": "set NODE_ENV=production && webpack --env=build --progress --color",
"build:prod": "set NODE_ENV=development && webpack --env=build --progress --color"
}, },
"author": "", "author": "",
"license": "MIT", "license": "MIT",
......
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