<template>
|
<div ref="container" class="page-list-container">
|
<!--数据Table-->
|
<yrt-data-list :ref="dataListRef" :editor-ref="editorRef" :data-options="dataOptions" :fields.sync="dataListOptions.fields" :buttons="dataListOptions.buttons" :button-click="buttonClick" :data-list-selections.sync="dataListSelections" :auth-nodes="authNodes">
|
</yrt-data-list>
|
|
<!--数据编辑器Editor-->
|
<yrt-editor :ref="editorRef" :data-list-ref="dataListRef" v-bind="editorOptions" :data-options="dataOptions" :action.sync="editorOptions.action" :visible.sync="editorOptions.config.visible" :detail-button-click="detailButtonClick" :auth-nodes="authNodes" @on-key-up="onProductKeyup" @on-row-change="(ref, selectedRow) => {onRowChange(ref, selectedRow);}">
|
|
</yrt-editor>
|
|
<el-dialog v-dialogDrag :visible.sync="dialogImport" width="600px">
|
<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-form>
|
<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>
|
<div slot="footer" class="dialog-footer">
|
<!-- <el-button type="primary" @click="EditlogLandingTimesave">确 定</el-button> -->
|
</div>
|
</el-dialog>
|
|
<el-dialog v-dialogDrag :visible.sync="oldDialogImport" width="600px" class="import-dialog-container">
|
<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="submitoldImport()">开始导入</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-form>
|
<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>
|
<div slot="footer" class="dialog-footer">
|
<!-- <el-button type="primary" @click="EditlogLandingTimesave">确 定</el-button> -->
|
</div>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script>
|
import baseLayout from "@/components/common/base-layout.vue";
|
|
export default {
|
name: "tms-basic-product-info-port",
|
components: {},
|
mixins: [baseLayout],
|
data() {
|
return {
|
// 弹出导入框
|
dialogImport: false,
|
// 原导入
|
oldDialogImport: false,
|
fileList: [],
|
// 消息内容
|
msgList: [],
|
// 导入获得消息interval handle
|
intervalHandler: null,
|
// 文件名
|
fileUrl: null,
|
// 导入key
|
uploadKey: null
|
};
|
},
|
mounted() {
|
this.uploadKey = this.common.getGUID();
|
},
|
methods: {
|
// 物料名称下拉框输入改变后
|
onProductKeyup(ref, val, event, field, tableData) {
|
if (field.options.prop === "productName") {
|
if (!val) {
|
tableData = [];
|
return;
|
}
|
const url = "/api/tms/waybillUpload/getProductList";
|
const params = {
|
key: val
|
};
|
this.common.ajax(url, params, res => {
|
tableData.length = 0;
|
this.common.showMsg(res);
|
if (res.result) {
|
res.data.forEach(item => {
|
this.$set(tableData, tableData.length, item);
|
});
|
}
|
});
|
}
|
},
|
// 物料名称下拉框行数据单击事件
|
onRowChange(ref, selectedRow) {
|
this.editor.changeValue("product_Id", selectedRow.product_Id);
|
this.editor.changeValue("productCode", selectedRow.productCode);
|
this.editor.changeValue("productName", selectedRow.productName);
|
this.editor.changeValue("productModel", selectedRow.productModel);
|
this.editor.changeValue("productSpec", selectedRow.productSpec);
|
this.editor.changeValue("smallUnit", selectedRow.smallUnit);
|
this.editor.changeValue("type_Id", selectedRow.type_Id);
|
this.editor.changeValue("typeName", selectedRow.typeName);
|
this.editor.changeValue("postMailCode", selectedRow.postMailCode);
|
this.editor.changeValue("hSCode", selectedRow.hSCode);
|
this.editor.changeValue("cIQName", selectedRow.cIQName);
|
this.editor.changeValue("brandName", selectedRow.brandName);
|
this.editor.changeValue("brand_Id", selectedRow.brand_Id);
|
this.editor.changeValue("originPlace", selectedRow.originPlace);
|
this.editor.changeValue("netWeight", selectedRow.netWeight);
|
this.editor.changeValue("weight", selectedRow.weight);
|
},
|
// 点击文件时的钩子
|
handlePreview(file) {},
|
handleRemove(file, fileList) {
|
this.fileUrl = null;
|
},
|
// 上传附件Url
|
upLoadUrl: function() {
|
var domain = this.common.domain;
|
return domain + "/api/common/uploadSingleFile";
|
},
|
// 上传成功后
|
handleSuccess(res, file) {
|
this.common.showMsg("上传成功!");
|
this.fileUrl = res.data.url;
|
},
|
// 列表页面按钮点击事件
|
buttonClick(authNode) {
|
switch (authNode) {
|
case "myImport":
|
// 批量导入
|
this.allImport();
|
return false;
|
case "oldImport":
|
// 原来导入
|
this.alloldImport();
|
return false;
|
}
|
},
|
// 批量导入
|
allImport() {
|
this.msgList = [];
|
this.dialogImport = true;
|
this.msg = "";
|
},
|
alloldImport() {
|
this.msgList = [];
|
this.oldDialogImport = true;
|
this.msg = "";
|
},
|
// 导入
|
submitImport() {
|
if (!this.fileUrl) {
|
this.$message.error("请上传文件!");
|
return;
|
}
|
this.msgList = [];
|
const url = "/api/tms/base/productinfoport/importExel";
|
const params = {
|
url: this.fileUrl,
|
key: this.uploadKey
|
};
|
var callback = res => {
|
if (res.result) {
|
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);
|
},
|
// 原来导入
|
submitoldImport() {
|
if (!this.fileUrl) {
|
this.$message.error("请上传文件!");
|
return;
|
}
|
this.msgList = [];
|
const url = "/api/tms/base/productinfoport/importOldExel";
|
const params = {
|
url: this.fileUrl,
|
key: this.uploadKey
|
// StorageName: StorageName
|
};
|
var callback = res => {
|
if (res.result) {
|
window.clearTimeout(this.intervalHandler);
|
this.intervalHandler = false;
|
this.getMsg();
|
this.fileList = [];
|
}
|
};
|
this.common.ajax(url, params, callback, true);
|
}
|
}
|
};
|
</script>
|
|
<style lang="scss" scoped>
|
.page-list-container {
|
min-height: calc(100vh - 110px);
|
overflow: hidden;
|
position: relative;
|
}
|
|
@media screen and (max-height: 900px) {
|
.page-list-container {
|
min-height: 600px;
|
}
|
}
|
|
.import-dialog-container {
|
.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>
|