马宇豪
2024-02-23 4cfbfd1b425f7b22b876ae6cae95c4fc29ae6bfb
src/views/purchase/dailySaleReport.vue
@@ -3,14 +3,21 @@
      <div class="filter-container" style="padding: 20px">
        <el-row>
          时间:&emsp;&emsp;
          <el-date-picker
            v-model="dateRange"
            type="datetimerange"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            :clearable="false"
            :default-time="['00:00:00','23:59:59']">
          </el-date-picker>
<!--          <el-date-picker-->
<!--            v-model="dateRange"-->
<!--            type="date"-->
<!--            start-placeholder="开始日期"-->
<!--            end-placeholder="结束日期"-->
<!--            :clearable="false"-->
<!--            :default-time="['00:00:00','23:59:59']">-->
<!--          </el-date-picker>-->
            <el-date-picker
                v-model="currentDate"
                value-format="yyyy-MM-dd"
                type="date"
                @change="changeDate"
                placeholder="选择日期">
            </el-date-picker>
            <el-button class="filter-item" style="margin-left: 10px;margin-bottom: 0" type="primary" icon="el-icon-back"
                       @click="dayForward">前一天</el-button>
            <el-button class="filter-item" style="margin-left: 10px;margin-bottom: 0" type="primary" icon="el-icon-right"
@@ -96,6 +103,7 @@
    name: "dailySaleReport",
    data(){
      return{
        currentDate: '',
        dateRange:[],
        startDate:'',
        endDate:'',
@@ -110,8 +118,9 @@
      }
    },
    mounted() {
      this.queryDateHandle();
    created() {
      this.queryDateHandle()
        this.getReportList()
    },
    methods:{
      // queryHandle(){
@@ -167,50 +176,36 @@
      },
      dayForward(){
        if (this.dateRange != null){
          const start = this.dateRange[0];
          const end = this.dateRange[1];
          start.setTime(start.getTime() - 3600 * 1000 * 24);
          end.setTime(end.getTime() - 3600 * 1000 * 24);
          start.setHours(0);
          start.setMinutes(0);
          start.setSeconds(0);
          end.setHours(23);
          end.setMinutes(59);
          end.setSeconds(59);
          this.dateRange = [start,end]
            const start = new Date(this.currentDate);
            start.setDate(start.getDate() - 1);
            this.currentDate = start.toISOString().slice(0, 10)
            this.dateRange[0] = start.toISOString().slice(0, 10) + " 00:00:00";
            this.dateRange[1] = start.toISOString().slice(0, 10) + " 23:59:59";
            this.getReportList()
        }
      },
      dayBackward(){
        if (this.dateRange != null){
          const start = this.dateRange[0];
          const end = this.dateRange[1];
          start.setTime(start.getTime() + 3600 * 1000 * 24);
          end.setTime(end.getTime() + 3600 * 1000 * 24);
          start.setHours(0);
          start.setMinutes(0);
          start.setSeconds(0);
          end.setHours(23);
          end.setMinutes(59);
          end.setSeconds(59);
          this.dateRange = [start,end]
            const start = new Date(this.currentDate);
            start.setDate(start.getDate() + 1);
            this.currentDate = start.toISOString().slice(0, 10)
            this.dateRange[0] = start.toISOString().slice(0, 10) + " 00:00:00";
            this.dateRange[1] = start.toISOString().slice(0, 10) + " 23:59:59";
            this.getReportList()
        }
      },
      queryDateHandle(){
        const end = new Date();
        const start = new Date();
        start.setHours(0);
        start.setMinutes(0);
        start.setSeconds(0);
        end.setHours(23);
        end.setMinutes(59);
        end.setSeconds(59);
        this.dateRange.push(start,end);
        this.startDate = start;
        this.endDate = end;
        this.getReportList()
          const end = new Date();
          this.currentDate = end.toISOString().slice(0, 10)
          this.dateRange[0] = end.toISOString().slice(0, 10) + " 00:00:00";
          this.dateRange[1] = end.toISOString().slice(0, 10) + " 23:59:59";
      },
        changeDate(){
          console.log(this.currentDate,555)
            this.dateRange[0] = this.currentDate + " 00:00:00"
            this.dateRange[1] = this.currentDate + " 23:59:59"
            this.getReportList()
        },
      sortChange(param){
        this.sort = param.prop;
        this.order = param.order;