WXL (wul)
2 天以前 574b449a39019a59dc90ecc19dda9f63d3aa9636
src/views/index.vue
@@ -3,9 +3,14 @@
    <div class="home" style="margin-top: 40px; margin-left: 20px">
      <!-- 头部两个 -->
      <el-row :gutter="20">
        <el-col :span="11">
        <el-col :span="8">
          <!-- 就诊统计盒子 -->
          <div class="grid-content bg-purple headerBox bgc1">
          <div
            class="grid-content bg-purple headerBox bgc1"
            v-loading="headerLoading"
            element-loading-text="加载中..."
            element-loading-background="rgba(255, 255, 255, 0.55)"
          >
            <div class="title">
              门诊服务<span
                style="
@@ -45,8 +50,13 @@
            </el-row>
          </div>
        </el-col>
        <el-col :span="9">
          <div class="grid-content bg-purple headerBox bgc2">
        <el-col :span="12">
          <div
            class="grid-content bg-purple headerBox bgc2"
            v-loading="headerLoading"
            element-loading-text="加载中..."
            element-loading-background="rgba(255, 255, 255, 0.55)"
          >
            <div class="title">
              出院服务
              <span
@@ -60,7 +70,8 @@
              <span>{{ endatd }} ~ {{ statd }}</span>
            </div>
            <el-row :gutter="20">
              <el-col :span="10">
              <!-- 出院就诊量 -->
              <el-col :span="6">
                <div class="home-user-task-stats">
                  <p style="color: red">{{ DischargeData.rc }}</p>
                </div>
@@ -68,12 +79,31 @@
                  <p>出院就诊量(人次)</p>
                </div>
              </el-col>
              <el-col :span="10">
              <!-- 首次服务 -->
              <el-col :span="6">
                <div class="home-user-task-stats">
                  <p style="color: red">{{ DischargeData.rs }}</p>
                  <div class="text-color2">
                    <p>出院服务量(人次)</p>
                  </div>
                  <p style="color: #67c23a">{{ DischargeData.scsf }}</p>
                </div>
                <div class="text-color2" style="color: #67c23a">
                  <p>首次服务(人次)</p>
                </div>
              </el-col>
              <!-- 再次服务 -->
              <el-col :span="6">
                <div class="home-user-task-stats">
                  <p style="color: #e6a23c">{{ DischargeData.zcsf }}</p>
                </div>
                <div class="text-color2" style="color: #e6a23c">
                  <p>再次服务(人次)</p>
                </div>
              </el-col>
              <!-- 专病服务 -->
              <el-col :span="6">
                <div class="home-user-task-stats">
                  <p style="color: #409eff">{{ DischargeData.zbsf }}</p>
                </div>
                <div class="text-color2" style="color: #409eff">
                  <p>专病服务(人次)</p>
                </div>
              </el-col>
            </el-row>
@@ -84,7 +114,13 @@
      <el-row :gutter="20">
        <el-col :span="20">
          <!-- echars数据可视化 -->
          <div class="grid-content bg-purple" style="min-height: 365px">
          <div
            class="grid-content bg-purple"
            style="min-height: 365px"
            v-loading="chartLoading"
            element-loading-text="图表数据加载中..."
            element-loading-background="rgba(255, 255, 255, 0.55)"
          >
            <div class="title">
              服务统计
              <span>{{ endatd }} ~ {{ statd }}</span>
@@ -128,13 +164,24 @@
        </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"
            v-loading="deptLoading"
            element-loading-text="加载中..."
            element-loading-background="rgba(255, 255, 255, 0.55)"
          >
            <div class="title">
              科室服务量
              <span>{{ endatd }} ~ {{ statd }}</span>
            </div>
            <div class="dept-table-container">
              <el-table v-if="SkuTop.length > 0" style="width: 100%" :data="SkuTop" :height="tableHeight">
              <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"
@@ -153,8 +200,8 @@
                </el-table-column>
              </el-table>
              <div v-else class="empty-tip">
  <el-empty description="暂无科室服务数据"></el-empty>
</div>
                <el-empty description="暂无科室服务数据"></el-empty>
              </div>
            </div>
          </div>
        </el-col>
@@ -316,6 +363,9 @@
  name: "home",
  data() {
    return {
      headerLoading: false, // 顶部统计卡加载中
      chartLoading: false, // 服务统计趋势图加载中
      deptLoading: false, // 科室服务量加载中
      NodeCount: "",
      PrtnerCount: "",
      NodeCount: "",
@@ -331,8 +381,11 @@
        年: "year",
      },
      DischargeData: {
        rs: "",
        rc: "",
        rc: "", // 出院就诊量(总人次)
        rs: "", // 出院服务量(总人次)
        scsf: 0, // 新增:首次服务人次
        zcsf: 0, // 新增:再次服务人次
        zbsf: 0, // 新增:专病服务人次
      },
      OutpatientData: {
        rs: "",
@@ -361,7 +414,7 @@
    atd() {
      return dayjs().subtract(this.dyat, "day").format("YYYY-MM-DD HH:mm:ss");
    },
   statd() {
    statd() {
      if (this.radio1 === "自定义" && this.customDateRange.length > 0) {
        return this.customDateRange[1];
      }
@@ -374,21 +427,21 @@
      return dayjs().subtract(this.dyat, "day").format("YYYY-MM-DD");
    },
    tableHeight() {
    // 根据数据量动态计算高度
    const rowHeight = 40; // 每行大约高度
    const headerHeight = 40; // 表头高度
    const minHeight = 500; // 最小高度
    const maxHeight = 600; // 最大高度
      // 根据数据量动态计算高度
      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);
  }
      const calculatedHeight = this.SkuTop.length * rowHeight + headerHeight;
      return Math.min(Math.max(calculatedHeight, minHeight), maxHeight);
    },
  },
  created() {
    // 各区块独立加载,loading 由各自方法内部管理
    this.getTopdata();
    this.getgraphdata();
    // this.getranking();
    this.$nextTick(function () {
    this.$nextTick(() => {
      this.myEcharts2();
      this.getnodeCollect();
      this.getSkuTop();
@@ -453,17 +506,24 @@
    },
    // top排行
    async getSkuTop() {
      this.deptLoading = true;
      let Rankingdata = {
        startDate: this.endatd,
        endDate: this.statd,
        cy: 1,
      };
      await getDeptRanking(Rankingdata).then((res) => {
        if (res.code == 200) {
          this.SkuTop = res.rows.sort((a, b) => b.rc - a.rc);
          console.log(this.SkuTop, "this.SkuTop");
        }
      });
      try {
        await getDeptRanking(Rankingdata).then((res) => {
          if (res.code == 200) {
            this.SkuTop = res.rows.sort((a, b) => b.rc - a.rc);
            console.log(this.SkuTop, "this.SkuTop");
          }
        });
      } catch (e) {
        console.error("获取科室排行失败:", e);
      } finally {
        this.deptLoading = false;
      }
      // this.SkuTop = [
      //   { amount: 0, count: 123, skuId: "0", skuName: "心肺科" },
@@ -485,6 +545,7 @@
    },
    // 获取头部数据
    getTopdata() {
      this.headerLoading = true;
      let hospCountdata = {
        startDate: this.endatd,
        endDate: this.statd,
@@ -495,36 +556,43 @@
        endDate: this.statd,
        cy: 1,
      };
      // 查询门诊看病人次和人数
      getEChartsPatMedOuthospCount(hospCountdata).then((res) => {
        if (res.code == 200) {
          this.OutpatientData = res.data;
        }
      });
      // 查询出、入院看病人次和人数
      getechartsListCountdata(Countdata).then((res) => {
        if (res.code == 200) {
          this.DischargeData = res.data;
        }
      // 查询门诊看病人次和人数 / 查询出、入院看病人次和人数
      return Promise.all([
        getEChartsPatMedOuthospCount(hospCountdata).then((res) => {
          if (res.code == 200) {
            this.OutpatientData = res.data;
          }
        }),
        getechartsListCountdata(Countdata).then((res) => {
          if (res.code == 200) {
            this.DischargeData = res.data;
          }
        }),
      ]).finally(() => {
        this.headerLoading = false;
      });
    },
    // 获取中部线柱图数据
    getranking() {},
    async getgraphdata() {
      this.chartLoading = true;
      let params = {
        startDate: this.endatd,
        endDate: this.statd,
        timeType: this.getTimeType()
        timeType: this.getTimeType(),
      };
      try {
        const res = await getServiceStatistics(params);
        if (res.code === 200) {
          this.processChartData(res.data);
        } else {
          this.chartLoading = false;
        }
      } catch (error) {
        console.error("获取图表数据失败:", error);
        this.chartLoading = false;
      }
    },
@@ -542,7 +610,7 @@
      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');
        const diffDays = end.diff(start, "day");
        return diffDays > 60 ? "month" : "day";
      }
@@ -562,18 +630,19 @@
      const pmoData = [];
      sortedData.forEach((item) => {
  // 根据时间类型格式化显示
  const timeType = this.getTimeType();
  const timeLabel = timeType === "day"
    ? dayjs(item.timePeriod).format("MM-DD")
    : dayjs(item.timePeriod).format("YYYY-MM");
        // 根据时间类型格式化显示
        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);
  outpatientFollowData.push(item.outpatientFollowCount);
  pmiData.push(item.pmiCount);
  pmoData.push(item.pmoCount);
});
        xAxisData.push(timeLabel);
        dischargeFollowData.push(item.dischargeFollowCount);
        outpatientFollowData.push(item.outpatientFollowCount);
        pmiData.push(item.pmiCount);
        pmoData.push(item.pmoCount);
      });
      // 更新图表
      this.updateChart(
@@ -631,6 +700,7 @@
      };
      this.myChart2.setOption(option);
      this.chartLoading = false;
    },
    // 计算最优的interval值
@@ -867,7 +937,6 @@
    },
    // 页面变化调整大小
    handleResize() {
      console.log(111);
      // 调整 ECharts 图表大小
      if (this.myChart2) {
        this.myChart2.resize();
@@ -1167,6 +1236,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;
@@ -1179,3 +1254,25 @@
  background-color: #f9fafc;
}
</style>
<style>
/* 首页分块加载动画:更轻量、更清爽的 loading */
.home .el-loading-mask {
  background-color: rgba(255, 255, 255, 0.55);
}
.home .el-loading-spinner {
  top: 50%;
  margin-top: -25px;
  width: 100%;
  text-align: center;
}
.home .el-loading-spinner .el-icon-loading {
  font-size: 30px;
  color: #409eff;
}
.home .el-loading-spinner .el-loading-text {
  margin-top: 8px;
  color: #606266;
  font-size: 13px;
}
</style>