Browse Source

出运明细列表查询预发货日期默认时间设置

jbb 2 years ago
parent
commit
1eadf883dd
1 changed files with 31 additions and 5 deletions
  1. 31 5
      src/views/shipment-details/shipmentList.vue

+ 31 - 5
src/views/shipment-details/shipmentList.vue

@@ -295,6 +295,8 @@ export default {
       loading: false, // 表格加载
       id: '',
       monthStartDate:'',//本月1号
+      nextMonthStartDate:'',//下月1号
+      nextMonthEndDate:'',//下月最后一天
       shipmentListColumns: [
         {
           title: '账套',
@@ -564,6 +566,8 @@ export default {
   },
   created() {
     // this.getShipmentList() // 渲染 发运明细列表
+    this.defalutDate()
+
   },
   methods: {
     moment,
@@ -571,8 +575,18 @@ export default {
     defalutDate(){
      var now = new Date(); //当前日期 
       var nowMonth = now.getMonth(); //当前月 
+      var nextMonth = nowMonth+1; //下个月
       var nowYear = now.getFullYear(); //当前年
       this.monthStartDate = moment(new Date(nowYear, nowMonth, 1)).format('YYYY-MM-DD');  
+      this.nextMonthStartDate = moment(new Date(nowYear, nextMonth, 1)).format('YYYY-MM-DD');  
+      if([1, 3, 5, 7, 8, 10, 12].indexOf(nextMonth) > -1){
+        this.nextMonthEndDate = moment(new Date(nowYear, nextMonth, 31)).format('YYYY-MM-DD');  
+      }else {
+        this.nextMonthEndDate = moment(new Date(nowYear, nextMonth, 30)).format('YYYY-MM-DD'); 
+      }
+      this.preDeliveryDate.push(this.nextMonthStartDate,this.nextMonthEndDate)
+      this.queryParam.preDeliveryDateB = this.nextMonthStartDate
+      this.queryParam.preDeliveryDateE = this.nextMonthEndDate
     },
     // 分页查询 发运明细
     async getShipmentList() {
@@ -620,7 +634,7 @@ export default {
     //参照订单数据
     referOrderDataOpen(){
       this.$refs.referOrderDataModal.referOrderDataModVis = true
-      this.defalutDate() 
+      // this.defalutDate() 
       this.$refs.referOrderDataModal.range.push(this.monthStartDate)     
       this.$refs.referOrderDataModal.queryParam.preDeliveryDateS = this.monthStartDate;
       this.$refs.referOrderDataModal.queryParam.preDeliveryDateE  = '';
@@ -836,10 +850,22 @@ export default {
     searchQuery() {
       if(this.queryParam.flourOrGarment === ''){
        this.$message.error('请选择查询类型!');
-      }else {
-      this.queryParam.pageNo = ''
-      this.queryParam.pageSize = 20
-      this.getShipmentList()        
+      }else if(this.preDeliveryDate.length !==2){
+       this.$message.error('请选择预发货时间区间!');
+      }else{
+        var separator = "-"; //日期分隔符  
+         var startDates = this.queryParam.preDeliveryDateB.split(separator);  
+         var endDates = this.queryParam.preDeliveryDateE.split(separator);  
+         var startDate = new Date(startDates[0], startDates[1]-1, startDates[2]);  
+         var endDate = new Date(endDates[0], endDates[1]-1, endDates[2]);  
+        var timeInterval= parseInt(Math.abs(endDate - startDate ) / 1000 / 60 / 60 /24) + 1;
+        if(timeInterval > 31){
+          this.$message.error('预发货时间区间超过31天,请重新选择!');
+        }else {
+          this.queryParam.pageNo = ''
+          this.queryParam.pageSize = 20
+          this.getShipmentList() 
+        }       
       }
     },