代码更新:
1.增加文件重复上传的判断 2.备料执行界面信息不刷新
This commit is contained in:
parent
9bd3dad1ee
commit
2a52f91fd1
|
|
@ -5,7 +5,7 @@ const uploadExcelStock = (data) => {
|
||||||
url: '/excel/uploadStocks',
|
url: '/excel/uploadStocks',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: data,
|
data: data,
|
||||||
timeout: 100000
|
timeout: 600000
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -14,7 +14,7 @@ const uploadExcelGoods = (data) => {
|
||||||
url: '/excel/uploadGoods',
|
url: '/excel/uploadGoods',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: data,
|
data: data,
|
||||||
timeout: 100000
|
timeout: 600000
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -23,7 +23,7 @@ const uploadStationConfig = (data) => {
|
||||||
url: '/excel/uploadStationConfig',
|
url: '/excel/uploadStationConfig',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: data,
|
data: data,
|
||||||
timeout: 100000
|
timeout: 600000
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -32,7 +32,7 @@ const uploadExcelDbs = (data) => {
|
||||||
url: '/excel/uploadDbs',
|
url: '/excel/uploadDbs',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: data,
|
data: data,
|
||||||
timeout: 100000
|
timeout: 600000
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -41,7 +41,7 @@ const uploadExcelOrders = (data) => {
|
||||||
url: '/excel/uploadKateOrders',
|
url: '/excel/uploadKateOrders',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: data,
|
data: data,
|
||||||
timeout: 100000
|
timeout: 600000
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -50,7 +50,7 @@ const uploadExcelInventoryList = (data) => {
|
||||||
url: '/excel/uploadInventoryList',
|
url: '/excel/uploadInventoryList',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: data,
|
data: data,
|
||||||
timeout: 100000
|
timeout: 600000
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,13 +13,17 @@ import { ref, reactive } from 'vue';
|
||||||
import { uploadExcelDbs } from '@/api/excel.js'
|
import { uploadExcelDbs } from '@/api/excel.js'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import { sizeFormatter } from '@/utils/formatter.js'
|
import { sizeFormatter } from '@/utils/formatter.js'
|
||||||
|
import loading from '@/utils/loading.js'
|
||||||
|
import { getHashString } from '@/utils/hashUtils.js'
|
||||||
const file = ref()
|
const file = ref()
|
||||||
|
var currentHash = ''
|
||||||
const uploadForm = reactive({
|
const uploadForm = reactive({
|
||||||
data: {
|
data: {
|
||||||
fileId: '',
|
fileId: '',
|
||||||
name: '',
|
name: '',
|
||||||
type: '',
|
type: '',
|
||||||
size: null,
|
size: null,
|
||||||
|
hash: '',
|
||||||
userName: store.getters.getUserName
|
userName: store.getters.getUserName
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -30,6 +34,7 @@ const changeFile = (uploadFile) => {
|
||||||
name: file.value.raw.name,
|
name: file.value.raw.name,
|
||||||
type: file.value.raw.type,
|
type: file.value.raw.type,
|
||||||
size: sizeFormatter(file.value.raw.size),
|
size: sizeFormatter(file.value.raw.size),
|
||||||
|
hash: getHashString(uploadFile),
|
||||||
userName: store.getters.getUserName
|
userName: store.getters.getUserName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -37,7 +42,13 @@ const uploadRef = ref()
|
||||||
const uploadDbs = () => {
|
const uploadDbs = () => {
|
||||||
if (uploadForm == undefined || file.value == undefined) {
|
if (uploadForm == undefined || file.value == undefined) {
|
||||||
ElMessage.error('请选择文件之后再上传')
|
ElMessage.error('请选择文件之后再上传')
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
if (currentHash != '' && currentHash == uploadForm.data.hash) {
|
||||||
|
ElMessage.error('请勿重复上传')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
currentHash = uploadForm.data.hash
|
||||||
const jsonStr = JSON.stringify(uploadForm.data);
|
const jsonStr = JSON.stringify(uploadForm.data);
|
||||||
const blob = new Blob([jsonStr], {
|
const blob = new Blob([jsonStr], {
|
||||||
type: 'application/json'
|
type: 'application/json'
|
||||||
|
|
@ -46,7 +57,10 @@ const uploadDbs = () => {
|
||||||
// 这里很重要 file.value.raw才是真实的file文件,file.value只是一个Proxy代理对象
|
// 这里很重要 file.value.raw才是真实的file文件,file.value只是一个Proxy代理对象
|
||||||
formData.append("obj", blob);
|
formData.append("obj", blob);
|
||||||
formData.append("file", file.value.raw);
|
formData.append("file", file.value.raw);
|
||||||
|
loading.open('导入中...')
|
||||||
uploadExcelDbs(formData).then(res => {
|
uploadExcelDbs(formData).then(res => {
|
||||||
|
loading.close()
|
||||||
|
currentHash = ''
|
||||||
if (res.data.code == 0) {
|
if (res.data.code == 0) {
|
||||||
ElMessage({
|
ElMessage({
|
||||||
message: '上传成功',
|
message: '上传成功',
|
||||||
|
|
@ -57,6 +71,8 @@ const uploadDbs = () => {
|
||||||
ElMessage.error(res.data.message)
|
ElMessage.error(res.data.message)
|
||||||
}
|
}
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
|
loading.close()
|
||||||
|
currentHash = ''
|
||||||
console.log(err)
|
console.log(err)
|
||||||
ElMessage.error('上传错误')
|
ElMessage.error('上传错误')
|
||||||
})
|
})
|
||||||
|
|
@ -69,6 +85,7 @@ const clearFileInfos = () => {
|
||||||
name: '',
|
name: '',
|
||||||
type: '',
|
type: '',
|
||||||
size: null,
|
size: null,
|
||||||
|
hash: '',
|
||||||
userName: store.getters.getUserName
|
userName: store.getters.getUserName
|
||||||
}
|
}
|
||||||
file.value = undefined
|
file.value = undefined
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,9 @@ import { ref, reactive } from 'vue';
|
||||||
import { uploadExcelGoods } from '@/api/excel.js'
|
import { uploadExcelGoods } from '@/api/excel.js'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import { sizeFormatter } from '@/utils/formatter.js'
|
import { sizeFormatter } from '@/utils/formatter.js'
|
||||||
|
import loading from '@/utils/loading.js'
|
||||||
|
import { getHashString } from '@/utils/hashUtils.js'
|
||||||
|
var currentHash = ''
|
||||||
const file = ref()
|
const file = ref()
|
||||||
const uploadForm = reactive({
|
const uploadForm = reactive({
|
||||||
data: {
|
data: {
|
||||||
|
|
@ -20,6 +23,7 @@ const uploadForm = reactive({
|
||||||
name: '',
|
name: '',
|
||||||
type: '',
|
type: '',
|
||||||
size: null,
|
size: null,
|
||||||
|
hash: '',
|
||||||
userName: store.getters.getUserName
|
userName: store.getters.getUserName
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -30,6 +34,7 @@ const changeFile = (uploadFile) => {
|
||||||
name: file.value.raw.name,
|
name: file.value.raw.name,
|
||||||
type: file.value.raw.type,
|
type: file.value.raw.type,
|
||||||
size: sizeFormatter(file.value.raw.size),
|
size: sizeFormatter(file.value.raw.size),
|
||||||
|
hash: getHashString(uploadFile),
|
||||||
userName: store.getters.getUserName
|
userName: store.getters.getUserName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -37,7 +42,13 @@ const uploadRef = ref()
|
||||||
const uploadGoods = () => {
|
const uploadGoods = () => {
|
||||||
if (uploadForm == undefined || file.value == undefined) {
|
if (uploadForm == undefined || file.value == undefined) {
|
||||||
ElMessage.error('请选择文件之后再上传')
|
ElMessage.error('请选择文件之后再上传')
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
if (currentHash != '' && currentHash == uploadForm.data.hash) {
|
||||||
|
ElMessage.error('请勿重复上传')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
currentHash = uploadForm.data.hash
|
||||||
const jsonStr = JSON.stringify(uploadForm.data);
|
const jsonStr = JSON.stringify(uploadForm.data);
|
||||||
const blob = new Blob([jsonStr], {
|
const blob = new Blob([jsonStr], {
|
||||||
type: 'application/json'
|
type: 'application/json'
|
||||||
|
|
@ -46,7 +57,10 @@ const uploadGoods = () => {
|
||||||
// 这里很重要 file.value.raw才是真实的file文件,file.value只是一个Proxy代理对象
|
// 这里很重要 file.value.raw才是真实的file文件,file.value只是一个Proxy代理对象
|
||||||
formData.append("obj", blob);
|
formData.append("obj", blob);
|
||||||
formData.append("file", file.value.raw);
|
formData.append("file", file.value.raw);
|
||||||
|
loading.open('导入中...')
|
||||||
uploadExcelGoods(formData).then(res => {
|
uploadExcelGoods(formData).then(res => {
|
||||||
|
loading.close()
|
||||||
|
currentHash = ''
|
||||||
if (res.data.code == 0) {
|
if (res.data.code == 0) {
|
||||||
ElMessage({
|
ElMessage({
|
||||||
message: '上传成功',
|
message: '上传成功',
|
||||||
|
|
@ -57,6 +71,8 @@ const uploadGoods = () => {
|
||||||
ElMessage.error(res.data.message)
|
ElMessage.error(res.data.message)
|
||||||
}
|
}
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
|
loading.close()
|
||||||
|
currentHash = ''
|
||||||
console.log(err)
|
console.log(err)
|
||||||
ElMessage.error('上传错误')
|
ElMessage.error('上传错误')
|
||||||
})
|
})
|
||||||
|
|
@ -69,6 +85,7 @@ const clearFileInfos = () => {
|
||||||
name: '',
|
name: '',
|
||||||
type: '',
|
type: '',
|
||||||
size: null,
|
size: null,
|
||||||
|
hash: '',
|
||||||
userName: store.getters.getUserName
|
userName: store.getters.getUserName
|
||||||
}
|
}
|
||||||
file.value = undefined
|
file.value = undefined
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,9 @@ import { ref, reactive } from 'vue';
|
||||||
import { uploadExcelInventoryList } from '@/api/excel.js'
|
import { uploadExcelInventoryList } from '@/api/excel.js'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import { sizeFormatter } from '@/utils/formatter.js'
|
import { sizeFormatter } from '@/utils/formatter.js'
|
||||||
|
import loading from '@/utils/loading.js'
|
||||||
|
import { getHashString } from '@/utils/hashUtils.js'
|
||||||
|
var currentHash = ''
|
||||||
const file = ref()
|
const file = ref()
|
||||||
const uploadForm = reactive({
|
const uploadForm = reactive({
|
||||||
data: {
|
data: {
|
||||||
|
|
@ -20,6 +23,7 @@ const uploadForm = reactive({
|
||||||
name: '',
|
name: '',
|
||||||
type: '',
|
type: '',
|
||||||
size: null,
|
size: null,
|
||||||
|
hash: '',
|
||||||
userName: store.getters.getUserName
|
userName: store.getters.getUserName
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -30,6 +34,7 @@ const changeFile = (uploadFile) => {
|
||||||
name: file.value.raw.name,
|
name: file.value.raw.name,
|
||||||
type: file.value.raw.type,
|
type: file.value.raw.type,
|
||||||
size: sizeFormatter(file.value.raw.size),
|
size: sizeFormatter(file.value.raw.size),
|
||||||
|
hash: getHashString(uploadFile),
|
||||||
userName: store.getters.getUserName
|
userName: store.getters.getUserName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -37,7 +42,13 @@ const uploadRef = ref()
|
||||||
const uploadInventory = () => {
|
const uploadInventory = () => {
|
||||||
if (uploadForm == undefined || file.value == undefined) {
|
if (uploadForm == undefined || file.value == undefined) {
|
||||||
ElMessage.error('请选择文件之后再上传')
|
ElMessage.error('请选择文件之后再上传')
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
if (currentHash != '' && currentHash == uploadForm.data.hash) {
|
||||||
|
ElMessage.error('请勿重复上传')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
currentHash = uploadForm.data.hash
|
||||||
const jsonStr = JSON.stringify(uploadForm.data);
|
const jsonStr = JSON.stringify(uploadForm.data);
|
||||||
const blob = new Blob([jsonStr], {
|
const blob = new Blob([jsonStr], {
|
||||||
type: 'application/json'
|
type: 'application/json'
|
||||||
|
|
@ -46,7 +57,10 @@ const uploadInventory = () => {
|
||||||
// 这里很重要 file.value.raw才是真实的file文件,file.value只是一个Proxy代理对象
|
// 这里很重要 file.value.raw才是真实的file文件,file.value只是一个Proxy代理对象
|
||||||
formData.append("obj", blob);
|
formData.append("obj", blob);
|
||||||
formData.append("file", file.value.raw);
|
formData.append("file", file.value.raw);
|
||||||
|
loading.open('导入中...')
|
||||||
uploadExcelInventoryList(formData).then(res => {
|
uploadExcelInventoryList(formData).then(res => {
|
||||||
|
loading.close()
|
||||||
|
currentHash = ''
|
||||||
if (res.data.code == 0) {
|
if (res.data.code == 0) {
|
||||||
ElMessage({
|
ElMessage({
|
||||||
message: '上传成功',
|
message: '上传成功',
|
||||||
|
|
@ -57,6 +71,8 @@ const uploadInventory = () => {
|
||||||
ElMessage.error(res.data.message)
|
ElMessage.error(res.data.message)
|
||||||
}
|
}
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
|
loading.close()
|
||||||
|
currentHash = ''
|
||||||
console.log(err)
|
console.log(err)
|
||||||
ElMessage.error('上传错误')
|
ElMessage.error('上传错误')
|
||||||
})
|
})
|
||||||
|
|
@ -69,6 +85,7 @@ const clearFileInfos = () => {
|
||||||
name: '',
|
name: '',
|
||||||
type: '',
|
type: '',
|
||||||
size: null,
|
size: null,
|
||||||
|
hash: '',
|
||||||
userName: store.getters.getUserName
|
userName: store.getters.getUserName
|
||||||
}
|
}
|
||||||
file.value = undefined
|
file.value = undefined
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,9 @@ import { ref, reactive } from 'vue';
|
||||||
import { uploadExcelOrders } from '@/api/excel.js'
|
import { uploadExcelOrders } from '@/api/excel.js'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import { sizeFormatter } from '@/utils/formatter.js'
|
import { sizeFormatter } from '@/utils/formatter.js'
|
||||||
|
import loading from '@/utils/loading.js'
|
||||||
|
import { getHashString } from '@/utils/hashUtils.js'
|
||||||
|
var currentHash = ''
|
||||||
const file = ref()
|
const file = ref()
|
||||||
const uploadForm = reactive({
|
const uploadForm = reactive({
|
||||||
data: {
|
data: {
|
||||||
|
|
@ -20,6 +23,7 @@ const uploadForm = reactive({
|
||||||
name: '',
|
name: '',
|
||||||
type: '',
|
type: '',
|
||||||
size: null,
|
size: null,
|
||||||
|
hash: '',
|
||||||
userName: store.getters.getUserName
|
userName: store.getters.getUserName
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -30,6 +34,7 @@ const changeFile = (uploadFile) => {
|
||||||
name: file.value.raw.name,
|
name: file.value.raw.name,
|
||||||
type: file.value.raw.type,
|
type: file.value.raw.type,
|
||||||
size: sizeFormatter(file.value.raw.size),
|
size: sizeFormatter(file.value.raw.size),
|
||||||
|
hash: getHashString(uploadFile),
|
||||||
userName: store.getters.getUserName
|
userName: store.getters.getUserName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -37,7 +42,13 @@ const uploadRef = ref()
|
||||||
const uploadOrders = () => {
|
const uploadOrders = () => {
|
||||||
if (uploadForm == undefined || file.value == undefined) {
|
if (uploadForm == undefined || file.value == undefined) {
|
||||||
ElMessage.error('请选择文件之后再上传')
|
ElMessage.error('请选择文件之后再上传')
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
if (currentHash != '' && currentHash == uploadForm.data.hash) {
|
||||||
|
ElMessage.error('请勿重复上传')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
currentHash = uploadForm.data.hash
|
||||||
const jsonStr = JSON.stringify(uploadForm.data);
|
const jsonStr = JSON.stringify(uploadForm.data);
|
||||||
const blob = new Blob([jsonStr], {
|
const blob = new Blob([jsonStr], {
|
||||||
type: 'application/json'
|
type: 'application/json'
|
||||||
|
|
@ -46,7 +57,10 @@ const uploadOrders = () => {
|
||||||
// 这里很重要 file.value.raw才是真实的file文件,file.value只是一个Proxy代理对象
|
// 这里很重要 file.value.raw才是真实的file文件,file.value只是一个Proxy代理对象
|
||||||
formData.append("obj", blob);
|
formData.append("obj", blob);
|
||||||
formData.append("file", file.value.raw);
|
formData.append("file", file.value.raw);
|
||||||
|
loading.open('导入中...')
|
||||||
uploadExcelOrders(formData).then(res => {
|
uploadExcelOrders(formData).then(res => {
|
||||||
|
loading.close()
|
||||||
|
currentHash = ''
|
||||||
if (res.data.code == 0) {
|
if (res.data.code == 0) {
|
||||||
ElMessage({
|
ElMessage({
|
||||||
message: '上传成功',
|
message: '上传成功',
|
||||||
|
|
@ -57,6 +71,8 @@ const uploadOrders = () => {
|
||||||
ElMessage.error(res.data.message)
|
ElMessage.error(res.data.message)
|
||||||
}
|
}
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
|
loading.close()
|
||||||
|
currentHash = ''
|
||||||
console.log(err)
|
console.log(err)
|
||||||
ElMessage.error('上传错误')
|
ElMessage.error('上传错误')
|
||||||
})
|
})
|
||||||
|
|
@ -69,6 +85,7 @@ const clearFileInfos = () => {
|
||||||
name: '',
|
name: '',
|
||||||
type: '',
|
type: '',
|
||||||
size: null,
|
size: null,
|
||||||
|
hash: '',
|
||||||
userName: store.getters.getUserName
|
userName: store.getters.getUserName
|
||||||
}
|
}
|
||||||
file.value = undefined
|
file.value = undefined
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,9 @@ import { ref, reactive } from 'vue';
|
||||||
import { uploadStationConfig } from '@/api/excel.js'
|
import { uploadStationConfig } from '@/api/excel.js'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import { sizeFormatter } from '@/utils/formatter.js'
|
import { sizeFormatter } from '@/utils/formatter.js'
|
||||||
|
import loading from '@/utils/loading.js'
|
||||||
|
import { getHashString } from '@/utils/hashUtils.js'
|
||||||
|
var currentHash = ''
|
||||||
const file = ref()
|
const file = ref()
|
||||||
const uploadForm = reactive({
|
const uploadForm = reactive({
|
||||||
data: {
|
data: {
|
||||||
|
|
@ -20,6 +23,7 @@ const uploadForm = reactive({
|
||||||
name: '',
|
name: '',
|
||||||
type: '',
|
type: '',
|
||||||
size: null,
|
size: null,
|
||||||
|
hash: '',
|
||||||
userName: store.getters.getUserName
|
userName: store.getters.getUserName
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -30,6 +34,7 @@ const changeFile = (uploadFile) => {
|
||||||
name: file.value.raw.name,
|
name: file.value.raw.name,
|
||||||
type: file.value.raw.type,
|
type: file.value.raw.type,
|
||||||
size: sizeFormatter(file.value.raw.size),
|
size: sizeFormatter(file.value.raw.size),
|
||||||
|
hash: getHashString(uploadFile),
|
||||||
userName: store.getters.getUserName
|
userName: store.getters.getUserName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -37,7 +42,13 @@ const uploadRef = ref()
|
||||||
const uploadDbs = () => {
|
const uploadDbs = () => {
|
||||||
if (uploadForm == undefined || file.value == undefined) {
|
if (uploadForm == undefined || file.value == undefined) {
|
||||||
ElMessage.error('请选择文件之后再上传')
|
ElMessage.error('请选择文件之后再上传')
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
if (currentHash != '' && currentHash == uploadForm.data.hash) {
|
||||||
|
ElMessage.error('请勿重复上传')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
currentHash = uploadForm.data.hash
|
||||||
const jsonStr = JSON.stringify(uploadForm.data);
|
const jsonStr = JSON.stringify(uploadForm.data);
|
||||||
const blob = new Blob([jsonStr], {
|
const blob = new Blob([jsonStr], {
|
||||||
type: 'application/json'
|
type: 'application/json'
|
||||||
|
|
@ -46,7 +57,10 @@ const uploadDbs = () => {
|
||||||
// 这里很重要 file.value.raw才是真实的file文件,file.value只是一个Proxy代理对象
|
// 这里很重要 file.value.raw才是真实的file文件,file.value只是一个Proxy代理对象
|
||||||
formData.append("obj", blob);
|
formData.append("obj", blob);
|
||||||
formData.append("file", file.value.raw);
|
formData.append("file", file.value.raw);
|
||||||
|
loading.open('导入中...')
|
||||||
uploadStationConfig(formData).then(res => {
|
uploadStationConfig(formData).then(res => {
|
||||||
|
loading.close()
|
||||||
|
currentHash = ''
|
||||||
if (res.data.code == 0) {
|
if (res.data.code == 0) {
|
||||||
ElMessage({
|
ElMessage({
|
||||||
message: '上传成功',
|
message: '上传成功',
|
||||||
|
|
@ -57,6 +71,8 @@ const uploadDbs = () => {
|
||||||
ElMessage.error(res.data.message)
|
ElMessage.error(res.data.message)
|
||||||
}
|
}
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
|
loading.close()
|
||||||
|
currentHash = ''
|
||||||
console.log(err)
|
console.log(err)
|
||||||
ElMessage.error('上传错误')
|
ElMessage.error('上传错误')
|
||||||
})
|
})
|
||||||
|
|
@ -69,6 +85,7 @@ const clearFileInfos = () => {
|
||||||
name: '',
|
name: '',
|
||||||
type: '',
|
type: '',
|
||||||
size: null,
|
size: null,
|
||||||
|
hash: '',
|
||||||
userName: store.getters.getUserName
|
userName: store.getters.getUserName
|
||||||
}
|
}
|
||||||
file.value = undefined
|
file.value = undefined
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,9 @@ import { ref, reactive } from 'vue';
|
||||||
import { uploadExcelStock } from '@/api/excel.js'
|
import { uploadExcelStock } from '@/api/excel.js'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import { sizeFormatter } from '@/utils/formatter.js'
|
import { sizeFormatter } from '@/utils/formatter.js'
|
||||||
|
import loading from '@/utils/loading.js'
|
||||||
|
import { getHashString } from '@/utils/hashUtils.js'
|
||||||
|
var currentHash = ''
|
||||||
const file = ref()
|
const file = ref()
|
||||||
const uploadForm = reactive({
|
const uploadForm = reactive({
|
||||||
data: {
|
data: {
|
||||||
|
|
@ -20,6 +23,7 @@ const uploadForm = reactive({
|
||||||
name: '',
|
name: '',
|
||||||
type: '',
|
type: '',
|
||||||
size: null,
|
size: null,
|
||||||
|
hash: '',
|
||||||
userName: store.getters.getUserName
|
userName: store.getters.getUserName
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -30,6 +34,7 @@ const changeFile = (uploadFile) => {
|
||||||
name: file.value.raw.name,
|
name: file.value.raw.name,
|
||||||
type: file.value.raw.type,
|
type: file.value.raw.type,
|
||||||
size: sizeFormatter(file.value.raw.size),
|
size: sizeFormatter(file.value.raw.size),
|
||||||
|
hash: getHashString(uploadFile),
|
||||||
userName: store.getters.getUserName
|
userName: store.getters.getUserName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -37,7 +42,13 @@ const uploadRef = ref()
|
||||||
const uploadStock = () => {
|
const uploadStock = () => {
|
||||||
if (uploadForm == undefined || file.value == undefined) {
|
if (uploadForm == undefined || file.value == undefined) {
|
||||||
ElMessage.error('请选择文件之后再上传')
|
ElMessage.error('请选择文件之后再上传')
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
if (currentHash != '' && currentHash == uploadForm.data.hash) {
|
||||||
|
ElMessage.error('请勿重复上传')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
currentHash = uploadForm.data.hash
|
||||||
const jsonStr = JSON.stringify(uploadForm.data);
|
const jsonStr = JSON.stringify(uploadForm.data);
|
||||||
const blob = new Blob([jsonStr], {
|
const blob = new Blob([jsonStr], {
|
||||||
type: 'application/json'
|
type: 'application/json'
|
||||||
|
|
@ -46,7 +57,10 @@ const uploadStock = () => {
|
||||||
// 这里很重要 file.value.raw才是真实的file文件,file.value只是一个Proxy代理对象
|
// 这里很重要 file.value.raw才是真实的file文件,file.value只是一个Proxy代理对象
|
||||||
formData.append("obj", blob);
|
formData.append("obj", blob);
|
||||||
formData.append("file", file.value.raw);
|
formData.append("file", file.value.raw);
|
||||||
|
loading.open('导入中...')
|
||||||
uploadExcelStock(formData).then(res => {
|
uploadExcelStock(formData).then(res => {
|
||||||
|
loading.close()
|
||||||
|
currentHash = ''
|
||||||
if (res.data.code == 0) {
|
if (res.data.code == 0) {
|
||||||
ElMessage({
|
ElMessage({
|
||||||
message: '上传成功',
|
message: '上传成功',
|
||||||
|
|
@ -57,6 +71,8 @@ const uploadStock = () => {
|
||||||
ElMessage.error(res.data.message)
|
ElMessage.error(res.data.message)
|
||||||
}
|
}
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
|
loading.close()
|
||||||
|
currentHash = ''
|
||||||
console.log(err)
|
console.log(err)
|
||||||
ElMessage.error('上传错误')
|
ElMessage.error('上传错误')
|
||||||
})
|
})
|
||||||
|
|
@ -69,6 +85,7 @@ const clearFileInfos = () => {
|
||||||
name: '',
|
name: '',
|
||||||
type: '',
|
type: '',
|
||||||
size: null,
|
size: null,
|
||||||
|
hash: '',
|
||||||
userName: store.getters.getUserName
|
userName: store.getters.getUserName
|
||||||
}
|
}
|
||||||
file.value = undefined
|
file.value = undefined
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
|
|
||||||
const request = axios.create({
|
const request = axios.create({
|
||||||
baseURL: 'http://localhost:12315/wms',
|
baseURL: 'http://10.90.36.70:443/wmsServer/wms',
|
||||||
timeout: 5000
|
timeout: 5000
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -253,18 +253,11 @@ export default {
|
||||||
},
|
},
|
||||||
// 重置参数
|
// 重置参数
|
||||||
resetForms() {
|
resetForms() {
|
||||||
this.workFormEntity = reactive({
|
this.workFormEntity.goodsId = ''
|
||||||
goodsId: '',
|
this.workFormEntity.planPickNum = 0
|
||||||
planPickNum: 0,
|
this.workFormEntity.remainNumOrigin = null
|
||||||
remainNumOrigin: null,
|
this.workFormEntity.remainNumReal = null
|
||||||
remainNumReal: null,
|
this.workFormEntity.remark = ''
|
||||||
remark: '',
|
|
||||||
finishedRows: 0,
|
|
||||||
totalRows: 0,
|
|
||||||
finishedCounts: 0,
|
|
||||||
totalCounts: 0,
|
|
||||||
tip: ''
|
|
||||||
})
|
|
||||||
this.$refs.goodsId.focus()
|
this.$refs.goodsId.focus()
|
||||||
},
|
},
|
||||||
// 确认完成工作
|
// 确认完成工作
|
||||||
|
|
|
||||||
16
src/utils/hashUtils.js
Normal file
16
src/utils/hashUtils.js
Normal file
|
|
@ -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
|
||||||
|
}
|
||||||
|
|
@ -1,9 +1,15 @@
|
||||||
import { ElLoading } from 'element-plus'
|
import { ElLoading } from 'element-plus'
|
||||||
|
const loading = {
|
||||||
const loading = ElLoading.service({
|
loadingInstance: null,
|
||||||
lock: true,
|
open: function (text) {
|
||||||
text: 'Loading',
|
this.loadingInstance = ElLoading.service({
|
||||||
background: 'rgba(0, 0, 0, 0.7)',
|
lock: true,
|
||||||
})
|
text: text,
|
||||||
|
background: 'rgba(0, 0, 0, 0.7)'
|
||||||
|
})
|
||||||
|
},
|
||||||
|
close: function () {
|
||||||
|
this.loadingInstance.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
export default loading
|
export default loading
|
||||||
Loading…
Reference in New Issue
Block a user