<template>
|
<div class="scan-container">
|
<el-card class="scan-card">
|
<div slot="header" class="clearfix">
|
<span>入库计划单批量导入</span>
|
</div>
|
<el-form ref="form" :model="formData" label-width="120px" class="scan-form">
|
<!-- <el-form-item label="货主名称">
|
<el-select v-model="formData.consignor_Id" placeholder="请选择" class="w-200">
|
<el-option v-for="item in consignorNames" :key="item.consignor_Id" :label="item.consignorName" :value="item.consignor_Id" @click.native="()=>{
|
formData.consignorCode=item.consignorCode;
|
formData.consignorName=item.consignorName;
|
}">
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="所属仓库">
|
<el-select v-model="formData.storage_Id" placeholder="请选择" class="w-200">
|
<el-option v-for="item in storageNames" :key="item.storage_Id" :label="item.storageName" :value="item.storage_Id" @click.native="formData.storageName=item.storageName">
|
</el-option>
|
</el-select>
|
</el-form-item> -->
|
|
<el-upload ref="upload" :on-error="handleError" :on-remove="handleRemove" :on-success="handleSuccess" :file-list="fileList" :auto-upload="true" :action="upLoadUrl()" :limit="1" class="upload-bill" accept=".xlsx">
|
<el-button slot="trigger" size="small" type="primary">选取文件</el-button>
|
<el-button style="margin-left: 10px;" size="small" type="success" @click="submitImport()">开始导入</el-button>
|
<el-button style="margin-left: 10px;" size="small" type="primary" plain>
|
<a :href="common.ossDomain+'/node-wms/template/入库计划单批量导入模板.xlsx'" target="_blank" style="color:while;font-size:12px;">下载模板</a>
|
<!-- <a :href="common.templateDomain+'/node-wms/template/入库计划单批量导入模板.xlsx'" target="_blank" style="color:while;font-size:12px;">下载模板</a> -->
|
</el-button>
|
<div slot="tip" class="el-upload__tip">只能上传扩展名为.xlsx的excel文件</div>
|
</el-upload>
|
|
<el-scrollbar :noresize="false" :native="false" wrap-class="scrollbar-wrap">
|
<ul class="msg-container">
|
<li v-for="(item, index) in msgList" :key="index" class="msg-item" v-html="item">
|
{{ index + 1 }}、{{ item }}
|
</li>
|
</ul>
|
</el-scrollbar>
|
</el-form>
|
</el-card>
|
|
</div>
|
</template>
|
|
<script>
|
export default {
|
name: "user-way-import-quotation",
|
data() {
|
return {
|
formData: {
|
consignor_Id: null,
|
storage_Id: null, // 仓库id
|
storageName: null
|
},
|
// 货主
|
consignorNames: [],
|
// 仓库
|
storageNames: [],
|
fileList: [],
|
// 消息内容
|
msgList: [],
|
// 导入获得消息interval handle
|
intervalHandler: null,
|
// 文件名
|
fileUrl: null,
|
// 导入key
|
uploadKey: null
|
};
|
},
|
mounted() {
|
this.getStorageList();
|
this.getConsignorList();
|
this.uploadKey = this.common.getGUID();
|
},
|
methods: {
|
// 获取仓库
|
getStorageList() {
|
const url = "/api/basicInfo/base/storage/getList";
|
const params = {
|
openNodeApi: true
|
};
|
var callback = res => {
|
if (res.result) {
|
this.storageNames = res.data;
|
}
|
};
|
this.common.ajax(url, params, callback, true);
|
},
|
// 获取货主名称下拉框
|
getConsignorList() {
|
const url = "/api/basicInfo/base/consignor/getList";
|
const params = {
|
openNodeApi: true
|
};
|
var callback = res => {
|
if (res.result) {
|
this.consignorNames = res.data;
|
}
|
};
|
this.common.ajax(url, params, callback, true);
|
},
|
handleError(err, file, fileList) {
|
this.common.showMsg(err);
|
},
|
handleRemove(file, fileList) {
|
this.fileUrl = null;
|
},
|
// 上传成功后
|
handleSuccess(res, file) {
|
if (res.statusCode === 200) {
|
this.$message.success(res.msg);
|
this.fileUrl = res.data.url;
|
} else {
|
this.$message.error(res.msg);
|
this.fileUrl = null;
|
this.fileList = [];
|
}
|
},
|
// 上传附件Url
|
upLoadUrl: function() {
|
var domain = this.common.domain;
|
return domain + "/api/common/uploadSingleFile";
|
},
|
// 开始导入
|
submitImport() {
|
this.msgList = [];
|
if (!this.fileUrl) {
|
this.$message.error("请上传文件!");
|
return;
|
}
|
// if (!this.formData.consignor_Id) {
|
// this.$message.error("请选择货主");
|
// return;
|
// }
|
// if (!this.formData.storageName) {
|
// this.$message.error("请选择仓库");
|
// return;
|
// }
|
this.msgList.push("开始导入");
|
const url = "/api/inbound/quotation/import";
|
const params = {
|
openNodeApi: true,
|
key: this.uploadKey,
|
fileUrl: this.fileUrl
|
// storage_Id: this.formData.storage_Id,
|
// storageName: this.formData.storageName,
|
// consignor_Id: this.formData.consignor_Id,
|
// consignorCode: this.formData.consignorCode,
|
// consignorName: this.formData.consignorName
|
};
|
var callback = res => {
|
window.clearTimeout(this.intervalHandler);
|
this.intervalHandler = false;
|
this.getMsg();
|
this.fileList = [];
|
};
|
this.common.ajax(url, params, callback, true);
|
},
|
// 获得导入消息
|
getMsg() {
|
// 获得同步消息
|
const url = "/api/common/getUploadMsg";
|
const params = {
|
openNodeApi: true,
|
key: this.uploadKey
|
};
|
// const ref = this.dataList;
|
var callBack = res => {
|
if (!res.result) {
|
window.clearTimeout(this.intervalHandler);
|
this.intervalHandler = false;
|
if (Array.isArray(res.data)) {
|
this.msgList = this.msgList.concat(res.data);
|
}
|
return;
|
}
|
|
if (Array.isArray(res.data)) {
|
this.msgList = this.msgList.concat(res.data.filter(item => item !== "-1"));
|
}
|
if (res.data.indexOf("-1") >= 0) {
|
window.clearTimeout(this.intervalHandler);
|
this.intervalHandler = null;
|
return;
|
}
|
this.intervalHandler = window.setTimeout(this.getMsg, 1000);
|
};
|
this.common.ajax(url, params, callBack, true, this.$refs.uploadRef);
|
}
|
}
|
};
|
</script>
|
|
<style lang="scss" scoped>
|
@import "../../../styles/scan.scss";
|
|
.scan-container {
|
/deep/ .el-upload__tip {
|
font-size: 14px;
|
}
|
/deep/ .el-upload-list__item-name {
|
font-size: 14px;
|
}
|
position: relative;
|
/deep/ .scrollbar-wrap {
|
max-height: 400px;
|
overflow-x: hidden;
|
padding: 0px;
|
}
|
.msg-container {
|
margin: 0;
|
padding: 0;
|
padding-bottom: 40px;
|
.msg-item {
|
padding: 5px 0;
|
word-wrap: break-word;
|
font-size: 14px;
|
line-height: 1;
|
}
|
}
|
}
|
</style>
|