常熟吴彦祖 4 months ago
parent
commit
90e5e42870
  1. 3
      src/api/orderIssure/soIssueNotify.js
  2. 6
      src/views/modules/orderIssure/newSoIssueNotify.vue
  3. 265
      src/views/modules/orderIssure/walmart_upload_excel.vue

3
src/api/orderIssure/soIssueNotify.js

@ -52,5 +52,8 @@ export const getShopOrderFromIFSWithOrderNo = data => createAPI(`/orderIssure/ne
export const getSOSBOMForIssureNew = data => createAPI(`/orderIssure/newIssure/getSOSBOMForIssureNew`,'post',data) export const getSOSBOMForIssureNew = data => createAPI(`/orderIssure/newIssure/getSOSBOMForIssureNew`,'post',data)
// 新增Excel上传接口
export const uploadNotifyExcel = data => createAPI(`/orderIssure/newIssure/uploadNotifyExcel`,'post',data)

6
src/views/modules/orderIssure/newSoIssueNotify.vue

@ -1661,8 +1661,12 @@ export default {
}) })
return return
} }
let data={
site: this.notifyData.site,
notifyNo: this.notifyData.notifyNo
}
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.walUploadExcel.init()
this.$refs.walUploadExcel.init(data)
}) })
}, },
// //

265
src/views/modules/orderIssure/walmart_upload_excel.vue

@ -1,156 +1,181 @@
<template> <template>
<div class="customer-css"> <div class="customer-css">
<el-dialog :title="titleCon" :close-on-click-modal="false" :visible.sync="visible" width="390px" style="height: 520px;" class="customer-dialog" @close="deleteFile">
<el-dialog :title="titleCon" :close-on-click-modal="false" :visible.sync="visible" width="390px" style="height: 520px;" class="customer-dialog" @close="handleDialogClose" :show-close="!uploading">
<el-form :inline="true" label-position="top" label-width="80px"> <el-form :inline="true" label-position="top" label-width="80px">
<el-row> <el-row>
<el-form-item label=" "> <el-form-item label=" ">
<el-button type="primary" @click="downloadFile()">下载文件模板</el-button>
<el-button type="primary" @click="downloadFile()" :disabled="uploading">下载文件模板</el-button>
</el-form-item> </el-form-item>
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="24"> <el-col :span="24">
<el-upload class="customer-upload" drag action="javascript:void(0);" ref="uploadFile" :limit="1" accept=".xlsx,.xls" <el-upload class="customer-upload" drag action="javascript:void(0);" ref="uploadFile" :limit="1" accept=".xlsx,.xls"
:before-upload="beforeUploadHandle" :on-change="onChange" :auto-upload="false" style="text-align: left;">
:before-upload="beforeUploadHandle" :on-change="onChange" :auto-upload="false" :disabled="uploading" style="text-align: left;">
<i class="el-icon-upload"></i> <i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处<em>点击上传</em></div>
<div class="el-upload__text">
{{ uploading ? '正在上传中,请稍候...' : '将文件拖到此处,或点击上传' }}
</div>
</el-upload> </el-upload>
</el-col> </el-col>
</el-row> </el-row>
</el-form> </el-form>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button type="primary" @click="saveUploadFile">保存</el-button>
<el-button type="primary" @click="closeDialog">关闭</el-button>
<el-button type="primary" @click="saveUploadFile" :loading="uploading" :disabled="uploading">
{{ uploading ? '上传中...' : '保存' }}
</el-button>
<el-button type="primary" @click="closeDialog" :disabled="uploading">关闭</el-button>
</span> </span>
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
<script> <script>
/* import {queryFileId} from "@/api/qc/qc.js"
import {saveWalMartOrderByExcel} from '@/api/ecss/ecss.js'
import {downLoadObjectFile} from '@/api/eam/eam_object_list.js' */
import {saveIssureNotifyByExcel} from '@/api/orderIssure/soIssueNotify.js'
export default {
name: 'bomComponentUpload',
data() {
return {
buList: [],
titleCon: '文件导入',
visible: false,
fileList: [],
pageData: {
site: '',
buNo: '',
createBy: this.$store.state.user.name,
import { uploadNotifyExcel } from '@/api/orderIssure/soIssueNotify.js'
},
export default {
name: 'bomComponentUpload',
data() {
return {
buList: [],
titleCon: '文件导入',
visible: false,
fileList: [],
pageData: {
site: '',
buNo: '',
createBy: this.$store.state.user.name,
},
notifyData:{
site: '',
notifyNo: '',
},
uploading: false, //
}
},
methods: {
//
init (data) {
this.fileList = []
this.uploading = false //
//
this.visible = true
this.notifyData=JSON.parse(JSON.stringify(data))
},
//
beforeUploadHandle (file) {
let extName = file.name.substring(file.name.lastIndexOf('.')).toLowerCase()
if (!(extName === '.xlsx' || extName === '.xls')) {
this.$message.error('数据导入失败,请选择正确的xlsx或xls格式的Excel文件')
return false
} }
return true
}, },
methods: {
//
init () {
this.fileList = []
//
this.visible = true
},
//
onChange (file) {
//
this.fileList = []
this.fileList.push(file)
},
//
beforeUploadHandle (file) {
let extName = file[0].name.substring(file[0].name.lastIndexOf('.')).toLowerCase()
if (!(extName === '.xlsx' || extName === '.xls')) {
this.$message.error('数据导入失败,请选择正确的xlsx模板文件')
return false
}
},
// modal
closeDialog () {
//
if (this.uploading) {
this.$message.warning('正在上传中,请稍候...')
return false
}
this.deleteFile()
//
this.visible = false
},
//
onChange (file) {
this.fileList.push(file)
},
// X
handleDialogClose () {
if (this.uploading) {
this.$message.warning('正在上传中,请稍候...')
return
}
this.deleteFile()
},
// modal
closeDialog () {
this.deleteFile()
//
this.visible = false
},
deleteFile(){
this.fileList = []
//
this.$refs.uploadFile.clearFiles()
//
this.$emit('refreshTable')
deleteFile(){
this.fileList = []
this.uploading = false //
//
this.$refs.uploadFile.clearFiles()
//
this.$emit('refreshTable')
},
},
//
saveUploadFile () {
//
if (null == this.fileList || 0 === this.fileList.length) {
this.$message.error("请先上传文件!")
return false
}
//
saveUploadFile () {
//
if (null == this.fileList || 0 === this.fileList.length) {
this.$message.error("请先上传文件!")
return false
}
const formData = new FormData()
formData.append("buNo",'03-RFID')
formData.append("username",this.$store.state.user.name)
formData.append("file", this.fileList[0].raw)
saveIssureNotifyByExcel(formData).then(({data}) => {
if (data.code === 0) {
if (data.errorMsg) {
this.$message.warning(data.errorMsg)
} else {
this.$message.success(data.msg)
}
//
this.closeDialog()
} else {
this.$message.error(data.msg)
}
})
},
//
const file = this.fileList[0].raw
const fileName = file.name
const fileExtension = fileName.substring(fileName.lastIndexOf('.')).toLowerCase()
//
async downloadFile () {
let file = {
id: 0,
fileName: ''
}
let tempData = {
orderRef1: 'ecss',
orderRef2: 'upLoadWalMart'
if (!('.xls' === fileExtension || '.xlsx' === fileExtension)) {
this.$message.error('文件格式不正确,只支持.xls和.xlsx格式的Excel文件')
return false
}
//
this.uploading = true
// FormData
const formData = new FormData()
formData.append("file", file)
formData.append("site", this.notifyData.site)
formData.append("notifyNo", this.notifyData.notifyNo)
//
uploadNotifyExcel(formData).then(({ data }) => {
if (data.code === 0) {
this.$message.success(data.msg || 'Excel文件上传成功')
//
this.closeDialog()
} else {
this.$message.error(data.msg || 'Excel文件上传失败')
} }
await queryFileId(tempData).then(({data}) => {
if (data && data.code === 0) {
file.id = data.data.id
file.fileName = data.data.fileName
} else {
this.$alert(data.msg, '错误', {
confirmButtonText: '确定'
})
}
})
}).catch(error => {
console.error('Excel上传异常:', error)
this.$message.error('Excel文件上传异常,请检查文件格式和内容')
}).finally(() => {
//
this.uploading = false
})
},
await downLoadObjectFile(file).then(({data}) => {
//
const blob = new Blob([data], {type: "application/octet-stream"})
//
const fileName = file.fileName
// a
const linkNode = document.createElement('a')
// adownload
linkNode.download = fileName
linkNode.style.display = 'none'
// Blob URL
linkNode.href = URL.createObjectURL(blob)
document.body.appendChild(linkNode)
//
linkNode.click()
// URL
URL.revokeObjectURL(linkNode.href)
document.body.removeChild(linkNode)
})
},
}
//
async downloadFile () {
//
//
this.$alert(
'模板格式说明:\n' +
'第1列:工厂编码(site)\n' +
'第2列:订单号(orderNo)\n' +
'第3列:发布号(releaseNo)\n' +
'第4列:序列号(sequenceNo)\n' +
'第5列:BOM行号(bomLineNo,必须为正整数)\n' +
'第6列:物料编码(materialPartNo)\n' +
'第7列:需求日期(needDate,格式:YYYY-MM-DD)\n' +
'第8列:数量(qty,必须为数字)',
'模板格式说明',
{
confirmButtonText: '确定',
type: 'info'
}
)
},
} }
}
</script> </script>
Loading…
Cancel
Save