瀏覽代碼

修改导入查询

liyg 2 年之前
父節點
當前提交
c8a13ecfa3

+ 7 - 0
src/views/TMS/components/domesticMine/wagonLoadAdd.vue

@@ -472,6 +472,13 @@ export default {
           }
         }
         console.log("表头行数:" + index);
+        if(index>=rows.length){
+          that.$message({
+            message: "文件错误!",
+            type: "warning",
+          });
+          return
+        }
         //校验表头
         if (
           typeof workbook.Sheets[workbook.SheetNames[0]]["A" + index] == 'undefined' ||

+ 51 - 4
src/views/TMS/components/importedMine/addWagonLoad.vue

@@ -31,6 +31,16 @@
         >
           <i class="el-icon-search"></i>查询
         </el-button>
+         <el-upload style="margin: 10px;"
+          class="upload-excel"
+          action=""
+          :on-change="importExcel"
+          :show-file-list="false"
+          accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
+          :auto-upload="false">
+          <el-button  type="primary">
+            <i class="el-icon-search"></i>导入查询</el-button>
+      </el-upload>
       </div>
       <!-- 临时表已导入配单的车皮 -->
       <div class="tempTable" style="height:300px;overflow:scroll;float:left;margin-left:5px">
@@ -383,7 +393,7 @@ export default {
         });
         return
       }
-      this.tableData=[];
+      let importData=[];
       var reader = new FileReader();
       var data=null;
       var workbook=null;
@@ -404,6 +414,13 @@ export default {
            }
         }
         console.log('表头行数:'+index);
+        if(index>=rows.length){
+          that.$message({
+            message: "文件错误!",
+            type: "warning",
+          });
+          return
+        }
         //校验表头
         if( workbook.Sheets[workbook.SheetNames[0]]['A'+index].v!='序号'
         || workbook.Sheets[workbook.SheetNames[0]]['B'+index].v!='发站'
@@ -514,10 +531,40 @@ export default {
               });
               continue;
             }
-            that.tableData.push(tableRow);
+            importData.push(tableRow);
           }
         }
-        console.log(that.tableData);
+        console.log("importData",importData);
+        if(importData.length<=0){
+          that.$message({
+            message:"Excel没有可用数据",
+            type:"warning"
+          });
+          return;
+        }else if(that.tableData.length<=0){
+          that.$message({
+            message:"当前列表没有可用数据",
+            type:"warning "
+          })
+          return;
+        }
+        //批量查询
+        let tableData=[];
+        importData.forEach((row)=>{
+          let temp=that.tableData.find(item=>item.wagonNo==row.wagonNo 
+          && row.productName.includes(item.foreignShipName)
+          && item.materialName.includes(row.mineral));
+          if(temp)
+            tableData.push(temp);
+        });
+        console.log("test",tableData);
+        that.tableData=tableData;
+        if(that.tableData.length<=0){
+           that.$message({
+            message: "查询不到相关车皮!",
+            type: "warning",
+          });
+        }
       };
       reader.readAsBinaryString(file.raw); //以二进制方式读取
     },
@@ -566,7 +613,7 @@ export default {
     rowClick(row, column, event) {
        let tempTable = this.$refs.tempTable; // 获取表格对象
        //判断是否已存在
-       let findRow = this.selectionRow.find(item => item.ROW_ID == row.ROW_ID);
+       let findRow = this.selectionRow.find(item => item.wagonNo == row.wagonNo);
        if (findRow) {
           tempTable.toggleRowSelection(row, false);
        }else{