瀏覽代碼

新增导入功能

lichao 3 年之前
父節點
當前提交
bcc4dfcbda
共有 1 個文件被更改,包括 208 次插入12 次删除
  1. 208 12
      src/views/kaihe/domesticTrade/orderInformation/index.vue

+ 208 - 12
src/views/kaihe/domesticTrade/orderInformation/index.vue

@@ -577,6 +577,22 @@
               @click="dialogPrint"
               :disabled="dataList.length === 0"
             >打印运单</el-button>
+            <el-upload
+              class="upload-demo"
+              :action="baseURL"
+              :headers="headers"
+              :on-progress="uploading"
+              :show-file-list=false
+              :data="{
+                fId:goodsList[0].fId
+              }"
+              :on-success="importTemplate"
+              accept=".xls,.xlsx"
+              :disabled="modify"
+              multiple
+              style="float: right;margin-right: 20px">
+              <el-button size="small" style="margin-left: 5px" type="warning" :disabled="modify">导入</el-button>
+            </el-upload>
           </div>
         </div>
         <el-table :data="dataList" style="width: 100%;" @selection-change="Selectinventory">
@@ -1314,9 +1330,9 @@
       <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
       <approval-comments v-if="addOrUpdateVisib" ref="ApprovalComments" @refreshDataList="returnData"
       ></approval-comments>
-      <el-button type="info" :disabled="jumpDonot" v-if="form.fBillstatus == 11 || form.fBillstatus == 6" @click="modify = false">修 改
+      <el-button type="info" :disabled="jumpDonot" v-if="form.fBillstatus <= 11 && form.fBillstatus >= 6" @click="modify = false">修 改
       </el-button>
-      <el-button type="success" :disabled="modify" v-if="form.fBillstatus == 11 || form.fBillstatus == 6" @click="approval(1)">保 存
+      <el-button type="success" :disabled="modify" v-if="form.fBillstatus <= 11 || form.fBillstatus >= 6" @click="approval(1)">保 存
       </el-button>
       <el-button type="primary" :disabled="modify" v-if="form.fBillstatus == 11 && this.form.moneyStatus < 4"
                  @click="feeSubmission"
@@ -1619,6 +1635,7 @@ import AddOrUpdate from '@/views/viewApproval'
 import ApprovalComments from '@/views/startApproval'
 import { revoke, revokeTwo } from '@/api/warehouseBusiness/warehouseInStock'
 import { queryUserVal } from '@/api/system/user'
+import request from '@/utils/request'
 
 Vue.directive('dialogDrag', {
   bind(el, binding, vnode, oldVnode) {
@@ -1741,6 +1758,7 @@ export default {
       uploadImgUrl: process.env.VUE_APP_BASE_API + '/common/upload', // 上传的图片服务器地址
       relevantAttachments: [],
       headers: { Authorization: 'Bearer ' + getToken() },
+      baseURL: process.env.VUE_APP_BASE_API + '/khwarehouse/warehousebills/importCreate',
       //集装箱尺码字典表
       CntrsizeOptions: [],
       //模糊查询箱类型
@@ -1780,6 +1798,13 @@ export default {
       actId: null,
       // 打印弹窗
       dialogPrinting: false,
+      boxSorting: {
+        pageNum: 1,
+        pageSize: 30,
+        total: null,
+      },
+      // 上传loading
+      uploadLoading: false,
     }
   },
   //页面跳转后传递参数
@@ -2542,7 +2567,6 @@ export default {
     revisionApproval(){
       let list = JSON.parse(this.$route.query.testing)
       let actId = ''
-      console.log(list)
       this.addOrUpdateVisible = true
       if(list.refno4 == 'XGDD'){
         actId = 471
@@ -2558,17 +2582,21 @@ export default {
     addOrUpdateHandle(status) {
       this.addOrUpdateVisible = true
       let id = '448'
-      // let actId = ''
-      // if (this.form.fBillstatus < 6) {
-      //   actId = '410'
-      // } else if (this.form.moneyStatus != null && this.form.moneyStatus < 6) {
-      //   actId = '460'
-      // } else {
-      //   actId = '420'
-      // }
+      let actId = ''
+      if (!this.actId){
+        if (this.form.fBillstatus < 6) {
+          actId = '410'
+        } else if (this.form.moneyStatus != null && this.form.moneyStatus < 6) {
+          actId = '460'
+        } else {
+          actId = '420'
+        }
+      }else {
+        actId = this.actId
+      }
       if (this.actId == '474') status = 'f_dismount_status'
       this.$nextTick(() => {
-        this.$refs.addOrUpdate.init(this.form.fId, this.actId,status)
+        this.$refs.addOrUpdate.init(this.form.fId, actId ,status)
       })
     },
     handleSelect() {
@@ -2752,6 +2780,174 @@ export default {
           });
         });
     },
+    //文件上传时
+    uploading(event, file, fileList) {
+      this.uploadLoading = true;
+      this.openFullScreen(false, '文件正在解析中');
+    },
+    //遮罩层
+    openFullScreen(res, text) {
+      const loading = this.$loading({
+        lock: true,
+        text: text,
+        spinner: 'el-icon-loading',
+        background: 'rgba(0, 0, 0, 0.7)'
+      });
+      if (res === true) loading.close();
+      // setTimeout(() => {
+      //   loading.close();
+      // }, 1000);
+    },
+    //导入模板
+    importTemplate(res, file) {
+      console.log(res.data)
+      if (res.data == 500) {
+        this.$message.error(res.msg);
+        return this.loading = false;
+      } else if (res.code == 200) {
+        if (res.msg === 'error') {
+          console.log(res.data.List);
+          if (res.data.tCnTrNoList && res.data.List){
+            this.$message({
+              showClose: true,
+              dangerouslyUseHTMLString: true,
+              type: 'error',
+              duration: 10000,
+              message: '<h3>导入数据有误</h3><h4 style="width: 80%;">' +res.data.tCnTrNoList+ '</h4><h4 style="width: 80%;">' + res.data.List + '</h4>'
+            });
+          }else if (res.data.tCnTrNoList && !res.data.List){
+            this.$message({
+              showClose: true,
+              dangerouslyUseHTMLString: true,
+              type: 'error',
+              duration: 10000,
+              message: '<h3>导入数据有误</h3><h4 style="width: 80%;">' +res.data.tCnTrNoList+ '</h4>'
+            });
+          }else {
+            this.$message({
+              showClose: true,
+              dangerouslyUseHTMLString: true,
+              type: 'error',
+              duration: 10000,
+              message: '<h3>导入数据有误</h3><h4 style="width: 80%;">' +res.data.List+ '</h4>'
+            });
+          }
+          this.uploadLoading = false;
+          return this.openFullScreen(true);
+        }
+
+        this.boxSorting = {
+          pageNum: 1,
+          total: null,
+        };
+        request({
+          url: '/system/config/configKey/data_excel_pagenum',
+          method: 'get',
+        })
+          .then(resErr => {
+            console.log(resErr)
+            if (resErr.msg) {
+              this.boxSorting.pageSize = resErr.msg;
+            } else {
+              this.boxSorting.pageSize = 10;
+            }
+            request({
+              url: '/warehouse/file/list',
+              method: 'get',
+              params: {
+                fileName: res.data.fileName,
+                pageNum: this.boxSorting.pageNum,
+                pageSize: this.boxSorting.pageSize
+              }
+            })
+              .then(response => {
+                console.log(response);
+                let i = this.dataList.length;
+                this.boxSorting.total = response.total;
+                let data = response.rows;
+                data.forEach(item => {
+                  item.fCntrid = this.goodsList[0].fCntrid
+                  item.fGoodsid = this.goodsList[0].fGoodsid
+                  item.fPackageid = this.goodsList[0].fPackageid
+                })
+                this.dataList = this.dataList.concat(data);
+                if (this.boxSorting.total > 1) {
+                  this.boxSorting.pageNum++;
+                  this.boxInformatiNO(res, i);
+                } else {
+                  console.log(res)
+                  request({
+                    url: '/warehouse/file/delete/' + res.data.fileName,
+                    method: 'delete',
+                  });
+                  this.loading = false;
+                  this.openFullScreen(true);
+                }
+              });
+          });
+      } else {
+        this.$message.error(res.msg);
+      }
+    },
+    storageBox(res, i) {
+      this.boxInformatiNO(res, i);
+    },
+    boxInformatiNO(res, i) {
+      if ((Number(this.dataList.length) - i) < this.boxSorting.total) {
+        request({
+          url: '/warehouse/file/list',
+          method: 'get',
+          params: {
+            fileName: res.data.fileName,
+            pageNum: this.boxSorting.pageNum,
+            pageSize: this.boxSorting.pageSize
+          }
+        })
+          .then(response => {
+            // this.tableData = this.tableData.concat(response.data.rows);
+            // console.log(this.tableData);
+            this.boxSorting.pageNum++;
+
+            let data = response.rows;
+            data.forEach(item => {
+              item.fCntrid = this.goodsList[0].fCntrid
+              item.fGoodsid = this.goodsList[0].fGoodsid
+              item.fPackageid = this.goodsList[0].fPackageid
+            })
+            this.dataList = this.dataList.concat(data);
+
+            // console.log(this.tableData.length+1,i);
+            // if (Number(Number(this.tableData.length+1)-i) === this.boxSorting.total){
+            //   this.loading = false
+            //   this.openFullScreen(true)
+            //   request({
+            //     url: '/warehouse/file/delete/'+res.fileName,
+            //     method: 'delete',
+            //   })
+            // }
+            // console.log(this.boxSorting.total);
+            this.storageBox(res, i);
+            // this.tableData = this.tableData.concat(response.data.data);
+            // let obj = {};
+            // this.tableData = this.tableData.reduce((current, next) => {
+            //   obj[next.fCntrno] ? '' : obj[next.fCntrno] = true && current.push(next);
+            //   return current;
+            // }, []);
+          });
+      } else {
+        let obj = {};
+        this.dataList = this.dataList.reduce((current, next) => {
+          obj[next.fCntrno] ? '' : obj[next.fCntrno] = true && current.push(next);
+          return current;
+        }, []);
+        request({
+          url: '/warehouse/file/delete/' + res.data.fileName,
+          method: 'delete',
+        });
+        this.uploading = false;
+        this.openFullScreen(true);
+      }
+    },
   }
 }
 </script>