WXL (wul)
8 天以前 58cd24c6664429e2a28eef6f7ee2e76c0e9c2d90
src/views/index.vue
@@ -7,49 +7,48 @@
          <!-- 就诊统计盒子 -->
          <div class="grid-content bg-purple headerBox bgc1">
            <div class="title">
              患者统计<span
              门诊服务<span
                style="
                  font-size: 25px;
                  font-weight: 600;
                  text-shadow: 2px 4px 7px rgb(85 132 255 / 50%);
                  color: black;
                "
                >12322 (人)</span
              >
              ></span>
              <span>{{ endatd }} ~ {{ statd }}</span>
            </div>
            <el-row :gutter="20">
              <el-col :span="8">
              <el-col :span="10">
                <div class="home-user-task-stats">
                  <p>{{ 11231 }}</p>
                  <p>{{ OutpatientData.rc }}</p>
                  <div class="text-color2">
                    <p>门诊总数(人)</p>
                    <p>门诊就诊量(人次)</p>
                  </div>
                </div>
              </el-col>
              <el-col :span="7">
              <el-col :span="10">
                <div class="home-user-task-stats">
                  <p>{{ 9207 }}</p>
                  <p>{{ OutpatientData.rs }}</p>
                  <div class="text-color2">
                    <p>住院总数(人)</p>
                    <p>门诊服务量(人次)</p>
                  </div>
                </div>
              </el-col>
              <el-col :span="7">
              <!-- <el-col :span="7">
                <div class="home-user-task-stats">
                  <p>{{ 1209 }}</p>
                  <div class="text-color2">
                    <p>体检总数(人)</p>
                  </div>
                </div>
              </el-col>
              </el-col> -->
            </el-row>
          </div>
        </el-col>
        <el-col :span="9">
          <div class="grid-content bg-purple headerBox bgc2">
            <div class="title">
              门诊服务总数
              出院服务
              <span
                style="
                  font-size: 25px;
@@ -57,24 +56,23 @@
                  font-weight: 600;
                  color: red;
                "
                >12322 (人)</span
              >
              ></span>
              <span>{{ endatd }} ~ {{ statd }}</span>
            </div>
            <el-row :gutter="20">
              <el-col :span="12">
              <el-col :span="10">
                <div class="home-user-task-stats">
                  <p style="color: red">{{ 3453 }}</p>
                  <p style="color: red">{{ DischargeData.rc }}</p>
                </div>
                <div class="text-color2">
                  <p>住院服务人数</p>
                  <p>出院就诊量(人次)</p>
                </div>
              </el-col>
              <el-col :span="12">
              <el-col :span="10">
                <div class="home-user-task-stats">
                  <p style="color: red">{{ 4213 }}</p>
                  <p style="color: red">{{ DischargeData.rs }}</p>
                  <div class="text-color2">
                    <p>体检服务人数</p>
                    <p>出院服务量(人次)</p>
                  </div>
                </div>
              </el-col>
@@ -88,7 +86,7 @@
          <!-- echars数据可视化 -->
          <div class="grid-content bg-purple" style="min-height: 365px">
            <div class="title">
              就诊统计
              服务统计
              <span>{{ endatd }} ~ {{ statd }}</span>
              <el-radio-group
                v-model="radio1"
@@ -107,17 +105,17 @@
                ></el-radio-button>
              </el-radio-group>
            </div>
            <!-- 中间echars -->
            <!-- 中部线性柱状图 -->
            <div class="boxEchars">
              <div class="echars1" id="echars"></div>
            </div>
          </div>
        </el-col>
        <!-- 中间和右边 -->
        <!-- 右边列表 -->
        <el-col :span="4" class="aside">
          <div class="grid-content bg-purple" style="margin-top: -180px">
            <div class="title">
              健康宣教
              科室服务量
              <span>{{ endatd }} ~ {{ statd }}</span>
            </div>
            <div style="max-height: 690px; width: 100%; overflow: auto">
@@ -130,14 +128,13 @@
                  type="index"
                ></el-table-column>
                <el-table-column
                  prop="skuName"
                  prop="deptname"
                  width="88"
                  class-name="name"
                ></el-table-column>
                <el-table-column prop="count" class-name="count">
                  <template slot-scope="scope">
                    {{ scope.row.count }}次
                  </template>
                <el-table-column prop="rc" class-name="rc">
                  <template slot-scope="scope"> {{ scope.row.rc }}次 </template>
                </el-table-column>
              </el-table>
            </div>
@@ -146,7 +143,7 @@
      </el-row>
      <!-- 底部一个 -->
      <el-row :gutter="20" style="margin-bottom: 20px">
        <el-col :span="15">
        <el-col :span="24">
          <div class="grid-content bg-purple" style="min-height: 300px">
            <div class="title">
              宣教统计
@@ -158,7 +155,7 @@
            </div>
          </div>
        </el-col>
        <el-col :span="9">
        <!-- <el-col :span="9">
          <div class="grid-content bg-purple" style="min-height: 300px">
            <div class="title">
              各项服务统计
@@ -167,7 +164,7 @@
            <div class="empenty">
              <el-row>
                <el-col :span="3"
                  ><div class="grid-contents bg-purples" >出院:</div></el-col
                  ><div class="grid-contents bg-purples">出院:</div></el-col
                >
                <el-col :span="7">
                  <div style="display: flex">
@@ -187,13 +184,13 @@
                    <div class="subtitle">复诊通知</div>
                    <div class="grid-contents bg-purple-light">0次</div>
                  </div>
                </el-col> </el-row
              >
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="3"
                  ><div class="grid-contents bg-purples" ></div></el-col
                >
                <el-col :span="7" >
                  ><div class="grid-contents bg-purples"></div
                ></el-col>
                <el-col :span="7">
                  <div style="display: flex">
                    <div class="subtitle">出院评估</div>
                    <div class="grid-contents bg-purple-light">0次</div>
@@ -212,16 +209,15 @@
                    <div class="grid-contents bg-purple-light">0次</div>
                  </div>
                </el-col>
                 </el-row
              >
              </el-row>
              <el-row>
                <el-col :span="3"
                  ><div class="grid-contents bg-purples" >门诊:</div></el-col
                  ><div class="grid-contents bg-purples">门诊:</div></el-col
                >
                <el-col :span="7">
                  <div style="display: flex">
                    <div class="subtitle">门诊随访</div>
                    <div class="subtitle">影像随访</div>
                    <div class="grid-contents bg-purple-light">0次</div>
                  </div>
                </el-col>
@@ -237,12 +233,12 @@
                    <div class="subtitle">复诊通知</div>
                    <div class="grid-contents bg-purple-light">0次</div>
                  </div>
                </el-col> </el-row
              >
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="3"
                  ><div class="grid-contents bg-purples" ></div></el-col
                >
                  ><div class="grid-contents bg-purples"></div
                ></el-col>
                <el-col :span="7">
                  <div style="display: flex">
                    <div class="subtitle">满意度调查</div>
@@ -255,12 +251,10 @@
                    <div class="grid-contents bg-purple-light">0次</div>
                  </div>
                </el-col>
                </el-row
              >
              </el-row>
              <el-row>
                <el-col :span="3"
                  ><div class="grid-contents bg-purples" >在院:</div></el-col
                  ><div class="grid-contents bg-purples">在院:</div></el-col
                >
                <el-col :span="7">
                  <div style="display: flex">
@@ -280,23 +274,25 @@
                    <div class="subtitle">其他通知</div>
                    <div class="grid-contents bg-purple-light">0次</div>
                  </div>
                </el-col> </el-row
              >
                </el-col>
              </el-row>
            </div>
          </div>
        </el-col>
        </el-col> -->
      </el-row>
    </div>
  </div>
</template>
<script>
// import {
//   getUserWork,
//   getregionCollect,
//   getregionOrderCount,
// } from "@/api/home";
import {
  getEChartsPatMedOuthospCount,
  getechartsListCountdata,
  getechartsMedOuthospList,
  getechartsMedInhospList,
  getServiceStatistics,
  getDeptRanking,
} from "@/api/AiCentre/index";
import dayjs from "dayjs";
export default {
@@ -312,6 +308,19 @@
      lastHeight: window.innerHeight,
      radio1: "周",
      ticketStatistics: {},
      timeTypeMap: {
        周: "day",
        月: "month",
        年: "year",
      },
      DischargeData: {
        rs: "",
        rc: "",
      },
      OutpatientData: {
        rs: "",
        rc: "",
      },
      order: "",
      Count: "",
      datatni: [],
@@ -321,7 +330,7 @@
      SkuTop: [],
      cylinderSeries: [],
      cylinderXAxis: [],
      dyat: 30,
      dyat: 6,
      intervalId: null,
    };
  },
@@ -342,13 +351,11 @@
    },
  },
  created() {
    this.getTopdata();
    this.getgraphdata();
    this.getranking();
    this.$nextTick(function () {
      this.getregionAmountCollect();
      this.getUserWorks();
      this.getregionCollect();
      this.getregionOrderCount();
      this.getNodeCount();
      this.getPrtnerCount();
      this.myEcharts2();
      this.getnodeCollect();
      this.getSkuTop();
    });
@@ -366,99 +373,237 @@
    // 改变时间事件
    changes() {
      if (this.radio1 == "周") {
        this.dyat = 7;
        this.dyat = 6;
      } else if (this.radio1 == "月") {
        this.dyat = 30;
      } else {
        this.dyat = 360;
        this.dyat = 364;
      }
      this.getregionAmountCollect();
      this.getUserWorks();
      this.getregionCollect();
      this.getregionOrderCount();
      this.getNodeCount();
      this.getPrtnerCount();
      this.getgraphdata();
      this.getranking();
      this.getTopdata();
      this.myEcharts2();
      this.getnodeCollect();
      this.getSkuTop();
    },
    // 获取点位总数
    async getNodeCount() {
      // const res = await getNodeCount();
      // this.NodeCount = res.data;
    },
    // 获取合作商总数
    async getPrtnerCount() {
      // const res = await getPrtnerCount();
      // this.PrtnerCount = res.data;
    },
    // 合作商点位汇总统计饼状图
    async getnodeCollect() {
      // const res = await getnodeCollect();
      // this.nodeCollect = res.data;
      this.nodeCollect = [
        { name: "门诊随访", value: 1232 },
        { name: "影像随访", value: 1232 },
        { name: "出院随访", value: 342 },
      ];
      this.myPieChart();
    },
    // top排行
    async getSkuTop() {
      // const res = await getSkuTop(10, this.endatd, this.statd);
      // this.SkuTop = res.data;
      this.SkuTop = [
        { amount: 0, count: 123, skuId: "0", skuName: "心肺科" },
        { amount: 0, count: 122, skuId: "0", skuName: "肾脏科" },
        { amount: 0, count: 112, skuId: "0", skuName: "泌尿科" },
        { amount: 0, count: 111, skuId: "0", skuName: "男科" },
        { amount: 0, count: 102, skuId: "0", skuName: "妇产科" },
        { amount: 0, count: 98, skuId: "0", skuName: "外科" },
        { amount: 0, count: 89, skuId: "0", skuName: "急诊" },
        { amount: 0, count: 88, skuId: "0", skuName: "器械科" },
        { amount: 0, count: 87, skuId: "0", skuName: "骨科" },
        { amount: 0, count: 67, skuId: "0", skuName: "放射科" },
        { amount: 0, count: 89, skuId: "0", skuName: "急诊" },
        { amount: 0, count: 88, skuId: "0", skuName: "器械科" },
        { amount: 0, count: 87, skuId: "0", skuName: "骨科" },
        { amount: 0, count: 67, skuId: "0", skuName: "放射科" },
      ];
      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");
        }
      });
      // this.SkuTop = [
      //   { amount: 0, count: 123, skuId: "0", skuName: "心肺科" },
      //   { amount: 0, count: 122, skuId: "0", skuName: "肾脏科" },
      //   { amount: 0, count: 112, skuId: "0", skuName: "泌尿科" },
      //   { amount: 0, count: 111, skuId: "0", skuName: "男科" },
      //   { amount: 0, count: 102, skuId: "0", skuName: "妇产科" },
      //   { amount: 0, count: 98, skuId: "0", skuName: "外科" },
      //   { amount: 0, count: 89, skuId: "0", skuName: "急诊" },
      //   { amount: 0, count: 88, skuId: "0", skuName: "器械科" },
      //   { amount: 0, count: 87, skuId: "0", skuName: "骨科" },
      //   { amount: 0, count: 67, skuId: "0", skuName: "放射科" },
      //   { amount: 0, count: 89, skuId: "0", skuName: "急诊" },
      //   { amount: 0, count: 88, skuId: "0", skuName: "器械科" },
      //   { amount: 0, count: 87, skuId: "0", skuName: "骨科" },
      //   { amount: 0, count: 67, skuId: "0", skuName: "放射科1" },
      //   { amount: 0, count: 67, skuId: "0", skuName: "放射科2" },
      // ];
    },
    // 获取工单数量
    async getUserWorks() {
      // const res = await getUserWork(this.atd, this.td);
      // this.ticketStatistics = res.data[0];
    // 获取头部数据
    getTopdata() {
      let hospCountdata = {
        startDate: this.endatd,
        endDate: this.statd,
        cy: 1,
      };
      let Countdata = {
        startDate: this.endatd,
        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;
        }
      });
    },
    // 获取就诊数量
    async getregionOrderCount() {
      // const res = await getregionOrderCount({
      //   start: this.atd,
      //   end: this.td,
      // });
      // this.order = res.data;
    // 获取中部线柱图数据
    getranking() {},
    async getgraphdata() {
      let params = {
        startDate: this.endatd,
        endDate: this.statd,
        timeType:
          this.radio1 === "周"
            ? "day"
            : this.radio1 === "月"
            ? "month"
            : "year",
      };
      try {
        const res = await getServiceStatistics(params);
        if (res.code === 200) {
          this.processChartData(res.data);
        }
      } catch (error) {
        console.error("获取图表数据失败:", error);
      }
    },
    // 获取总量数量
    async getregionCollect() {
      // const res = await getregionCollect({
      //   start: this.atd,
      //   end: this.td,
      // });
      // this.Count = (res.data / 1000000).toFixed(2);
    processChartData(data) {
      // 按时间排序确保数据顺序正确
      const sortedData = [...data].sort(
        (a, b) => new Date(a.timePeriod) - new Date(b.timePeriod)
      );
      const xAxisData = [];
      const dischargeFollowData = [];
      const outpatientFollowData = [];
      const pmiData = [];
      const pmoData = [];
      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] + "年";
        }
        xAxisData.push(timeLabel);
        dischargeFollowData.push(item.dischargeFollowCount);
        outpatientFollowData.push(item.outpatientFollowCount);
        pmiData.push(item.pmiCount);
        pmoData.push(item.pmoCount);
      });
      // 更新图表
      this.updateChart(
        xAxisData,
        dischargeFollowData,
        outpatientFollowData,
        pmiData,
        pmoData
      );
    },
    updateChart(
      xAxisData,
      dischargeFollowData,
      outpatientFollowData,
      pmiData,
      pmoData
    ) {
      if (!this.myChart2) {
        this.myEcharts2();
        return;
      }
      // 计算随访量的最大值
      const maxFollow = Math.max(
        ...dischargeFollowData,
        ...outpatientFollowData
      );
      // 计算服务人次的最大值
      const maxService = Math.max(...pmiData, ...pmoData);
      // 动态计算interval值
      const followInterval = this.calculateOptimalInterval(maxFollow);
      const serviceInterval = this.calculateOptimalInterval(maxService);
      const option = {
        xAxis: {
          data: xAxisData,
        },
        yAxis: [
          {
            interval: followInterval,
            max: Math.ceil(maxFollow / followInterval) * followInterval,
          },
          {
            interval: serviceInterval,
            max: Math.ceil(maxService / serviceInterval) * serviceInterval,
          },
        ],
        series: [
          { data: dischargeFollowData },
          { data: outpatientFollowData },
          { data: pmiData },
          { data: pmoData },
        ],
      };
      this.myChart2.setOption(option);
    },
    // 计算最优的interval值
    calculateOptimalInterval(maxValue) {
      if (maxValue <= 0) return 50; // 默认值
      // 根据最大值计算合适的间隔
      const magnitude = Math.pow(10, Math.floor(Math.log10(maxValue)));
      const stepRatio = maxValue / magnitude;
      let interval;
      if (stepRatio > 5) {
        interval = magnitude;
      } else if (stepRatio > 2) {
        interval = magnitude / 2;
      } else {
        interval = magnitude / 5;
      }
      // 确保interval是整数
      interval = Math.round(interval);
      // 限制最小间隔
      return Math.max(interval, 50);
    },
    // 获取线状图时间
    async getregionAmountCollect() {
      // const res = await getregionAmountCollect(1, this.endatd, this.statd);
      //getregionAmountCollect(1, this.endatd, this.statd);
      // this.xAxis = res.data.xAxis;
      // this.series = res.data.series;
      this.xAxis = ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月"];
      this.series = [123, 123, 223, 212, 432, 123, 442, 234];
      this.myEcharts2();
    },
    // 线性图
    // 线性图及柱状图
    myEcharts2() {
      var echarts = require("echarts");
      var myChart2 = echarts.init(document.getElementById("echars"));
      this.myChart2 = myChart2;
      var option2 = {
        tooltip: {
          trigger: "axis",
@@ -478,30 +623,12 @@
          },
        },
        legend: {
          data: [
            "出院随访量",
            "门诊随访量",
            "在院随访量",
            "门诊复诊通知",
            "出院复诊通知",
            "在院评估量",
          ],
          data: ["出院服务量", "门诊服务量", "出院就诊人次", "门诊就诊人次"],
        },
        xAxis: [
          {
            type: "category",
            data: [
              "一月",
              "二月",
              "三月",
              "四月",
              "五月",
              "六月",
              "七月",
              "八月",
              "九月",
              "十月",
            ],
            data: [], // 初始为空,将通过API数据填充
            axisPointer: {
              type: "shadow",
            },
@@ -512,18 +639,14 @@
            type: "value",
            name: "随访量",
            min: 0,
            max: 250,
            interval: 50,
            axisLabel: {
              formatter: "{value} 人",
            },
          },
          {
            type: "value",
            name: "复诊/评估次数",
            name: "服务人次",
            min: 0,
            max: 250,
            interval: 50,
            axisLabel: {
              formatter: "{value} 次",
            },
@@ -532,38 +655,27 @@
        grid: { top: "35%" },
        series: [
          {
            name: "出院随访量",
            name: "出院服务量",
            type: "bar",
            tooltip: {
              valueFormatter: function (value) {
                return value + " 人";
              },
            },
            data: [120, 150, 165, 90, 140, 200, 130, 85, 175, 95, 110, 160],
            data: [], // 初始为空,将通过API数据填充
          },
          {
            name: "门诊随访量",
            name: "门诊服务量",
            type: "bar",
            tooltip: {
              valueFormatter: function (value) {
                return value + " 人";
              },
            },
            data: [102, 190, 135, 88, 175, 160, 83, 145, 200, 110, 97, 180],
            data: [], // 初始为空,将通过API数据填充
          },
          {
            name: "在院随访量",
            type: "bar",
            tooltip: {
              valueFormatter: function (value) {
                return value + " 人";
              },
            },
            data: [145, 92, 178, 134, 167, 85, 199, 112, 156, 88, 120, 145],
          },
          {
            name: "出院复诊通知",
            name: "出院就诊人次",
            type: "line",
            smooth: 0.3,
            yAxisIndex: 1,
@@ -572,10 +684,10 @@
                return value + " 次";
              },
            },
            data: [45, 123, 78, 156, 89, 34, 199, 112, 67, 145, 88, 175],
            data: [], // 初始为空,将通过API数据填充
          },
          {
            name: "门诊复诊通知",
            name: "门诊就诊人次",
            type: "line",
            smooth: 0.3,
            yAxisIndex: 1,
@@ -584,41 +696,15 @@
                return value + " 次";
              },
            },
            data: [102, 190, 135, 88, 175, 160, 83, 145, 200, 110, 97, 180],
          },
          {
            name: "在院评估量",
            type: "line",
            smooth: 0.3,
            yAxisIndex: 1,
            tooltip: {
              valueFormatter: function (value) {
                return value + " 次";
              },
            },
            data: [120, 150, 165, 90, 140, 200, 130, 85, 175, 95, 110, 160],
            data: [], // 初始为空,将通过API数据填充
          },
        ],
      };
      myChart2.on("updateAxisPointer", function (event) {
        const xAxisInfo = event.axesInfo[0];
        if (xAxisInfo) {
          const dimension = xAxisInfo.value + 1;
          myChart2.setOption({
            series: {
              id: "pie",
              label: {
                formatter: "{b}: {@[" + dimension + "]} ",
              },
              encode: {
                value: dimension,
                tooltip: dimension,
              },
            },
          });
        }
      });
      myChart2.setOption(option2);
      // 初始加载数据
      this.getgraphdata();
    },
    // 饼状图
    myPieChart() {
@@ -998,7 +1084,7 @@
  line-height: 36px;
  width: 6vw;
}
.subtitle{
.subtitle {
  text-align: center;
  align-items: center;
}
@@ -1006,7 +1092,9 @@
  min-height: 36px;
  border-radius: 20px;
  padding: 0 10px;
  text-align: center;
}
.grid-contents {
  min-height: 36px;
  border-radius: 20px;