From f2a3c1daf949a1946a0fe09d56285cc727b6129b Mon Sep 17 00:00:00 2001 From: guoxing <1369478551@qq.com> Date: Mon, 27 Mar 2023 18:24:21 +0800 Subject: [PATCH] 2023-3-27 --- mallplusui-web-admin/config/dev.env.js | 4 +- mallplusui-web-admin/src/api/order.js | 8 + .../src/api/orderStatistic.js | 1 + mallplusui-web-admin/src/utils/request.js | 139 ++++++++++-------- .../src/views/oms/order/index1.vue | 99 ++++++++++--- .../src/views/oms/order/orderStatistic.vue | 17 ++- 6 files changed, 181 insertions(+), 87 deletions(-) diff --git a/mallplusui-web-admin/config/dev.env.js b/mallplusui-web-admin/config/dev.env.js index ad226ad..9253274 100644 --- a/mallplusui-web-admin/config/dev.env.js +++ b/mallplusui-web-admin/config/dev.env.js @@ -4,7 +4,7 @@ const prodEnv = require('./prod.env') module.exports = merge(prodEnv, { NODE_ENV: '"development"', - // BASE_API: '"http://mall.yyundong.com/adminapi"', - BASE_API: '"http://192.168.3.9:8085"' + BASE_API: '"http://mall.yyundong.com/adminapi"', + // BASE_API: '"http://192.168.3.9:8085"' // BASE_API: '"http://127.0.0.1:8085"' }) diff --git a/mallplusui-web-admin/src/api/order.js b/mallplusui-web-admin/src/api/order.js index 5ed2982..8e6b5e5 100644 --- a/mallplusui-web-admin/src/api/order.js +++ b/mallplusui-web-admin/src/api/order.js @@ -30,6 +30,14 @@ export function deliveryOrder(data) { }); } +export function newDeliveryOrder(data) { + return request({ + url: '/oms/OmsOrder/update/deliveryNew', + method: 'post', + data: data + }); +} + export function getOrderDetail(id) { return request({ url: '/oms/OmsOrder/' + id, diff --git a/mallplusui-web-admin/src/api/orderStatistic.js b/mallplusui-web-admin/src/api/orderStatistic.js index a9c61b8..de1e0e1 100644 --- a/mallplusui-web-admin/src/api/orderStatistic.js +++ b/mallplusui-web-admin/src/api/orderStatistic.js @@ -85,6 +85,7 @@ export function orderData(params) { export function exportExcel(params) { return request({ + baseURL: '/api', url: '/oms/OmsOrder/exportExcel2', method: 'post', responseType: 'blob', // 表明返回服务器返回的数据类型 diff --git a/mallplusui-web-admin/src/utils/request.js b/mallplusui-web-admin/src/utils/request.js index 742d118..2e7704e 100644 --- a/mallplusui-web-admin/src/utils/request.js +++ b/mallplusui-web-admin/src/utils/request.js @@ -1,79 +1,98 @@ import axios from 'axios' -import { Message, MessageBox } from 'element-ui' +import { + Message, + MessageBox +} from 'element-ui' import store from '../store' -import { getToken,get } from '@/utils/auth' +import { + getToken, + get +} from '@/utils/auth' // 创建axios实例 const service = axios.create({ - baseURL: process.env.BASE_API, // api的base_url - timeout: 35000 // 请求超时时间 + baseURL: process.env.BASE_API, // api的base_url + timeout: 35000 // 请求超时时间 }) // request拦截器 service.interceptors.request.use(config => { - if (store.getters.token) { - let test = config.data; - if(test){ - config.data['access_token']= getToken() - } + if (store.getters.token) { + let test = config.data; + if (test) { + config.data['access_token'] = getToken() + } - if (get('storeId') && 'undefined'!=get('storeId')){ - config.headers['storeid'] = get('storeId') - } + if (get('storeId') && 'undefined' != get('storeId')) { + config.headers['storeid'] = get('storeId') + } - config.headers['Authorization'] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改 - }else{ - config.headers['client_id'] = 'app'; - config.headers['client_secret'] = 'app'; - } - return config + config.headers['Authorization'] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改 + } else { + config.headers['client_id'] = 'app'; + config.headers['client_secret'] = 'app'; + } + return config }, error => { - // Do something with request error - console.log(error) // for debug - Promise.reject(error) + // Do something with request error + console.log(error) // for debug + Promise.reject(error) }) // respone拦截器 service.interceptors.response.use( - response => { - /** - * code为非200是抛错 可结合自己业务进行修改 - */ - const res = response.data - if (res.code !== 200 && !res.access_token) { - console.log(res); - Message({ - message: res.msg, - type: 'error', - duration: 3 * 1000 - }) + response => { + /** + * code为非200是抛错 可结合自己业务进行修改 + */ + const res = response.data + const statusCode = response.status - // 401:未登录; - if (res.code === 401||res.code === 403) { - MessageBox.confirm('你已被登出,可以取消继续留在该页面,或者重新登录', '确定登出', { - confirmButtonText: '重新登录', - cancelButtonText: '取消', - type: 'warning' - }).then(() => { - store.dispatch('FedLogOut').then(() => { - location.reload()// 为了重新实例化vue-router对象 避免bug - }) - }) - } - return Promise.reject('error') - } else { - return response.data - } - }, - error => { - console.log(error); - Message({ - message: error.message, - type: 'error', - duration: 3 * 1000 - }) - return Promise.reject(error) - } + console.log("response>>>>", response); + + if (statusCode !== 200) { + Message({ + message: res.msg || response.message || 'Error', + type: 'error', + showClose: true, + duration: 5 * 1000 + }) + + + // 401:未登录; + if (statusCode === 401 || statusCode === 403) { + MessageBox.confirm('你已被登出,可以取消继续留在该页面,或者重新登录', '确定登出', { + confirmButtonText: '重新登录', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + store.dispatch('FedLogOut').then(() => { + location.reload() // 为了重新实例化vue-router对象 避免bug + }) + }) + } + return Promise.reject('error') + } else { + if (!res.success && res.success !== null && res.success !== undefined) { + Message({ + message: res.msg || 'Error', + type: 'error', + showClose: true, + duration: 5 * 1000 + }) + } + return res + } + }, + error => { + console.log(error); + Message({ + message: error.message, + type: 'error', + duration: 3 * 1000 + }) + return Promise.reject(error) + } ) -export default service +export default service \ No newline at end of file diff --git a/mallplusui-web-admin/src/views/oms/order/index1.vue b/mallplusui-web-admin/src/views/oms/order/index1.vue index 23fa3be..2eb0e7e 100644 --- a/mallplusui-web-admin/src/views/oms/order/index1.vue +++ b/mallplusui-web-admin/src/views/oms/order/index1.vue @@ -239,7 +239,8 @@ closeOrder, deleteOrder, orderData, - exportExcel + exportExcel, + newDeliveryOrder } from '@/api/order'; import { formatDate @@ -544,14 +545,22 @@ this.closeOrder.orderIds = [row.id]; }, handleDeliveryOrder(index, row) { - let listItem = this.covertOrder(row); - console.log("listItem", listItem) - this.$router.push({ - path: '/oms/deliverOrderList', - query: { - list: [listItem] - } + // let listItem = this.covertOrder(row); + // console.log("listItem", listItem) + // this.$router.push({ + // path: '/oms/deliverOrderList', + // query: { + // list: [listItem] + // } + // }); + + let idList = [] + + idList.push({ + orderId: row.id }); + + this.sendGoods("是否确认发货", idList); }, handleViewLogistics(index, row) { this.logisticsDialogVisible = true; @@ -769,6 +778,48 @@ // 批量发货 doBatch() { + if (this.multipleSelection.length == 0) { + this.$message({ + message: '暂无数据可导出!', + type: 'warning', + duration: 1000 + }); + return + } + let idList = [] + + this.multipleSelection.forEach(row => { + idList.push({ + orderId: row.id + }) + }); + + this.sendGoods("是否确认批量发货?", idList); + + }, + + // 发货 + sendGoods(str, idList) { + + this.$confirm(str, '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + newDeliveryOrder(idList).then(response => { + this.$message({ + type: 'success', + message: '发货成功!' + }); + this.getList(); + this.orderDatas(this.listQuery.status); + }); + }).catch(() => { + this.$message({ + type: 'info', + message: '已取消发货' + }); + }); }, // 导出 doExport() { @@ -781,24 +832,24 @@ return } + const loading = this.$loading({ + lock: true, + text: 'Loading', + spinner: 'el-icon-loading', + background: 'rgba(0, 0, 0, 0.7)' + }) - // const loading = this.$loading({ - // lock: true, - // text: 'Loading', - // spinner: 'el-icon-loading', - // background: 'rgba(0, 0, 0, 0.7)' - // }) - this.listQuery = { - status: 0, - orderSn: '00382', - receiverPhone: '', - createTimeStart: '', - createTimeEnd: '' + const data = { + status: this.listQuery.status == null ? "" : this.listQuery.status, + orderSn: this.listQuery.orderSn == null ? "" : this.listQuery.orderSn, + receiverPhone: this.listQuery.receiverPhone == null ? "" : this.listQuery.receiverPhone, + createTimeStart: this.listQuery.createTimeStart == null ? "" : this.listQuery.createTimeStart, + createTimeEnd: this.listQuery.createTimeEnd == null ? "" : this.listQuery.createTimeEnd, } - exportExcel(this.listQuery).then((resp) => { - // loading.close() + exportExcel(data).then((resp) => { + loading.close() const blob = new Blob([resp], { - type: 'application/vnd.ms-excel;charset=utf-8' + type: 'application/vnd.ms-excel;charset=UTF-8' }) const fileName = '订单列表' + '.xls' const elink = document.createElement('a') @@ -810,7 +861,7 @@ URL.revokeObjectURL(elink.href) document.body.removeChild(elink) }).catch(() => { - // loading.close() + loading.close() }) }, diff --git a/mallplusui-web-admin/src/views/oms/order/orderStatistic.vue b/mallplusui-web-admin/src/views/oms/order/orderStatistic.vue index 629e310..1cff604 100644 --- a/mallplusui-web-admin/src/views/oms/order/orderStatistic.vue +++ b/mallplusui-web-admin/src/views/oms/order/orderStatistic.vue @@ -400,6 +400,14 @@ }, // 导出 doExport() { + if (this.list.length == 0) { + this.$message({ + message: '暂无数据可导出!', + type: 'warning', + duration: 1000 + }); + return + } const loading = this.$loading({ lock: true, @@ -407,7 +415,14 @@ spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.7)' }) - exportExcel(this.listQuery).then((resp) => { + + const data = { + status: this.listQuery.status == null ? "" : this.listQuery.status, + receiverPhone: this.listQuery.receiverPhone == null ? "" : this.listQuery.receiverPhone, + valueszd: this.listQuery.valueszd == null ? "" : this.listQuery.valueszd, + valueqhd: this.listQuery.valueqhd == null ? "" : this.listQuery.valueqhd, + } + exportExcel(data).then((resp) => { loading.close() const blob = new Blob([resp], { type: 'application/vnd.ms-excel'