zhangyuewww 2 năm trước cách đây
mục cha
commit
29ea82b3ff

+ 3 - 1
src/api/V2/outboundManagement/index.js

@@ -42,6 +42,8 @@ export const API_POST_NEW_SUBMIT = '/warehouseInOutInfo/api/newInOutWarehouse'
 export const API_POST_CHANE_NO = `/weighingManagement/api/changeWarehouse`
 // 退回
 export const API_POST_GO_BACK = `/weighingManagement/api/outWeightReturn`
-//导入
+//导入销售出
 export const API_POST_IMPORT_SALE ='/weighingManagement/api/importWeighingOut'
+//导入移库出库
+export const API_POST_IMPORT_YK ='/weighingManagement/api/importWeighingMoveOut'
 

+ 4 - 1
src/model/outboundManagement/index.js

@@ -24,6 +24,7 @@ import {
     API_POST_NEW_SUBMIT,
     API_POST_CHANE_NO,
     API_POST_IMPORT_SALE,
+    API_POST_IMPORT_YK,
     API_POST_GO_BACK
 }   from '@/api/V2/outboundManagement'
 
@@ -72,4 +73,6 @@ export const changeNo = appRx.post(API_POST_CHANE_NO, errorCatcher, errorHandle,
 // 退回
 export const goBack = appRx.post(API_POST_GO_BACK, errorCatcher, errorHandle, filter)
 // 导入销售出库
-export const importWordSale = appRx.post(API_POST_IMPORT_SALE, errorCatcher, errorHandle, filter)
+export const importWordSale = appRx.post(API_POST_IMPORT_SALE, errorCatcher, errorHandle, filter)
+// 导入移库出库
+export const importWordYk = appRx.post(API_POST_IMPORT_YK, errorCatcher, errorHandle, filter)

+ 112 - 1
src/views/outboundManagement/weighingManagementrecord.vue

@@ -7,7 +7,15 @@
           :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>
+          <ws-button type="primary">导入(销售)</ws-button>
+        </el-upload>
+      </template>
+      <template slot="left">
+         <el-upload style="margin-left: 8px;" class="upload-demo inline-block margin-right-10" action=""
+          :on-change="importClickYk" :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>
       </template>
       <!-- <template slot="left"> </template> -->
@@ -141,6 +149,7 @@
     getweighing,
     changeNo,
     importWordSale,
+    importWordYk,
     goBack
   } from '@/model/outboundManagement/index'
   import {
@@ -299,6 +308,108 @@
           reader.readAsBinaryString(f);
         }
 
+      },
+      importClickYk(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.importfYk(this.fileTemp)
+          } else {
+            this.$message({
+              type: 'warning',
+              message: '附件格式错误,请删除后重新上传!',
+            })
+          }
+        } else {
+          this.$message({
+            type: 'warning',
+            message: '请上传附件!',
+          })
+        }
+      },
+      importfYk(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.outType = 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;