qinxianzhangyao
2024-03-25 c2943d4c365e6a4719fbd5fedf89f8c2232cf88e
src/views/count/chart/index.vue
@@ -1,25 +1,10 @@
<template>
  <div>
    <el-form
      :model="queryParams"
      ref="tableList"
      :inline="true"
      label-width="76px"
      style="margin: 10px 10px"
    >
    <el-form :model="queryParams" ref="tableList" :inline="true" label-width="76px" style="margin: 10px 10px">
      <el-form-item label="体检时间" prop="date">
        <el-date-picker
          v-model="value1"
          type="datetimerange"
          align="right"
          start-placeholder="开始日期"
          :picker-options="pickerOptions"
          end-placeholder="结束日期"
          :default-time="['00:00:00', '23:00:00']"
          format="yyyy-MM-dd HH:mm"
          value-format="yyyy-MM-dd HH:mm"
          @change="dateChangebirthday1"
        >
        <el-date-picker v-model="value1" type="datetimerange" align="right" start-placeholder="开始日期"
          :picker-options="pickerOptions" end-placeholder="结束日期" :default-time="['00:00:00', '23:00:00']"
          format="yyyy-MM-dd HH:mm" value-format="yyyy-MM-dd HH:mm" @change="dateChangebirthday1">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
@@ -32,8 +17,8 @@
    </div>
  </div>
</template>
<script>
import { GetChartByDate } from "@/api/count/chart";
const echarts = require("echarts/lib/echarts");
@@ -55,32 +40,32 @@
  data() {
    return {
      pickerOptions: {
          shortcuts: [{
            text: '最近一周',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit('pick', [start, end]);
            }
          }, {
            text: '最近一个月',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit('pick', [start, end]);
            }
          }, {
            text: '最近三个月',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit('pick', [start, end]);
            }
          }]
        },
        shortcuts: [{
          text: '最近一周',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '最近一个月',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '最近三个月',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
            picker.$emit('pick', [start, end]);
          }
        }]
      },
      value1: "",
      DateList: [],
      startTime: "",
@@ -93,21 +78,31 @@
    };
  },
created() {
  created() {
    this.getdate();
  },
  methods: {
    getdate() {
      getNewDateList().then((res) => {
        this.value1 = [
            moment(res.data).format("YYYY-MM-DD 00:00:00"),
            moment(res.data).format("YYYY-MM-DD 23:59:00")
          ];;
          moment(res.data).format("YYYY-MM-DD 00:00:00"),
          moment(res.data).format("YYYY-MM-DD 23:59:00")
        ];;
        this.getList()
      });
    },
    getList() {
      this.queryParams.startDate = this.startTime[0];
      this.queryParams.endDate = this.startTime[1];
      if (this.value1) {
        this.queryParams.startDate = this.value1[0];
        this.queryParams.endDate = this.value1[1];
      }else if(this.value1 == null) {
        this.queryParams.startDate = null;
        this.queryParams.endDate = null;
      } else {
        this.queryParams.startDate = this.startTime[0];
        this.queryParams.endDate = this.startTime[1];
      }
      GetChartByDate(this.queryParams).then((response) => {
        this.DateList = response;
        console.log(this.DateList);
@@ -170,7 +165,4 @@
  height: 580px;
  background-color: #fff;
}
</style>
</style>