This commit is contained in:
2023-03-01 14:55:56 +08:00
parent 00db75e767
commit 0540dc5f6a
8 changed files with 128 additions and 49 deletions

View File

38
src/assets/js/getData2.js Normal file
View File

@@ -0,0 +1,38 @@
// import {post} from './http.js'
// 设备监控
// export const deviceMonitor = () => post('api/cockpit/deviceMonitor', {
// })
export const deviceMonitor = () => {
let res = [
{
'point_id': '1',
'point_code': 'HLJDJW01',
'point_name': '混料机1对接位',
'point_status': '3',
'material_id': 1556534702800769024,
'material_name': '木质花纹2cm',
'ivt_weight': 29.500000,
'work_time': '50',
'ivt_qty': 600.000000,
'vehicle_qty': 15,
'vehicle_max_qty': 20,
'device_url': 'hlj'
},
{
'point_id': '1518105008862793728',
'point_code': 'YZJ02XL01',
'point_name': '压制机2下料位1',
'point_status': '3',
'material_id': 1556534702800769024,
'material_name': '木质花纹2cm',
'ivt_weight': 29.500000,
'work_time': '50',
'ivt_qty': 600.000000,
'vehicle_qty': 15,
'vehicle_max_qty': 20,
'device_url': 'yzj'
}
]
return res
}

65
src/assets/js/http.js Normal file
View File

@@ -0,0 +1,65 @@
import axios from 'axios'
import { Dialog } from './mUtils.js'
import store from '../../vuex/store'
import router from '@/router'
axios.defaults.timeout = 50000
axios.defaults.headers.post['Content-Type'] = 'application/json;charset=UTF-8'
axios.interceptors.request.use(
config => {
// let token = ''
// if (store.getters.userInfo !== '') {
// token = JSON.parse(store.getters.userInfo).token
// }
// token && (config.headers.Authorization = token)
if (config.method === 'post') {
if (!config.data.flag) {
config.data = config.data
} else {
config.data = config.data.formData
}
}
return config
},
error => {
Dialog('错误的传参')
return Promise.reject(error)
}
)
axios.interceptors.response.use(
response => {
return Promise.resolve(response)
},
error => {
if (error && error.response) {
switch (error.response.status) {
case 400:
break
case 401:
// store.dispatch('setSignOut')
router.push('/setup')
break
}
return Promise.reject(error.response.data)
} else {
return Promise.reject(error)
}
}
)
export const post = (sevmethod, params) => {
return new Promise((resolve, reject) => {
axios.post(`${store.getters.baseUrl}/` + sevmethod, params)
.then(response => {
resolve(response.data)
}, error => {
Dialog(error.message)
reject(error.message)
})
.catch((error) => {
reject(error)
})
})
}

View File

@@ -6,9 +6,9 @@ import store from '../../vuex/store'
export const Dialog = (str) => {
store.dispatch('showAlert', true)
store.dispatch('alertMsg', str)
setTimeout(() => {
store.dispatch('showAlert', false)
}, 30000)
// setTimeout(() => {
// store.dispatch('showAlert', false)
// }, 30000)
}
/**