Przeglądaj źródła

优化订购记录搜索默认项

litong 2 lat temu
rodzic
commit
f811330094
1 zmienionych plików z 32 dodań i 11 usunięć
  1. 32 11
      purchase_ao/src/views/dataPage/orderData/index.vue

+ 32 - 11
purchase_ao/src/views/dataPage/orderData/index.vue

@@ -25,7 +25,7 @@
               <el-option key="0" label="失败" value="0" />
             </el-select>
           </el-form-item>
-          <el-form-item label="时间范围">
+          <el-form-item label="时间范围(默认7天)">
             <el-date-picker
               v-model="value2"
               type="datetimerange"
@@ -147,34 +147,55 @@ export default {
     var that = this
       this.searchForm.startTime = filter.frDateTime(new Date(Date.now() - 7*24*60*60*1000))
       this.searchForm.endTime = filter.frDateTime(new Date())
+      this.value2 = [this.searchForm.startTime, this.searchForm.endTime]
     that.search()
   },
   methods: {
     async search() { // 同步搜索
-      await get('/handleRecord/page', this.searchForm)
-        .then((res) => {
-          this.tableData = res.data.list
-          this.total = res.data.total
-        }).catch((err) => {
-          console.log(err)
-        })
+        let st = Date.parse(this.searchForm.startTime)
+        let et = Date.parse(this.searchForm.endTime)
+        if (et - st > 90*24*60*60*1000) {
+            this.$confirm("您的搜索时间范围大于3个月,搜索或因数据量过大而失败,是否确认继续?").then((_) => {
+                get('/handleRecord/page', this.searchForm)
+                    .then((res) => {
+                        this.tableData = res.data.list
+                        this.total = res.data.total
+                    }).catch((err) => {
+                    console.log(err)
+                })
+            });
+        }else {
+            await get('/handleRecord/page', this.searchForm)
+                .then((res) => {
+                    this.tableData = res.data.list
+                    this.total = res.data.total
+                }).catch((err) => {
+                console.log(err)
+            })
+        }
+
+
+
+
     },
     searchBtn() { // 搜索按钮
       this.search()
     },
     reset() { // 重置
+      this.searchForm.startTime = filter.frDateTime(new Date(Date.now() - 7*24*60*60*1000))
+      this.searchForm.endTime = filter.frDateTime(new Date())
+      this.value2 = [this.searchForm.startTime, this.searchForm.endTime]
       this.searchForm = {
         cpid: '',
         categoryName: '',
         pageSize: 20,
         pageNum: 1,
-        startTime : filter.frDateTime(new Date(Date.now() - 7*24*60*60*1000)),
-        endTime : filter.frDateTime(new Date())
+        startTime : this.searchForm.startTime,
+        endTime : this.searchForm.endTime
       }
       this.search()
     },
     dateChange(e) {
-      console.log(e)
       this.searchForm.startTime = filter.frDateTime(e[0])
       this.searchForm.endTime = filter.frDateTime(e[1])
     },