Bladeren bron

bug 修复

lilei 2 jaren geleden
bovenliggende
commit
1b3f8222e0
3 gewijzigde bestanden met toevoegingen van 37 en 15 verwijderingen
  1. 1 1
      public/version.json
  2. 14 3
      src/views/common/rangeDate.vue
  3. 22 11
      src/views/salesManagement/salesQuery/list.vue

+ 1 - 1
public/version.json

@@ -1,5 +1,5 @@
 {
   "message": "发现有新版本发布,确定更新系统?",
   "vendorJsVersion": "",
-  "version": 1670851922081
+  "version": 1670860583535
 }

+ 14 - 3
src/views/common/rangeDate.vue

@@ -32,6 +32,10 @@ export default {
     allowClear: {
       type: Boolean,
       default: true
+    },
+    hasDisabledAreaTime: {
+      type: Boolean,
+      default: true
     }
   },
   data () {
@@ -43,7 +47,9 @@ export default {
         '今天': [moment(), moment()],
         '近一个月': [moment().subtract(1, 'months'), moment()],
         '本月': [moment().startOf('month'), moment()],
-        '上月': [moment().subtract(1, 'months').startOf('month'), moment().subtract(1, 'months').endOf('month')] }
+        '上月': [moment().subtract(1, 'months').startOf('month'), moment().subtract(1, 'months').endOf('month')],
+        '近一年': [moment().subtract(1, 'years'), moment()]
+      }
     }
   },
   methods: {
@@ -52,10 +58,15 @@ export default {
       //  最早可倒推选择两年数据,最晚为今天
       const minYearVs = moment().subtract(2, 'years') //  两年前   负值
       const maxYearVs = moment().endOf('day') //  今天,包含今天
+
+      if (!this.hasDisabledAreaTime) {
+        return current && current > maxYearVs
+      }
+      console.log(this.selectPriceDate)
       //  限制最多只能查一年区间的数据
       if (this.selectPriceDate) {
-        const oMinYearVs = moment(this.selectPriceDate, 'YYYY-MM-DD').subtract(2, 'years') //  当前选中开始日期前推一年
-        const oMaxYearVs = moment(this.selectPriceDate, 'YYYY-MM-DD').add(2, 'years') //  当前选中开始日期后推一年
+        const oMinYearVs = moment(this.selectPriceDate, 'YYYY-MM-DD').subtract(1, 'years') //  当前选中开始日期前推一年
+        const oMaxYearVs = moment(this.selectPriceDate, 'YYYY-MM-DD').add(1, 'years') //  当前选中开始日期后推一年
         // 判断两个时间段是否相差m天  第二个参数指相差单位,第三个参数指是否返回浮点形式(小数)
         const beginDate = minYearVs.diff(oMinYearVs, 'days') > 0 ? minYearVs : oMinYearVs // 若当前选中开始日期前推一年超出最多倒推两年数据时,则以两年为标准
         const endDate = maxYearVs.diff(oMaxYearVs, 'days') > 0 ? oMaxYearVs : maxYearVs // 若当前选中开始日期后推一年超出今天时,则以今天为标准

+ 22 - 11
src/views/salesManagement/salesQuery/list.vue

@@ -3,11 +3,11 @@
     <a-spin :spinning="spinning" tip="Loading...">
       <!-- 搜索条件 -->
       <div ref="tableSearch" class="table-page-search-wrapper">
-        <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
+        <a-form layout="inline" @keyup.enter.native="searchForm">
           <a-row :gutter="15">
             <a-col :md="6" :sm="24">
               <a-form-item label="创建时间">
-                <rangeDate :allowClear="false" ref="rangeDate" :value="time" @change="dateChange" />
+                <rangeDate :allowClear="false" :hasDisabledAreaTime="false" ref="rangeDate" :value="time" @change="dateChange" />
               </a-form-item>
             </a-col>
             <a-col :md="6" :sm="24">
@@ -23,12 +23,12 @@
             <template v-if="advanced">
               <a-col :md="6" :sm="24">
                 <a-form-item label="审核时间">
-                  <rangeDate :allowClear="false" ref="auditRangeDate" :value="auditTime" @change="auditDateChange" />
+                  <rangeDate ref="auditRangeDate" :value="auditTime" @change="auditDateChange" />
                 </a-form-item>
               </a-col>
               <a-col :md="6" :sm="24">
                 <a-form-item label="出库时间">
-                  <rangeDate :allowClear="false" ref="outWareRangeDate" :value="outWareTime" @change="outWareDateChange" />
+                  <rangeDate ref="outWareRangeDate" :value="outWareTime" @change="outWareDateChange" />
                 </a-form-item>
               </a-col>
               <a-col :md="6" :sm="24">
@@ -88,7 +88,7 @@
             </template>
             <a-col :md="6" :sm="24">
               <span class="table-page-search-submitButtons">
-                <a-button type="primary" :disabled="disabled" @click="$refs.table.refresh(true)">查询</a-button>
+                <a-button type="primary" :disabled="disabled" @click="searchForm">查询</a-button>
                 <a-button style="margin-left: 5px" :disabled="disabled" @click="resetSearchForm()">重置</a-button>
                 <a-button
                   type="primary"
@@ -229,6 +229,7 @@ import rangeDate from '@/views/common/rangeDate.vue'
 import custList from '@/views/common/custList.vue'
 import { downloadExcel } from '@/libs/JGPrint.js'
 import stateIcon from '@/views/common/stateIcon'
+import moment from 'moment'
 export default {
   name: 'SalesList',
   components: { STable, VSelect, chooseCustomModal, rangeDate, auditModal, custList, stateIcon },
@@ -242,15 +243,15 @@ export default {
       exportLoading: false, // 导出loading
       openModal: false, // 选择客户弹框是否显示
       time: [
-        getDate.getCurrMonthDays().starttime,
-        getDate.getCurrMonthDays().endtime
+        getDate.getMonthDays(12).starttime,
+        getDate.getMonthDays(12).endtime
       ],
       auditTime: [],
       outWareTime: [],
       // 查询参数
       queryParam: {
-        beginDate: getDate.getCurrMonthDays().starttime,
-        endDate: getDate.getCurrMonthDays().endtime,
+        beginDate: getDate.getMonthDays(12).starttime,
+        endDate: getDate.getMonthDays(12).endtime,
         auditBeginDate: '',
         auditEndDate: '',
         outWarehouseBeginDate: '',
@@ -437,6 +438,16 @@ export default {
         }
       })
     },
+    searchForm () {
+      const a = moment(this.queryParam.beginDate)
+      const b = moment(this.queryParam.endDate)
+      console.log(b.diff(a, 'years'))
+      if (b.diff(a, 'years') > 2) {
+        this.$message.info('最多只能选择2年的时间区间')
+        return false
+      }
+      this.$refs.table.refresh(true)
+    },
     // 重置
     resetSearchForm () {
       this.resetData()
@@ -445,8 +456,8 @@ export default {
     // 重置数据
     resetData (flag) {
       this.$refs.rangeDate.resetDate(flag ? '' : this.time)
-      this.queryParam.beginDate = flag ? '' : getDate.getCurrMonthDays().starttime
-      this.queryParam.endDate = flag ? '' : getDate.getCurrMonthDays().endtime
+      this.queryParam.beginDate = flag ? '' : getDate.getMonthDays(12).starttime
+      this.queryParam.endDate = flag ? '' : getDate.getMonthDays(12).endtime
       this.$refs.auditRangeDate.resetDate('')
       this.queryParam.auditBeginDate = ''
       this.queryParam.auditEndDate = ''