From 2a52f91fd128115aaf391577e4a96103dd6aef29 Mon Sep 17 00:00:00 2001 From: liangzhou <594755172@qq.com> Date: Fri, 30 Aug 2024 16:52:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=9B=B4=E6=96=B0=EF=BC=9A?= =?UTF-8?q?=201.=E5=A2=9E=E5=8A=A0=E6=96=87=E4=BB=B6=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E7=9A=84=E5=88=A4=E6=96=AD=202.=E5=A4=87?= =?UTF-8?q?=E6=96=99=E6=89=A7=E8=A1=8C=E7=95=8C=E9=9D=A2=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E4=B8=8D=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/excel.js | 12 ++++++------ src/excel/UploadExcelDbs.vue | 17 +++++++++++++++++ src/excel/UploadExcelGoods.vue | 17 +++++++++++++++++ src/excel/UploadExcelInventoryList.vue | 17 +++++++++++++++++ src/excel/UploadExcelOrders.vue | 17 +++++++++++++++++ src/excel/UploadExcelStationConfig.vue | 17 +++++++++++++++++ src/excel/UploadExcelStock.vue | 17 +++++++++++++++++ src/http/request.js | 2 +- src/layout/doKitting.vue | 17 +++++------------ src/utils/hashUtils.js | 16 ++++++++++++++++ src/utils/loading.js | 20 +++++++++++++------- 11 files changed, 143 insertions(+), 26 deletions(-) create mode 100644 src/utils/hashUtils.js diff --git a/src/api/excel.js b/src/api/excel.js index c553742..98f0d7e 100644 --- a/src/api/excel.js +++ b/src/api/excel.js @@ -5,7 +5,7 @@ const uploadExcelStock = (data) => { url: '/excel/uploadStocks', method: 'post', data: data, - timeout: 100000 + timeout: 600000 }) } @@ -14,7 +14,7 @@ const uploadExcelGoods = (data) => { url: '/excel/uploadGoods', method: 'post', data: data, - timeout: 100000 + timeout: 600000 }) } @@ -23,7 +23,7 @@ const uploadStationConfig = (data) => { url: '/excel/uploadStationConfig', method: 'post', data: data, - timeout: 100000 + timeout: 600000 }) } @@ -32,7 +32,7 @@ const uploadExcelDbs = (data) => { url: '/excel/uploadDbs', method: 'post', data: data, - timeout: 100000 + timeout: 600000 }) } @@ -41,7 +41,7 @@ const uploadExcelOrders = (data) => { url: '/excel/uploadKateOrders', method: 'post', data: data, - timeout: 100000 + timeout: 600000 }) } @@ -50,7 +50,7 @@ const uploadExcelInventoryList = (data) => { url: '/excel/uploadInventoryList', method: 'post', data: data, - timeout: 100000 + timeout: 600000 }) } diff --git a/src/excel/UploadExcelDbs.vue b/src/excel/UploadExcelDbs.vue index ce6e7a3..10f1991 100644 --- a/src/excel/UploadExcelDbs.vue +++ b/src/excel/UploadExcelDbs.vue @@ -13,13 +13,17 @@ import { ref, reactive } from 'vue'; import { uploadExcelDbs } from '@/api/excel.js' import { ElMessage } from 'element-plus' import { sizeFormatter } from '@/utils/formatter.js' +import loading from '@/utils/loading.js' +import { getHashString } from '@/utils/hashUtils.js' const file = ref() +var currentHash = '' const uploadForm = reactive({ data: { fileId: '', name: '', type: '', size: null, + hash: '', userName: store.getters.getUserName } }) @@ -30,6 +34,7 @@ const changeFile = (uploadFile) => { name: file.value.raw.name, type: file.value.raw.type, size: sizeFormatter(file.value.raw.size), + hash: getHashString(uploadFile), userName: store.getters.getUserName } } @@ -37,7 +42,13 @@ const uploadRef = ref() const uploadDbs = () => { if (uploadForm == undefined || file.value == undefined) { ElMessage.error('请选择文件之后再上传') + return } + if (currentHash != '' && currentHash == uploadForm.data.hash) { + ElMessage.error('请勿重复上传') + return + } + currentHash = uploadForm.data.hash const jsonStr = JSON.stringify(uploadForm.data); const blob = new Blob([jsonStr], { type: 'application/json' @@ -46,7 +57,10 @@ const uploadDbs = () => { // 这里很重要 file.value.raw才是真实的file文件,file.value只是一个Proxy代理对象 formData.append("obj", blob); formData.append("file", file.value.raw); + loading.open('导入中...') uploadExcelDbs(formData).then(res => { + loading.close() + currentHash = '' if (res.data.code == 0) { ElMessage({ message: '上传成功', @@ -57,6 +71,8 @@ const uploadDbs = () => { ElMessage.error(res.data.message) } }).catch(err => { + loading.close() + currentHash = '' console.log(err) ElMessage.error('上传错误') }) @@ -69,6 +85,7 @@ const clearFileInfos = () => { name: '', type: '', size: null, + hash: '', userName: store.getters.getUserName } file.value = undefined diff --git a/src/excel/UploadExcelGoods.vue b/src/excel/UploadExcelGoods.vue index 3893bb6..1e1c7ed 100644 --- a/src/excel/UploadExcelGoods.vue +++ b/src/excel/UploadExcelGoods.vue @@ -13,6 +13,9 @@ import { ref, reactive } from 'vue'; import { uploadExcelGoods } from '@/api/excel.js' import { ElMessage } from 'element-plus' import { sizeFormatter } from '@/utils/formatter.js' +import loading from '@/utils/loading.js' +import { getHashString } from '@/utils/hashUtils.js' +var currentHash = '' const file = ref() const uploadForm = reactive({ data: { @@ -20,6 +23,7 @@ const uploadForm = reactive({ name: '', type: '', size: null, + hash: '', userName: store.getters.getUserName } }) @@ -30,6 +34,7 @@ const changeFile = (uploadFile) => { name: file.value.raw.name, type: file.value.raw.type, size: sizeFormatter(file.value.raw.size), + hash: getHashString(uploadFile), userName: store.getters.getUserName } } @@ -37,7 +42,13 @@ const uploadRef = ref() const uploadGoods = () => { if (uploadForm == undefined || file.value == undefined) { ElMessage.error('请选择文件之后再上传') + return } + if (currentHash != '' && currentHash == uploadForm.data.hash) { + ElMessage.error('请勿重复上传') + return + } + currentHash = uploadForm.data.hash const jsonStr = JSON.stringify(uploadForm.data); const blob = new Blob([jsonStr], { type: 'application/json' @@ -46,7 +57,10 @@ const uploadGoods = () => { // 这里很重要 file.value.raw才是真实的file文件,file.value只是一个Proxy代理对象 formData.append("obj", blob); formData.append("file", file.value.raw); + loading.open('导入中...') uploadExcelGoods(formData).then(res => { + loading.close() + currentHash = '' if (res.data.code == 0) { ElMessage({ message: '上传成功', @@ -57,6 +71,8 @@ const uploadGoods = () => { ElMessage.error(res.data.message) } }).catch(err => { + loading.close() + currentHash = '' console.log(err) ElMessage.error('上传错误') }) @@ -69,6 +85,7 @@ const clearFileInfos = () => { name: '', type: '', size: null, + hash: '', userName: store.getters.getUserName } file.value = undefined diff --git a/src/excel/UploadExcelInventoryList.vue b/src/excel/UploadExcelInventoryList.vue index befc9af..bece2ac 100644 --- a/src/excel/UploadExcelInventoryList.vue +++ b/src/excel/UploadExcelInventoryList.vue @@ -13,6 +13,9 @@ import { ref, reactive } from 'vue'; import { uploadExcelInventoryList } from '@/api/excel.js' import { ElMessage } from 'element-plus' import { sizeFormatter } from '@/utils/formatter.js' +import loading from '@/utils/loading.js' +import { getHashString } from '@/utils/hashUtils.js' +var currentHash = '' const file = ref() const uploadForm = reactive({ data: { @@ -20,6 +23,7 @@ const uploadForm = reactive({ name: '', type: '', size: null, + hash: '', userName: store.getters.getUserName } }) @@ -30,6 +34,7 @@ const changeFile = (uploadFile) => { name: file.value.raw.name, type: file.value.raw.type, size: sizeFormatter(file.value.raw.size), + hash: getHashString(uploadFile), userName: store.getters.getUserName } } @@ -37,7 +42,13 @@ const uploadRef = ref() const uploadInventory = () => { if (uploadForm == undefined || file.value == undefined) { ElMessage.error('请选择文件之后再上传') + return } + if (currentHash != '' && currentHash == uploadForm.data.hash) { + ElMessage.error('请勿重复上传') + return + } + currentHash = uploadForm.data.hash const jsonStr = JSON.stringify(uploadForm.data); const blob = new Blob([jsonStr], { type: 'application/json' @@ -46,7 +57,10 @@ const uploadInventory = () => { // 这里很重要 file.value.raw才是真实的file文件,file.value只是一个Proxy代理对象 formData.append("obj", blob); formData.append("file", file.value.raw); + loading.open('导入中...') uploadExcelInventoryList(formData).then(res => { + loading.close() + currentHash = '' if (res.data.code == 0) { ElMessage({ message: '上传成功', @@ -57,6 +71,8 @@ const uploadInventory = () => { ElMessage.error(res.data.message) } }).catch(err => { + loading.close() + currentHash = '' console.log(err) ElMessage.error('上传错误') }) @@ -69,6 +85,7 @@ const clearFileInfos = () => { name: '', type: '', size: null, + hash: '', userName: store.getters.getUserName } file.value = undefined diff --git a/src/excel/UploadExcelOrders.vue b/src/excel/UploadExcelOrders.vue index 8744efc..309c0cf 100644 --- a/src/excel/UploadExcelOrders.vue +++ b/src/excel/UploadExcelOrders.vue @@ -13,6 +13,9 @@ import { ref, reactive } from 'vue'; import { uploadExcelOrders } from '@/api/excel.js' import { ElMessage } from 'element-plus' import { sizeFormatter } from '@/utils/formatter.js' +import loading from '@/utils/loading.js' +import { getHashString } from '@/utils/hashUtils.js' +var currentHash = '' const file = ref() const uploadForm = reactive({ data: { @@ -20,6 +23,7 @@ const uploadForm = reactive({ name: '', type: '', size: null, + hash: '', userName: store.getters.getUserName } }) @@ -30,6 +34,7 @@ const changeFile = (uploadFile) => { name: file.value.raw.name, type: file.value.raw.type, size: sizeFormatter(file.value.raw.size), + hash: getHashString(uploadFile), userName: store.getters.getUserName } } @@ -37,7 +42,13 @@ const uploadRef = ref() const uploadOrders = () => { if (uploadForm == undefined || file.value == undefined) { ElMessage.error('请选择文件之后再上传') + return } + if (currentHash != '' && currentHash == uploadForm.data.hash) { + ElMessage.error('请勿重复上传') + return + } + currentHash = uploadForm.data.hash const jsonStr = JSON.stringify(uploadForm.data); const blob = new Blob([jsonStr], { type: 'application/json' @@ -46,7 +57,10 @@ const uploadOrders = () => { // 这里很重要 file.value.raw才是真实的file文件,file.value只是一个Proxy代理对象 formData.append("obj", blob); formData.append("file", file.value.raw); + loading.open('导入中...') uploadExcelOrders(formData).then(res => { + loading.close() + currentHash = '' if (res.data.code == 0) { ElMessage({ message: '上传成功', @@ -57,6 +71,8 @@ const uploadOrders = () => { ElMessage.error(res.data.message) } }).catch(err => { + loading.close() + currentHash = '' console.log(err) ElMessage.error('上传错误') }) @@ -69,6 +85,7 @@ const clearFileInfos = () => { name: '', type: '', size: null, + hash: '', userName: store.getters.getUserName } file.value = undefined diff --git a/src/excel/UploadExcelStationConfig.vue b/src/excel/UploadExcelStationConfig.vue index a495ea6..15d0f99 100644 --- a/src/excel/UploadExcelStationConfig.vue +++ b/src/excel/UploadExcelStationConfig.vue @@ -13,6 +13,9 @@ import { ref, reactive } from 'vue'; import { uploadStationConfig } from '@/api/excel.js' import { ElMessage } from 'element-plus' import { sizeFormatter } from '@/utils/formatter.js' +import loading from '@/utils/loading.js' +import { getHashString } from '@/utils/hashUtils.js' +var currentHash = '' const file = ref() const uploadForm = reactive({ data: { @@ -20,6 +23,7 @@ const uploadForm = reactive({ name: '', type: '', size: null, + hash: '', userName: store.getters.getUserName } }) @@ -30,6 +34,7 @@ const changeFile = (uploadFile) => { name: file.value.raw.name, type: file.value.raw.type, size: sizeFormatter(file.value.raw.size), + hash: getHashString(uploadFile), userName: store.getters.getUserName } } @@ -37,7 +42,13 @@ const uploadRef = ref() const uploadDbs = () => { if (uploadForm == undefined || file.value == undefined) { ElMessage.error('请选择文件之后再上传') + return } + if (currentHash != '' && currentHash == uploadForm.data.hash) { + ElMessage.error('请勿重复上传') + return + } + currentHash = uploadForm.data.hash const jsonStr = JSON.stringify(uploadForm.data); const blob = new Blob([jsonStr], { type: 'application/json' @@ -46,7 +57,10 @@ const uploadDbs = () => { // 这里很重要 file.value.raw才是真实的file文件,file.value只是一个Proxy代理对象 formData.append("obj", blob); formData.append("file", file.value.raw); + loading.open('导入中...') uploadStationConfig(formData).then(res => { + loading.close() + currentHash = '' if (res.data.code == 0) { ElMessage({ message: '上传成功', @@ -57,6 +71,8 @@ const uploadDbs = () => { ElMessage.error(res.data.message) } }).catch(err => { + loading.close() + currentHash = '' console.log(err) ElMessage.error('上传错误') }) @@ -69,6 +85,7 @@ const clearFileInfos = () => { name: '', type: '', size: null, + hash: '', userName: store.getters.getUserName } file.value = undefined diff --git a/src/excel/UploadExcelStock.vue b/src/excel/UploadExcelStock.vue index c504cd1..6abfc64 100644 --- a/src/excel/UploadExcelStock.vue +++ b/src/excel/UploadExcelStock.vue @@ -13,6 +13,9 @@ import { ref, reactive } from 'vue'; import { uploadExcelStock } from '@/api/excel.js' import { ElMessage } from 'element-plus' import { sizeFormatter } from '@/utils/formatter.js' +import loading from '@/utils/loading.js' +import { getHashString } from '@/utils/hashUtils.js' +var currentHash = '' const file = ref() const uploadForm = reactive({ data: { @@ -20,6 +23,7 @@ const uploadForm = reactive({ name: '', type: '', size: null, + hash: '', userName: store.getters.getUserName } }) @@ -30,6 +34,7 @@ const changeFile = (uploadFile) => { name: file.value.raw.name, type: file.value.raw.type, size: sizeFormatter(file.value.raw.size), + hash: getHashString(uploadFile), userName: store.getters.getUserName } } @@ -37,7 +42,13 @@ const uploadRef = ref() const uploadStock = () => { if (uploadForm == undefined || file.value == undefined) { ElMessage.error('请选择文件之后再上传') + return } + if (currentHash != '' && currentHash == uploadForm.data.hash) { + ElMessage.error('请勿重复上传') + return + } + currentHash = uploadForm.data.hash const jsonStr = JSON.stringify(uploadForm.data); const blob = new Blob([jsonStr], { type: 'application/json' @@ -46,7 +57,10 @@ const uploadStock = () => { // 这里很重要 file.value.raw才是真实的file文件,file.value只是一个Proxy代理对象 formData.append("obj", blob); formData.append("file", file.value.raw); + loading.open('导入中...') uploadExcelStock(formData).then(res => { + loading.close() + currentHash = '' if (res.data.code == 0) { ElMessage({ message: '上传成功', @@ -57,6 +71,8 @@ const uploadStock = () => { ElMessage.error(res.data.message) } }).catch(err => { + loading.close() + currentHash = '' console.log(err) ElMessage.error('上传错误') }) @@ -69,6 +85,7 @@ const clearFileInfos = () => { name: '', type: '', size: null, + hash: '', userName: store.getters.getUserName } file.value = undefined diff --git a/src/http/request.js b/src/http/request.js index f931042..140e628 100644 --- a/src/http/request.js +++ b/src/http/request.js @@ -1,7 +1,7 @@ import axios from 'axios' const request = axios.create({ - baseURL: 'http://localhost:12315/wms', + baseURL: 'http://10.90.36.70:443/wmsServer/wms', timeout: 5000 }) diff --git a/src/layout/doKitting.vue b/src/layout/doKitting.vue index ba9aa63..9d4ee26 100644 --- a/src/layout/doKitting.vue +++ b/src/layout/doKitting.vue @@ -253,18 +253,11 @@ export default { }, // 重置参数 resetForms() { - this.workFormEntity = reactive({ - goodsId: '', - planPickNum: 0, - remainNumOrigin: null, - remainNumReal: null, - remark: '', - finishedRows: 0, - totalRows: 0, - finishedCounts: 0, - totalCounts: 0, - tip: '' - }) + this.workFormEntity.goodsId = '' + this.workFormEntity.planPickNum = 0 + this.workFormEntity.remainNumOrigin = null + this.workFormEntity.remainNumReal = null + this.workFormEntity.remark = '' this.$refs.goodsId.focus() }, // 确认完成工作 diff --git a/src/utils/hashUtils.js b/src/utils/hashUtils.js new file mode 100644 index 0000000..f05bc03 --- /dev/null +++ b/src/utils/hashUtils.js @@ -0,0 +1,16 @@ +import crypto from 'crypto' +function base64URLEncode(str) { + return str.toString('base64') + .replace(/\+/g, '-') + .replace(/\//g, '_') + .replace(/=/g, ''); +} + +function getHashString(obj) { + return base64URLEncode(crypto.createHash('sha256').update(obj).digest()) +} + +export { + base64URLEncode, + getHashString +} \ No newline at end of file diff --git a/src/utils/loading.js b/src/utils/loading.js index e3ada52..99c0858 100644 --- a/src/utils/loading.js +++ b/src/utils/loading.js @@ -1,9 +1,15 @@ import { ElLoading } from 'element-plus' - -const loading = ElLoading.service({ - lock: true, - text: 'Loading', - background: 'rgba(0, 0, 0, 0.7)', -}) - +const loading = { + loadingInstance: null, + open: function (text) { + this.loadingInstance = ElLoading.service({ + lock: true, + text: text, + background: 'rgba(0, 0, 0, 0.7)' + }) + }, + close: function () { + this.loadingInstance.close() + } +} export default loading \ No newline at end of file