|
<template>
|
<el-dialog v-dialogDrag :visible.sync="currentVisible">
|
<!-- <el-tabs :tab-position="tabPosition" @tab-click='fenlei' style="height: 500px;"> -->
|
<!-- <el-tab-pane label="批量拆分导入">批量拆分导入</el-tab-pane> -->
|
<el-button style="margin-left: 10px;" size="small" type="success" @click="submitUpload">确认导入</el-button>
|
<el-button class="download" type="text" @click="downloadhttp">点击下载导入模板</el-button>
|
<el-upload :drag="true" :limit="1" :on-exceed="handleExceed" :action="Uploadxlsx()" :on-success="handleXlsxSuccess" class="upload-demo" multiple>
|
<i class="el-icon-upload"></i>
|
<div class="el-upload__text">将文件拖到此处,或
|
<em>点击上传</em>
|
</div>
|
<div slot="tip" class="el-upload__tip">只能上传xls、xlsx格式文件,且不超过500kb</div>
|
</el-upload>
|
<!-- </el-tabs> -->
|
<div slot="footer" class="dialog-footer">
|
<el-button @click="currentVisible = false">取 消</el-button>
|
<!-- <el-button type="primary" @click="batchTransfer">确 定</el-button> -->
|
</div>
|
</el-dialog>
|
</template>
|
|
<script>
|
// multiple 是否支持多选文件
|
// auto-upload 是否在选取文件后立即上传
|
// drag 是否启用拖拽
|
// list-type 文件类型
|
// show-file-list 是否显示已上传的文件列表
|
// limit 最大允许上传的个数
|
// action 参数选择上传的地址
|
// 文件超出数时限制的钩子
|
// handlePreview 点击文件列表已上传文件的钩子
|
// on-remove 文件列表移除文件时的钩子
|
// http-request 覆盖默认的上传行为,可以自定义上传的实现
|
// import baseLayout from "@/components/common/base-layout.vue";
|
export default {
|
props: {
|
visible: {
|
type: Boolean,
|
default: false,
|
required: true
|
}
|
},
|
data() {
|
return {
|
tabPosition: "left",
|
fullFileRote: null,
|
ImportType: "tab-0",
|
tableData: []
|
};
|
},
|
computed: {
|
currentVisible: {
|
get: function() {
|
return this.visible;
|
},
|
set: function(val) {
|
this.$emit("update:visible", val);
|
}
|
}
|
},
|
methods: {
|
// 接受预到货单主表信息
|
showData(rows) {
|
this.tableData = rows;
|
},
|
// 更改导入类型
|
fenlei(tab, event) {
|
this.ImportType = event.target.getAttribute("id");
|
},
|
// 导入模板下载
|
downloadhttp(authNode) {
|
// 分类信息导入模板下载
|
if (this.ImportType === "tab-0") {
|
window.open(
|
this.ossDomain + "/node-wms/template/批量拆分导入模板.xlsx"
|
);
|
}
|
},
|
// 文件上传之前的钩子
|
beforeUpload(file) {
|
const isText = file.type === "application/vnd.ms-excel";
|
const isTextComputer =
|
file.type ===
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
return isText | isTextComputer;
|
},
|
// 上传文件个数超过定义的数量
|
handleExceed(files, fileList) {
|
this.$message.warning("当前限制选择 1 个文件,请删除后继续上传");
|
},
|
// 上传文件
|
Uploadxlsx: function() {
|
const url = this.common.domain + "/api/Purchase_Order/UploadImport";
|
return url;
|
},
|
// 文件上传成功返回文件保存路径
|
handleXlsxSuccess(res, file) {
|
this.fullFileRote = res.data.Url;
|
},
|
// 文件上传
|
submitUpload() {
|
let url = "";
|
// 分类信息导入
|
if (this.ImportType === "tab-0") {
|
url = "/api/Purchase_Order/ImportbatchExel";
|
}
|
const params = {
|
Url: this.fullFileRote,
|
Order_Id: this.tableData[0].Order_Id
|
};
|
var callback = res => {
|
this.common.showMsg(res);
|
if (res.result) {
|
this.reload();
|
}
|
};
|
this.common.ajax(url, params, callback);
|
},
|
reload() {}
|
}
|
};
|
</script>
|
|
<style lang="scss" scoped>
|
.upload-demo {
|
text-align: center;
|
margin-top: 100px;
|
}
|
.download {
|
margin: 50px 0px 0px 80px;
|
text-decoration: underline;
|
}
|
</style>
|