@{
|
Layout = "~/Views/Shared/_LayoutVue.cshtml";
|
ViewBag.Title = "库存初始化";
|
}
|
|
@section head{
|
<style type="text/css">
|
.el-message-box__content {
|
max-height: 380px;
|
overflow: scroll;
|
}
|
</style>
|
}
|
|
<div id="StockInit" v-loading.fullscreen.lock="fullscreenLoading" element-loading-text="正在处理文件,请稍等…">
|
<el-card class="box-card">
|
<el-upload ref="upload" action="UnscrambleXls"
|
v-bind:on-change="onUploadChange"
|
v-bind:auto-upload="true"
|
v-bind:multiple="false"
|
v-bind:on-progress="onStartProgress"
|
v-bind:on-success="loadFileSuccess"
|
v-bind:on-remove="handleRemove"
|
v-bind:limit="1">
|
<el-button slot="trigger" size="min" type="success" style="margin-left: 10px;margin-top:5px;margin-bottom:5px;padding: 7px 15px;font-size: 12px;">选取文件</el-button>
|
</el-upload>
|
</el-card>
|
|
<el-table v-bind:data="tableData" class="tb-edit" style="width: 100%;" v-bind:height="tableHeight" border highlight-current-row size="mini" empty-text="暂无预览数据">
|
<el-table-column label="行号" type="index" width="50" align="center" v-bind:index="indexMethod"></el-table-column>
|
<el-table-column label="仓库号" prop="CN_S_STOCK_CODE" width="120" align="center"></el-table-column>
|
<el-table-column label="货位号" prop="CN_S_LOCATION_CODE" width="150" align="center"></el-table-column>
|
<el-table-column label="托盘号" prop="CN_S_TRAY_CODE" width="120" align="center"></el-table-column>
|
<el-table-column label="物料编码" prop="CN_S_ITEM_CODE" width="180" align="center"></el-table-column>
|
<el-table-column label="数量" prop="CN_F_QUANTITY" width="100" align="center"></el-table-column>
|
<el-table-column label="生产批次" prop="CN_S_PRODUCTION_BATCH" width="130" align="center"></el-table-column>
|
@*<el-table-column label="到货批次" prop="CN_S_LOT_CODE" width="120" align="center"></el-table-column>*@
|
<el-table-column label="物料状态" prop="CN_S_ITEM_STATE" width="100" align="center"></el-table-column>
|
</el-table>
|
<el-card class="box-card" style="text-align:right">
|
<el-row style="padding-right:20px;margin-top:5px;margin-bottom:5px;">
|
<el-button size="mini" id="btn_check" type="warning" v-on:click="checkData">数据校验</el-button>
|
<el-button size="mini" id="btn_submit" type="primary" v-on:click="submitUpload">确认初始化</el-button>
|
</el-row>
|
</el-card>
|
</div>
|
@section scripts{
|
<script>
|
new Vue({
|
el: "#StockInit",
|
mixins: [useAutoHeight],
|
computed: {
|
tableHeight: function () {
|
return this.autoHeight - 130;
|
}
|
},
|
data: {
|
fullscreenLoading: false,
|
importData: [],
|
errorData: [],
|
defaults: {
|
fileType: ["xls", "XLS", "xlsx", "XLSX"],
|
fileSize: 1024 * 1024 * 10
|
},
|
//tableData: [{
|
// CN_S_STOCK_CODE: '',
|
// CN_S_LOCATION_CODE: '',
|
// CN_S_TRAY_CODE: '',
|
// CN_S_ITEM_CODE: '',
|
// CN_F_QUANTITY: '',
|
// CN_S_PRODUCTION_BATCH: '',
|
// CN_S_LOT_CODE: '',
|
// CN_S_ITEM_STATE: ''
|
//}]
|
tableData: []
|
},
|
methods: {
|
indexMethod: function (index) {
|
return index + 2;
|
},
|
submitUpload: function () {
|
var $this = this;
|
var validData = [];
|
|
$.each($this.tableData, function (i, n) {
|
if (n.CN_S_ITEM_CODE) {
|
validData.push(n);
|
}
|
});
|
|
if (validData.length == 0) {
|
wms.warning("请先选择文件!");
|
return false;
|
}
|
if ($this.errorData.length != 0) {
|
var htmlStr = "<div style=\"padding-left:30px\">";
|
$.each($this.errorData, function (i, n) {
|
if (n.CN_S_RowIndex != "0")
|
htmlStr = htmlStr + "<font color=\"blue\">第" + n.CN_S_RowIndex + "行存在问题:</font>" + n.CN_S_ErrorContent + "</br>";
|
else
|
htmlStr = htmlStr + "<font color=\"blue\">存在问题:</font>" + n.CN_S_ErrorContent + "</br>";
|
});
|
htmlStr = htmlStr + "</div>";
|
|
wms.customConfirm({
|
title: '验证结果提示',
|
content: htmlStr,
|
confirmText: '关闭',
|
callback: function (action) {
|
}
|
});
|
}
|
else {
|
wms.confirm("确认初始化?", function () {
|
$this.submit();
|
});
|
}
|
},
|
submit: function () {
|
|
var $this = this;
|
$this.fullscreenLoading = true;
|
ajaxManage({
|
url: "@Url.Action("ImportExcelData")",
|
data: JSON.stringify($this.importData),
|
success: function (data) {
|
$this.fullscreenLoading = false;
|
if (data.Success) {
|
wms.success("初始化成功!");
|
$this.$refs.upload.clearFiles();
|
$this.errorData = [];
|
$this.importData = [];
|
$this.tableData = [];
|
} else {
|
wms.warning(data.Msg);
|
}
|
}
|
});
|
},
|
checkData: function () {
|
var $this = this;
|
var validData = [];
|
|
$.each($this.tableData, function (i, n) {
|
if (n.CN_S_ITEM_CODE) {
|
validData.push(n);
|
}
|
});
|
|
if (validData.length == 0) {
|
wms.warning("请先选择文件!");
|
return false;
|
}
|
|
if ($this.errorData.length != 0) {
|
var htmlStr = "<div style=\"padding-left:30px\">";
|
$.each($this.errorData, function (i, n) {
|
if (n.CN_S_RowIndex != "0")
|
htmlStr = htmlStr + "<font color=\"blue\">第" + n.CN_S_RowIndex + "行存在问题:</font>" + n.CN_S_ErrorContent + "</br>"
|
else
|
htmlStr = htmlStr + "<font color=\"blue\">存在问题:</font>" + n.CN_S_ErrorContent + "</br>"
|
});
|
htmlStr = htmlStr + "</div>";
|
|
wms.customConfirm({
|
title: '验证结果提示',
|
content: htmlStr,
|
confirmText: '关闭',
|
callback: function (action) {
|
}
|
});
|
}
|
else {
|
wms.customConfirm({
|
title: '初始化提示',
|
confirmText: '确定',
|
content: "数据校验通过,是否直接初始化?",
|
callback: function (action) {
|
if (action == "confirm") {
|
$this.submit();
|
}
|
}
|
});
|
}
|
},
|
onUploadChange: function (file) {
|
var _this = this;
|
if ($.inArray(file.name.substring(file.name.lastIndexOf(".") + 1, file.name.length), _this.defaults.fileType) <= -1) {
|
wms.warning("只能上传Excel文件!");
|
this.$refs.upload.clearFiles();
|
return false;
|
}
|
|
if (file.size >= _this.defaults.fileSize) {
|
wms.warning("文件超出10M!");
|
return false;
|
}
|
},
|
onStartProgress: function (event, file, fileList) {
|
var $this = this;
|
$this.fullscreenLoading = true;
|
},
|
loadFileSuccess: function (response, file, fileList) {
|
var $this = this;
|
$this.fullscreenLoading = false;
|
|
$this.importData = response.ImportData;
|
$this.errorData = response.ErrorData;
|
console.log(response);
|
$this.tableData = response.ImportData;
|
},
|
handleRemove: function (file, fileList) {
|
var $this = this;
|
$this.importData = [];
|
$this.errorData = [];
|
}
|
},
|
mounted: function () {
|
|
}
|
})
|
</script>
|
}
|