From 5ec80073fe35e554e1644f1f2a98bfca1318f6cd Mon Sep 17 00:00:00 2001 From: Kelvin Date: Tue, 26 Nov 2024 09:36:29 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0wcs=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/md/TASK.js | 11 +++++- src/api/mes/wm/wmsInTask.js | 13 +++++-- src/utils/request.js | 71 ++++++++++++++++++++++--------------- vue.config.js | 2 +- 4 files changed, 63 insertions(+), 34 deletions(-) diff --git a/src/api/md/TASK.js b/src/api/md/TASK.js index a3bdf30..e1d5a0f 100644 --- a/src/api/md/TASK.js +++ b/src/api/md/TASK.js @@ -1,4 +1,4 @@ -import request from '@/utils/request' +import request, {requestWcs} from '@/utils/request' // 查询出库任务列表 export function listTASK(query) { @@ -58,3 +58,12 @@ export function autoRunTASK(wmsOutTaskId) { method: 'put' }) } + +// 下发任务至 WCS +export function issueWmsOutTaskToWcs(data) { + return requestWcs({ + url: '/StackerCraneCK', + method: 'post', + data + }) +} diff --git a/src/api/mes/wm/wmsInTask.js b/src/api/mes/wm/wmsInTask.js index e4db657..b40070d 100644 --- a/src/api/mes/wm/wmsInTask.js +++ b/src/api/mes/wm/wmsInTask.js @@ -1,4 +1,4 @@ -import request from '@/utils/request' +import request, {requestWcs} from '@/utils/request' // 查询入库任务列表 export function listWmsInTask(query) { @@ -46,9 +46,16 @@ export function delWmsInTask(id) { // 批量执行入库任务 export function issueBatchWmsInTask(data) { return request({ - url: '/wm/wmsInTask/open/issueBatch', + url: '/wm/wmsInTask/open/issueBatch/' + data, + method: 'post', + }) +} + +// 下发任务至 WCS +export function issueWmsInTaskToWcs(data) { + return requestWcs({ + url: '/StackerCraneRK', method: 'post', data }) } - diff --git a/src/utils/request.js b/src/utils/request.js index 20b613f..3b9cda1 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -1,15 +1,15 @@ import axios from 'axios' -import { Notification, MessageBox, Message, Loading } from 'element-ui' +import {Notification, MessageBox, Message, Loading} from 'element-ui' import store from '@/store' -import { getToken } from '@/utils/auth' +import {getToken} from '@/utils/auth' import errorCode from '@/utils/errorCode' -import { tansParams, blobValidate } from "@/utils/ruoyi"; +import {tansParams, blobValidate} from "@/utils/ruoyi"; import cache from '@/plugins/cache' -import { saveAs } from 'file-saver' +import {saveAs} from 'file-saver' let downloadLoadingInstance; // 是否显示重新登录 -export let isRelogin = { show: false }; +export let isRelogin = {show: false}; axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8' // 创建axios实例 @@ -20,6 +20,13 @@ const service = axios.create({ timeout: 30000 }) +const serviceWcs = axios.create({ + // axios中请求配置有baseURL选项,表示请求URL公共部分 + baseURL: "http://192.168.8.60:1880", + // 超时 + timeout: 30000 +}) + // request拦截器 service.interceptors.request.use(config => { // 是否需要设置 token @@ -61,8 +68,8 @@ service.interceptors.request.use(config => { } return config }, error => { - console.log(error) - Promise.reject(error) + console.log(error) + Promise.reject(error) }) // 响应拦截器 @@ -72,26 +79,26 @@ service.interceptors.response.use(res => { // 获取错误信息 const msg = errorCode[code] || res.data.msg || errorCode['default'] // 二进制数据则直接返回 - if(res.request.responseType === 'blob' || res.request.responseType === 'arraybuffer'){ + if (res.request.responseType === 'blob' || res.request.responseType === 'arraybuffer') { return res.data } if (code === 401) { if (!isRelogin.show) { isRelogin.show = true; MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', { - confirmButtonText: '重新登录', - cancelButtonText: '取消', - type: 'warning' - } - ).then(() => { - isRelogin.show = false; - store.dispatch('LogOut').then(() => { - location.href = '/index'; - }) - }).catch(() => { - isRelogin.show = false; - }); - } + confirmButtonText: '重新登录', + cancelButtonText: '取消', + type: 'warning' + } + ).then(() => { + isRelogin.show = false; + store.dispatch('LogOut').then(() => { + location.href = '/index'; + }) + }).catch(() => { + isRelogin.show = false; + }); + } return Promise.reject('无效的会话,或者会话已过期,请重新登录。') } else if (code === 500) { Message({ @@ -110,14 +117,12 @@ service.interceptors.response.use(res => { }, error => { console.log('err' + error) - let { message } = error; + let {message} = error; if (message == "Network Error") { message = "后端接口连接异常"; - } - else if (message.includes("timeout")) { + } else if (message.includes("timeout")) { message = "系统接口请求超时"; - } - else if (message.includes("Request failed with status code")) { + } else if (message.includes("Request failed with status code")) { message = "系统接口" + message.substr(message.length - 3) + "异常"; } Message({ @@ -131,10 +136,16 @@ service.interceptors.response.use(res => { // 通用下载方法 export function download(url, params, filename) { - downloadLoadingInstance = Loading.service({ text: "正在下载数据,请稍候", spinner: "el-icon-loading", background: "rgba(0, 0, 0, 0.7)", }) + downloadLoadingInstance = Loading.service({ + text: "正在下载数据,请稍候", + spinner: "el-icon-loading", + background: "rgba(0, 0, 0, 0.7)", + }) return service.post(url, params, { - transformRequest: [(params) => { return tansParams(params) }], - headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, + transformRequest: [(params) => { + return tansParams(params) + }], + headers: {'Content-Type': 'application/x-www-form-urlencoded'}, responseType: 'blob' }).then(async (data) => { const isLogin = await blobValidate(data); @@ -156,3 +167,5 @@ export function download(url, params, filename) { } export default service + +export const requestWcs = serviceWcs diff --git a/vue.config.js b/vue.config.js index efdc079..edc0352 100644 --- a/vue.config.js +++ b/vue.config.js @@ -35,7 +35,7 @@ module.exports = { proxy: { // detail: https://cli.vuejs.org/config/#devserver-proxy [process.env.VUE_APP_BASE_API]: { - target: `http://localhost:8080`, + target: `http://localhost:8081`, changeOrigin: true, pathRewrite: { ['^' + process.env.VUE_APP_BASE_API]: ''