瀏覽代碼

导入excel

qukaidi 4 年之前
父節點
當前提交
64f48d8b1d
共有 2 個文件被更改,包括 163 次插入20 次删除
  1. 20 4
      src/views/Warehousing/inStock/AddOrUpdate.vue
  2. 143 16
      src/views/Warehousing/inStock/uploadExcel.vue

+ 20 - 4
src/views/Warehousing/inStock/AddOrUpdate.vue

@@ -1097,8 +1097,8 @@
                 @click="addRelevant('copy')"
                 >复制录入</el-button
               >
-              <el-button type="primary" size="small"> 下载模板 </el-button>
-              <el-button size="small" type="primary">导入Execl</el-button>
+              <el-button type="primary" size="small" @click="downloadExcel"> 下载模板 </el-button>
+              <el-button size="small" type="primary" @click="openUploadExcel">导入Execl</el-button>
             </el-col>
             <el-col style="display: flex; justify-content: flex-end">
               <el-button size="small" type="info" prop="打印" @click="printZyd"
@@ -3212,6 +3212,8 @@
     <upload-excel
       ref="upexcel"
       :uploadExcelVisible="uploadExcel"
+      @changeShow="showAddOrUpdate2"
+      @adddetailList="adddetailList"
     ></upload-excel>
   </div>
 </template>
@@ -5544,6 +5546,7 @@ export default {
                   }
                 });
               });
+              this.$set(this.form, "fDateChanged", response.data.fDateChanged);
               this.$set(this.form, "fItemsStatus", 2);
             }
           });
@@ -5696,8 +5699,8 @@ export default {
         });
     },
     openUploadExcel() {
-      this.uploadExcel = true;
-      this.$refs.upexcel.init(this.form.fWarehouseid);
+      this.uploadExcel =! this.uploadExcel;
+      this.$refs.upexcel.init(this.form.fWarehouseid,this.detailList);
     },
     // 监听 子组件弹窗关闭后触发,有子组件调用
     showAddOrUpdate(data) {
@@ -5708,6 +5711,19 @@ export default {
         this.addOrUpdateVisible = true;
       }
     },
+    showAddOrUpdate2(data) {
+      this.uploadExcel=data
+    },
+    adddetailList(rows){
+      rows.map(e=>{
+        e.fMblno=this.form.fMblno
+        e.fBillstatus=10
+      })
+      this.detailList.push(...rows)
+    },
+    downloadExcel(){
+      window.location.href = "http://121.36.212.131:8080/file/入库模板.xlsx";
+    }
   },
   watch: {
     // 监听 addOrUpdateVisible 改变

+ 143 - 16
src/views/Warehousing/inStock/uploadExcel.vue

@@ -4,6 +4,7 @@
     :visible.sync="uploadVisible"
     width="70%"
     :close-on-click-modal="false"
+    @close="handleClose"
   >
     <span>
       <div style="display: flex; justify-content: space-between">
@@ -46,7 +47,6 @@
           :prop="item.label"
           align="center"
           :fixed="item.fixed"
-          :show-overflow-tooltip="true"
           sortable
         >
           <template slot-scope="scope">
@@ -97,16 +97,13 @@
                 placeholder="请填写属性描述"
               />
             </span>
-            <span v-else-if="item.label == 'fWarehouselocid'">
-              <treeselect
-                v-model="scope.row.fWarehouselocid"
-                @select="getAlltree"
-                :options="fWarehouseidOptions"
-                :show-count="true"
-                :disable-branch-nodes="true"
-                placeholder="请选择库区"
-                style="z-index:10"
-              />
+            <span v-else-if="item.label == 'fWarehouseInformation'">
+              <el-input
+                placeholder="请选择"
+                v-model="scope.row.fWarehouseInformation"
+                @focus="getTreeselect(scope)"
+              >
+              </el-input>
             </span>
             <span v-else-if="item.label == 'fQty'">
               <el-input
@@ -145,6 +142,7 @@
                 style="width: 100%"
                 placeholder="箱号"
                 v-Alphabet
+                @change="unRepeat(scope.row.fCntrno, scope.$index)"
               />
             </span>
             <span v-else-if="item.label == 'fTruckno'">
@@ -237,8 +235,29 @@
     </span>
     <span slot="footer" class="dialog-footer">
       <el-button @click="uploadVisible = false">取 消</el-button>
-      <el-button type="primary" @click="uploadVisible = false">确 定</el-button>
+      <el-button type="primary" @click="importData">导 入</el-button>
     </span>
+    <el-dialog
+      title="选择库位"
+      :data="treeselectList"
+      :visible.sync="choiceWarehouse"
+      width="30%"
+      :close-on-click-modal="false"
+      append-to-body
+    >
+      <treeselect
+        v-model="treeselectList.fWarehouselocid"
+        @select="getAlltree"
+        :options="fWarehouseidOptions"
+        :show-count="true"
+        :disable-branch-nodes="true"
+        placeholder="请选择归属库区"
+      />
+      <span slot="footer" class="dialog-footer">
+        <el-button @click="choiceWarehouse = false">取 消</el-button>
+        <el-button type="primary" @click="confirm">确 定</el-button>
+      </span>
+    </el-dialog>
   </el-dialog>
 </template>
 
@@ -308,7 +327,7 @@ export default {
         },
         {
           surface: "5",
-          label: "fWarehouselocid",
+          label: "fWarehouseInformation",
           name: "库区",
           checked: 0,
           width: 100,
@@ -360,6 +379,11 @@ export default {
       goodsOptions: [],
       fStorageTypeOptions: [],
       fWarehouseidOptions: [],
+      treeselectList: {
+        fWarehouselocid: null,
+      },
+      choiceWarehouse: false,
+      oldList: [],
     };
   },
   created() {
@@ -374,7 +398,10 @@ export default {
     this.getRow();
   },
   methods: {
-    init(fWarehouseid) {
+    init(fWarehouseid, rows) {
+      this.oldList = [];
+      this.excelList = [];
+      this.oldList = rows;
       treeselect(fWarehouseid).then((response) => {
         this.fWarehouseidOptions = response.data;
       });
@@ -459,10 +486,110 @@ export default {
       this.drag = false;
     },
     getAlltree(tree) {
-      this.importList.fWarehouseInformation = tree.fWarehouseInformation;
+      this.information = tree.fWarehouseInformation;
+    },
+    importData() {
+      if (this.excelList.length == 0) {
+        return this.$message.error("请上传Excel文件,并完善数据");
+      }
+      for (let item in this.excelList) {
+        if (this.excelList[item].fBsdate == null) {
+          return this.$message.error(
+            "请选择第" + (Number(item) + 1) + "行的入库日期"
+          );
+        }
+        if (this.excelList[item].fGoodsid == null) {
+          return this.$message.error(
+            "请选择第" + (Number(item) + 1) + "行的品名"
+          );
+        }
+        if (this.excelList[item].fBusinessType == null) {
+          return this.$message.error(
+            "请选择第" + (Number(item) + 1) + "行的货物属性"
+          );
+        }
+        if (this.excelList[item].fMarks == null) {
+          return this.$message.error(
+            "请输入第" + (Number(item) + 1) + "行的属性详情"
+          );
+        }
+        if (this.excelList[item].fWarehouseInformation == null) {
+          return this.$message.error(
+            "请选择第" + (Number(item) + 1) + "行的库区"
+          );
+        }
+        if (this.excelList[item].fQty == null) {
+          return this.$message.error(
+            "请输入第" + (Number(item) + 1) + "行的件数"
+          );
+        }
+        if (this.excelList[item].fGrossweight == null) {
+          return this.$message.error(
+            "请输入第" + (Number(item) + 1) + "行的毛重"
+          );
+        }
+        if (this.excelList[item].fNetweight == null) {
+          return this.$message.error(
+            "请输入第" + (Number(item) + 1) + "行的净重"
+          );
+        }
+        if (this.excelList[item].fPackagespecs == null) {
+          return this.$message.error(
+            "请输入第" + (Number(item) + 1) + "行的包装规格"
+          );
+        }
+        if (this.excelList[item].fCntrno == null) {
+          return this.$message.error(
+            "请输入第" + (Number(item) + 1) + "行的箱号"
+          );
+        }
+        if (this.excelList[item].fTruckno == null) {
+          return this.$message.error(
+            "请输入第" + (Number(item) + 1) + "行的车号"
+          );
+        }
+      }
+      this.$emit("adddetailList", this.excelList)
+      this.uploadVisible=false
+    },
+    unRepeat(row, index) {
+      this.oldList.map((e) => {
+        if (row == e.fCntrno) {
+          this.excelList[index].fCntrno = null;
+          this.$message.error("该箱号和明细表上的存在重复");
+        }
+      });
+      this.excelList.map((e, i) => {
+        if (index != i) {
+          if (row && row == e.fCntrno) {
+            this.excelList[index].fCntrno = null;
+            this.$message.error("该箱号存在重复");
+          }
+        }
+      });
     },
     handleClose() {
-      this.$emit("changeShow", "false");
+      this.$emit("changeShow", false);
+    },
+    getTreeselect(row) {
+      this.treeselectList.fWarehouselocid = row.row.fWarehouselocid
+        ? row.row.fWarehouselocid
+        : null;
+      this.TreeIndex = row.$index;
+      this.choiceWarehouse = true;
+    },
+    confirm() {
+      this.$set(
+        this.excelList[this.TreeIndex],
+        "fWarehouseInformation",
+        this.information
+      );
+      this.$set(
+        this.excelList[this.TreeIndex],
+        "fWarehouselocid",
+        this.treeselectList.fWarehouselocid
+      );
+      this.choiceWarehouse = false;
     },
   },
   watch: {