<template>
|
<el-card class="box-card">
|
<div slot="header" class="clearfix">
|
<span>面单上传</span>
|
</div>
|
<el-form ref="form" v-model="formData" label-width="120px">
|
<el-form-item label="选择仓库">
|
<el-select v-model="formData.storage_Id" placeholder="请选择">
|
<el-option v-for="item in storageNames" :key="item.storage_Id" :label="item.storageName" :value="item.storage_Id">
|
</el-option>
|
</el-select>
|
</el-form-item>
|
</el-form>
|
|
<el-upload ref="upload" :on-preview="handlePreview" :on-remove="handleRemove" :on-success="handleSuccess" :file-list="fileList" :auto-upload="true" :action="upLoadUrl()" :limit="1" class="upload-bill">
|
<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'" style="color:while;font-size:12px;">下载模板</a>
|
</el-button>
|
<div slot="tip" class="el-upload__tip">只能上传扩展名为.xlsx的excel文件</div>
|
</el-upload>
|
<el-scrollbar ref="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>
|
<div ref="loading"></div>
|
</el-card>
|
</template>
|
|
<script>
|
export default {
|
name: "user-way-import",
|
data() {
|
return {
|
formData: {
|
port_Id: null,
|
expressCorp_Id: null,
|
storage_Id: null
|
},
|
// 仓库
|
storageNames: null,
|
portOptions: null,
|
expressCorpoptions: null,
|
fileList: [],
|
fullFileRote: null,
|
// 消息内容
|
msgList: [],
|
uploadKey: null
|
};
|
},
|
mounted() {
|
// this.getPortList();
|
// this.getExpressCorpList();
|
this.getStorageList();
|
this.uploadKey = this.common.getGUID();
|
},
|
methods: {
|
// 开始导入
|
submitImport() {
|
if (!this.fullFileRote) {
|
this.$message.error("请上传文件!");
|
return;
|
}
|
this.msgList = [];
|
this.importMsg = null;
|
const url = "/api/tms/userSys/wayimport/importExel";
|
// const ref = this.dataList;
|
// var PortName = "";
|
// var ExpressCorpName = "";
|
// var portOptions = this.portOptions;
|
// var expressCorpoptions = this.expressCorpoptions;
|
// for (var index in portOptions) {
|
// if (portOptions[index].port_Id === this.formData.port_Id) {
|
// PortName = portOptions[index].PortName;
|
// }
|
// }
|
|
// for (var index2 in expressCorpoptions) {
|
// if (
|
// expressCorpoptions[index2].expressCorp_Id ===
|
// this.formData.expressCorp_Id
|
// ) {
|
// ExpressCorpName = expressCorpoptions[index2].ExpressCorpName;
|
// }
|
// }
|
|
// 仓库
|
var storageName = "";
|
for (var index3 in this.storageNames) {
|
if (this.storageNames[index3].storage_Id === this.formData.storage_Id) {
|
storageName = this.storageNames[index3].storageName;
|
}
|
}
|
|
// if (!this.formData.port_Id) {
|
// this.$message.error("请选择口岸!");
|
// return;
|
// }
|
|
// if (!this.formData.expressCorp_Id) {
|
// this.$message.error("请选择快递!");
|
// return;
|
// }
|
|
if (!this.formData.storage_Id) {
|
this.$message.error("请选择仓库!");
|
return;
|
}
|
|
var userInfo = this.common.getUserInfo();
|
const params = {
|
url: this.fullFileRote,
|
expressCorp_Id: 0,
|
expressCorpName: null,
|
port_Id: 0,
|
portName: null,
|
storage_Id: this.formData.storage_Id,
|
storageName: storageName,
|
consignor_Id: userInfo.user_Id,
|
consignorCode: userInfo.userName,
|
consignorName: userInfo.userTrueName,
|
key: this.uploadKey
|
};
|
var callback = res => {
|
window.clearTimeout(this.intervalHandler);
|
this.intervalHandler = false;
|
this.getMsg();
|
this.fileList = [];
|
this.fullFileRote = null;
|
};
|
this.common.ajax(url, params, callback, true);
|
// var callback = res => {
|
// if (res.result) {
|
// this.msg = res.msg;
|
// this.fullFileRote = null;
|
// this.fileList = [];
|
// } else {
|
// this.msg = "<font color='red'>" + res.msg + "</font>";
|
// }
|
// };
|
// 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 => {
|
// 自动滚动到最后一行
|
window.setTimeout(() => {
|
const div = this.$refs.scrollbar.$refs.wrap;
|
div.scrollTop = div.scrollHeight + 1000;
|
}, 1500);
|
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, this.$refs.loading);
|
},
|
handleRemove(file, fileList) {
|
this.fullFileRote = null;
|
},
|
// 点击文件时的钩子
|
handlePreview(file) {},
|
// 获取口岸下拉框
|
getPortList() {
|
const url = "/api/basicInfo/base/port/dataList";
|
const params = {};
|
var callback = res => {
|
if (res.result) {
|
this.portOptions = res.data;
|
}
|
};
|
this.common.ajax(url, params, callback, true);
|
},
|
// 获快递下拉框
|
getExpressCorpList() {
|
const url = "/api/basicInfo/base/expressCopr/getList";
|
const params = {};
|
var callback = res => {
|
if (res.result) {
|
this.expressCorpoptions = res.data;
|
}
|
};
|
this.common.ajax(url, params, callback, true);
|
},
|
// 获取仓库
|
getStorageList() {
|
const url = "/api/basicInfo/base/storage/getList";
|
const params = {};
|
var callback = res => {
|
if (res.result) {
|
this.storageNames = res.data;
|
}
|
};
|
this.common.ajax(url, params, callback, true);
|
},
|
// 上传附件Url
|
upLoadUrl: function() {
|
var domain = this.common.domain;
|
return domain + "/api/common/uploadSingleFile";
|
},
|
// 上传成功后
|
handleSuccess(res, file) {
|
this.common.showMsg("上传成功!");
|
this.fullFileRote = res.data.url;
|
}
|
}
|
};
|
</script>
|
|
<style lang="scss" scoped>
|
.box-card {
|
.upload-bill {
|
width: 480px;
|
.el-upload__tip {
|
margin-top: 20px;
|
}
|
}
|
.msg-container {
|
margin: 0;
|
padding: 0;
|
.msg-item {
|
margin: 0;
|
padding: 5px 0;
|
word-wrap: break-word;
|
}
|
}
|
/deep/ .scrollbar-wrap {
|
max-height: 400px !important;
|
margin-top: 10px;
|
font-size: 14px;
|
.msg-container {
|
margin: 0;
|
padding: 0;
|
.msg-item {
|
margin: 0;
|
padding: 5px 0;
|
word-wrap: break-word;
|
}
|
}
|
}
|
}
|
</style>
|