Commit a9edc2b1 by Zhang Xin

fix bugs

parent 510d6966
......@@ -47,18 +47,14 @@ const getStoreInfo = (storeId)=>{
}).then((response)=>response.json())
.then(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){
dispatch(saveStoreInfo(Object.assign({},json.data.warehouse,{id:storeId})))
}else{
//没有店铺信息
}
}).catch(e=>{console.error(e)})
}
}
......
......@@ -77,7 +77,7 @@ var myHeaders = new Headers({
const getTroubleList = (info)=>{
console.log(info);
console.log("getTroubleList ",info);
//{storeId: 17, employeeId: 5, token: "966D5C0B-3CF2-420D-B9A3-313BA37DE092"}
return(dispatch)=>{
let bodyData = Object.assign({},{
......@@ -92,15 +92,15 @@ const getTroubleList = (info)=>{
body : JSON.stringify(bodyData)
}).then((response)=>response.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){
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){
// dispatch(saveHeaderInfo({taskId:json.data.taskId,sellOrderId:json.data.sellOrderId}))
// dispatch(saveTroubleList(json.data))
// }
}
};
......
......@@ -91,20 +91,20 @@ const getRefreshImg = (errorId,type)=>{
.then(json=>{
console.log(json);
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 = {
errorId,
type,
files : json.data.files ? json.data.files : []
};
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)=>{
.then(parseJson)
.then((data) => {
console.log("data :",data);
// if(data.meta.success){
// dispatch(getRefreshImg(errorId,type))
// }
if(data.meta.success){
dispatch(getRefreshImg(errorId,type))
}
})
.catch((err) =>{
console.error("Err:",err);
});
let info = json.data.files.filter(i=>i.id !== fileId);
let data = {
errorId,
type,
files : info
};
dispatch(refreshImg(data))
// let info = json.data.files.filter(i=>i.id !== fileId);
// let data = {
// errorId,
// type,
// files : info
// };
// dispatch(refreshImg(data))
}
}
......
......@@ -11,7 +11,7 @@ let json = {
"success": true
},
"data": {
"types":'ER',
"type":'ER',
"employee":{
"id": 5,
"employeeName": "机器库管员",
......@@ -36,10 +36,11 @@ var myHeaders = new Headers({
const getUserinfo = (info)=>{
const getUserinfo = (info,headerInfo)=>{
console.log("getUserinfo ",info)
let employeeId = info.employeeId;
let bodyData = Object.assign({},{employeeId})
let storeId = headerInfo.storeId;
let bodyData = Object.assign({},{employeeId,storeId})
return(dispatch)=>{
dispatch(saveHeaderInfo(info));
fetch(domain + 'machine_pad/get_alowed_task.action',{
......@@ -51,19 +52,19 @@ const getUserinfo = (info)=>{
}).then((response)=>response.json())
.then(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){
// dispatch(saveUserinfo(json.data));
// if(!json.data.types){
// 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 {
}
getSocketMsg(data){
let {dispatch} = this.props;
let {dispatch,state} = this.props;
switch (data.type){
case 'SUCCESS_OPENDOOR':
//执行开门
let info = JSON.parse(data.info);
let info = data.info;
let headerInfo = state.headerInfo;
console.log("SUCCESS_OPENDOOR " ,info);
dispatch(getUserinfo(info));
dispatch(getUserinfo(info,headerInfo));
this.setState({
successCloseDoor : false
});
......@@ -174,10 +175,10 @@ class PageContainer extends React.Component {
let nowUserInfo = this.props.state.userInfo;
let isNotOneUser = userinfo.employee && 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){
this.dealPageByType(userinfo.types);
this.dealPageByType(userinfo.type);
}
if(state.errMsg.errMsg){
this.showError(state.errMsg.errMsg)
......
......@@ -158,7 +158,7 @@ export default class TroubleContainer extends React.Component{
})
}else{
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);
this.setState({
......
......@@ -3,5 +3,5 @@
*/
module.exports = {
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 @@
* Created by ruibing on 16/11/2.
*/
module.exports = {
domain: 'http://www.mjitech.com',
uploadImg : "https://www.mjitech.com/static/uploadTrouble/"
domain: 'http://preprod.mjitech.com/web/',
uploadImg : "https://preprod.mjitech.com/static/uploadTrouble"
}
\ No newline at end of file
......@@ -2,5 +2,6 @@
* Created by ruibing on 16/11/2.
*/
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) {
let store = activateVendor();
UTILPATH.socket.init(115,17);
// UTILPATH.socket.init(129,17);
UTILPATH.socket.testIp(209);
renderPage(store);
\ No newline at end of file
......@@ -89,11 +89,11 @@ const testIp = (ip) => {
.then((data) => {
if(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;
currentIpIndex = i;
init(i,data.storeId);
let wsUrl = 'ws://' + domainIp + ip + ':7788/notify?from=plant&storeId='+data.storeId;
currentIpIndex = ip;
init(ip,data.storeId);
}
})
.catch((err) =>{
......@@ -197,4 +197,4 @@ const closeSocket = ()=>{
}
}
module.exports = {getIp,sendMsg,init};
\ No newline at end of file
module.exports = {getIp,sendMsg,init,testIp};
\ No newline at end of file
......@@ -8,7 +8,8 @@
"test": "echo \"Error: no test specified\" && exit 1",
"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",
"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": "",
"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