WXL (wul)
5 天以前 5e3f064530fe71987e2a5920fe59967ef348cbd7
src/views/index.vue
@@ -20,7 +20,7 @@
            <el-row :gutter="20">
              <el-col :span="10">
                <div class="home-user-task-stats">
                  <p>{{ OutpatientData.rs }}</p>
                  <p>{{ OutpatientData.rc }}</p>
                  <div class="text-color2">
                    <p>门诊就诊量(人次)</p>
                  </div>
@@ -28,7 +28,7 @@
              </el-col>
              <el-col :span="10">
                <div class="home-user-task-stats">
                  <p>{{ OutpatientData.rc }}</p>
                  <p>{{ OutpatientData.rs }}</p>
                  <div class="text-color2">
                    <p>门诊服务量(人次)</p>
                  </div>
@@ -62,7 +62,7 @@
            <el-row :gutter="20">
              <el-col :span="10">
                <div class="home-user-task-stats">
                  <p style="color: red">{{ DischargeData.rs }}</p>
                  <p style="color: red">{{ DischargeData.rc }}</p>
                </div>
                <div class="text-color2">
                  <p>出院就诊量(人次)</p>
@@ -70,7 +70,7 @@
              </el-col>
              <el-col :span="10">
                <div class="home-user-task-stats">
                  <p style="color: red">{{ DischargeData.rc }}</p>
                  <p style="color: red">{{ DischargeData.rs }}</p>
                  <div class="text-color2">
                    <p>出院服务量(人次)</p>
                  </div>
@@ -94,15 +94,30 @@
                style="margin-left: 390px"
                @change="changes"
              >
                <el-radio-button label="周" @click="dyat = 7"></el-radio-button>
                <el-radio-button
                  label="月"
                  @click="dyat = 30"
                  label="近一周"
                  @click="dyat = 7"
                ></el-radio-button>
                <el-radio-button
                  label="年"
                  @click="dyat = 360"
                  label="近一月"
                  @click="dyat = 31"
                ></el-radio-button>
                <el-radio-button
                  label="近一年"
                  @click="dyat = 365"
                ></el-radio-button>
                <el-radio-button label="自定义">
                  <el-date-picker
                    v-if="radio1 === '自定义'"
                    v-model="customDateRange"
                    type="daterange"
                    range-separator="至"
                    start-placeholder="开始日期"
                    end-placeholder="结束日期"
                    value-format="yyyy-MM-dd"
                    @change="handleCustomDateChange"
                  ></el-date-picker>
                </el-radio-button>
              </el-radio-group>
            </div>
            <!-- 中部线性柱状图 -->
@@ -113,13 +128,18 @@
        </el-col>
        <!-- 右边列表 -->
        <el-col :span="4" class="aside">
          <div class="grid-content bg-purple" style="margin-top: -180px">
          <div class="grid-contentsa bg-purple" style="margin-top: -180px">
            <div class="title">
              科室服务量
              <span>{{ endatd }} ~ {{ statd }}</span>
            </div>
            <div style="max-height: 690px; width: 100%; overflow: auto">
              <el-table style="width: 100%" :data="SkuTop">
            <div class="dept-table-container">
              <el-table
                v-if="SkuTop.length > 0"
                style="width: 100%"
                :data="SkuTop"
                :height="tableHeight"
              >
                <template v-for="(item, index) in SkuTop"></template>
                <el-table-column
                  prop="order"
@@ -129,7 +149,7 @@
                ></el-table-column>
                <el-table-column
                  prop="deptname"
                  width="88"
                  width="120"
                  class-name="name"
                ></el-table-column>
@@ -137,24 +157,26 @@
                  <template slot-scope="scope"> {{ scope.row.rc }}次 </template>
                </el-table-column>
              </el-table>
              <div v-else class="empty-tip">
                <el-empty description="暂无科室服务数据"></el-empty>
              </div>
            </div>
          </div>
        </el-col>
      </el-row>
      <!-- 底部一个 -->
      <el-row :gutter="20" style="margin-bottom: 20px">
        <el-col :span="24">
        <!-- <el-col :span="24">
          <div class="grid-content bg-purple" style="min-height: 300px">
            <div class="title">
              宣教统计
              <span class="el-icon-s-unfold moreIcon"></span>
            </div>
            <div class="cooperate">
              <!-- 合作区域 -->
              <div class="pieChart" id="pieCharts"></div>
            </div>
          </div>
        </el-col>
        </el-col> -->
        <!-- <el-col :span="9">
          <div class="grid-content bg-purple" style="min-height: 300px">
            <div class="title">
@@ -306,7 +328,7 @@
      mypPieCharts: null,
      lastWidth: window.innerWidth,
      lastHeight: window.innerHeight,
      radio1: "周",
      radio1: "近一年",
      ticketStatistics: {},
      timeTypeMap: {
        周: "day",
@@ -330,7 +352,8 @@
      SkuTop: [],
      cylinderSeries: [],
      cylinderXAxis: [],
      dyat: 30,
      customDateRange: [], // 自定义日期范围
      dyat: 365,
      intervalId: null,
    };
  },
@@ -344,16 +367,32 @@
      return dayjs().subtract(this.dyat, "day").format("YYYY-MM-DD HH:mm:ss");
    },
    statd() {
      if (this.radio1 === "自定义" && this.customDateRange.length > 0) {
        return this.customDateRange[1];
      }
      return dayjs().format("YYYY-MM-DD");
    },
    endatd() {
      if (this.radio1 === "自定义" && this.customDateRange.length > 0) {
        return this.customDateRange[0];
      }
      return dayjs().subtract(this.dyat, "day").format("YYYY-MM-DD");
    },
    tableHeight() {
      // 根据数据量动态计算高度
      const rowHeight = 40; // 每行大约高度
      const headerHeight = 40; // 表头高度
      const minHeight = 500; // 最小高度
      const maxHeight = 600; // 最大高度
      const calculatedHeight = this.SkuTop.length * rowHeight + headerHeight;
      return Math.min(Math.max(calculatedHeight, minHeight), maxHeight);
    },
  },
  created() {
    this.getTopdata();
    this.getgraphdata();
    this.getranking();
    // this.getranking();
    this.$nextTick(function () {
      this.myEcharts2();
      this.getnodeCollect();
@@ -372,15 +411,35 @@
  methods: {
    // 改变时间事件
    changes() {
      if (this.radio1 == "周") {
        this.dyat = 7;
      } else if (this.radio1 == "月") {
        this.dyat = 30;
      } else {
        this.dyat = 360;
      switch (this.radio1) {
        case "近一周":
          this.dyat = 7;
          break;
        case "近一月":
          this.dyat = 30;
          break;
        case "近一年":
          this.dyat = 365;
          break;
        case "自定义":
          // 自定义日期处理在handleCustomDateChange方法中
          return;
      }
      this.refreshData();
    },
    // 处理自定义日期变化
    handleCustomDateChange(range) {
      if (!range || range.length !== 2) return;
      this.customDateRange = range;
      this.refreshData();
    },
    // 统一刷新数据的方法
    refreshData() {
      this.getgraphdata();
      this.getranking();
      // this.getranking();
      this.getTopdata();
      this.myEcharts2();
      this.getnodeCollect();
@@ -461,12 +520,7 @@
      let params = {
        startDate: this.endatd,
        endDate: this.statd,
        timeType:
          this.radio1 === "周"
            ? "day"
            : this.radio1 === "月"
            ? "month"
            : "year",
        timeType: this.getTimeType(),
      };
      try {
@@ -477,6 +531,28 @@
      } catch (error) {
        console.error("获取图表数据失败:", error);
      }
    },
    // 获取时间类型
    getTimeType() {
      if (this.radio1 === "近一周" || this.radio1 === "近一月") {
        return "day";
      }
      if (this.radio1 === "近一年") {
        return "month";
      }
      // 自定义日期范围
      if (this.radio1 === "自定义" && this.customDateRange.length === 2) {
        const start = dayjs(this.customDateRange[0]);
        const end = dayjs(this.customDateRange[1]);
        const diffDays = end.diff(start, "day");
        return diffDays > 60 ? "month" : "day";
      }
      return "day"; // 默认返回day类型
    },
    processChartData(data) {
      // 按时间排序确保数据顺序正确
@@ -492,14 +568,11 @@
      sortedData.forEach((item) => {
        // 根据时间类型格式化显示
        let timeLabel = item.timePeriod;
        if (this.radio1 === "周") {
          timeLabel = dayjs(item.timePeriod).format("MM-DD");
        } else if (this.radio1 === "月") {
          timeLabel = item.timePeriod.split("-")[1] + "月";
        } else {
          timeLabel = item.timePeriod.split("-")[0] + "年";
        }
        const timeType = this.getTimeType();
        const timeLabel =
          timeType === "day"
            ? dayjs(item.timePeriod).format("MM-DD")
            : dayjs(item.timePeriod).format("YYYY-MM");
        xAxisData.push(timeLabel);
        dischargeFollowData.push(item.dischargeFollowCount);
@@ -623,7 +696,7 @@
          },
        },
        legend: {
          data: ["出院随访量", "门诊随访量", "出院服务人次", "门诊服务人次"],
          data: ["出院服务量", "门诊服务量", "出院就诊人次", "门诊就诊人次"],
        },
        xAxis: [
          {
@@ -655,7 +728,7 @@
        grid: { top: "35%" },
        series: [
          {
            name: "出院随访量",
            name: "出院服务量",
            type: "bar",
            tooltip: {
              valueFormatter: function (value) {
@@ -665,7 +738,7 @@
            data: [], // 初始为空,将通过API数据填充
          },
          {
            name: "门诊随访量",
            name: "门诊服务量",
            type: "bar",
            tooltip: {
              valueFormatter: function (value) {
@@ -675,7 +748,7 @@
            data: [], // 初始为空,将通过API数据填充
          },
          {
            name: "出院服务人次",
            name: "出院就诊人次",
            type: "line",
            smooth: 0.3,
            yAxisIndex: 1,
@@ -687,7 +760,7 @@
            data: [], // 初始为空,将通过API数据填充
          },
          {
            name: "门诊服务人次",
            name: "门诊就诊人次",
            type: "line",
            smooth: 0.3,
            yAxisIndex: 1,
@@ -836,6 +909,12 @@
  .echars1 {
    flex: 1;
  }
}
.dept-table-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0; /* 重要:允许内容收缩 */
}
::v-deep .el-table {
  td:first-child {
@@ -1094,6 +1173,12 @@
  padding: 0 10px;
  text-align: center;
}
.grid-contentsa {
  min-height: 600px;
  border-radius: 20px;
  padding: 0 10px;
  text-align: center;
}
.grid-contents {
  min-height: 36px;