|
@@ -1,9 +1,8 @@
|
|
|
<template>
|
|
|
- <!-- 添加车皮装车实绩 -->
|
|
|
+ <!-- 国产矿导入-->
|
|
|
<div class="addWagonLoad">
|
|
|
<page-title>返回</page-title>
|
|
|
<div class="cp">
|
|
|
- <span >车皮号:</span>
|
|
|
<el-upload style="margin: 8px;"
|
|
|
class="upload-excel"
|
|
|
action=""
|
|
@@ -11,15 +10,21 @@
|
|
|
:show-file-list="false"
|
|
|
accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
|
|
|
:auto-upload="false">
|
|
|
- <el-button type="primary">导入</el-button>
|
|
|
+ <el-button type="primary">导入车皮号(Excel)</el-button>
|
|
|
</el-upload>
|
|
|
- <span >当前导入数量:{{tableData.length}}</span>
|
|
|
+ <div style="margin-right:200px;">当前导入数量:{{tableData.length}}</div>
|
|
|
+ <!-- <el-button type="primary" @click="exportData()"
|
|
|
+ ><i class="el-icon-download"></i>下载导入模板</el-button> -->
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <span style="color:red">导入数据中的 品名、发货单位、车号、发站 是必须的</span>
|
|
|
</div>
|
|
|
<div class="table item">
|
|
|
<el-table
|
|
|
stripe
|
|
|
:data="tableData"
|
|
|
- style="width: 100%">
|
|
|
+ style="width: 100%"
|
|
|
+ id="domesticTable">
|
|
|
<el-table-column
|
|
|
type="index"
|
|
|
width="50"
|
|
@@ -216,6 +221,7 @@
|
|
|
<script>
|
|
|
import PageTitle from "@/components/Page/Title";
|
|
|
import { sjTime, isNumber } from "@/utils/sharedJsFile";
|
|
|
+import {getCookie} from "@/utils/util.js";
|
|
|
export default {
|
|
|
components: { PageTitle },
|
|
|
data() {
|
|
@@ -523,10 +529,14 @@ export default {
|
|
|
row.resultLoadingDate=sjTime(that.form1.resultLoadingDate);//装车日期
|
|
|
row.resultRemarks=that.form1.resultRemarks;//备注
|
|
|
})
|
|
|
- console.log(that.tableData);
|
|
|
+ let data={
|
|
|
+ list:this.tableData,
|
|
|
+ userId:getCookie("userId")
|
|
|
+ }
|
|
|
+ console.log(data);
|
|
|
//请求添加
|
|
|
this.axios
|
|
|
- .post("/api/v1/tms/addDomesticLoadResult", that.tableData)
|
|
|
+ .post("/api/v1/tms/addDomesticLoadResult", data)
|
|
|
.then((res) => {
|
|
|
console.log(res);
|
|
|
if (res.data.code == "200") {
|
|
@@ -570,9 +580,30 @@ export default {
|
|
|
if(rows.length>0){
|
|
|
that.disable=false;
|
|
|
that.tableData=[];
|
|
|
- if((typeof rows[0]['车号'])=='undefined' || (typeof rows[0]['发站'])=='undefined' ){
|
|
|
- that.$message({
|
|
|
- message: "导入Excel格式错误,请参考下方表头格式!",
|
|
|
+ if((typeof rows[0]['车号'])=='undefined'){
|
|
|
+ that.$message({
|
|
|
+ message: "导入Excel格式错误,车号不能为空!",
|
|
|
+ type: "warning",
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if((typeof rows[0]['品 名'])=='undefined' && (typeof rows[0]['品名'])=='undefined' && (typeof rows[0]['物资'])=='undefined'){
|
|
|
+ that.$message({
|
|
|
+ message: "导入Excel格式错误,品名不能为空!",
|
|
|
+ type: "warning",
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if((typeof rows[0]['发货单位'])=='undefined'){
|
|
|
+ that.$message({
|
|
|
+ message: "导入Excel格式错误,发货单位不能为空!",
|
|
|
+ type: "warning",
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if((typeof rows[0]['发站']) =='undefined'){
|
|
|
+ that.$message({
|
|
|
+ message: "导入Excel格式错误,发站不能为空!",
|
|
|
type: "warning",
|
|
|
});
|
|
|
return;
|
|
@@ -599,6 +630,35 @@ export default {
|
|
|
if(typeof temp.materialName=='undefined' || temp.materialName==null){
|
|
|
temp.materialName=row['物资'];
|
|
|
}
|
|
|
+ //判断校验
|
|
|
+ if((typeof temp.wagonNo)=='undefined'){
|
|
|
+ that.$message({
|
|
|
+ message: "车号不能为空!导入Excel停止!",
|
|
|
+ type: "warning",
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if((typeof temp.materialName)=='undefined'){
|
|
|
+ that.$message({
|
|
|
+ message: "品名不能为空!导入Excel停止!",
|
|
|
+ type: "warning",
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if((typeof temp.supplierName)=='undefined'){
|
|
|
+ that.$message({
|
|
|
+ message: "发货单位不能为空!导入Excel停止!",
|
|
|
+ type: "warning",
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if((typeof temp.sendStation)=='undefined'){
|
|
|
+ that.$message({
|
|
|
+ message: "发站不能为空!导入Excel停止!",
|
|
|
+ type: "warning",
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
that.tableData.push(temp);
|
|
|
}
|
|
|
else{
|
|
@@ -607,6 +667,25 @@ export default {
|
|
|
});
|
|
|
};
|
|
|
reader.readAsBinaryString(file.raw); //以二进制方式读取
|
|
|
+ },
|
|
|
+ //导出模板
|
|
|
+ exportData(){
|
|
|
+ let tables = document.getElementById("domesticTable");
|
|
|
+ let table_book = XLSX.utils.table_to_book(tables);
|
|
|
+ var table_write = XLSX.utils.write(table_book, {
|
|
|
+ bookType: "xlsx",
|
|
|
+ bookSST: true,
|
|
|
+ type: "array",
|
|
|
+ });
|
|
|
+ try {
|
|
|
+ this.$FileSaver.saveAs(
|
|
|
+ new Blob([table_write], { type: "application/octet-stream" }),
|
|
|
+ ".xlsx"
|
|
|
+ );
|
|
|
+ } catch (e) {
|
|
|
+ if (typeof console !== "undefined") console.log(e, table_write);
|
|
|
+ }
|
|
|
+ return table_write;
|
|
|
}
|
|
|
},
|
|
|
};
|