WXL (wul)
3 天以前 a78c4c8208a4a05dd54781443c08336f142a2dd6
src/views/sfstatistics/percentage/index.vue
@@ -61,7 +61,7 @@
                </el-select>
              </el-form-item>
              <el-form-item label="统计类型" prop="userName">
              <el-form-item label="服务类型" prop="userName">
                <el-select
                  v-model="queryParams.serviceType"
                  multiple
@@ -90,7 +90,6 @@
                  end-placeholder="结束日期"
                  :default-time="['00:00:00', '23:59:59']"
                >
                  >
                </el-date-picker>
              </el-form-item>
@@ -109,711 +108,814 @@
                  >重置</el-button
                >
              </el-form-item>
              <el-col :span="19">
                <el-button
                  type="warning"
                  plain
                  icon="el-icon-download"
                  size="medium"
                  @click="exportTable"
                  >导出</el-button
                >
                <el-button
                  type="primary"
                  plain
                  icon="el-icon-data-line"
                  size="medium"
                  @click="showChartDialog"
                  >统计趋势图</el-button
                >
              </el-col>
            </el-form>
            <div class="your-table-container">
              <el-table
                ref="exportTable"
                id="exportTableid"
                v-loading="loading"
                :data="userList"
                :border="true"
                @selection-change="handleSelectionChange"
                @expand-change="handleRowClick"
                :row-key="getRowKey"
                show-summary
                :summary-method="getSummaries"
                :expand-row-keys="expands"
              <el-button
                type="warning"
                plain
                icon="el-icon-download"
                size="medium"
                @click="exportTable"
                >导出</el-button
              >
                <!-- 展开行箭头列 -->
                <el-table-column type="expand">
                  <template slot-scope="props">
                    <el-table
                      :data="props.row.doctorStats"
                      border
                      style="width: 95%; margin: 0 auto"
                      class="inner-table"
                      show-summary
                      :summary-method="getInnerSummaries"
              <el-button
                type="primary"
                plain
                icon="el-icon-data-line"
                size="medium"
                @click="showChartDialog"
                >统计趋势图</el-button
              >
            </el-form>
            <!-- 新增:Tab标签页 -->
            <el-tabs v-model="activeTab" @tab-click="handleTabClick">
              <el-tab-pane label="首次随访" name="first">
                <div class="your-table-container">
                  <el-table
                    ref="exportTable"
                    id="exportTableid"
                    v-loading="loading"
                    :data="firstFollowUpList"
                    :border="true"
                    @selection-change="handleSelectionChange"
                    @expand-change="handleRowClick"
                    :row-key="getRowKey"
                    show-summary
                    :summary-method="getSummaries"
                    :expand-row-keys="expands"
                  >
                    <!-- 展开行箭头列 -->
                    <el-table-column type="expand">
                      <template slot-scope="props">
                        <el-table
                          :data="props.row.doctorStats"
                          border
                          style="width: 95%; margin: 0 auto"
                          class="inner-table"
                          show-summary
                          :summary-method="getInnerSummaries"
                        >
                          <el-table-column
                            label="医生姓名"
                            prop="drname"
                            align="center"
                          />
                          <el-table-column
                            label="科室"
                            width="120"
                            prop="deptname"
                            align="center"
                          />
                          <el-table-column
                            label="出院人次"
                            prop="dischargeCount"
                            align="center"
                          />
                          <el-table-column
                            label="出院人次"
                            align="center"
                            key="dischargeCount"
                            prop="dischargeCount"
                          >
                          </el-table-column>
                          <el-table-column
                            label="无需随访人次"
                            align="center"
                            width="100"
                            key="nonFollowUp"
                            prop="nonFollowUp"
                          >
                          </el-table-column>
                          <el-table-column
                            label="应随访人次"
                            align="center"
                            width="100"
                            key="followUpNeeded"
                            prop="followUpNeeded"
                          >
                          </el-table-column>
                          <el-table-column align="center" label="首次出院随访">
                            <el-table-column
                              label="需随访"
                              align="center"
                              key="needFollowUp"
                              prop="needFollowUp"
                            >
                            </el-table-column>
                            <el-table-column
                              label="待随访"
                              align="center"
                              key="pendingFollowUp"
                              prop="pendingFollowUp"
                            >
                            </el-table-column>
                            <el-table-column
                              label="随访成功"
                              align="center"
                              key="followUpSuccess"
                              prop="followUpSuccess"
                            >
                            </el-table-column>
                            <el-table-column
                              label="随访失败"
                              align="center"
                              key="followUpFail"
                              prop="followUpFail"
                            >
                            </el-table-column>
                            <el-table-column
                              label="随访率"
                              align="center"
                              width="120"
                              key="followUpRate"
                              prop="followUpRate"
                            >
                            </el-table-column>
                            <el-table-column
                              v-if="orgname != '丽水市中医院'"
                              label="及时率"
                              align="center"
                              width="120"
                              key="rate"
                              prop="rate"
                            >
                              <template slot-scope="scope">
                                <el-button
                                  size="medium"
                                  type="text"
                                  @click="Seedetails(scope.row)"
                                  ><span class="button-zx"
                                    >{{
                                      (Number(scope.row.rate) * 100).toFixed(2)
                                    }}%</span
                                  ></el-button
                                >
                              </template>
                            </el-table-column>
                            <el-table-column
                              label="人工"
                              align="center"
                              key="manual"
                              prop="manual"
                            >
                            </el-table-column>
                            <el-table-column
                              label="短信"
                              align="center"
                              key="sms"
                              prop="sms"
                            >
                            </el-table-column>
                            <el-table-column
                              label="微信"
                              align="center"
                              key="weChat"
                              prop="weChat"
                            >
                            </el-table-column>
                          </el-table-column>
                        </el-table>
                      </template>
                    </el-table-column>
                    <el-table-column
                      label="出院病区"
                      align="center"
                      sortable
                      key="leavehospitaldistrictname"
                      prop="leavehospitaldistrictname"
                      width="150"
                      :show-overflow-tooltip="true"
                      :sort-method="sortChineseNumber"
                    />
                    <el-table-column
                      label="科室"
                      align="center"
                      key="deptname"
                      prop="deptname"
                      :show-overflow-tooltip="true"
                    />
                    <el-table-column
                      label="出院人次"
                      align="center"
                      key="dischargeCount"
                      prop="dischargeCount"
                    >
                    </el-table-column>
                    <el-table-column
                      label="无需随访人次"
                      align="center"
                      width="100"
                      key="nonFollowUp"
                      prop="nonFollowUp"
                    >
                    </el-table-column>
                    <el-table-column
                      label="应随访人次"
                      align="center"
                      width="100"
                      key="followUpNeeded"
                      prop="followUpNeeded"
                    >
                    </el-table-column>
                    <el-table-column align="center" label="首次出院随访">
                      <el-table-column
                        label="需随访"
                        align="center"
                        key="needFollowUp"
                        prop="needFollowUp"
                      >
                        <template slot-scope="scope">
                          <el-button
                            size="medium"
                            type="text"
                            @click="
                              viewDetails(
                                scope.row.needFollowUpInfo,
                                scope.row.leavehospitaldistrictname +
                                  '需随访列表'
                              )
                            "
                            ><span class="button-zx">{{
                              scope.row.needFollowUp
                            }}</span></el-button
                          >
                        </template>
                      </el-table-column>
                      <el-table-column
                        label="待随访"
                        align="center"
                        key="pendingFollowUp"
                        prop="pendingFollowUp"
                      >
                        <template slot-scope="scope">
                          <el-button
                            size="medium"
                            type="text"
                            @click="
                              viewDetails(
                                scope.row.pendingFollowUpInfo,
                                scope.row.leavehospitaldistrictname +
                                  '待随访列表'
                              )
                            "
                            ><span class="button-zx">{{
                              scope.row.pendingFollowUp
                            }}</span></el-button
                          >
                        </template>
                      </el-table-column>
                      <el-table-column
                        label="随访成功"
                        align="center"
                        key="followUpSuccess"
                        prop="followUpSuccess"
                      >
                        <template slot-scope="scope">
                          <el-button
                            size="medium"
                            type="text"
                            @click="
                              viewDetails(
                                scope.row.followUpSuccessInfo,
                                scope.row.leavehospitaldistrictname +
                                  '随访成功列表'
                              )
                            "
                            ><span class="button-zx">{{
                              scope.row.followUpSuccess
                            }}</span></el-button
                          >
                        </template>
                      </el-table-column>
                      <el-table-column
                        label="随访失败"
                        align="center"
                        key="followUpFail"
                        prop="followUpFail"
                      >
                        <template slot-scope="scope">
                          <el-button
                            size="medium"
                            type="text"
                            @click="
                              viewDetails(
                                scope.row.followUpFailInfo,
                                scope.row.leavehospitaldistrictname +
                                  '随访失败列表'
                              )
                            "
                            ><span class="button-zx">{{
                              scope.row.followUpFail
                            }}</span></el-button
                          >
                        </template>
                      </el-table-column>
                      <el-table-column
                        label="随访率"
                        align="center"
                        width="120"
                        key="followUpRate"
                        prop="followUpRate"
                      >
                      </el-table-column>
                      <el-table-column
                        v-if="orgname != '丽水市中医院'"
                        label="及时率"
                        align="center"
                        width="120"
                        key="rate"
                        prop="rate"
                      >
                        <template slot-scope="scope">
                          <el-button
                            size="medium"
                            type="text"
                            @click="Seedetails(scope.row)"
                            ><span class="button-zx"
                              >{{
                                (Number(scope.row.rate) * 100).toFixed(2)
                              }}%</span
                            ></el-button
                          >
                        </template>
                      </el-table-column>
                      <el-table-column
                        label="人工"
                        align="center"
                        key="manual"
                        prop="manual"
                      >
                        <template slot-scope="scope">
                          <el-button
                            size="medium"
                            type="text"
                            @click="
                              viewDetails(
                                scope.row.manualInfo,
                                scope.row.leavehospitaldistrictname +
                                  '人工随访列表'
                              )
                            "
                            ><span class="button-zx">{{
                              scope.row.manual
                            }}</span></el-button
                          >
                        </template>
                      </el-table-column>
                      <el-table-column
                        label="短信"
                        align="center"
                        key="sms"
                        prop="sms"
                      >
                        <template slot-scope="scope">
                          <el-button
                            size="medium"
                            type="text"
                            @click="
                              viewDetails(
                                scope.row.smsInfo,
                                scope.row.leavehospitaldistrictname +
                                  '短信随访列表'
                              )
                            "
                            ><span class="button-zx">{{
                              scope.row.sms
                            }}</span></el-button
                          >
                        </template>
                      </el-table-column>
                      <el-table-column
                        label="微信"
                        align="center"
                        key="weChat"
                        prop="weChat"
                      >
                        <template slot-scope="scope">
                          <el-button
                            size="medium"
                            type="text"
                            @click="
                              viewDetails(
                                scope.row.weChatInfo,
                                scope.row.leavehospitaldistrictname +
                                  '微信随访列表'
                              )
                            "
                            ><span class="button-zx">{{
                              scope.row.weChat
                            }}</span></el-button
                          >
                        </template>
                      </el-table-column>
                    </el-table-column>
                    <!-- 随访情况列(仅丽水市中医院显示) -->
                    <el-table-column
                      v-if="orgname == '丽水市中医院'"
                      align="center"
                      label="随访情况"
                    >
                      <el-table-column
                        label="医生姓名"
                        prop="drname"
                        label="正常语音"
                        align="center"
                      />
                      <el-table-column
                        label="科室"
                        width="120"
                        prop="deptname"
                        width="100"
                        key="taskSituation1"
                        prop="taskSituation1"
                      >
                      </el-table-column
                      ><el-table-column
                        label="患者拒接或拒访"
                        align="center"
                      />
                      <el-table-column
                        label="出院人次"
                        prop="dischargeCount"
                        width="100"
                        key="taskSituation2"
                        prop="taskSituation2"
                      >
                      </el-table-column
                      ><el-table-column
                        label="面访或者接诊"
                        align="center"
                      />
                      <el-table-column
                        label="出院人次"
                        width="100"
                        key="taskSituation3"
                        prop="taskSituation3"
                      >
                      </el-table-column
                      ><el-table-column
                        label="微信随访"
                        align="center"
                        key="dischargeCount"
                        prop="dischargeCount"
                        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>
              </el-tab-pane>
                      <el-table-column
                        label="无需随访人次"
                        align="center"
                        width="100"
                        key="nonFollowUp"
                        prop="nonFollowUp"
                      >
                      </el-table-column>
                      <el-table-column
                        label="应随访人次"
                        align="center"
                        width="100"
                        key="followUpNeeded"
                        prop="followUpNeeded"
                      >
                      </el-table-column>
                      <el-table-column align="center" label="首次出院随访">
                        <el-table-column
                          label="需随访"
                          align="center"
                          key="needFollowUp"
                          prop="needFollowUp"
              <el-tab-pane label="再次随访" name="second">
                <div class="your-table-container">
                  <el-table
                    ref="exportTableSecond"
                    id="exportTableidSecond"
                    v-loading="loadingSecond"
                    :data="secondFollowUpList"
                    :border="true"
                    @selection-change="handleSelectionChangeSecond"
                    @expand-change="handleRowClickSecond"
                    :row-key="getRowKey"
                    show-summary
                    :summary-method="getSummariesSecond"
                    :expand-row-keys="expandsSecond"
                  >
                    <!-- 展开行箭头列 -->
                    <el-table-column type="expand">
                      <template slot-scope="props">
                        <el-table
                          :data="props.row.doctorStats"
                          border
                          style="width: 95%; margin: 0 auto"
                          class="inner-table"
                          show-summary
                          :summary-method="getInnerSummariesSecond"
                        >
                        </el-table-column>
                        <el-table-column
                          label="待随访"
                          align="center"
                          key="pendingFollowUp"
                          prop="pendingFollowUp"
                        >
                        </el-table-column>
                        <el-table-column
                          label="随访成功"
                          align="center"
                          key="followUpSuccess"
                          prop="followUpSuccess"
                        >
                        </el-table-column>
                        <el-table-column
                          label="随访失败"
                          align="center"
                          key="followUpFail"
                          prop="followUpFail"
                        >
                        </el-table-column>
                        <el-table-column
                          label="随访率"
                          align="center"
                          width="120"
                          key="followUpRate"
                          prop="followUpRate"
                        >
                          <!-- <template slot-scope="scope">
                      <span
                        >{{
                          (Number(scope.row.followUpRate) * 100).toFixed(2)
                        }}%</span
                      >
                    </template> -->
                        </el-table-column>
                        <el-table-column
                          label="及时率"
                          align="center"
                          width="120"
                          key="rate"
                          prop="rate"
                        >
                          <template slot-scope="scope">
                            <el-button
                              size="medium"
                              type="text"
                              @click="Seedetails(scope.row)"
                              ><span class="button-zx"
                                >{{
                                  (Number(scope.row.rate) * 100).toFixed(2)
                                }}%</span
                              ></el-button
                          <el-table-column
                            label="医生姓名"
                            prop="drname"
                            align="center"
                          />
                          <el-table-column
                            label="科室"
                            width="120"
                            prop="deptname"
                            align="center"
                          />
                          <el-table-column
                            label="出院人次"
                            prop="dischargeCount"
                            align="center"
                          />
                          <el-table-column
                            label="出院人次"
                            align="center"
                            key="dischargeCount"
                            prop="dischargeCount"
                          >
                          </el-table-column>
                          <el-table-column
                            label="无需随访人次"
                            align="center"
                            width="100"
                            key="nonFollowUp"
                            prop="nonFollowUp"
                          >
                          </el-table-column>
                          <el-table-column
                            label="应随访人次"
                            align="center"
                            width="100"
                            key="followUpNeeded"
                            prop="followUpNeeded"
                          >
                          </el-table-column>
                          <el-table-column align="center" label="再次出院随访">
                            <el-table-column
                              label="需随访"
                              align="center"
                              key="needFollowUpAgain"
                              prop="needFollowUpAgain"
                            >
                          </template>
                        </el-table-column>
                        <el-table-column
                          label="人工"
                          align="center"
                          key="manual"
                          prop="manual"
                        >
                        </el-table-column>
                        <el-table-column
                          label="短信"
                          align="center"
                          key="sms"
                          prop="sms"
                        >
                        </el-table-column>
                        <el-table-column
                          label="微信"
                          align="center"
                          key="weChat"
                          prop="weChat"
                        >
                        </el-table-column>
                      </el-table-column>
                      <el-table-column align="center" label="再次出院随访">
                        <el-table-column
                          label="需随访"
                          align="center"
                          key="needFollowUpAgain"
                          prop="needFollowUpAgain"
                        >
                        </el-table-column>
                        <el-table-column
                          label="待随访"
                          align="center"
                          key="pendingFollowUpAgain"
                          prop="pendingFollowUpAgain"
                        >
                        </el-table-column>
                        <el-table-column
                          label="随访成功"
                          align="center"
                          key="followUpSuccessAgain"
                          prop="followUpSuccessAgain"
                        >
                        </el-table-column>
                        <el-table-column
                          label="随访失败"
                          align="center"
                          key="followUpFailAgain"
                          prop="followUpFailAgain"
                        >
                        </el-table-column>
                        <el-table-column
                          label="随访率"
                          align="center"
                          width="120"
                          key="followUpRateAgain"
                          prop="followUpRateAgain"
                        >
                          <!-- <template slot-scope="scope">
                      <span
                        >{{
                          (Number(scope.row.FollowUpRateAgain) * 100).toFixed(2)
                        }}%</span
                      >
                    </template> -->
                        </el-table-column>
                        <el-table-column
                          label="人工"
                          align="center"
                          key="manualAgain"
                          prop="manualAgain"
                        >
                        </el-table-column>
                        <el-table-column
                          label="短信"
                          align="center"
                          key="smsAgain"
                          prop="smsAgain"
                        >
                        </el-table-column>
                        <el-table-column
                          label="微信"
                          align="center"
                          key="weChatAgain"
                          prop="weChatAgain"
                        >
                        </el-table-column>
                      </el-table-column>
                    </el-table>
                  </template>
                </el-table-column>
                <el-table-column
                  label="出院病区"
                  align="center"
                  sortable
                  key="leavehospitaldistrictname"
                  prop="leavehospitaldistrictname"
                  width="150"
                  :show-overflow-tooltip="true"
                />
                <el-table-column
                  label="科室"
                  align="center"
                  key="deptname"
                  prop="deptname"
                  :show-overflow-tooltip="true"
                />
                <el-table-column
                  label="出院人次"
                  align="center"
                  key="dischargeCount"
                  prop="dischargeCount"
                >
                </el-table-column>
                            </el-table-column>
                            <el-table-column
                              label="待随访"
                              align="center"
                              key="pendingFollowUpAgain"
                              prop="pendingFollowUpAgain"
                            >
                            </el-table-column>
                            <el-table-column
                              label="随访成功"
                              align="center"
                              key="followUpSuccessAgain"
                              prop="followUpSuccessAgain"
                            >
                            </el-table-column>
                            <el-table-column
                              label="随访失败"
                              align="center"
                              key="followUpFailAgain"
                              prop="followUpFailAgain"
                            >
                            </el-table-column>
                            <el-table-column
                              label="随访率"
                              align="center"
                              width="120"
                              key="followUpRateAgain"
                              prop="followUpRateAgain"
                            >
                            </el-table-column>
                            <el-table-column
                              label="人工"
                              align="center"
                              key="manualAgain"
                              prop="manualAgain"
                            >
                            </el-table-column>
                            <el-table-column
                              label="短信"
                              align="center"
                              key="smsAgain"
                              prop="smsAgain"
                            >
                            </el-table-column>
                            <el-table-column
                              label="微信"
                              align="center"
                              key="weChatAgain"
                              prop="weChatAgain"
                            >
                            </el-table-column>
                          </el-table-column>
                        </el-table>
                      </template>
                    </el-table-column>
                    <el-table-column
                      label="出院病区"
                      align="center"
                      sortable
                      key="leavehospitaldistrictname"
                      prop="leavehospitaldistrictname"
                      width="150"
                      :show-overflow-tooltip="true"
                      :sort-method="sortChineseNumber"
                    />
                    <el-table-column
                      label="科室"
                      align="center"
                      key="deptname"
                      prop="deptname"
                      :show-overflow-tooltip="true"
                    />
                    <el-table-column
                      label="出院人次"
                      align="center"
                      key="dischargeCount"
                      prop="dischargeCount"
                    >
                    </el-table-column>
                <el-table-column
                  label="无需随访人次"
                  align="center"
                  width="100"
                  key="nonFollowUp"
                  prop="nonFollowUp"
                >
                </el-table-column>
                <el-table-column
                  label="应随访人次"
                  align="center"
                  width="100"
                  key="followUpNeeded"
                  prop="followUpNeeded"
                >
                </el-table-column>
                <el-table-column align="center" label="首次出院随访">
                  <el-table-column
                    label="需随访"
                    align="center"
                    key="needFollowUp"
                    prop="needFollowUp"
                  >
                    <template slot-scope="scope">
                      <el-button
                        size="medium"
                        type="text"
                        @click="
                          viewDetails(
                            scope.row.needFollowUpInfo,
                            scope.row.leavehospitaldistrictname + '需随访列表'
                          )
                        "
                        ><span class="button-zx">{{
                          scope.row.needFollowUp
                        }}</span></el-button
                    <el-table-column
                      label="无需随访人次"
                      align="center"
                      width="100"
                      key="nonFollowUp"
                      prop="nonFollowUp"
                    >
                    </el-table-column>
                    <el-table-column
                      label="应随访人次"
                      align="center"
                      width="100"
                      key="followUpNeeded"
                      prop="followUpNeeded"
                    >
                    </el-table-column>
                    <el-table-column align="center" label="再次出院随访">
                      <el-table-column
                        label="需随访"
                        align="center"
                        key="needFollowUpAgain"
                        prop="needFollowUpAgain"
                      >
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="待随访"
                    align="center"
                    key="pendingFollowUp"
                    prop="pendingFollowUp"
                  >
                    <template slot-scope="scope">
                      <el-button
                        size="medium"
                        type="text"
                        @click="
                          viewDetails(
                            scope.row.pendingFollowUpInfo,
                            scope.row.leavehospitaldistrictname + '待随访列表'
                          )
                        "
                        ><span class="button-zx">{{
                          scope.row.pendingFollowUp
                        }}</span></el-button
                        <template slot-scope="scope">
                          <el-button
                            size="medium"
                            type="text"
                            @click="
                              viewDetails(
                                scope.row.needFollowUpAgainInfo,
                                scope.row.leavehospitaldistrictname +
                                  '再次随访需随访列表'
                              )
                            "
                            ><span class="button-zx">{{
                              scope.row.needFollowUpAgain
                            }}</span></el-button
                          >
                        </template>
                      </el-table-column>
                      <el-table-column
                        label="待随访"
                        align="center"
                        key="pendingFollowUpAgain"
                        prop="pendingFollowUpAgain"
                      >
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="随访成功"
                    align="center"
                    key="followUpSuccess"
                    prop="followUpSuccess"
                  >
                    <template slot-scope="scope">
                      <el-button
                        size="medium"
                        type="text"
                        @click="
                          viewDetails(
                            scope.row.followUpSuccessInfo,
                            scope.row.leavehospitaldistrictname + '随访成功列表'
                          )
                        "
                        ><span class="button-zx">{{
                          scope.row.followUpSuccess
                        }}</span></el-button
                        <template slot-scope="scope">
                          <el-button
                            size="medium"
                            type="text"
                            @click="
                              viewDetails(
                                scope.row.pendingFollowUpAgainInfo,
                                scope.row.leavehospitaldistrictname +
                                  '再次随访待随访列表'
                              )
                            "
                            ><span class="button-zx">{{
                              scope.row.pendingFollowUpAgain
                            }}</span></el-button
                          >
                        </template>
                      </el-table-column>
                      <el-table-column
                        label="随访成功"
                        align="center"
                        key="followUpSuccessAgain"
                        prop="followUpSuccessAgain"
                      >
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="随访失败"
                    align="center"
                    key="followUpFail"
                    prop="followUpFail"
                  >
                    <template slot-scope="scope">
                      <el-button
                        size="medium"
                        type="text"
                        @click="
                          viewDetails(
                            scope.row.followUpFailInfo,
                            scope.row.leavehospitaldistrictname + '随访失败列表'
                          )
                        "
                        ><span class="button-zx">{{
                          scope.row.followUpFail
                        }}</span></el-button
                        <template slot-scope="scope">
                          <el-button
                            size="medium"
                            type="text"
                            @click="
                              viewDetails(
                                scope.row.followUpSuccessAgainInfo,
                                scope.row.leavehospitaldistrictname +
                                  '再次随访随访成功列表'
                              )
                            "
                            ><span class="button-zx">{{
                              scope.row.followUpSuccessAgain
                            }}</span></el-button
                          >
                        </template>
                      </el-table-column>
                      <el-table-column
                        label="随访失败"
                        align="center"
                        key="followUpFailAgain"
                        prop="followUpFailAgain"
                      >
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="随访率"
                    align="center"
                    width="120"
                    key="followUpRate"
                    prop="followUpRate"
                  >
                    <!-- <template slot-scope="scope">
                      <span
                        >{{
                          (Number(scope.row.followUpRate) * 100).toFixed(2)
                        }}%</span
                        <template slot-scope="scope">
                          <el-button
                            size="medium"
                            type="text"
                            @click="
                              viewDetails(
                                scope.row.followUpFailAgainInfo,
                                scope.row.leavehospitaldistrictname +
                                  '再次随访随访失败列表'
                              )
                            "
                            ><span class="button-zx">{{
                              scope.row.followUpFailAgain
                            }}</span></el-button
                          >
                        </template>
                      </el-table-column>
                      <el-table-column
                        label="随访率"
                        align="center"
                        width="120"
                        key="followUpRateAgain"
                        prop="followUpRateAgain"
                      >
                    </template> -->
                  </el-table-column>
                  <el-table-column
                    label="及时率"
                    align="center"
                    width="120"
                    key="rate"
                    prop="rate"
                  >
                    <template slot-scope="scope">
                      <el-button
                        size="medium"
                        type="text"
                        @click="Seedetails(scope.row)"
                        ><span class="button-zx"
                          >{{
                            (Number(scope.row.rate) * 100).toFixed(2)
                          }}%</span
                        ></el-button
                      </el-table-column>
                      <el-table-column
                        label="人工"
                        align="center"
                        key="manualAgain"
                        prop="manualAgain"
                      >
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="人工"
                    align="center"
                    key="manual"
                    prop="manual"
                  >
                    <template slot-scope="scope">
                      <el-button
                        size="medium"
                        type="text"
                        @click="
                          viewDetails(
                            scope.row.manualInfo,
                            scope.row.leavehospitaldistrictname + '人工随访列表'
                          )
                        "
                        ><span class="button-zx">{{
                          scope.row.manual
                        }}</span></el-button
                        <template slot-scope="scope">
                          <el-button
                            size="medium"
                            type="text"
                            @click="
                              viewDetails(
                                scope.row.manualAgainInfo,
                                scope.row.leavehospitaldistrictname +
                                  '再次随访人工随访列表'
                              )
                            "
                            ><span class="button-zx">{{
                              scope.row.manualAgain
                            }}</span></el-button
                          >
                        </template>
                      </el-table-column>
                      <el-table-column
                        label="短信"
                        align="center"
                        key="smsAgain"
                        prop="smsAgain"
                      >
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="短信"
                    align="center"
                    key="sms"
                    prop="sms"
                  >
                    <template slot-scope="scope">
                      <el-button
                        size="medium"
                        type="text"
                        @click="
                          viewDetails(
                            scope.row.smsInfo,
                            scope.row.leavehospitaldistrictname + '短信随访列表'
                          )
                        "
                        ><span class="button-zx">{{
                          scope.row.sms
                        }}</span></el-button
                        <template slot-scope="scope">
                          <el-button
                            size="medium"
                            type="text"
                            @click="
                              viewDetails(
                                scope.row.smsAgainInfo,
                                scope.row.leavehospitaldistrictname +
                                  '再次随访短信随访列表'
                              )
                            "
                            ><span class="button-zx">{{
                              scope.row.smsAgain
                            }}</span></el-button
                          >
                        </template>
                      </el-table-column>
                      <el-table-column
                        label="微信"
                        align="center"
                        key="weChatAgain"
                        prop="weChatAgain"
                      >
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="微信"
                    align="center"
                    key="weChat"
                    prop="weChat"
                  >
                    <template slot-scope="scope">
                      <el-button
                        size="medium"
                        type="text"
                        @click="
                          viewDetails(
                            scope.row.weChatInfo,
                            scope.row.leavehospitaldistrictname + '微信随访列表'
                          )
                        "
                        ><span class="button-zx">{{
                          scope.row.weChat
                        }}</span></el-button
                      >
                    </template>
                  </el-table-column>
                </el-table-column>
                <el-table-column align="center" label="再次出院随访">
                  <el-table-column
                    label="需随访"
                    align="center"
                    key="needFollowUpAgain"
                    prop="needFollowUpAgain"
                  >
                    <template slot-scope="scope">
                      <el-button
                        size="medium"
                        type="text"
                        @click="
                          viewDetails(
                            scope.row.needFollowUpAgainInfo,
                            scope.row.leavehospitaldistrictname +
                              '再次随访需随访列表'
                          )
                        "
                        ><span class="button-zx">{{
                          scope.row.needFollowUpAgain
                        }}</span></el-button
                      >
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="待随访"
                    align="center"
                    key="pendingFollowUpAgain"
                    prop="pendingFollowUpAgain"
                  >
                    <template slot-scope="scope">
                      <el-button
                        size="medium"
                        type="text"
                        @click="
                          viewDetails(
                            scope.row.pendingFollowUpAgainInfo,
                            scope.row.leavehospitaldistrictname +
                              '再次随访待随访列表'
                          )
                        "
                        ><span class="button-zx">{{
                          scope.row.pendingFollowUpAgain
                        }}</span></el-button
                      >
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="随访成功"
                    align="center"
                    key="followUpSuccessAgain"
                    prop="followUpSuccessAgain"
                  >
                    <template slot-scope="scope">
                      <el-button
                        size="medium"
                        type="text"
                        @click="
                          viewDetails(
                            scope.row.followUpSuccessAgainInfo,
                            scope.row.leavehospitaldistrictname +
                              '再次随访随访成功列表'
                          )
                        "
                        ><span class="button-zx">{{
                          scope.row.followUpSuccessAgain
                        }}</span></el-button
                      >
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="随访失败"
                    align="center"
                    key="followUpFailAgain"
                    prop="followUpFailAgain"
                  >
                    <template slot-scope="scope">
                      <el-button
                        size="medium"
                        type="text"
                        @click="
                          viewDetails(
                            scope.row.followUpFailAgainInfo,
                            scope.row.leavehospitaldistrictname +
                              '再次随访随访失败列表'
                          )
                        "
                        ><span class="button-zx">{{
                          scope.row.followUpFailAgain
                        }}</span></el-button
                      >
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="随访率"
                    align="center"
                    width="120"
                    key="followUpRateAgain"
                    prop="followUpRateAgain"
                  >
                    <!-- <template slot-scope="scope">
                      <span
                        >{{
                          (Number(scope.row.FollowUpRateAgain) * 100).toFixed(2)
                        }}%</span
                      >
                    </template> -->
                  </el-table-column>
                  <el-table-column
                    label="人工"
                    align="center"
                    key="manualAgain"
                    prop="manualAgain"
                  >
                    <template slot-scope="scope">
                      <el-button
                        size="medium"
                        type="text"
                        @click="
                          viewDetails(
                            scope.row.manualAgainInfo,
                            scope.row.leavehospitaldistrictname +
                              '再次随访人工随访列表'
                          )
                        "
                        ><span class="button-zx">{{
                          scope.row.manualAgain
                        }}</span></el-button
                      >
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="短信"
                    align="center"
                    key="smsAgain"
                    prop="smsAgain"
                  >
                    <template slot-scope="scope">
                      <el-button
                        size="medium"
                        type="text"
                        @click="
                          viewDetails(
                            scope.row.smsAgainInfo,
                            scope.row.leavehospitaldistrictname +
                              '再次随访短信随访列表'
                          )
                        "
                        ><span class="button-zx">{{
                          scope.row.smsAgain
                        }}</span></el-button
                      >
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="微信"
                    align="center"
                    key="weChatAgain"
                    prop="weChatAgain"
                  >
                    <template slot-scope="scope">
                      <el-button
                        size="medium"
                        type="text"
                        @click="
                          viewDetails(
                            scope.row.weChatAgainInfo,
                            scope.row.leavehospitaldistrictname +
                              '再次随访微信随访列表'
                          )
                        "
                        ><span class="button-zx">{{
                          scope.row.weChatAgain
                        }}</span></el-button
                      >
                    </template>
                  </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>
                        <template slot-scope="scope">
                          <el-button
                            size="medium"
                            type="text"
                            @click="
                              viewDetails(
                                scope.row.weChatAgainInfo,
                                scope.row.leavehospitaldistrictname +
                                  '再次随访微信随访列表'
                              )
                            "
                            ><span class="button-zx">{{
                              scope.row.weChatAgain
                            }}</span></el-button
                          >
                        </template>
                      </el-table-column>
                    </el-table-column>
                  </el-table>
                </div>
              </el-tab-pane>
            </el-tabs>
            <!-- 原来的分页组件保留(如果需要) -->
            <!-- <pagination
              v-show="total > 0"
              :total="total"
@@ -1068,7 +1170,7 @@
            :total="patienttotal"
            :page.sync="patientqueryParams.pn"
            :limit.sync="patientqueryParams.ps"
            @pagination="Seedetails"
            @pagination="Seedetailstion"
          />
        </div>
      </div>
@@ -1165,6 +1267,20 @@
                        >已完成</el-tag
                      >
                    </div>
                  </template>
                </el-table-column>
                <el-table-column
                  label="任务执行方式"
                  align="center"
                  key="preachform"
                  prop="preachform"
                  width="160"
                  :show-overflow-tooltip="true"
                >
                  <template slot-scope="scope">
                    <span v-for="item in scope.row.preachform"
                      >{{ item }}、
                    </span>
                  </template>
                </el-table-column>
                <el-table-column
@@ -1283,13 +1399,6 @@
              </el-table>
            </div>
          </el-row>
          <pagination
            v-show="patienttotal > 0 && this.patientqueryParams.allhosp != 6"
            :total="patienttotal"
            :page.sync="patientqueryParams.pn"
            :limit.sync="patientqueryParams.ps"
            @pagination="Seedetails"
          />
        </div>
      </div>
    </el-dialog>
@@ -1311,6 +1420,7 @@
import { saveAs } from "file-saver";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
const shortcuts = [
  {
    text: "今天",
@@ -1335,41 +1445,52 @@
    },
  },
];
export default {
  name: "Percentage",
  dicts: ["sys_normal_disable", "sys_user_sex"],
  components: { Treeselect },
  data() {
    return {
      topactiveName: "Local", //顶部选择
      activeName: "first", //侧边选择
      // 新增:Tab标签页控制
      activeTab: "first", // 当前激活的tab,first-首次随访,second-再次随访
      // 分离的数据列表
      firstFollowUpList: [], // 首次随访数据
      secondFollowUpList: [], // 再次随访数据
      // 分离的加载状态
      loading: false, // 首次随访表格加载状态
      loadingSecond: false, // 再次随访表格加载状态
      // 分离的展开状态
      expands: [], // 首次随访表格展开行
      expandsSecond: [], // 再次随访表格展开行
      // 分离的选择状态
      ids: [], // 首次随访选中项
      idsSecond: [], // 再次随访选中项
      orgname: "",
      expands: [],
      infotitlelist: [],
      currentDisplayList: [], // 当前显示的数据
      loadIndex: 0, // 当前已加载的数据索引
      pageSize: 100, // 每次加载的数据量
      isLoading: false, // 防止滚动时重复加载
      // 遮罩层
      loading: false,
      currentDisplayList: [],
      loadIndex: 0,
      pageSize: 100,
      isLoading: false,
      Seedloading: false,
      chartDialogVisible: false,
      infotitleVisible: false,
      searchName: "", // 搜索关键词
      searchName: "",
      infotitloading: false,
      infotitle: "",
      pieChart: null,
      barLineChart: null,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      idds: "", //分类id
      // 总条数
      idds: "",
      total: 0,
      flatArrayhospit: [],
      flatArraydept: [],
@@ -1389,12 +1510,11 @@
        pn: 1,
        ps: 10,
      },
      amendtag: false, //是否修改类别
      lstamendtag: false, //是否修改标签
      scavisible: false, //删除弹框
      deleteVisible: false, //分类删除弹框
      deletefenl: "高血压", //删除项
      //修改添加标签弹框数据
      amendtag: false,
      lstamendtag: false,
      scavisible: false,
      deleteVisible: false,
      deletefenl: "高血压",
      tagform: {
        isupload: "",
        tagname: "",
@@ -1404,32 +1524,23 @@
      classifyform: {
        categoryname: "",
      },
      // 标签表格数据
      userList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 日期范围
      dateRange: [],
      // 岗位选项
      postOptions: [],
      // 角色选项
      roleOptions: [],
      // 存储所有科室代码
      allDeptCodes: [],
      // 存储所有病区代码
      allWardCodes: [],
      // 表单参数
      checkboxlist: [],
      form: {},
      forms: {
        name: "",
      },
      numberlb: 22,
      dialogFormVisible: false, //添加、修改类别弹框
      lstamendtagVisible: false, //添加、修改标签弹框
      goQRCodeVisible: false, //二维码弹框
      sidecolumnval: "", //类别搜索
      dialogFormVisible: false,
      lstamendtagVisible: false,
      goQRCodeVisible: false,
      sidecolumnval: "",
      propss: { multiple: true },
      SeedetailsVisible: false,
      options: store.getters.tasktypes,
@@ -1445,15 +1556,14 @@
        },
        shortcuts: shortcuts,
      },
      // 查询标签列表参数
      queryParams: {
        serviceType: [2],
        dateRange: [],
        statisticaltype: 1,
        leavehospitaldistrictcodes: ["all"], // 默认选中全部病区
        deptcodes: [], // 默认选中全部科室
        leavehospitaldistrictcodes: ["all"],
        deptcodes: [],
        visitCount: 1, // 新增:随访次数参数,1-首次,2-再次
      },
      // 列信息
      columns: [
        { key: 0, label: `标签编号`, visible: true },
        { key: 1, label: `标签名称`, visible: true },
@@ -1468,17 +1578,19 @@
  watch: {},
  created() {
    this.getDeptTree();
    this.getList();
    this.getFirstFollowUpList(); // 默认加载首次随访数据
    this.checkboxlist = store.getters.checkboxlist;
    this.orgname = localStorage.getItem("orgname");
  },
  methods: {
    /** 查询标签列表 */
    getList() {
      // 处理查询参数
    /** 查询首次随访列表 */
    async getFirstFollowUpList() {
      this.loading = true;
      this.queryParams.visitCount = 1; // 设置随访次数为首次
      const params = {
        ...this.queryParams,
        // 如果选择了"全部",则传所有病区/科室代码
        leavehospitaldistrictcodes:
          this.queryParams.leavehospitaldistrictcodes.includes("all")
            ? this.allWardCodes
@@ -1488,14 +1600,152 @@
          : this.queryParams.deptcodes,
      };
      // 移除可能存在的"all"值
      delete params.leavehospitaldistrictcodes.all;
      delete params.deptcodes.all;
      getSfStatistics(params).then((response) => {
        console.log(response);
        // this.total = response.total;
        this.userList = this.customSort(response.data);
      });
      try {
        const response = await getSfStatistics(params);
        this.firstFollowUpList = this.customSort(response.data);
        this.total = response.total;
      } catch (error) {
        console.error("获取首次随访数据失败:", error);
        this.$message.error("获取首次随访数据失败");
      } finally {
        this.loading = false;
      }
    },
    /** 查询再次随访列表 */
    async getSecondFollowUpList() {
      this.loadingSecond = true;
      this.queryParams.visitCount = 2; // 设置随访次数为再次
      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;
      try {
        const response = await getSfStatistics(params);
        this.secondFollowUpList = this.customSort(response.data);
        this.total = response.total;
      } catch (error) {
        console.error("获取再次随访数据失败:", error);
        this.$message.error("获取再次随访数据失败");
      } finally {
        this.loadingSecond = false;
      }
    },
    /** Tab切换事件 */
    handleTabClick(tab) {
      if (tab.name === "first") {
        if (this.firstFollowUpList.length === 0) {
          this.getFirstFollowUpList();
        }
      } else if (tab.name === "second") {
        if (this.secondFollowUpList.length === 0) {
          this.getSecondFollowUpList();
        }
      }
    },
    sortChineseNumber(aRow, bRow) {
      const a = aRow.leavehospitaldistrictname;
      const b = bRow.leavehospitaldistrictname;
      // 中文数字到阿拉伯数字的映射(扩展到45)
      const chineseNumMap = {
        一: 1,
        二: 2,
        三: 3,
        四: 4,
        五: 5,
        六: 6,
        七: 7,
        八: 8,
        九: 9,
        十: 10,
        十一: 11,
        十二: 12,
        十三: 13,
        十四: 14,
        十五: 15,
        十六: 16,
        十七: 17,
        十八: 18,
        十九: 19,
        二十: 20,
        二十一: 21,
        二十二: 22,
        二十三: 23,
        二十四: 24,
        二十五: 25,
        二十六: 26,
        二十七: 27,
        二十八: 28,
        二十九: 29,
        三十: 30,
        三十一: 31,
        三十二: 32,
        三十三: 33,
        三十四: 34,
        三十五: 35,
        三十六: 36,
        三十七: 37,
        三十八: 38,
        三十九: 39,
        四十: 40,
        四十一: 41,
        四十二: 42,
        四十三: 43,
        四十四: 44,
        四十五: 45,
      };
      // 提取中文数字
      const getNumberFromText = (text) => {
        if (!text || typeof text !== "string") return -1;
        // 匹配中文数字,支持一到四十五
        const match = text.match(/^([一二三四五六七八九十]+)/);
        if (match && match[1]) {
          const chineseNum = match[1];
          return chineseNumMap[chineseNum] !== undefined
            ? chineseNumMap[chineseNum]
            : -1;
        }
        // 如果没有匹配到中文数字,尝试匹配阿拉伯数字
        const arabicMatch = text.match(/^(\d+)/);
        if (arabicMatch && arabicMatch[1]) {
          const num = parseInt(arabicMatch[1], 10);
          return num >= 1 && num <= 45 ? num : -1;
        }
        return -1;
      };
      const numA = getNumberFromText(a);
      const numB = getNumberFromText(b);
      // 处理无法解析的情况
      if (numA === -1 && numB === -1) {
        return (a || "").localeCompare(b || "");
      }
      if (numA === -1) return 1;
      if (numB === -1) return -1;
      return numA - numB;
    },
    // 搜索处理函数
    handleSearch() {
@@ -1511,8 +1761,9 @@
      }
    },
    customSort(data) {
      // 定义您期望的病区顺序(扩展到三十)
      // 定义您期望的病区顺序(扩展到四十五)
      const order = [
        "一",
        "二",
        "三",
        "四",
@@ -1542,21 +1793,55 @@
        "二十八",
        "二十九",
        "三十",
        "三十一",
        "三十二",
        "三十三",
        "三十四",
        "三十五",
        "三十六",
        "三十七",
        "三十八",
        "三十九",
        "四十",
        "四十一",
        "四十二",
        "四十三",
        "四十四",
        "四十五",
      ];
      return data.sort((a, b) => {
        // 提取病区名称中的中文数字部分[6](@ref)
        // 提取病区名称中的中文数字部分
        const getIndex = (name) => {
          const numStr = name.match(
            /^(二|三|四|五|六|七|八|九|十|十一|十二|十三|十四|十五|十六|十七|十八|十九|二十|二十一|二十二|二十三|二十四|二十五|二十六|二十七|二十八|二十九|三十)/
          )?.[1];
          return order.indexOf(numStr);
          if (!name || typeof name !== "string") return -1;
          // 匹配中文数字
          const chineseMatch = name.match(/^([一二三四五六七八九十]+)/);
          if (chineseMatch && chineseMatch[1]) {
            return order.indexOf(chineseMatch[1]);
          }
          // 匹配阿拉伯数字
          const arabicMatch = name.match(/^(\d+)/);
          if (arabicMatch && arabicMatch[1]) {
            const num = parseInt(arabicMatch[1], 10);
            if (num >= 1 && num <= 45) {
              return num - 1; // 因为数组索引从0开始
            }
          }
          return -1;
        };
        const indexA = getIndex(a.leavehospitaldistrictname);
        const indexB = getIndex(b.leavehospitaldistrictname);
        // 如果都在定义的顺序中,按定义顺序排;否则,未定义的排在后面[2](@ref)
        // 排序逻辑
        if (indexA === -1 && indexB === -1) {
          return (a.leavehospitaldistrictname || "").localeCompare(
            b.leavehospitaldistrictname || ""
          );
        }
        if (indexA === -1) return 1;
        if (indexB === -1) return -1;
        return indexA - indexB;
@@ -1586,6 +1871,7 @@
          : this.queryParams.deptcodes,
        leavehospitaldistrictcodes: [row.leavehospitaldistrictcode],
        drcode: "1",
        visitCount: 1, // 设置为首次随访
      };
      // 移除可能存在的"all"值
@@ -1847,11 +2133,36 @@
        this.Seedloading = false;
      });
    },
    Seedetailstion() {
      selectTimelyRate(this.patientqueryParams).then((response) => {
        this.logsheetlist = response.data.detail;
        this.patienttotal = response.data.total;
        this.Seedloading = false;
      });
    },
    viewDetails(row, title) {
      this.infotitleVisible = true;
      this.infotitle = title;
      this.infotitlelist = row; // 假设row就是需要展示的详细数组
      console.log(this.infotitlelist, "this.infotitlelist");
      this.infotitlelist.forEach((item) => {
        let idArray = null;
        if (item.preachform) {
          if (item.endtime) {
            item.preachformson = item.preachform;
            idArray = item.preachform.split(",");
          }
          item.preachform = idArray.map((value) => {
            // 查找id对应的对象
            const item = this.checkboxlist.find((item) => item.value == value);
            // 如果找到对应的id,返回label值,否则返回null
            return item ? item.label : null;
          });
        }
      });
      // 初始化加载
      this.loadIndex = 0;
      this.currentDisplayList = [];
@@ -1865,6 +2176,8 @@
      // 模拟异步加载,实际可能是直接切片本地数据
      setTimeout(() => {
        console.log(this.infotitlelist, "this.infotitlelist");
        const nextChunk = this.infotitlelist.slice(
          this.loadIndex,
          this.loadIndex + this.pageSize
@@ -1974,7 +2287,7 @@
          row.isupload = row.isupload === "0" ? "1" : "0";
        });
    },
    /** 搜索按钮操作 */
    /** 搜索按钮操作 - 修改为搜索当前激活的tab数据 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      if (!this.queryParams.dateRange) this.queryParams.dateRange = [];
@@ -1983,14 +2296,20 @@
      } else if (this.queryParams.statisticaltype == 2) {
        this.queryParams.leavehospitaldistrictcodes = [];
      }
      console.log(this.queryParams.dateRange);
      this.queryParams.startTime = this.parseTime(
        this.queryParams.dateRange[0]
      );
      this.queryParams.endTime = this.parseTime(this.queryParams.dateRange[1]);
      this.getList();
      // 根据当前激活的tab加载对应数据
      if (this.activeTab === "first") {
        this.getFirstFollowUpList();
      } else {
        this.getSecondFollowUpList();
      }
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams.dateRange = [];
@@ -2026,337 +2345,77 @@
        .catch(() => {});
    },
    // 导出方法
    // 替换您原来的 exportTable 方法
    async exportTable() {
      try {
        // 1. 获取并格式化日期范围
        let dateRangeString = ""; // 用于文件名
        let sheetNameSuffix = ""; // 用于工作表名
        let dateRangeString = "";
        let sheetNameSuffix = "";
        // 检查是否存在选中的日期范围
        if (
          this.queryParams.dateRange &&
          this.queryParams.dateRange.length === 2
        ) {
          const startDateStr = this.queryParams.dateRange[0]; // 开始日期字符串,例如 "2026-01-01 00:00:00"
          const endDateStr = this.queryParams.dateRange[1]; // 结束日期字符串
          // 格式化日期为 YYYY-MM-DD(去掉时间部分)
          const startDateStr = this.queryParams.dateRange[0];
          const endDateStr = this.queryParams.dateRange[1];
          const formatDateForDisplay = (dateTimeStr) => {
            return dateTimeStr.split(" ")[0]; // 取空格前的部分,即 "YYYY-MM-DD"
            return dateTimeStr.split(" ")[0];
          };
          const startDateFormatted = formatDateForDisplay(startDateStr);
          const endDateFormatted = formatDateForDisplay(endDateStr);
          // 构建日期范围字符串
          dateRangeString = `${startDateFormatted}至${endDateFormatted}`;
          sheetNameSuffix = `${startDateFormatted}至${endDateFormatted}`;
        } else {
          // 如果没有选择日期范围,则使用当前月份作为备选方案
          const now = new Date();
          const currentMonth = now.getMonth() + 1;
          dateRangeString = `${currentMonth}月`;
          sheetNameSuffix = `${currentMonth}月`;
        }
        // 2. 动态构建文件名和工作表名
        const excelName = `出院随访统计表_${dateRangeString}.xlsx`;
        const worksheetName = `随访统计_${sheetNameSuffix}`; // 工作表名不能超过31个字符[2](@ref)
        // 创建新的工作簿和工作表
        const workbook = new ExcelJS.Workbook();
        const worksheet = workbook.addWorksheet(worksheetName); // 使用动态工作表名
        // 定义样式(新增总标题样式)
        const titleStyle = {
          font: {
            name: "微软雅黑",
            size: 16,
            bold: true,
            color: { argb: "FF000000" },
          },
          fill: {
            type: "pattern",
            pattern: "solid",
            fgColor: { argb: "FFE6F3FF" },
          },
          alignment: {
            vertical: "middle",
            horizontal: "center",
            wrapText: true,
          },
          border: {
            top: { style: "thin", color: { argb: "FFD0D0D0" } },
            left: { style: "thin", color: { argb: "FFD0D0D0" } },
            bottom: { style: "thin", color: { argb: "FFD0D0D0" } },
            right: { style: "thin", color: { argb: "FFD0D0D0" } },
          },
        };
        // 定义样式
        const headerStyle = {
          font: {
            name: "微软雅黑",
            size: 11,
            bold: true,
            color: { argb: "FF000000" },
          },
          fill: {
            type: "pattern",
            pattern: "solid",
            fgColor: { argb: "FFF5F7FA" },
          },
          alignment: {
            vertical: "middle",
            horizontal: "center",
            wrapText: true,
          },
          border: {
            top: { style: "thin", color: { argb: "FFD0D0D0" } },
            left: { style: "thin", color: { argb: "FFD0D0D0" } },
            bottom: { style: "thin", color: { argb: "FFD0D0D0" } },
            right: { style: "thin", color: { argb: "FFD0D0D0" } },
          },
        };
        // 2. 根据当前激活的tab确定导出的数据
        const isFirstFollowUp = this.activeTab === "first";
        let excelName, worksheetName, dataToExport;
        const cellStyle = {
          font: {
            name: "宋体",
            size: 10,
            color: { argb: "FF000000" },
          },
          alignment: {
            vertical: "middle",
            horizontal: "center",
          },
          border: {
            top: { style: "thin", color: { argb: "FFD0D0D0" } },
            left: { style: "thin", color: { argb: "FFD0D0D0" } },
            bottom: { style: "thin", color: { argb: "FFD0D0D0" } },
            right: { style: "thin", color: { argb: "FFD0D0D0" } },
          },
        };
        if (isFirstFollowUp) {
          excelName = `首次出院随访统计表_${dateRangeString}.xlsx`;
          worksheetName = `首次随访统计_${sheetNameSuffix}`;
          dataToExport = this.firstFollowUpList;
        const summaryStyle = {
          font: {
            name: "宋体",
            size: 10,
            bold: true,
            color: { argb: "FF409EFF" },
          },
          fill: {
            type: "pattern",
            pattern: "solid",
            fgColor: { argb: "FFF5F7FA" },
          },
          alignment: {
            vertical: "middle",
            horizontal: "center",
          },
          border: {
            top: { style: "thin", color: { argb: "FFD0D0D0" } },
            left: { style: "thin", color: { argb: "FFD0D0D0" } },
            bottom: { style: "thin", color: { argb: "FFD0D0D0" } },
            right: { style: "thin", color: { argb: "FFD0D0D0" } },
          },
        };
        // 1. 添加总标题行(第一行)
        worksheet.mergeCells(1, 1, 1, 23); // 合并A1到W1的所有列[1,4](@ref)
        const titleCell = worksheet.getCell(1, 1);
        titleCell.value = `${sheetNameSuffix}出院随访统计表`; // 使用文件名作为总标题
        titleCell.style = titleStyle;
        worksheet.getRow(1).height = 35; // 设置总标题行高
        // 1. 首先,创建并设置第二行(子表头)的所有单元格
        const secondRowHeaders = [
          "", // A2 展开列占位(其值将由第一行合并后的主单元格决定)
          "出院病区",
          "科室",
          "出院人次",
          "无需随访人次",
          "应随访人次", // B2 to F2
          // 首次出院随访子表头
          "需随访",
          "待随访",
          "随访成功",
          "随访失败",
          "随访率",
          "及时率",
          "人工",
          "短信",
          "微信",
          // 再次出院随访子表头
          "需随访",
          "待随访",
          "随访成功",
          "随访失败",
          "随访率",
          "人工",
          "短信",
          "微信",
        ];
        // 添加第二行(原第一行下移)
        secondRowHeaders.forEach((header, index) => {
          const cell = worksheet.getCell(3, index + 1); // 改为第3行
          cell.value = header;
          cell.style = headerStyle;
        });
        // 3. 调整原合并单元格位置(原第1行合并单元格下移到第2行)
        // 合并 A2:A3
        worksheet.mergeCells(2, 1, 3, 1);
        worksheet.getCell(2, 1).value = "";
        worksheet.getCell(2, 1).style = headerStyle;
        // 合并 B2:B3
        worksheet.mergeCells(2, 2, 3, 2);
        worksheet.getCell(2, 2).value = "出院病区";
        worksheet.getCell(2, 2).style = headerStyle;
        // 合并 C2:C3
        worksheet.mergeCells(2, 3, 3, 3);
        worksheet.getCell(2, 3).value = "科室";
        worksheet.getCell(2, 3).style = headerStyle;
        // 合并 D2:D3
        worksheet.mergeCells(2, 4, 3, 4);
        worksheet.getCell(2, 4).value = "出院人次";
        worksheet.getCell(2, 4).style = headerStyle;
        // 合并 E2:E3
        worksheet.mergeCells(2, 5, 3, 5);
        worksheet.getCell(2, 5).value = "无需随访人次";
        worksheet.getCell(2, 5).style = headerStyle;
        // 合并 F2:F3
        worksheet.mergeCells(2, 6, 3, 6);
        worksheet.getCell(2, 6).value = "应随访人次";
        worksheet.getCell(2, 6).style = headerStyle;
        // 4. 调整横向合并标题位置(下移到第2行)
        // 首次出院随访(合并G2:O2)
        worksheet.mergeCells(2, 7, 2, 15); // G2:O2
        worksheet.getCell(2, 7).value = "首次出院随访";
        worksheet.getCell(2, 7).style = headerStyle;
        // 再次出院随访(合并P2:W2)
        worksheet.mergeCells(2, 16, 2, 23); // P2:W2
        worksheet.getCell(2, 16).value = "再次出院随访";
        worksheet.getCell(2, 16).style = headerStyle;
        // 5. 设置行高
        worksheet.getRow(1).height = 35; // 总标题行高
        worksheet.getRow(2).height = 28; // 原第一行下移
        worksheet.getRow(3).height = 25; // 原第二行下移
        // 6. 添加数据行(注意行索引需要+1,因为上面插入了一行)
        this.userList.forEach((item, rowIndex) => {
          const dataRow = worksheet.addRow(
            [
              "", // 展开列
              item.leavehospitaldistrictname || "",
              item.deptname || "",
              item.dischargeCount || 0,
              item.nonFollowUp || 0,
              item.followUpNeeded || 0,
              // 首次出院随访数据
              item.needFollowUp || 0,
              item.pendingFollowUp || 0,
              item.followUpSuccess || 0,
              item.followUpFail || 0,
              item.followUpRate || "0%",
              item.rate ? (Number(item.rate) * 100).toFixed(2) + "%" : "0%",
              item.manual || 0,
              item.sms || 0,
              item.weChat || 0,
              // 再次出院随访数据
              item.needFollowUpAgain || 0,
              item.pendingFollowUpAgain || 0,
              item.followUpSuccessAgain || 0,
              item.followUpFailAgain || 0,
              item.followUpRateAgain || "0%",
              item.manualAgain || 0,
              item.smsAgain || 0,
              item.weChatAgain || 0,
            ],
            rowIndex + 4
          ); // 从第4行开始添加数据(原第3行)
          // 应用数据行样式
          dataRow.eachCell((cell) => {
            cell.style = cellStyle;
          });
          dataRow.height = 24;
        });
        // 添加合计行
        const summaries = this.getSummaries({
          columns: [
            { property: "" },
            { property: "leavehospitaldistrictname" },
            { property: "deptname" },
            { property: "dischargeCount" },
            { property: "nonFollowUp" },
            { property: "followUpNeeded" },
            { property: "needFollowUp" },
            { property: "pendingFollowUp" },
            { property: "followUpSuccess" },
            { property: "followUpFail" },
            { property: "followUpRate" },
            { property: "rate" },
            { property: "manual" },
            { property: "sms" },
            { property: "weChat" },
            { property: "needFollowUpAgain" },
            { property: "pendingFollowUpAgain" },
            { property: "followUpSuccessAgain" },
            { property: "followUpFailAgain" },
            { property: "followUpRateAgain" },
            { property: "manualAgain" },
            { property: "smsAgain" },
            { property: "weChatAgain" },
          ],
          data: this.userList,
        });
        const summaryRow = worksheet.addRow(summaries);
        summaryRow.eachCell((cell, colNumber) => {
          cell.style = summaryStyle;
          // 第一列显示"合计"
          if (colNumber === 1) {
            cell.value = "合计";
          if (!dataToExport || dataToExport.length === 0) {
            this.$message.warning("暂无首次随访数据可导出");
            return false;
          }
        });
        summaryRow.height = 28;
        } else {
          excelName = `再次出院随访统计表_${dateRangeString}.xlsx`;
          worksheetName = `再次随访统计_${sheetNameSuffix}`;
          dataToExport = this.secondFollowUpList;
        // 设置列宽
        worksheet.columns = [
          { width: 8 }, // 展开列
          { width: 20 }, // 出院病区
          { width: 15 }, // 科室
          { width: 12 }, // 出院人次
          { width: 12 }, // 无需随访人次
          { width: 12 }, // 应随访人次
          // 首次出院随访列
          { width: 10 },
          { width: 10 },
          { width: 10 },
          { width: 10 },
          { width: 12 },
          { width: 12 },
          { width: 8 },
          { width: 8 },
          { width: 8 },
          // 再次出院随访列
          { width: 10 },
          { width: 10 },
          { width: 10 },
          { width: 10 },
          { width: 12 },
          { width: 8 },
          { width: 8 },
          { width: 8 },
        ];
          if (!dataToExport || dataToExport.length === 0) {
            this.$message.warning("暂无再次随访数据可导出");
            return false;
          }
        }
        // 生成并下载文件
        // 3. 创建工作簿和工作表
        const workbook = new ExcelJS.Workbook();
        const worksheet = workbook.addWorksheet(worksheetName);
        // 4. 构建表格
        if (isFirstFollowUp) {
          this.buildFirstFollowUpExportSheet(
            worksheet,
            dataToExport,
            sheetNameSuffix
          );
        } else {
          this.buildSecondFollowUpExportSheet(
            worksheet,
            dataToExport,
            sheetNameSuffix
          );
        }
        // 5. 生成并下载文件
        const buffer = await workbook.xlsx.writeBuffer();
        const blob = new Blob([buffer], {
          type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
@@ -2371,7 +2430,666 @@
        return false;
      }
    },
    /** 构建首次随访导出表格 */
    buildFirstFollowUpExportSheet(worksheet, data, sheetNameSuffix) {
      const titleStyle = {
        font: {
          name: "微软雅黑",
          size: 16,
          bold: true,
          color: { argb: "FF000000" },
        },
        fill: {
          type: "pattern",
          pattern: "solid",
          fgColor: { argb: "FFE6F3FF" },
        },
        alignment: { vertical: "middle", horizontal: "center", wrapText: true },
        border: {
          top: { style: "thin", color: { argb: "FFD0D0D0" } },
          left: { style: "thin", color: { argb: "FFD0D0D0" } },
          bottom: { style: "thin", color: { argb: "FFD0D0D0" } },
          right: { style: "thin", color: { argb: "FFD0D0D0" } },
        },
      };
      const headerStyle = {
        font: {
          name: "微软雅黑",
          size: 11,
          bold: true,
          color: { argb: "FF000000" },
        },
        fill: {
          type: "pattern",
          pattern: "solid",
          fgColor: { argb: "FFF5F7FA" },
        },
        alignment: { vertical: "middle", horizontal: "center", wrapText: true },
        border: {
          top: { style: "thin", color: { argb: "FFD0D0D0" } },
          left: { style: "thin", color: { argb: "FFD0D0D0" } },
          bottom: { style: "thin", color: { argb: "FFD0D0D0" } },
          right: { style: "thin", color: { argb: "FFD0D0D0" } },
        },
      };
      const cellStyle = {
        font: { name: "宋体", size: 10, color: { argb: "FF000000" } },
        alignment: { vertical: "middle", horizontal: "center" },
        border: {
          top: { style: "thin", color: { argb: "FFD0D0D0" } },
          left: { style: "thin", color: { argb: "FFD0D0D0" } },
          bottom: { style: "thin", color: { argb: "FFD0D0D0" } },
          right: { style: "thin", color: { argb: "FFD0D0D0" } },
        },
      };
      const summaryStyle = {
        font: {
          name: "宋体",
          size: 10,
          bold: true,
          color: { argb: "FF409EFF" },
        },
        fill: {
          type: "pattern",
          pattern: "solid",
          fgColor: { argb: "FFF5F7FA" },
        },
        alignment: { vertical: "middle", horizontal: "center" },
        border: {
          top: { style: "thin", color: { argb: "FFD0D0D0" } },
          left: { style: "thin", color: { argb: "FFD0D0D0" } },
          bottom: { style: "thin", color: { argb: "FFD0D0D0" } },
          right: { style: "thin", color: { argb: "FFD0D0D0" } },
        },
      };
      // 1. 添加总标题行
      worksheet.mergeCells(1, 1, 1, 16); // 合并A1到P1
      const titleCell = worksheet.getCell(1, 1);
      titleCell.value = `首次出院随访统计表_${sheetNameSuffix}`;
      titleCell.style = titleStyle;
      worksheet.getRow(1).height = 35;
      // 2. 创建表头
      const secondRowHeaders = [
        "", // A2 展开列占位
        "出院病区",
        "科室",
        "出院人次",
        "无需随访人次",
        "应随访人次", // B2 to F2
        // 首次出院随访子表头
        "需随访",
        "待随访",
        "随访成功",
        "随访失败",
        "随访率",
        "及时率",
        "人工",
        "短信",
        "微信",
      ];
      // 添加第二行
      secondRowHeaders.forEach((header, index) => {
        const cell = worksheet.getCell(3, index + 1);
        cell.value = header;
        cell.style = headerStyle;
      });
      // 3. 合并单元格
      // 合并 A2:A3, B2:B3, C2:C3, D2:D3, E2:E3, F2:F3
      for (let i = 1; i <= 6; i++) {
        worksheet.mergeCells(2, i, 3, i);
        const cell = worksheet.getCell(2, i);
        cell.style = headerStyle;
      }
      // 设置第一行合并单元格的值
      worksheet.getCell(2, 1).value = "";
      worksheet.getCell(2, 2).value = "出院病区";
      worksheet.getCell(2, 3).value = "科室";
      worksheet.getCell(2, 4).value = "出院人次";
      worksheet.getCell(2, 5).value = "无需随访人次";
      worksheet.getCell(2, 6).value = "应随访人次";
      // 4. 合并"首次出院随访"标题
      worksheet.mergeCells(2, 7, 2, 15); // G2:O2
      worksheet.getCell(2, 7).value = "首次出院随访";
      worksheet.getCell(2, 7).style = headerStyle;
      // 5. 设置行高
      worksheet.getRow(2).height = 28;
      worksheet.getRow(3).height = 25;
      // 6. 添加数据行
      data.forEach((item, rowIndex) => {
        const dataRow = worksheet.addRow(
          [
            "", // 展开列
            item.leavehospitaldistrictname || "",
            item.deptname || "",
            item.dischargeCount || 0,
            item.nonFollowUp || 0,
            item.followUpNeeded || 0,
            // 首次出院随访数据
            item.needFollowUp || 0,
            item.pendingFollowUp || 0,
            item.followUpSuccess || 0,
            item.followUpFail || 0,
            item.followUpRate || "0%",
            item.rate ? (Number(item.rate) * 100).toFixed(2) + "%" : "0%",
            item.manual || 0,
            item.sms || 0,
            item.weChat || 0,
          ],
          rowIndex + 4
        );
        // 应用数据行样式
        dataRow.eachCell((cell) => {
          cell.style = cellStyle;
        });
        dataRow.height = 24;
      });
      // 7. 添加合计行
      const summaries = this.getFirstFollowUpSummaries(data);
      const summaryRow = worksheet.addRow(summaries);
      summaryRow.eachCell((cell, colNumber) => {
        cell.style = summaryStyle;
        if (colNumber === 1) {
          cell.value = "合计";
        }
      });
      summaryRow.height = 28;
      // 8. 设置列宽
      worksheet.columns = [
        { width: 8 }, // 展开列
        { width: 20 }, // 出院病区
        { width: 15 }, // 科室
        { width: 12 }, // 出院人次
        { width: 12 }, // 无需随访人次
        { width: 12 }, // 应随访人次
        // 首次出院随访列
        { width: 10 }, // 需随访
        { width: 10 }, // 待随访
        { width: 10 }, // 随访成功
        { width: 10 }, // 随访失败
        { width: 12 }, // 随访率
        { width: 12 }, // 及时率
        { width: 8 }, // 人工
        { width: 8 }, // 短信
        { width: 8 }, // 微信
      ];
    },
    /** 首次随访数据合计行计算 */
    getFirstFollowUpSummaries(data) {
      const summaries = [
        "合计",
        "/",
        "/",
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        "0%",
        "0%",
        0,
        0,
        0,
      ];
      data.forEach((item) => {
        // 数值字段求和
        summaries[3] += Number(item.dischargeCount) || 0;
        summaries[4] += Number(item.nonFollowUp) || 0;
        summaries[5] += Number(item.followUpNeeded) || 0;
        summaries[6] += Number(item.needFollowUp) || 0;
        summaries[7] += Number(item.pendingFollowUp) || 0;
        summaries[8] += Number(item.followUpSuccess) || 0;
        summaries[9] += Number(item.followUpFail) || 0;
        summaries[12] += Number(item.manual) || 0;
        summaries[13] += Number(item.sms) || 0;
        summaries[14] += Number(item.weChat) || 0;
      });
      // 计算百分比字段的平均值
      const followUpRateValues = data
        .map((item) => this.extractPercentageValue(item.followUpRate))
        .filter((value) => value !== null);
      const rateValues = data
        .map((item) => this.extractPercentageValue(item.rate))
        .filter((value) => value !== null);
      if (followUpRateValues.length > 0) {
        const avgFollowUpRate =
          followUpRateValues.reduce((sum, val) => sum + val, 0) /
          followUpRateValues.length;
        summaries[10] = (avgFollowUpRate * 100).toFixed(2) + "%";
      }
      if (rateValues.length > 0) {
        const avgRate =
          rateValues.reduce((sum, val) => sum + val, 0) / rateValues.length;
        summaries[11] = (avgRate * 100).toFixed(2) + "%";
      }
      // 格式化数字
      summaries[3] = this.formatNumber(summaries[3]);
      summaries[4] = this.formatNumber(summaries[4]);
      summaries[5] = this.formatNumber(summaries[5]);
      summaries[6] = this.formatNumber(summaries[6]);
      summaries[7] = this.formatNumber(summaries[7]);
      summaries[8] = this.formatNumber(summaries[8]);
      summaries[9] = this.formatNumber(summaries[9]);
      summaries[12] = this.formatNumber(summaries[12]);
      summaries[13] = this.formatNumber(summaries[13]);
      summaries[14] = this.formatNumber(summaries[14]);
      return summaries;
    },
    /** 构建再次随访导出表格 */
    buildSecondFollowUpExportSheet(worksheet, data, sheetNameSuffix) {
      const titleStyle = {
        font: {
          name: "微软雅黑",
          size: 16,
          bold: true,
          color: { argb: "FF000000" },
        },
        fill: {
          type: "pattern",
          pattern: "solid",
          fgColor: { argb: "FFE6F3FF" },
        },
        alignment: { vertical: "middle", horizontal: "center", wrapText: true },
        border: {
          top: { style: "thin", color: { argb: "FFD0D0D0" } },
          left: { style: "thin", color: { argb: "FFD0D0D0" } },
          bottom: { style: "thin", color: { argb: "FFD0D0D0" } },
          right: { style: "thin", color: { argb: "FFD0D0D0" } },
        },
      };
      const headerStyle = {
        font: {
          name: "微软雅黑",
          size: 11,
          bold: true,
          color: { argb: "FF000000" },
        },
        fill: {
          type: "pattern",
          pattern: "solid",
          fgColor: { argb: "FFF5F7FA" },
        },
        alignment: { vertical: "middle", horizontal: "center", wrapText: true },
        border: {
          top: { style: "thin", color: { argb: "FFD0D0D0" } },
          left: { style: "thin", color: { argb: "FFD0D0D0" } },
          bottom: { style: "thin", color: { argb: "FFD0D0D0" } },
          right: { style: "thin", color: { argb: "FFD0D0D0" } },
        },
      };
      const cellStyle = {
        font: { name: "宋体", size: 10, color: { argb: "FF000000" } },
        alignment: { vertical: "middle", horizontal: "center" },
        border: {
          top: { style: "thin", color: { argb: "FFD0D0D0" } },
          left: { style: "thin", color: { argb: "FFD0D0D0" } },
          bottom: { style: "thin", color: { argb: "FFD0D0D0" } },
          right: { style: "thin", color: { argb: "FFD0D0D0" } },
        },
      };
      const summaryStyle = {
        font: {
          name: "宋体",
          size: 10,
          bold: true,
          color: { argb: "FF409EFF" },
        },
        fill: {
          type: "pattern",
          pattern: "solid",
          fgColor: { argb: "FFF5F7FA" },
        },
        alignment: { vertical: "middle", horizontal: "center" },
        border: {
          top: { style: "thin", color: { argb: "FFD0D0D0" } },
          left: { style: "thin", color: { argb: "FFD0D0D0" } },
          bottom: { style: "thin", color: { argb: "FFD0D0D0" } },
          right: { style: "thin", color: { argb: "FFD0D0D0" } },
        },
      };
      // 1. 添加总标题行
      worksheet.mergeCells(1, 1, 1, 15); // 合并A1到O1
      const titleCell = worksheet.getCell(1, 1);
      titleCell.value = `再次出院随访统计表_${sheetNameSuffix}`;
      titleCell.style = titleStyle;
      worksheet.getRow(1).height = 35;
      // 2. 创建表头
      const secondRowHeaders = [
        "", // A2 展开列占位
        "出院病区",
        "科室",
        "出院人次",
        "无需随访人次",
        "应随访人次", // B2 to F2
        // 再次出院随访子表头
        "需随访",
        "待随访",
        "随访成功",
        "随访失败",
        "随访率",
        "人工",
        "短信",
        "微信",
      ];
      // 添加第二行
      secondRowHeaders.forEach((header, index) => {
        const cell = worksheet.getCell(3, index + 1);
        cell.value = header;
        cell.style = headerStyle;
      });
      // 3. 合并单元格
      // 合并 A2:A3, B2:B3, C2:C3, D2:D3, E2:E3, F2:F3
      for (let i = 1; i <= 6; i++) {
        worksheet.mergeCells(2, i, 3, i);
        const cell = worksheet.getCell(2, i);
        cell.style = headerStyle;
      }
      // 设置第一行合并单元格的值
      worksheet.getCell(2, 1).value = "";
      worksheet.getCell(2, 2).value = "出院病区";
      worksheet.getCell(2, 3).value = "科室";
      worksheet.getCell(2, 4).value = "出院人次";
      worksheet.getCell(2, 5).value = "无需随访人次";
      worksheet.getCell(2, 6).value = "应随访人次";
      // 4. 合并"再次出院随访"标题
      worksheet.mergeCells(2, 7, 2, 14); // G2:N2
      worksheet.getCell(2, 7).value = "再次出院随访";
      worksheet.getCell(2, 7).style = headerStyle;
      // 5. 设置行高
      worksheet.getRow(2).height = 28;
      worksheet.getRow(3).height = 25;
      // 6. 添加数据行
      data.forEach((item, rowIndex) => {
        const dataRow = worksheet.addRow(
          [
            "", // 展开列
            item.leavehospitaldistrictname || "",
            item.deptname || "",
            item.dischargeCount || 0,
            item.nonFollowUp || 0,
            item.followUpNeeded || 0,
            // 再次出院随访数据
            item.needFollowUpAgain || 0,
            item.pendingFollowUpAgain || 0,
            item.followUpSuccessAgain || 0,
            item.followUpFailAgain || 0,
            item.followUpRateAgain || "0%",
            item.manualAgain || 0,
            item.smsAgain || 0,
            item.weChatAgain || 0,
          ],
          rowIndex + 4
        );
        // 应用数据行样式
        dataRow.eachCell((cell) => {
          cell.style = cellStyle;
        });
        dataRow.height = 24;
      });
      // 7. 添加合计行
      const summaries = this.getSecondFollowUpSummaries(data);
      const summaryRow = worksheet.addRow(summaries);
      summaryRow.eachCell((cell, colNumber) => {
        cell.style = summaryStyle;
        if (colNumber === 1) {
          cell.value = "合计";
        }
      });
      summaryRow.height = 28;
      // 8. 设置列宽
      worksheet.columns = [
        { width: 8 }, // 展开列
        { width: 20 }, // 出院病区
        { width: 15 }, // 科室
        { width: 12 }, // 出院人次
        { width: 12 }, // 无需随访人次
        { width: 12 }, // 应随访人次
        // 再次出院随访列
        { width: 10 }, // 需随访
        { width: 10 }, // 待随访
        { width: 10 }, // 随访成功
        { width: 10 }, // 随访失败
        { width: 12 }, // 随访率
        { width: 8 }, // 人工
        { width: 8 }, // 短信
        { width: 8 }, // 微信
      ];
    },
    /** 再次随访数据合计行计算 */
    getSecondFollowUpSummaries(data) {
      const summaries = ["合计", "/", "/", 0, 0, 0, 0, 0, 0, 0, "0%", 0, 0, 0];
      data.forEach((item) => {
        // 数值字段求和
        summaries[3] += Number(item.dischargeCount) || 0;
        summaries[4] += Number(item.nonFollowUp) || 0;
        summaries[5] += Number(item.followUpNeeded) || 0;
        summaries[6] += Number(item.needFollowUpAgain) || 0;
        summaries[7] += Number(item.pendingFollowUpAgain) || 0;
        summaries[8] += Number(item.followUpSuccessAgain) || 0;
        summaries[9] += Number(item.followUpFailAgain) || 0;
        summaries[11] += Number(item.manualAgain) || 0;
        summaries[12] += Number(item.smsAgain) || 0;
        summaries[13] += Number(item.weChatAgain) || 0;
      });
      // 计算随访率百分比字段的平均值
      const followUpRateAgainValues = data
        .map((item) => this.extractPercentageValue(item.followUpRateAgain))
        .filter((value) => value !== null);
      if (followUpRateAgainValues.length > 0) {
        const avgFollowUpRateAgain =
          followUpRateAgainValues.reduce((sum, val) => sum + val, 0) /
          followUpRateAgainValues.length;
        summaries[10] = (avgFollowUpRateAgain * 100).toFixed(2) + "%";
      }
      // 格式化数字
      summaries[3] = this.formatNumber(summaries[3]);
      summaries[4] = this.formatNumber(summaries[4]);
      summaries[5] = this.formatNumber(summaries[5]);
      summaries[6] = this.formatNumber(summaries[6]);
      summaries[7] = this.formatNumber(summaries[7]);
      summaries[8] = this.formatNumber(summaries[8]);
      summaries[9] = this.formatNumber(summaries[9]);
      summaries[11] = this.formatNumber(summaries[11]);
      summaries[12] = this.formatNumber(summaries[12]);
      summaries[13] = this.formatNumber(summaries[13]);
      return summaries;
    },
    /** 再次随访表格的合计行计算方法 */
    getSummariesSecond(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 === "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);
          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;
    },
    /** 再次随访内部表格合计行计算方法 */
    getInnerSummariesSecond(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 === "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);
          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;
    },
    /** 再次随访表格的行点击展开 */
    handleRowClickSecond(row) {
      if (this.expandsSecond.includes(this.getRowKey(row))) {
        this.expandsSecond = [];
        return;
      }
      const params = {
        ...this.queryParams,
        deptcodes: this.queryParams.deptcodes.includes("all")
          ? this.allDeptCodes
          : this.queryParams.deptcodes,
        leavehospitaldistrictcodes: [row.leavehospitaldistrictcode],
        drcode: "1",
        visitCount: 2, // 设置为再次随访
      };
      delete params.leavehospitaldistrictcodes.all;
      delete params.deptcodes.all;
      if (!row.doctorStats) {
        this.loadingSecond = true;
        getSfStatistics(params).then((res) => {
          this.$set(row, "doctorStats", res.data);
          this.expandsSecond = [this.getRowKey(row)];
          this.loadingSecond = false;
        });
      } else {
        this.expandsSecond = [this.getRowKey(row)];
      }
    },
    /** 再次随访表格的多选框选中数据 */
    handleSelectionChangeSecond(selection) {
      this.idsSecond = selection.map((item) => item.tagid);
      this.single = selection.length != 1;
      this.multiple = !selection.length;
    },
    // 显示图表弹窗
    showChartDialog() {
@@ -2729,6 +3447,27 @@
</script>
<style lang="scss" scoped>
::v-deep .el-tabs__header {
  margin-bottom: 20px;
}
::v-deep .el-tabs__item {
  font-size: 16px;
  padding: 0 20px;
  height: 40px;
  line-height: 40px;
}
::v-deep .el-tabs__active-bar {
  height: 3px;
}
/* Tab内容区域样式 */
.el-tab-pane {
  .your-table-container {
    margin-top: 10px;
  }
}
.sidecolumn {
  width: 180px;
  min-height: 100vh;