瀏覽代碼

移库入库导入

zhangyuewww 2 年之前
父節點
當前提交
7737ad8f79

+ 2 - 0
src/api/V2/houseSelfCollect/index.js

@@ -106,6 +106,8 @@ export const API_POST_WORKFLOW_TASK = `/newWorkflow/getTaskWebsocket`
 export const API_POST_SUSPENDINSTANCE ='/paymentManagement/api/ReSettlement'
 //导入
 export const API_POST_IMPORT ='/qualityInspectionManagement/api/importQuality'
+//导入移库
+export const API_POST_IMPORT_YK ='/weighingManagement/api/importWeighing'
 // 结算单
 export const API_GET_SETTLEACCOUT = '/warehouseInOutInfo/getInfo'
 // 退回

+ 3 - 0
src/model/houseSelfCollect/index.js

@@ -54,6 +54,7 @@ import {
   API_POST_INSPECT_GETWEIGHTDELETE,
   API_POST_SUSPENDINSTANCE,
   API_POST_IMPORT,
+  API_POST_IMPORT_YK,
   API_GET_INSPECT_CONTRACTNO,
   API_GET_SETTLEACCOUT,
   API_POST_RETURN,
@@ -169,6 +170,8 @@ export const workflowcontent = appRx.get(API_POST_WORKFLOW_TASK, errorCatcher, e
 export const suspendinstance = appRx.post(API_POST_SUSPENDINSTANCE, errorCatcher, errorHandle, filter)
 // 导入
 export const importWord = appRx.post(API_POST_IMPORT, errorCatcher, errorHandle, filter)
+// 导入移库
+export const importWordYk = appRx.post(API_POST_IMPORT_YK, errorCatcher, errorHandle, filter)
 // 查看结算单
 export const getsettleaccout = appRx.get(API_GET_SETTLEACCOUT, errorCatcher, errorHandle, filter)
 // 退回

+ 118 - 1
src/views/houseSelfCollect/weightCheckRecord.vue

@@ -40,7 +40,12 @@
       <el-button :type="choice == 2?'primary':''" size="small" @click="screen(2)" class="btn_css">已称毛重</el-button>
       <el-button :type="choice == 3?'primary':''" size="small" @click="screen(3)" class="btn_css">已称皮重</el-button>
       <el-button size="small" @click="print('',1)">批量打印</el-button>
-        
+       <el-upload style="margin-top: -35px; margin-left:430px" class="upload-demo inline-block margin-right-10" action=""
+          :on-change="importClick" :show-file-list="false"
+          accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
+          :auto-upload="false">
+          <ws-button type="primary">导入</ws-button>
+        </el-upload>
       <el-table class="forData" :data="weighingRecordList" style="width: 100%; margin-top: 20px" height="780"
         @selection-change="handleSelectionChange">
         <el-table-column type="selection" width="55"></el-table-column>
@@ -170,6 +175,7 @@
     getPrint,
     returnInfo,
     changeNo,
+    importWordYk,
     getweighingDelete
   } from '@/model/houseSelfCollect/index'
   import weightCheckPrint from './component/weightCheckPrint.vue'
@@ -311,6 +317,117 @@
       this.getList()
     },
     methods: {
+      importClick(file, fileList) {
+        this.fileTemp = file.raw
+        let fileName = file.raw.name
+        let fileType = fileName.substring(fileName.lastIndexOf('.') + 1)
+        // 判断上传文件格式
+        if (this.fileTemp) {
+          if (fileType == 'xlsx' || fileType == 'xls') {
+            this.importf(this.fileTemp)
+          } else {
+            this.$message({
+              type: 'warning',
+              message: '附件格式错误,请删除后重新上传!',
+            })
+          }
+        } else {
+          this.$message({
+            type: 'warning',
+            message: '请上传附件!',
+          })
+        }
+      },
+      importf(obj) {
+        this.excelFreightspace = []
+        // this.dialogVisible = true;
+        let _this = this;
+        let inputDOM = this.$refs.inputer; // 通过DOM取文件数据
+        this.file = event.currentTarget.files[0];
+        var rABS = false; //是否将文件读取为二进制字符串
+        var f = this.file;
+        var reader = new FileReader();
+        //if (!FileReader.prototype.readAsBinaryString) {
+        FileReader.prototype.readAsBinaryString = function(f) {
+          var binary = '';
+          var rABS = false; //是否将文件读取为二进制字符串
+          var pt = this;
+          var wb; //读取完成的数据
+          var outdata;
+          var reader = new FileReader();
+          reader.onload = function(e) {
+            var bytes = new Uint8Array(reader.result);
+            var length = bytes.byteLength;
+            for (var i = 0; i < length; i++) {
+              binary += String.fromCharCode(bytes[i]);
+            }
+            var XLSX = require('xlsx');
+            if (rABS) {
+              wb = XLSX.read(btoa(fixdata(binary)), { //手动转化
+                type: 'base64',
+                cellDates: true
+              });
+            } else {
+              wb = XLSX.read(binary, {
+                type: 'binary'
+              });
+            }
+            // outdata就是你想要的东西 excel导入的数据
+            outdata = XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]);
+            // excel 数据再处理
+            let arr = []
+            outdata.map(v => {
+              // let jsonString = JSON.stringify(v).replace(/\*/g, '').replace(/\s/ig,'');
+              let jsonString = JSON.stringify(v).replace(/\//g, '').replace(/\s/ig, '');
+              v = JSON.parse(jsonString);
+              let obj = {}
+              //xxx代表列名
+              obj.number = v.业务编号
+              obj.inOutTaskNo = v.移库任务编号
+              obj.carNumber = v.车牌号
+              obj.grossWeight = v.毛重
+              obj.tare = v.皮重
+              obj.netWeight = v.净重
+              obj.grossDate = _this.formatDate(v.入库日期, '-')
+              _this.excelFreightspace.push(obj)
+            })
+            if (_this.excelFreightspace) {
+              importWordYk({
+                  warehouseName: _this.warehouseName,
+                  weighingManagementList: _this.excelFreightspace
+                }).toPromise()
+                .then((response) => {
+                  if (response == 'ok') {
+                    this.$notify({
+                      title: '成功',
+                      message: '导入成功',
+                      type: 'success'
+                    });
+                    _this.getList()
+                  }
+                })
+
+            }
+          }
+          reader.readAsArrayBuffer(f);
+        }
+        if (rABS) {
+          reader.readAsArrayBuffer(f);
+        } else {
+          reader.readAsBinaryString(f);
+        }
+
+      },
+      formatDate(numb, format) {
+        const old = numb - 1;
+        const t = Math.round((old - Math.floor(old)) * 24 * 60 * 60);
+        const time = new Date(1900, 0, old, 0, 0, t)
+        const year = time.getFullYear();
+        const month = time.getMonth() + 1;
+        const date = time.getDate();
+        return year + format + (month < 10 ? '0' + month : month) + format + (date < 10 ? '0' + date : date) +
+          ' 00:00:00'
+      },
       binNumberChange(e){
         this.binNumber = e
         for(let i = 0 ; i < this.binnumberList.length ; i++){