马宇豪
2024-02-23 4cfbfd1b425f7b22b876ae6cae95c4fc29ae6bfb
src/views/purchase/dailySaleReport.vue
@@ -1,26 +1,33 @@
<template>
    <div class="container">
      <div class="filter-container">
      <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"
                       @click="dayBackward">后一天</el-button>
<!--            <el-button class="filter-item" style="margin-left: 10px;margin-bottom: 0" type="primary" icon="el-icon-search"-->
<!--                       @click="queryHandle"/>-->
        </el-row>
        <el-row style="padding-top: 10px">
          <el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-back"
                     @click="dayForward">前一天</el-button>
          <el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-right"
                     @click="dayBackward">后一天</el-button>
          <el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-search"
                     @click="queryHandle"/>
        </el-row>
      </div>
      <div class="table_content">
@@ -37,7 +44,7 @@
            @sort-change="sortChange">
            <el-table-column type="index" label="序号" align="center" width="50"></el-table-column>
            <el-table-column type="itemCode" label="流向码" align="center">
            <el-table-column type="itemCode" label="产品码" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.itemCode }}</span>
              </template>
@@ -69,6 +76,7 @@
          </el-table>
        </el-row>
        <br/>
        <el-row>
          <el-pagination
          v-if="recordTotal"
@@ -95,6 +103,7 @@
    name: "dailySaleReport",
    data(){
      return{
        currentDate: '',
        dateRange:[],
        startDate:'',
        endDate:'',
@@ -109,13 +118,14 @@
      }
    },
    mounted() {
      this.queryDateHandle();
    created() {
      this.queryDateHandle()
        this.getReportList()
    },
    methods:{
      queryHandle(){
        this.getReportList();
      },
      // queryHandle(){
      //   this.getReportList();
      // },
      getReportList(){
        const _this = this;
        const params = {};
@@ -166,47 +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;
          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;