Преглед изворни кода

批记录-产品查询时间范围限制

lucw пре 8 месеци
родитељ
комит
836d94a46d
1 измењених фајлова са 39 додато и 0 уклоњено
  1. 39 0
      src/views/batchRecord/index.vue

+ 39 - 0
src/views/batchRecord/index.vue

@@ -32,6 +32,19 @@
                       placeholder="选择日期"
                       placeholder="选择日期"
                       format="yyyy-MM-dd HH:mm:ss"
                       format="yyyy-MM-dd HH:mm:ss"
                       value-format="yyyy-MM-dd HH:mm:ss"
                       value-format="yyyy-MM-dd HH:mm:ss"
+                      :picker-options="{
+                        disabledDate: (date) => {
+                          const end = productBody.createTimeEnd
+                            ? new Date(productBody.createTimeEnd)
+                            : new Date();
+                          const start = new Date(end);
+                          start.setMonth(start.getMonth() - 3);
+                          return (
+                            date.getTime() < start.getTime() ||
+                            date.getTime() > end.getTime()
+                          );
+                        }
+                      }"
                     >
                     >
                     </el-date-picker>
                     </el-date-picker>
                     <div style="margin-top: 10px">
                     <div style="margin-top: 10px">
@@ -43,6 +56,17 @@
                         format="yyyy-MM-dd HH:mm:ss"
                         format="yyyy-MM-dd HH:mm:ss"
                         value-format="yyyy-MM-dd HH:mm:ss"
                         value-format="yyyy-MM-dd HH:mm:ss"
                         @change="createTimeEndDateChange"
                         @change="createTimeEndDateChange"
+                        :picker-options="{
+                          disabledDate: (date) => {
+                            const now = new Date();
+                            const start = new Date(now);
+                            start.setMonth(start.getMonth() - 3);
+                            return (
+                              date.getTime() < start.getTime() ||
+                              date.getTime() > now.getTime()
+                            );
+                          }
+                        }"
                       >
                       >
                       </el-date-picker>
                       </el-date-picker>
                     </div>
                     </div>
@@ -260,6 +284,21 @@
     },
     },
     computed: {},
     computed: {},
     created() {
     created() {
+      // 设置 productBody.createTimeStart 和 productBody.createTimeEnd 为前一个月时间包含今天
+      const endDate = new Date();
+      const startDate = new Date();
+      startDate.setMonth(startDate.getMonth() - 1);
+      // 设置时间为 00:00:00
+      startDate.setHours(0, 0, 0, 0);
+      this.productBody.createTimeStart = this.$util.toDateString(
+        startDate,
+        'yyyy-MM-dd HH:mm:ss'
+      );
+      this.productBody.createTimeEnd = this.$util.toDateString(
+        endDate,
+        'yyyy-MM-dd HH:mm:ss'
+      );
+
       this.getAllProductInWorkOrder();
       this.getAllProductInWorkOrder();
     },
     },
     methods: {
     methods: {