feat: 阳采按钮

dev_unify
chenhc 3 months ago
parent ce7bf9f444
commit 3fd5063813

@ -5,6 +5,13 @@
style="margin-bottom: -15px">
<el-button-group
style="display: flex; margin: 0px 0 15px 75%; height: 35px">
<el-button size="mini" type="primary" @click="triggerFileUpload"
v-if="(curAction.checkWebNew !== 2 || viewType !== 1) && orderFormData.billNo">
导入阳采追溯码
</el-button>
<!-- 隐藏的文件输入元素 -->
<input type="file" ref="fileInput" accept=".xlsx,.xls" style="display: none;" @change="handleFileUpload" />
<el-button size="mini" type="primary" @click.native="selectOrder()"
v-if="curAction.checkWebNew != 2 || viewType !=1"
>选入码上放心单据
@ -419,6 +426,50 @@ export default {
codesPanel, codeDetailPanel, bizDetailPanel, editCodeDialog,selectMsfxOrderDialog
},
methods: {
triggerFileUpload() {
this.$refs.fileInput.click();
},
handleFileUpload(event) {
const file = event.target.files[0];
const billNo = this.orderFormData.billNo; // UUID
const uploadUrl = process.env.VUE_APP_BASE_API + '/udiwms/inout/order/yc/fileUpload'; // URL
if (this.$isBlank(this.orderFormData.billNo)){
this.$message.error("单据编号不可以为空!");
return
}
if (file) {
const formData = new FormData();
formData.append('billNo', billNo);
formData.append('file', file);
fetch(uploadUrl, {
method: 'POST',
body: formData,
})
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
return response.json(); // JSON
})
.then(data => {
//
if (data.code === 20000) {
this.$message.success("上传成功!")
}else {
this.$message.error(data.message);
}
})
.catch(error => {
//
console.error('File upload failed:', error);
//
});
} else {
//
console.error('No file selected for upload!');
}
},
//url
selectAuthMenuByMenuKeys() {
selectAuthMenuByMenuKeys(this.helpMenuKeys).then((res) => {

Loading…
Cancel
Save