WXL (wul)
2025-11-13 de147dda682f8ac597bbcc8555b57acbdf45dba2
src/views/sfstatistics/percentage/index.vue
@@ -126,14 +126,16 @@
                >
              </el-col>
            </el-form>
            <div class="your-table-container">
            <el-table
              v-loading="loading"
              :data="userList"
              :border="true"
              @selection-change="handleSelectionChange"
              @row-click="handleRowClick"
              @expand-change="handleRowClick"
              :row-key="getRowKey"
                show-summary
                :summary-method="getSummaries"
              :expand-row-keys="expands"
            >
              <!-- 展开行箭头列 -->
@@ -144,6 +146,8 @@
                    border
                    style="width: 95%; margin: 0 auto"
                    class="inner-table"
                      show-summary
                      :summary-method="getInnerSummaries"
                  >
                    <el-table-column
                      label="医生姓名"
@@ -187,7 +191,7 @@
                    </el-table-column>
                    <el-table-column align="center" label="首次出院随访">
                      <el-table-column
                        label="应随访"
                          label="需随访"
                        align="center"
                        key="needFollowUp"
                        prop="needFollowUp"
@@ -273,7 +277,7 @@
                    </el-table-column>
                    <el-table-column align="center" label="再次出院随访">
                      <el-table-column
                        label="应随访"
                          label="需随访"
                        align="center"
                        key="needFollowUpAgain"
                        prop="needFollowUpAgain"
@@ -382,7 +386,7 @@
              </el-table-column>
              <el-table-column align="center" label="首次出院随访">
                <el-table-column
                  label="应随访"
                    label="需随访"
                  align="center"
                  key="needFollowUp"
                  prop="needFollowUp"
@@ -437,7 +441,9 @@
                      type="text"
                      @click="Seedetails(scope.row)"
                      ><span class="button-zx"
                        >{{ (Number(scope.row.rate) * 100).toFixed(2) }}%</span
                          >{{
                            (Number(scope.row.rate) * 100).toFixed(2)
                          }}%</span
                      ></el-button
                    >
                  </template>
@@ -466,7 +472,7 @@
              </el-table-column>
              <el-table-column align="center" label="再次出院随访">
                <el-table-column
                  label="应随访"
                    label="需随访"
                  align="center"
                  key="needFollowUpAgain"
                  prop="needFollowUpAgain"
@@ -530,7 +536,62 @@
                >
                </el-table-column>
              </el-table-column>
                <el-table-column
                  v-if="orgname == '丽水市中医院'"
                  align="center"
                  label="随访情况"
                >
                  <el-table-column
                    label="正常语音"
                    align="center"
                    width="100"
                    key="taskSituation1"
                    prop="taskSituation1"
                  >
                  </el-table-column
                  ><el-table-column
                    label="患者拒接或拒访"
                    align="center"
                    width="100"
                    key="taskSituation2"
                    prop="taskSituation2"
                  >
                  </el-table-column
                  ><el-table-column
                    label="面访或者接诊"
                    align="center"
                    width="100"
                    key="taskSituation3"
                    prop="taskSituation3"
                  >
                  </el-table-column
                  ><el-table-column
                    label="微信随访"
                    align="center"
                    width="100"
                    key="taskSituation4"
                    prop="taskSituation4"
                  >
                  </el-table-column
                  ><el-table-column
                    label="随访电话不正确"
                    align="center"
                    width="100"
                    key="taskSituation5"
                    prop="taskSituation5"
                  >
                  </el-table-column
                  ><el-table-column
                    label="其他情况不宜随访"
                    align="center"
                    width="100"
                    key="taskSituation6"
                    prop="taskSituation6"
                  >
                  </el-table-column>
                </el-table-column>
            </el-table>
            </div>
            <!-- <pagination
              v-show="total > 0"
@@ -838,6 +899,7 @@
    return {
      topactiveName: "Local", //顶部选择
      activeName: "first", //侧边选择
      orgname: "",
      expands: [],
      // 遮罩层
      loading: false,
@@ -917,51 +979,7 @@
      sidecolumnval: "", //类别搜索
      propss: { multiple: true },
      SeedetailsVisible: false,
      options: [
        {
          value: 1,
          label: "监测评估",
        },
        {
          value: 2,
          label: "出院随访",
        },
        {
          value: 3,
          label: "门诊随访",
        },
        {
          value: 4,
          label: "宣教关怀",
        },
        {
          value: 5,
          label: "复诊管理",
        },
        {
          value: 7,
          label: "患者报告",
        },
        {
          value: 9,
          label: "体检随访",
        },
        {
          value: 11,
          label: "影像随访",
        },
        {
          value: 12,
          label: "心电随访",
        },
        {
          value: 13,
          label: "专病随访",
        },
      ],
      options: store.getters.tasktypes,
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() < Date.now() - 3600 * 1000 * 24;
@@ -1000,6 +1018,7 @@
  created() {
    this.getDeptTree();
    this.getList();
    this.orgname = localStorage.getItem("orgname");
  },
  methods: {
@@ -1060,6 +1079,162 @@
      } else {
        this.expands = [this.getRowKey(row)];
      }
    },
    getSummaries(param) {
      const { columns, data } = param;
      const sums = [];
      columns.forEach((column, index) => {
        if (index === 0) {
          sums[index] = "合计";
          return;
        }
         if (index === 1||index === 2) {
          sums[index] = "/";
          return;
        }
        // 对百分比字段特殊处理 - 取平均值
        if (
          column.property === "followUpRate" ||
          column.property === "rate" ||
          column.property === "followUpRateAgain"
        ) {
          // 提取所有有效百分比值并转换为小数
          const percentageValues = data
            .map((item) => {
              const value = item[column.property];
              if (!value || value === "-" || value === "0%") return null;
              // 处理带百分号的数据
              if (typeof value === "string" && value.includes("%")) {
                // 去除百分号并转换为小数
                const numValue = parseFloat(value.replace("%", "")) / 100;
                return isNaN(numValue) ? null : numValue;
              } else {
                // 处理已经是小数的数据
                const numValue = parseFloat(value);
                return isNaN(numValue) ? null : numValue;
              }
            })
            .filter((value) => value !== null && value !== 0); // 过滤掉null和0值
          if (percentageValues.length > 0) {
            const average =
              percentageValues.reduce((sum, value) => sum + value, 0) /
              percentageValues.length;
            sums[index] = (average * 100).toFixed(2) + "%";
          } else {
            sums[index] = "0.00%";
          }
        } else {
          // 普通数字字段 - 求和
          const values = data.map((item) => {
            const value = item[column.property];
            if (value === "-" || value === "" || value === null) return 0;
            return Number(value) || 0;
          });
          if (!values.every((value) => isNaN(value))) {
            sums[index] = values.reduce((prev, curr) => prev + curr, 0);
            sums[index] = this.formatNumber(sums[index]);
          } else {
            sums[index] = "-";
          }
        }
      });
      return sums;
    },
    // 内部表格合计行计算方法
    getInnerSummaries(param) {
      const { columns, data } = param;
      const sums = [];
      columns.forEach((column, index) => {
        if (index === 0) {
          sums[index] = "小计";
          return;
        }
        if (column.property === "drname" || column.property === "deptname") {
          sums[index] = "-";
          return;
        }
        // 对百分比字段特殊处理 - 取平均值
        if (column.property === "followUpRate" || column.property === "rate") {
          // 提取所有有效百分比值并转换为小数
          const percentageValues = data
            .map((item) => {
              const value = item[column.property];
              if (!value || value === "-" || value === "0%") return null;
              // 处理带百分号的数据
              if (typeof value === "string" && value.includes("%")) {
                // 去除百分号并转换为小数
                const numValue = parseFloat(value.replace("%", "")) / 100;
                return isNaN(numValue) ? null : numValue;
              } else {
                // 处理已经是小数的数据
                const numValue = parseFloat(value);
                return isNaN(numValue) ? null : numValue;
              }
            })
            .filter((value) => value !== null && value !== 0);
          if (percentageValues.length > 0) {
            const average =
              percentageValues.reduce((sum, value) => sum + value, 0) /
              percentageValues.length;
            sums[index] = (average * 100).toFixed(2) + "%";
          } else {
            sums[index] = "0.00%";
          }
        } else {
          // 普通数字字段 - 求和
          const values = data.map((item) => {
            const value = item[column.property];
            if (value === "-" || value === "" || value === null) return 0;
            return Number(value) || 0;
          });
          if (!values.every((value) => isNaN(value))) {
            sums[index] = values.reduce((prev, curr) => prev + curr, 0);
            sums[index] = this.formatNumber(sums[index]);
          } else {
            sums[index] = "-";
          }
        }
      });
      return sums;
    },
    // 辅助方法:提取百分比数值
    extractPercentageValue(value) {
      if (!value) return null;
      if (typeof value === "string") {
        // 处理带百分号的字符串
        if (value.includes("%")) {
          const num = parseFloat(value.replace("%", ""));
          return isNaN(num) ? null : num / 100;
        }
        // 处理纯数字字符串
        const num = parseFloat(value);
        return isNaN(num) ? null : num;
      }
      // 处理数字类型
      return typeof value === "number" ? value : null;
    },
    // 数字格式化方法
    formatNumber(num) {
      if (isNaN(num)) return "-";
      return Number.isInteger(num) ? num.toString() : num.toFixed(0);
    },
    /** 修改标签 */
    handleUpdate(row) {
@@ -1287,10 +1462,23 @@
    },
    /** 导出按钮操作 */
    handleExport() {
      const params = {
        ...this.queryParams,
        // 如果选择了"全部",则传所有病区/科室代码
        leavehospitaldistrictcodes:
          this.queryParams.leavehospitaldistrictcodes.includes("all")
            ? this.allWardCodes
            : this.queryParams.leavehospitaldistrictcodes,
        deptcodes: this.queryParams.deptcodes.includes("all")
          ? this.allDeptCodes
          : this.queryParams.deptcodes,
      };
       delete params.leavehospitaldistrictcodes.all;
      delete params.deptcodes.all;
      this.download(
        "smartor/serviceSubtask/getSfStatisticsExport",
        {
          ...this.queryParams,
          ...params,
        },
        `user_${new Date().getTime()}.xlsx`
      );
@@ -1351,9 +1539,9 @@
      text: "随访状态分布",
      left: "center",
      textStyle: {
        color: '#333',
        fontSize: 16
      }
            color: "#333",
            fontSize: 16,
          },
    },
    tooltip: {
      trigger: "item",
@@ -1364,10 +1552,10 @@
      left: "left",
      data: ["待随访", "随访成功", "随访失败"],
      textStyle: {
        color: '#666'
      }
            color: "#666",
    },
    color: ['#FF9D4D', '#36B37E', '#FF5C5C'], // 新的配色方案
        },
        color: ["#FF9D4D", "#36B37E", "#FF5C5C"], // 新的配色方案
    series: [
      {
        name: "随访状态",
@@ -1377,41 +1565,41 @@
        itemStyle: {
          borderRadius: 10,
          borderColor: "#fff",
          borderWidth: 2
              borderWidth: 2,
        },
        label: {
          show: true,
          formatter: "{b}: {c} ({d}%)",
          color: '#333'
              color: "#333",
        },
        emphasis: {
          label: {
            show: true,
            fontSize: "18",
            fontWeight: "bold"
                fontWeight: "bold",
          },
          itemStyle: {
            shadowBlur: 10,
            shadowOffsetX: 0,
            shadowColor: 'rgba(0, 0, 0, 0.5)'
          }
                shadowColor: "rgba(0, 0, 0, 0.5)",
              },
        },
        data: [
          {
            value: followUpData.pending,
            name: "待随访"
                name: "待随访",
          },
          {
            value: followUpData.success,
            name: "随访成功"
                name: "随访成功",
          },
          {
            value: followUpData.fail,
            name: "随访失败"
          }
        ]
      }
    ]
                name: "随访失败",
              },
            ],
          },
        ],
  };
  this.pieChart.setOption(pieOption);
@@ -1443,14 +1631,14 @@
  );
  // 新增两条折线数据
 const followUpRateData = this.userList.map(item => {
      const followUpRateData = this.userList.map((item) => {
    if (!item.followUpRate) return 0;
    // 去掉百分号并转为数字
    const rateStr = String(item.followUpRate).replace('%', '');
        const rateStr = String(item.followUpRate).replace("%", "");
    return parseFloat(rateStr) || 0;
  });
  const timelyRateData = this.userList.map(item =>
      const timelyRateData = this.userList.map((item) =>
    item.rate ? (Number(item.rate) * 100).toFixed(2) : 0
  );
@@ -1459,9 +1647,9 @@
      text: "科室/病区随访趋势",
      left: "center",
      textStyle: {
        color: '#333',
        fontSize: 16
      }
            color: "#333",
            fontSize: 16,
          },
    },
    tooltip: {
      trigger: "axis",
@@ -1476,23 +1664,23 @@
      data: ["出院人次", "应随访人次", "随访率(%)", "及时率(%)"],
      top: "bottom",
      textStyle: {
        color: '#666'
      }
            color: "#666",
    },
    color: ['#5470C6', '#91CC75', '#EE6666', '#9A60B4'], // 新增紫色用于及时率
        },
        color: ["#5470C6", "#91CC75", "#EE6666", "#9A60B4"], // 新增紫色用于及时率
    xAxis: {
      type: "category",
      data: categories,
      axisLabel: {
        interval: 0,
        rotate: 30,
        color: '#666'
            color: "#666",
      },
      axisLine: {
        lineStyle: {
          color: '#ddd'
        }
      }
              color: "#ddd",
            },
          },
    },
    yAxis: [
      {
@@ -1500,18 +1688,18 @@
        name: "人次",
        min: 0,
        axisLabel: {
          color: '#666'
              color: "#666",
        },
        axisLine: {
          lineStyle: {
            color: '#ddd'
          }
                color: "#ddd",
              },
        },
        splitLine: {
          lineStyle: {
            color: '#f0f0f0'
          }
        }
                color: "#f0f0f0",
              },
            },
      },
      {
        type: "value",
@@ -1519,18 +1707,18 @@
        min: 0,
        max: 100,
        axisLabel: {
          color: '#666',
          formatter: '{value}%'
              color: "#666",
              formatter: "{value}%",
        },
        axisLine: {
          lineStyle: {
            color: '#ddd'
          }
                color: "#ddd",
              },
        },
        splitLine: {
          show: false
        }
      }
              show: false,
            },
          },
    ],
    series: [
      {
@@ -1539,8 +1727,8 @@
        barWidth: "25%",
        data: dischargeData,
        itemStyle: {
          borderRadius: [4, 4, 0, 0]
        }
              borderRadius: [4, 4, 0, 0],
            },
      },
      {
        name: "应随访人次",
@@ -1548,8 +1736,8 @@
        barWidth: "25%",
        data: followUpData,
        itemStyle: {
          borderRadius: [4, 4, 0, 0]
        }
              borderRadius: [4, 4, 0, 0],
            },
      },
      {
        name: "随访率(%)",
@@ -1558,22 +1746,24 @@
        data: followUpRateData,
        symbolSize: 8,
        lineStyle: {
          width: 3
              width: 3,
        },
        markLine: {
          silent: true,
          data: [{
              data: [
                {
            yAxis: 80,
            lineStyle: {
              color: '#EE6666',
              type: 'dashed'
                    color: "#EE6666",
                    type: "dashed",
            },
            // label: {
            //   position: 'end',
            //   formatter: '目标80%'
            // }
          }]
        }
                },
              ],
            },
      },
      {
        name: "及时率(%)",
@@ -1583,31 +1773,33 @@
        symbolSize: 8,
        lineStyle: {
          width: 3,
          type: 'dotted' // 使用虚线区分
              type: "dotted", // 使用虚线区分
        },
        markLine: {
          silent: true,
          data: [{
              data: [
                {
            yAxis: 90,
            lineStyle: {
              color: '#9A60B4',
              type: 'dashed'
                    color: "#9A60B4",
                    type: "dashed",
            },
            // label: {
            //   position: 'end',
            //   formatter: '目标90%'
            // }
          }]
        }
      }
                },
              ],
            },
          },
    ],
    grid: {
      top: '15%',
      left: '3%',
      right: '4%',
      bottom: '15%',
      containLabel: true
    }
          top: "15%",
          left: "3%",
          right: "4%",
          bottom: "15%",
          containLabel: true,
        },
  };
  this.barLineChart.setOption(option);
@@ -1723,6 +1915,41 @@
  text-align: left;
  font-size: 20px;
}
// 美化合计行样式
::v-deep .el-table__footer {
  .el-table__cell {
    background-color: #f5f7fa;
    font-weight: 600;
    color: #409eff;
    .cell {
      font-weight: 600;
      color: #409eff;
    }
  }
}
// 内部表格合计行样式
::v-deep .inner-table .el-table__footer {
  .el-table__cell {
    background-color: #ecf5ff;
    font-weight: 500;
    color: #67c23a;
    .cell {
      font-weight: 500;
      color: #67c23a;
    }
  }
}
// 百分比字段特殊样式
.your-table-container ::v-deep .el-table__footer .el-table__cell[data-field="followUpRate"] .cell,
.your-table-container ::v-deep .el-table__footer .el-table__cell[data-field="rate"] .cell,
.your-table-container ::v-deep .el-table__footer .el-table__cell[data-field="followUpRateAgain"] .cell {
  color: #e6a23c !important;
  font-weight: 700 !important;
}
.leftvlue {
  //   display: flex;