WXL (wul)
昨天 d3c60e18b95b50751f8088fa2d23cd8ff7f173bc
src/views/followvisit/discharge/index.vue
@@ -1,5 +1,11 @@
<template>
  <div class="app-container">
    <statistics-cards
      :cardlist="cardlist"
      :ycvalue="ycvalue"
      :jgvalue="jgvalue"
      :show-warning-condition="orgname == '省立同德翠苑院区'"
    />
    <el-row :gutter="20">
      <!--用户数据-->
      <el-form
@@ -11,12 +17,13 @@
        label-width="98px"
      >
        <el-form-item label="任务名称">
          <el-input v-model="topqueryParams.taskName"></el-input>
          <el-input
            v-model="topqueryParams.taskName"
            placeholder="请选择任务名称"
          ></el-input>
        </el-form-item>
        <el-form-item label="发起人">
          <el-input v-model="topqueryParams.createBy"></el-input>
        </el-form-item>
        <!-- <el-form-item label="审核时间">
        <el-form-item label="出院时间">
          <el-date-picker
            v-model="dateRange"
            style="width: 240px"
@@ -27,24 +34,52 @@
            end-placeholder="结束日期"
          ></el-date-picker>
        </el-form-item>
        <el-form-item label="随访类型" prop="status">
          <el-select v-model="topqueryParams.topic" placeholder="请选择">
            <el-option
              v-for="item in topicoptions"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item> -->
        <el-form-item label="模板名称" prop="status">
          <el-input v-model="topqueryParams.templatename"></el-input>
        <el-form-item label="应随访时间">
          <el-date-picker
            v-model="dateRangefs"
            style="width: 240px"
            value-format="yyyy-MM-dd"
            type="daterange"
            range-separator="-"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          ></el-date-picker>
        </el-form-item>
        <el-form-item label="出院随访状态" prop="status">
          <el-select v-model="topqueryParams.sendstate" placeholder="请选择">
        <el-form-item label="患者姓名" prop="sendname">
          <el-input
            v-model="topqueryParams.sendname"
            placeholder="请输入患者姓名"
          ></el-input>
        </el-form-item>
        <el-form-item label="诊断名称" prop="leavediagname">
          <el-input
            v-model="topqueryParams.leavediagname"
            placeholder="请输入诊断名称"
          ></el-input>
        </el-form-item>
        <el-form-item label="随访人员" prop="updateBy">
          <el-input
            v-model="topqueryParams.updateBy"
            placeholder="请输入随访人员"
          ></el-input>
        </el-form-item>
        <el-form-item label="主治医生" prop="drname">
          <el-input
            v-model="topqueryParams.drname"
            placeholder="请输入主治医生"
          ></el-input>
        </el-form-item>
        <el-form-item label="经管医生" prop="managementDoctor">
          <el-input
            v-model="topqueryParams.managementDoctor"
            placeholder="请输入主治医生"
          ></el-input>
        </el-form-item>
        <el-form-item label="日期限制" prop="status">
          <el-select v-model="endOut" placeholder="请选择">
            <el-option
              v-for="item in topicoptions"
              v-for="item in endOuts"
              :key="item.value"
              :label="item.label"
              :value="item.value"
@@ -52,12 +87,47 @@
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="患者范围" prop="status">
          <el-cascader
            v-model="topqueryParams.scopetype"
            placeholder="默认全部"
            :options="sourcetype"
            :props="{ expandTrigger: 'hover' }"
            @change="handleChange"
            filterable
            clearable
          ></el-cascader>
        </el-form-item>
        <el-form-item label="随访状态" prop="status">
          <el-cascader
            v-model="serviceStatusValue"
            placeholder="请选择"
            :options="serviceStatusOptions"
            :props="cascaderProps"
            @change="handleServiceStatusChange"
            clearable
          ></el-cascader>
        </el-form-item>
        <el-form-item label="排序方式" prop="status">
          <el-select v-model="topqueryParams.sort" placeholder="请选择">
            <el-option
              v-for="item in topicoptionssort"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button
            type="primary"
            icon="el-icon-search"
            size="medium"
            @click="handleQuery"
            @click="handleQuery(1)"
            >搜索</el-button
          >
          <el-button icon="el-icon-refresh" size="medium" @click="resetQuery"
@@ -68,17 +138,6 @@
      <el-divider></el-divider>
      <el-row :gutter="10" class="mb8">
        <el-col :span="1.5">
          <el-button
            type="primary"
            plain
            icon="el-icon-plus"
            size="medium"
            @click="handleAdd"
            v-hasPermi="['system:user:add']"
            >新增</el-button
          >
        </el-col>
        <!-- <el-col :span="1.5">
          <div class="documentf">
            <div class="document">
              <el-button
@@ -87,8 +146,45 @@
                icon="el-icon-upload2"
                size="medium"
                @click="handleExport"
                v-hasPermi="['system:user:export']"
                >导出</el-button
              >
            </div>
          </div>
        </el-col>
        <!-- <el-col :span="1.5">
          <el-button
            type="primary"
            icon="el-icon-plus"
            size="medium"
            @click="handleAdd"
            >新增</el-button
          >
        </el-col> -->
        <el-col :span="1.5">
          <div class="documentf">
            <div class="document">
              <el-button
                type="warning"
                plain
                icon="el-icon-warning-outline"
                size="medium"
                @click="toleadExport(1)"
                >执行失败</el-button
              >
            </div>
          </div>
        </el-col>
        <el-col :span="1.5">
          <div class="documentf">
            <div class="document">
              <el-button
                type="danger"
                plain
                icon="el-icon-warning"
                size="medium"
                @click="toleadExport(2)"
                >结果异常</el-button
              >
            </div>
          </div>
@@ -99,11 +195,9 @@
              <el-button
                type="success"
                plain
                icon="el-icon-download"
                size="medium"
                @click="toleadExport"
                v-hasPermi="['system:user:export']"
                >导入</el-button
                @click="buidegetTasklist()"
                >待办服务</el-button
              >
            </div>
          </div>
@@ -111,13 +205,8 @@
        <el-col :span="1.5">
          <div class="documentf">
            <div class="document">
              <el-button
                type="info"
                icon="el-icon-refresh"
                size="medium"
                @click="TaskReset"
                v-hasPermi="['system:user:export']"
                >任务重置</el-button
              <el-button type="primary" size="medium" @click="affiliation()"
                >本人所属服务</el-button
              >
            </div>
          </div>
@@ -125,192 +214,404 @@
        <el-col :span="1.5">
          <div class="documentf">
            <div class="document">
              <el-button
                type="success"
                icon="el-icon-position"
                size="medium"
                @click="AllStarted"
                v-hasPermi="['system:user:export']"
                >全部开始</el-button
              <el-button type="success" size="medium" @click="onthatday()"
                >今日服务</el-button
              >
            </div>
          </div>
        </el-col>
        <el-col :span="1.5">
        <el-col :span="1.5" v-if="orgname == '景宁畲族自治县人民医院'">
          <div class="documentf">
            <div class="document">
              <el-button
                type="warning"
                icon="el-icon-remove"
                size="medium"
                @click="AllStop"
                v-hasPermi="['system:user:export']"
                >全部停止</el-button
              <el-tooltip
                content="请先选中服务"
                placement="top"
                :disabled="!multiple"
              >
                <div class="tooltip-wrapper">
                  <el-button
                    type="primary"
                    :disabled="multiple"
                    class="purple-button"
                    @click="scoreDialogVisible = true"
                  >
                    满意度调查
                  </el-button>
                </div>
              </el-tooltip>
            </div>
          </div>
        </el-col>
        <el-col :span="1.5">
          <div class="documentf">
            <div class="document">
              <el-button
                type="primary"
                icon="el-icon-remove"
                size="medium"
                @click="Sendtimesetting"
                v-hasPermi="['system:user:export']"
                >发送时间设置</el-button
              >
            </div>
          </div>
        </el-col> -->
        <!-- <el-col :span="1.5"> </el-col> -->
      </el-row>
      <div class="selected-info">
        已选中
        <span style="color: #409eff; font-weight: bold">{{
          getSelectedCount()
        }}</span>
        条数据
        <el-button
          v-if="getSelectedCount() > 0"
          type="text"
          @click="clearAllSelection"
        >
          清除选中
        </el-button>
      </div>
      <el-table
        v-loading="loading"
        ref="userform"
        :data="userList"
        :row-class-name="tableRowClassName"
        @selection-change="handleSelectionChange"
        @select-all="handleSelectAll"
      >
        <el-table-column type="selection" width="50" align="center" />
        <el-table-column label="序号" fixed align="center" key="id" prop="id" />
        <el-table-column
          label="任务名称"
          fixed
          width="150"
          show-overflow-tooltip
          align="center"
          key="taskName"
          prop="taskName"
        />
        <!-- <el-table-column label="序号" fixed align="center" key="id" prop="id" /> -->
        <el-table-column
          label="姓名"
          fixed
          width="100"
          align="center"
          key="sendname"
          prop="sendname"
        />
        <el-table-column
          label="病历号"
          align="center"
          sortable
          key="medicalRecordNo"
          prop="medicalRecordNo"
          width="120"
        />
        <el-table-column label="年龄" align="center" key="age" prop="age" />
        <el-table-column label="性别" align="center" key="sex" prop="sex" />
        <el-table-column label="床号" align="center" key="badNo" prop="badNo" />
        <el-table-column
          label="病区"
          align="center"
          key="deptname"
          prop="deptname"
          width="120"
        >
          <template slot-scope="scope">
            <el-button
              size="medium"
              type="text"
              @click="
                gettoken360(
                  scope.row.sfzh,
                  scope.row.drcode,
                  scope.row.drname,
                  scope.row.patid
                )
              "
              ><span class="button-textsc">{{
                scope.row.sendname
              }}</span></el-button
            >
          </template>
        </el-table-column>
        <el-table-column
          label="疾病名称"
          label="诊断名称"
          align="center"
          key="icdName"
          prop="icdName"
          key="leavediagname"
          prop="leavediagname"
          width="120"
          :show-overflow-tooltip="true"
        >
        </el-table-column>
        <el-table-column
          label="任务名称"
          align="center"
          key="taskName"
          prop="taskName"
          width="120"
        />
        <el-table-column
          label="随访方式(需调整格式)"
          label="随访状态"
          align="center"
          key="serviceform"
          prop="serviceform"
          key="sendstateView"
          prop="sendstateView"
          width="120"
        />
        <el-table-column
          label="随访人员"
          align="center"
          key="operator"
          prop="operator"
          width="120"
        />
        <el-table-column
          label="就诊时间"
          sortable
          align="center"
          prop="admindate"
          width="160"
        >
          <template slot-scope="scope">
            <span>{{ formatTime(scope.row.admindate) }}</span>
            <el-tooltip
              class="item"
              effect="dark"
              :content="scope.row.remark"
              placement="top-start"
              popper-class="statistics-tooltip"
            >
              <div v-if="scope.row.sendstateView == 1">
                <el-tag type="primary" :disable-transitions="false"
                  >待随访</el-tag
                >
              </div>
              <div v-if="scope.row.sendstateView == 2">
                <el-tag type="success" :disable-transitions="false"
                  >已完成</el-tag
                >
              </div>
              <div v-if="scope.row.sendstateView == 3">
                <el-tag type="warning" :disable-transitions="false"
                  >无需随访</el-tag
                >
              </div>
            </el-tooltip>
          </template>
        </el-table-column>
        <!-- <el-table-column
          label="随访时间"
          sortable
        <el-table-column
          label="处理意见"
          align="center"
          prop="createTime"
          width="160"
          key="suggest"
          prop="suggest"
          width="120"
        >
          <template slot-scope="scope">
            <span v-if="scope.row.sendType != 3">{{
              formatTime(scope.row.createTime)
            }}</span>
            <span v-else>即刻发送</span>
            <dict-tag
              :options="dict.type.sys_suggest"
              :value="scope.row.suggest"
            />
          </template>
        </el-table-column> -->
        </el-table-column>
        <el-table-column
          label="随访时间"
          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
          label="随访完成时间"
          sortable
          align="center"
          prop="finishtime"
          width="160"
        >
          <template slot-scope="scope">
            <span>{{ formatTime(scope.row.finishtime) }}</span>
            <span>{{ parseTime(scope.row.finishtime) }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="随访状态"
          fixed="right"
          label="出院日期"
          width="146"
          align="center"
          key="endtime"
          prop="endtime"
        >
          <template slot-scope="scope">
            <span>{{ formatTime(scope.row.endtime) }}</span>
          </template></el-table-column
        >
        <el-table-column
          label="应随访日期"
          width="146"
          align="center"
          key="visitTime"
          prop="visitTime"
        >
          <template slot-scope="scope">
            <span>{{ formatTime(scope.row.visitTime) }}</span>
          </template></el-table-column
        >
        <!-- 原 -->
        <el-table-column
          label="主治医生"
          width="120"
          align="center"
          key="drname"
          prop="drname"
        />
        <el-table-column
          v-if="orgname != '丽水市中医院'"
          label="随访人员"
          align="center"
          key="updateBy"
          prop="updateBy"
          width="120"
        />
        <el-table-column
          label="任务状态"
          align="center"
          key="sendstate"
          prop="sendstate"
          width="120"
          :show-overflow-tooltip="true"
        >
          <template slot-scope="scope">
            <dict-tag :options="serviceState" :value="scope.row.sendstate" />
            <el-tooltip
              class="item"
              effect="dark"
              :content="scope.row.remark"
              placement="top-start"
            >
              <div v-if="scope.row.sendstate == 1">
                <el-tag type="primary" :disable-transitions="false"
                  >表单已领取</el-tag
                >
              </div>
              <div v-if="scope.row.sendstate == 2">
                <el-tag type="primary" :disable-transitions="false"
                  >待随访</el-tag
                >
              </div>
              <div v-if="scope.row.sendstate == 3">
                <el-tag type="success" :disable-transitions="false"
                  >表单已发送</el-tag
                >
              </div>
              <div v-if="scope.row.sendstate == 4">
                <el-tag type="info" :disable-transitions="false">不执行</el-tag>
              </div>
              <div v-if="scope.row.sendstate == 5">
                <el-tag type="danger" :disable-transitions="false"
                  >发送失败</el-tag
                >
              </div>
              <div v-if="scope.row.sendstate == 6">
                <el-tag type="success" :disable-transitions="false"
                  >已完成</el-tag
                >
              </div>
              <div v-if="scope.row.sendstate == 7">
                <el-tag type="danger" :disable-transitions="false">超时</el-tag>
              </div>
            </el-tooltip>
          </template>
        </el-table-column>
        <el-table-column
          label="出院天数"
          width="120"
          align="center"
          key="endDay"
          prop="endDay"
        >
          <template slot-scope="scope">
            <span>{{ scope.row.endDay ? scope.row.endDay + "天" : "" }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="联系电话"
          width="200"
          align="center"
          key="phone"
          prop="phone"
        />
        <el-table-column
          label="身份证号码"
          width="200"
          align="center"
          key="sfzh"
          prop="sfzh"
        />
        <el-table-column
          label="责任护士"
          width="120"
          align="center"
          key="nurseName"
          prop="nurseName"
        />
        <el-table-column
          label="经管医生"
          align="center"
          key="managementDoctor"
          prop="managementDoctor"
          width="120"
        />
        <!-- <el-table-column
          label="病历号"
          align="center"
          sortable
          key="medicalRecordNo"
          prop="medicalRecordNo"
          width="120"
        /> -->
        <!-- <el-table-column label="年龄" align="center" key="age" prop="age" /> -->
        <!-- <el-table-column label="性别"width="100" align="center" key="sex" prop="sex" /> -->
        <!-- <el-table-column label="床号" align="center" key="badNo" prop="badNo" /> -->
        <el-table-column
          label="科室"
          align="center"
          key="deptname"
          prop="deptname"
          width="120"
        >
        </el-table-column>
        <el-table-column
          label="病区"
          align="center"
          key="leavehospitaldistrictname"
          prop="leavehospitaldistrictname"
          width="120"
        >
        </el-table-column>
        <el-table-column
          label="操作"
          fixed="right"
          label="出院随访模板名称"
          align="center"
          key="templatename"
          prop="templatename"
          width="200"
        />
        <!-- <el-table-column
          label="任务发送流程"
          align="center"
          key="serviceSubtaskRecordList"
          prop="serviceSubtaskRecordList"
          width="160"
          :show-overflow-tooltip="true"
        >
          <template slot-scope="scope">
            <span v-for="item in scope.row.serviceSubtaskRecordList"
              >{{ item.remark }}、
            </span>
          </template>
        </el-table-column> -->
        <el-table-column
          label="任务结果说明"
          width="220"
          align="center"
          key="remark"
          prop="remark"
        >
          <template slot-scope="scope" v-if="scope.row.remark">
            <el-tooltip
              :content="scope.row.remark"
              placement="top"
              effect="dark"
            >
              <el-tag
                type="warning"
                v-if="scope.row.sendstate != 5 && scope.row.sendstate != 4"
                >{{ scope.row.remark }}</el-tag
              >
              <el-tag type="warning" v-else>{{ scope.row.remark }}</el-tag>
            </el-tooltip>
          </template>
        </el-table-column>
        <el-table-column
          label="操作"
          align="center"
          fixed="right"
          width="300"
          class-name="small-padding fixed-width"
        >
          <template slot-scope="scope">
            <!-- <el-tooltip
              class="item"
              effect="dark"
              content="重新随访"
              content="再次随访"
              placement="top"
            >
              <el-button
                size="medium"
                type="text"
                v-if="scope.row.isVisitAgain!=2"
                @click="followupvisit(scope.row)"
                v-hasPermi="['system:user:edit']"
                ><span class="button-bb"
                  ><i class="el-icon-s-promotion"></i></span
              ></el-button>
            </el-tooltip> -->
            <!-- <el-tooltip
                  ><i class="el-icon-s-promotion"></i>再次随访</span
                ></el-button
              >
            </el-tooltip>
            <el-tooltip
              v-if="scope.row.sendstate == 1 || scope.row.sendstate == 2"
              class="item"
              effect="dark"
              content="停止"
              content="暂停服务"
              placement="top"
            >
              <el-button
@@ -318,30 +619,22 @@
                type="text"
                @click="handlestop(scope.row)"
                v-hasPermi="['system:user:edit']"
                ><span class="button-sc"><i class="el-icon-delete"></i></span
              ></el-button>
                ><span class="button-sc"
                  ><i class="el-icon-remove-outline"></i>暂停服务</span
                ></el-button
              >
            </el-tooltip> -->
            <!-- <el-tooltip
              class="item"
              effect="dark"
              content="查看任务详情"
              placement="top"
            <el-button size="medium" type="text" @click="Seedetails(scope.row)"
              ><span class="button-zx"
                ><i class="el-icon-s-order"></i>查看详情</span
              ></el-button
            >
              <el-button
                size="medium"
                type="text"
                @click="Seedetails(scope.row)"
                v-hasPermi="['system:user:edit']"
                ><span class="button-zx"><i class="el-icon-s-order"></i></span
              ></el-button>
            </el-tooltip> -->
            <el-button
              size="medium"
              type="text"
              @click="Seedetails(scope.row)"
              v-hasPermi="['system:user:edit']"
              ><span class="button-zx"
                ><i class="el-icon-s-order"></i>查看详情</span
              @click="handleUpdate(scope.row)"
              ><span class="button-textxga"
                ><i class="el-icon-edit"></i>患者过滤</span
              ></el-button
            >
          </template>
@@ -356,58 +649,251 @@
        @pagination="getList"
      />
    </el-row>
    <!-- 添加或修改门诊随访对话框 -->
    <!-- 满意度弹框 -->
    <el-dialog
      :title="title"
      :visible.sync="addalteropen"
      width="700px"
      append-to-body
      title="随访满意度评分"
      :visible.sync="scoreDialogVisible"
      width="80%"
      :close-on-click-modal="false"
    >
      <el-form ref="form" :model="form" label-width="100px">
        <el-row :gutter="20">
          <el-col :span="12"
            ><el-form-item label="任务名称">
              <el-input v-model="form.name"></el-input> </el-form-item
          ></el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="24"
            ><el-form-item label="所属科室">
              <el-select v-model="form.region" placeholder="请选择科室">
                <el-option label="区域一" value="shanghai"></el-option>
                <el-option label="区域二" value="beijing"></el-option>
              </el-select> </el-form-item></el-col
        ></el-row>
        <el-row :gutter="20">
          <el-col :span="24"
            ><el-form-item label="随访类型">
              <el-select v-model="form.region" placeholder="请选择随访类型">
                <el-option label="区域一" value="shanghai"></el-option>
                <el-option label="区域二" value="beijing"></el-option>
              </el-select> </el-form-item
          ></el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item label="服务模块">
              <el-select v-model="form.region" placeholder="请选择模块">
                <el-option label="区域一" value="shanghai"></el-option>
                <el-option label="区域二" value="beijing"></el-option>
      <el-table :data="selectedRows" border style="width: 100%">
        <el-table-column
          label="姓名"
          width="100"
          align="center"
          prop="sendname"
        />
        <el-table-column
          label="任务名称"
          width="180"
          align="center"
          prop="taskName"
        />
        <!-- 新增评分列 -->
        <el-table-column
          label="真实性(20)"
          align="center"
          key="authenticity"
          prop="authenticity"
          width="150"
        >
          <template slot-scope="scope">
            <el-input-number
              v-model="scope.row.authenticity"
              :min="0"
              :max="20"
              :step="1"
              size="small"
            />
          </template>
        </el-table-column>
        <el-table-column
          label="一周内完成(20)"
          align="center"
          key="weekFinish"
          prop="weekFinish"
          width="150"
        >
          <template slot-scope="scope">
            <el-input-number
              v-model="scope.row.weekFinish"
              :min="0"
              :max="20"
              :step="1"
              size="small"
            />
          </template>
        </el-table-column>
        <el-table-column
          label="规范性(10)"
          align="center"
          key="standard"
          prop="standard"
          width="150"
        >
          <template slot-scope="scope">
            <el-input-number
              v-model="scope.row.standard"
              :min="0"
              :max="10"
              :step="1"
              size="small"
            />
          </template>
        </el-table-column>
        <el-table-column
          label="及时性(10)"
          align="center"
          key="timeliness"
          prop="timeliness"
          width="150"
        >
          <template slot-scope="scope">
            <el-input-number
              v-model="scope.row.timeliness"
              :min="0"
              :max="10"
              :step="1"
              size="small"
            />
          </template>
        </el-table-column>
        <el-table-column
          label="宣教情况(10)"
          align="center"
          key="library"
          prop="library"
          width="150"
        >
          <template slot-scope="scope">
            <el-input-number
              v-model="scope.row.library"
              :min="0"
              :max="10"
              :step="1"
              size="small"
            />
          </template>
        </el-table-column>
        <el-table-column
          label="环境满意度(10)"
          align="center"
          key="environment"
          prop="environment"
          width="150"
        >
          <template slot-scope="scope">
            <el-input-number
              v-model="scope.row.environment"
              :min="0"
              :max="10"
              :step="1"
              size="small"
            />
          </template>
        </el-table-column>
        <el-table-column
          label="医生满意度(10)"
          align="center"
          key="doctorSatisfaction"
          prop="doctorSatisfaction"
          width="150"
        >
          <template slot-scope="scope">
            <el-input-number
              v-model="scope.row.doctorSatisfaction"
              :min="0"
              :max="10"
              :step="1"
              size="small"
            />
          </template>
        </el-table-column>
        <el-table-column
          label="护士满意度(10)"
          align="center"
          key="nurseSatisfaction"
          prop="nurseSatisfaction"
          width="150"
        >
          <template slot-scope="scope">
            <el-input-number
              v-model="scope.row.nurseSatisfaction"
              :min="0"
              :max="10"
              :step="1"
              size="small"
            />
          </template>
        </el-table-column>
        <el-table-column
          label="总分"
          align="center"
          key="total"
          prop="total"
          fixed="right"
        >
          <template slot-scope="scope">
            <span>{{ calculateTotal(scope.row) }}</span>
          </template>
        </el-table-column>
      </el-table>
      <div slot="footer" class="dialog-footer">
        <el-button @click="scoreDialogVisible = false">取消</el-button>
        <el-button type="primary" @click="saveScores">保存</el-button>
      </div>
    </el-dialog>
    <!-- 添加或修改影像随访对话框 -->
    <el-dialog
      :title="amendtag ? '修改患者信息' : '新增患者'"
      :visible.sync="Labelchange"
      width="900px"
    >
      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
        <el-row>
          <el-col :span="8">
            <el-form-item label="姓名" width="100" prop="name">
              <el-input
                v-model="form.name"
                placeholder="请输入姓名"
                maxlength="30"
              />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="性别" width="100" prop="sex">
              <el-select v-model="form.sex" placeholder="请选择性别">
                <el-option
                  v-for="dict in sextype"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="年龄" prop="age">
              <el-input
                v-model="form.age"
                placeholder="请输入年龄"
                maxlength="30"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
        <el-row>
          <el-col :span="8">
            <el-form-item label="过滤医生" width="100" prop="filterDrname">
              <el-input
                v-model="form.filterDrname"
                placeholder="请输入医生姓名"
                maxlength="30"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="门诊随访要求">
              <el-input type="textarea" v-model="form.desc"></el-input>
            <el-form-item label="过滤原因">
              <el-input
                v-model="form.notrequiredreason"
                type="textarea"
                placeholder="请输入过滤原因"
              ></el-input>
              <!-- 提醒文字 -->
              <div class="filter-warning">
                <i class="el-icon-warning-outline"></i>
                该功能适用于死亡、列入医院黑名单、明确拒绝随访等患者的过滤排除,过滤后该患者所有进行中任务全部停止且无法匹配新的随访任务,请谨慎操作!
              </div>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">提 交</el-button>
        <el-button @click="cancel">返 回</el-button>
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 修改发送时间对话框 -->
@@ -485,28 +971,108 @@
        >
      </span>
    </el-dialog>
    <!-- 再次随访 -->
    <el-dialog title="患者再次随访" :visible.sync="dialogFormVisible">
      <el-form ref="zcform" :rules="zcrules" :model="zcform" label-width="80px">
        <el-form-item label="任务名称">
          <el-input
            style="width: 400px"
            disabled
            v-model="zcform.taskName"
          ></el-input>
        </el-form-item>
        <el-form-item label="患者名称">
          <el-input
            style="width: 400px"
            disabled
            v-model="zcform.sendname"
          ></el-input>
        </el-form-item>
        <el-form-item label="年龄">
          <el-input
            style="width: 400px"
            disabled
            v-model="zcform.age"
          ></el-input>
        </el-form-item>
        <el-form-item label="科室">
          <el-input
            style="width: 400px"
            disabled
            v-model="zcform.deptname"
          ></el-input>
        </el-form-item>
        <el-form-item label="病区">
          <el-input
            style="width: 400px"
            disabled
            v-model="zcform.leavehospitaldistrictname"
          ></el-input>
        </el-form-item>
        <el-form-item label="随访方式" prop="resource">
          <el-radio-group v-model="zcform.resource">
            <el-radio label="1">本病区随访</el-radio>
            <el-radio label="2">随访中心随访</el-radio>
          </el-radio-group>
        </el-form-item>
        <!-- <el-form-item label="即刻发送">
          <el-switch v-model="zcform.delivery"></el-switch>
        </el-form-item> -->
        <el-form-item label="出院时间">
          <el-input
            style="width: 400px"
            disabled
            v-model="zcform.endtime"
          ></el-input>
        </el-form-item>
        <el-form-item label="随访完成时间" prop="date1">
          <el-date-picker
            type="date"
            placeholder="选择日期"
            v-model="zcform.date1"
            style="width: 100%"
          ></el-date-picker>
        </el-form-item>
        <el-form-item label="随访记录">
          <el-input type="textarea" v-model="zcform.remark"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="setupsubtask">确认创建服务</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import {
  listUser,
  getUser,
  delUser,
  addUser,
  updateUser,
  resetUserPwd,
  changeUserStatus,
} from "@/api/system/user";
import { getTaskservelist } from "@/api/AiCentre/index";
import {
  getTaskservelist,
  buidegetTasklist,
  addserviceSubtask,
  query360PatInfo,
  addsatisfaction,
  query360PatInfonh,
} from "@/api/AiCentre/index";
import { alterpatient, particularpatient } from "@/api/patient/homepage";
import Treeselect from "@riophae/vue-treeselect";
import StatisticsCards from "@/components/StatisticsCards";
import store from "@/store";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
export default {
  name: "User",
  dicts: ["sys_normal_disable", "sys_user_sex"],
  components: { Treeselect },
  name: "Discharge",
  dicts: ["sys_normal_disable", "sys_user_sex", "sys_yujing", "sys_suggest"],
  components: { Treeselect, StatisticsCards },
  data() {
    return {
      // 遮罩层
@@ -519,12 +1085,13 @@
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      dialogFormVisible: false,
      // 总条数
      total: 0,
      // 用户表格数据
      userList: null,
      // 弹出层标题
      title: "新增门诊随访",
      title: "新增影像随访",
      // 是否显示修改、添加弹出层
      addalteropen: false,
      // 修改发送时间对话框
@@ -535,106 +1102,116 @@
      initPassword: undefined,
      // 日期范围
      dateRange: [],
      dateRangefs: [],
      // 岗位选项
      postOptions: [],
      ruleForm: {
        type: [],
      },
      zcform: {},
      dynamicTags: ["选项一", "选项二", "选项三"], //选项
      inputVisible: false,
      Labelchange: false,
      ycvalue: 0,
      jgvalue: "",
      yfsvalue: "",
      inputValue: "",
      previewVisible: false, //门诊随访预览弹框
      preachform: "",
      previewVisible: false, //影像随访预览弹框
      isRestoring: false,
      radio: "",
      radios: [],
      previewtype: 2, //预览门诊随访类型
      previewtype: 2, //预览影像随访类型
      total: 0, // 总条数
      ImportQuantity: 999, //导门诊随访数量
      //预览门诊随访信息
      previewvalue: {
        username: "这个医生对你怎么样",
      // 满意度调查数据
      scoreDialogVisible: false,
      selectedRows: [],
      selectedRowMap: new Map(), // key: row.id, value: row 数据
      // 级联选择器绑定值
      serviceStatusValue: 10,
      cascaderProps: {
        expandTrigger: "hover", // 悬停展开
        checkStrictly: true, // ✅ 关键:允许选中任意一级
        emitPath: false, // ✅ 只返回选中的值,不返回路径数组
      },
      // 服务状态选项(一级和二级值不冲突)
      serviceStatusOptions: [
        {
          value: null,
          label: "全部",
        },
        {
          value: 10, // 一级:待随访
          label: "待随访",
          children: [
            { value: 1, label: "被领取" },
            { value: 2, label: "待发送" },
            { value: 3, label: "已发送" },
            { value: 5, label: "发送失败" },
            { value: 7, label: "超时" },
          ],
        },
        {
          value: 20, // 一级:已完成
          label: "已完成",
          children: [{ value: 6, label: "已完成" }],
        },
        {
          value: 30, // 一级:无需随访
          label: "无需随访",
          children: [{ value: 4, label: "不执行" }],
        },
      ],
      value: [],
      list: [],
      loading: false,
      states: [
        "Alabama",
        "Alaska",
        "Arizona",
        "Arkansas",
        "California",
        "Colorado",
        "Connecticut",
        "Delaware",
        "Florida",
        "Georgia",
        "Hawaii",
        "Idaho",
        "Illinois",
        "Indiana",
        "Iowa",
        "Kansas",
        "Kentucky",
        "Louisiana",
        "Maine",
        "Maryland",
        "Massachusetts",
        "Michigan",
        "Minnesota",
        "Mississippi",
        "Missouri",
        "Montana",
        "Nebraska",
        "Nevada",
        "New Hampshire",
        "New Jersey",
        "New Mexico",
        "New York",
        "North Carolina",
        "North Dakota",
        "Ohio",
        "Oklahoma",
        "Oregon",
        "Pennsylvania",
        "Rhode Island",
        "South Carolina",
        "South Dakota",
        "Tennessee",
        "Texas",
        "Utah",
        "Vermont",
        "Virginia",
        "Washington",
        "West Virginia",
        "Wisconsin",
        "Wyoming",
      ],
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() > Date.now();
      sourcetype: [
        {
          value: 1,
          label: "科室",
          children: [],
        },
        shortcuts: [
          {
            text: "今天",
            onClick(picker) {
              picker.$emit("pick", new Date());
            },
          },
          {
            text: "昨天",
            onClick(picker) {
              const date = new Date();
              date.setTime(date.getTime() - 3600 * 1000 * 24);
              picker.$emit("pick", date);
            },
          },
          {
            text: "一周前",
            onClick(picker) {
              const date = new Date();
              date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", date);
            },
          },
        {
          value: 2,
          label: "病区",
          children: [],
        },
        {
          value: 3,
          label: "全部",
        },
      ],
      loading: false,
      cardlist: [
        {
          name: "患者服务总量",
          value: 0,
        },
        {
          name: "无需随访",
          value: 0,
        },
        {
          name: "需随访",
          value: 0,
        },
        {
          name: "待随访",
          value: 0,
        },
        {
          name: "已完成",
          value: 0,
        },
      ],
      zcrules: {
        date1: [
          { required: true, message: "请选择随访方式", trigger: "change" },
        ],
        resource: [
          { required: true, message: "请选择随访时间", trigger: "blur" },
        ],
      },
      // 表单参数
@@ -646,56 +1223,447 @@
        qystatus: "",
        btstatus: "",
      },
      // endOut: 1,
      endOut:
        localStorage.getItem("orgname") == "景宁畲族自治县人民医院" ? 0 : 1, //0 出院时间(正序)    1 出院时间(倒序)   2 发送时间(正序)    3 发送时间(倒序)  7应随访日期(倒序) 应随访日期(正序)
      endOuts: [
        {
          value: 0,
          label: "截止至当日服务",
        },
        {
          value: 1,
          label: "全部服务",
        },
      ],
      topicoptionssort: [
        {
          value: 0,
          label: "出院时间(正序)",
        },
        {
          value: 1,
          label: "出院时间(倒序)",
        },
        {
          value: 2,
          label: "发送时间(正序)",
        },
        {
          value: 3,
          label: "发送时间(倒序)",
        },
        {
          value: 7,
          label: "应随访日期(正序)",
        },
        {
          value: 8,
          label: "应随访日期(倒序)",
        },
        {
          value: 9,
          label: "按照患者排序",
        },
      ],
      // 查询参数
      topqueryParams: {
        pageNum: 1,
        pageSize: 10,
        serviceType:2,
        sendstateView: 1,
        sort: localStorage.getItem("orgname") == "丽水市中医院" ? 8 : 1, //0 出院时间(正序)    1 出院时间(倒序)   2 发送时间(正序)    3 发送时间(倒序)  7应随访日期(倒序) 应随访日期(正序)
        serviceType: 2,
        sendstate: null,
        searchscope: 3,
        visitCount: 1,
        scopetype: [],
        leaveldeptcodes: [],
        leavehospitaldistrictcodes: [],
      },
      orgname: "",
      propss: { multiple: true },
      options: [],
      topicoptions: [
        {
          value: null,
          label: "全部",
        },
        {
          value: 1,
          label: "被领取",
          label: "待随访",
        },
        {
          value: 2,
          label: "待发送",
          label: "随访中",
        },
        {
          value: 3,
          label: "已发送",
          label: "未完成",
        },
        {
          value: 4,
          label: "已完成",
        },
        {
          value: 5,
          label: "无需随访",
        },
      ],
      sextype: [
        {
          value: 1,
          label: "男",
        },
        {
          value: 2,
          label: "女",
        },
      ],
      topicoptionsyj: [
        {
          value: 1,
          label: "异常",
        },
        {
          value: 2,
          label: "警告",
        },
        {
          value: 0,
          label: "正常",
        },
      ],
      url: "http://9.208.2.190:8090/smartor/serviceExternal/query360PatInfo",
      postData: {
        XiaoXiTou: {
          FaSongFCSJC: "ZJHES",
          FaSongJGID: localStorage.getItem("orgid"),
          FaSongJGMC: localStorage.getItem("orgname"),
          FaSongSJ: "2025-01-09 17:29:36",
          FaSongXTJC: "SUIFANGXT",
          FaSongXTMC: "随访系统",
          XiaoXiID: "5FA92AFB-9833-4608-87C7-F56A654AC171",
          XiaoXiLX: "SC_LC_360STCX",
          XiaoXiMC: "360 视图查询",
          ZuHuID: localStorage.getItem("ZuHuID"),
          ZuHuMC: localStorage.getItem("orgname"),
        },
        YeWuXX: {
          BingRenXX: {
            ZhengJianHM: "",
            ZhengJianLXDM: "01",
            ZhengJianLXMC: "居民身份证",
            ZuZhiJGID: localStorage.getItem("orgid"),
            ZuZhiJGMC: localStorage.getItem("orgname"),
          },
          YongHuXX: {
            XiTongID: "SUIFANGXT",
            XiTongMC: "随访系统",
            YongHuID: localStorage.getItem("YongHuID"),
            YongHuXM: localStorage.getItem("YongHuXM"),
            ZuZhiJGID: localStorage.getItem("orgid"),
            ZuZhiJGMC: localStorage.getItem("orgname"),
            idp: "lyra",
          },
        },
      },
      amendtag: false,
      errtype: "",
      leavehospitaldistrictcode: "",
      serviceState: [],
      checkboxlist: [],
      // 表单校验
      rules: {},
    };
  },
  watch: {},
  watch: {
    // 监听路由参数变化
    "$route.query": {
      handler(newQuery, oldQuery) {
        if (newQuery?.errtype !== oldQuery?.errtype) {
          console.log(22);
          this.loadData();
        }
      },
      immediate: true,
    },
  },
  created() {
    this.serviceState = store.getters.serviceState;
    this.getList();
    this.checkboxlist = store.getters.checkboxlist;
    this.orgname = localStorage.getItem("orgname");
    this.errtype = this.$route.query.errtype;
    this.leavehospitaldistrictcode =
      this.$route.query.leavehospitaldistrictcode;
    this.sourcetype[0].children = store.getters.belongDepts.map((dept) => {
      return {
        label: dept.deptName,
        value: dept.deptCode,
      };
    });
    this.sourcetype[1].children = store.getters.belongWards.map((dept) => {
      return {
        label: dept.districtName,
        value: dept.districtCode,
      };
    });
    if (this.errtype == 1) {
      this.toleadExport(2);
    } else if (this.errtype == 2) {
      // 待随访
      this.toleadExport(3);
    } else if (this.errtype == 3) {
      // 失败
      this.toleadExport(4);
    } else if (this.errtype == 4) {
      // 异常
      this.toleadExport(2);
    } else if (this.errtype == 5) {
      // 全部
      this.toleadExport(5);
    } else {
      this.getList(1);
    }
    this.getConfigKey("sys.user.initPassword").then((response) => {
      this.initPassword = response.msg;
    });
  },
  // 搜索
  mounted() {
    this.list = this.states.map((item) => {
      return { value: `value:${item}`, label: `label:${item}` };
    });
  activated() {
    this.errtype = this.$route.query.errtype;
    if (this.errtype == 1) {
      this.toleadExport(2);
    } else if (this.errtype == 2) {
      // 待随访
      this.toleadExport(3);
    } else if (this.errtype == 3) {
      // 失败
      this.toleadExport(4);
    } else if (this.errtype == 4) {
      // 异常
      this.toleadExport(2);
    } else if (this.errtype == 5) {
      // 全部
      this.toleadExport(5);
    } else {
      this.getList(1);
    }
  },
  methods: {
    /** 查询门诊随访服务列表 */
    getList() {
    /** 查询随访服务列表 */
    async getList(refresh) {
      // 默认全部
      if (this.topqueryParams.searchscope == 3) {
        this.topqueryParams.leaveldeptcodes = store.getters.belongDepts.map(
          (obj) => obj.deptCode
        );
        this.topqueryParams.leavehospitaldistrictcodes =
          store.getters.belongWards.map((obj) => obj.districtCode);
      }
      if (this.endOut == 0) {
        this.topqueryParams.endSendDateTime = this.formatDateToYYYYMMDDHHMMSS(
          this.getEndOfDay()
        );
      }
      // 接受异常跳转
      if (this.errtype) {
        this.topqueryParams.leavehospitaldistrictcodes.push(
          this.leavehospitaldistrictcode
        );
      }
      this.loading = true;
      getTaskservelist(this.topqueryParams).then((response) => {
        this.userList = response.rows;
      if (
        this.topqueryParams.leavehospitaldistrictcodes[0] &&
        this.topqueryParams.leaveldeptcodes[0]
      ) {
        this.topqueryParams.deptOrDistrict = 2;
      } else {
        this.topqueryParams.deptOrDistrict = 1;
      }
      if (!this.followupAuthority()) {
        this.$message.warning("未配置科室/病区相关权限不可查询");
        this.loading = false;
        return Promise.reject(new Error("无权限查询"));
      }
      try {
        const response = await getTaskservelist(this.topqueryParams);
        // ✅ 第一步:先锁定恢复状态
        this.isRestoring = true;
        // ✅ 第二步:再更新数据(这会触发 selection-change,但被锁住了)
        this.userList = response.rows[0].serviceSubtaskList;
        this.total = response.total;
        // ✅ 第三步:恢复选中状态
        // this.restoreSelection();
        this.$nextTick(() => {
          this.restoreSelection();
        });
        // ✅ 第四步:处理其他数据
        if (refresh) {
          this.cardlist[0].value =
            Number(response.rows[0].wxsf) + Number(response.rows[0].xsf) || 0;
          this.cardlist[1].value = response.rows[0].wxsf || 0;
          this.ycvalue = Number(response.rows[0].yc) || 0;
          this.jgvalue = response.rows[0].jg;
          this.cardlist[2].value = response.rows[0].xsf || 0;
          this.cardlist[3].value = response.rows[0].dsf || 0;
          this.cardlist[4].value = response.rows[0].ywc || 0;
          this.yfsvalue = response.rows[0].yfs;
        }
        // ✅ 第五步:处理 preachform 等其他数据
        this.userList.forEach((item) => {
          let idArray = null;
          if (item.endtime) {
            item.endDay = this.daysBetween(item.endtime);
          }
          if (item.preachform) {
            if (item.endtime) {
              item.preachformson = item.preachform;
              idArray = item.preachform.split(",");
            }
            item.preachform = idArray.map((value) => {
              const item = this.checkboxlist.find(
                (item) => item.value == value
              );
              return item ? item.label : null;
            });
          }
        });
        this.total = response.total;
        this.loading = false;
        // ✅ 第六步:解锁
        this.$nextTick(() => {
          this.isRestoring = false;
        });
      } catch (error) {
        console.error("获取列表失败:", error);
        this.loading = false;
        this.isRestoring = false;
      }
    },
    loadData() {
      this.errtype = this.$route.query.errtype;
      if (this.errtype == 1) {
        this.toleadExport(2);
      } else if (this.errtype == 2) {
        // 待随访
        this.toleadExport(3);
      } else if (this.errtype == 3) {
        // 失败
        this.toleadExport(4);
      } else if (this.errtype == 4) {
        // 异常
        this.toleadExport(2);
      } else if (this.errtype == 5) {
        // 全部
        this.toleadExport(5);
      } else {
        this.getList(1);
      }
    },
    // 时间
    getEndOfDay() {
      const date = new Date(); // 创建一个表示当前时间的Date对象
      date.setHours(23, 59, 59, 0); // 将时间设置为23:59:59.000
      return date;
    },
    formatDateToYYYYMMDDHHMMSS(date) {
      const year = date.getFullYear();
      const month = String(date.getMonth() + 1).padStart(2, "0"); // 月份补零
      const day = String(date.getDate()).padStart(2, "0"); // 日期补零
      const hours = String(date.getHours()).padStart(2, "0");
      const minutes = String(date.getMinutes()).padStart(2, "0");
      const seconds = String(date.getSeconds()).padStart(2, "0");
      return `${year}-${month}-${day}`;
    },
    affiliation() {
      this.topqueryParams.managementDoctorCode = store.getters.hisUserId;
      this.getList(1);
    },
    onthatday() {
      this.topqueryParams.startSendDateTime = this.getCurrentDate();
      this.topqueryParams.endSendDateTime = this.getCurrentDate();
      this.getList(1);
    },
    getCurrentDate() {
      const now = new Date();
      return now.toISOString().slice(0, 10); // 截取前10个字符,即 YYYY-MM-DD
    },
    buidegetTasklist(type) {
      if (this.topqueryParams.searchscope == 3) {
        this.topqueryParams.leaveldeptcodes = store.getters.belongDepts.map(
          (obj) => obj.deptCode
        );
        this.topqueryParams.leavehospitaldistrictcodes =
          store.getters.belongWards.map((obj) => obj.districtCode);
      }
      // 接受异常跳转
      if (this.errtype) {
        this.topqueryParams.leavehospitaldistrictcodes.push(
          this.leavehospitaldistrictcode
        );
      }
      let obj = {
        pageNum: 1,
        pageSize: 10,
        leavehospitaldistrictcodes:
          this.topqueryParams.leavehospitaldistrictcodes,
        sendstates: [2, 3],
        leaveldeptcodes: this.topqueryParams.leaveldeptcodes,
      };
      buidegetTasklist(obj).then((response) => {
        this.userList = response.rows[0].serviceSubtaskList;
        this.total = response.total;
        this.cardlist[0].value =
          Number(response.rows[0].wxsf) + Number(response.rows[0].xsf) || 0;
        this.cardlist[1].value = response.rows[0].wzx;
        this.cardlist[2].value = response.rows[0].ysf;
        this.ycvalue = Number(response.rows[0].yc) || 0;
        this.jgvalue = response.rows[0].jg;
        this.cardlist[3].value = response.rows[0].fssb;
        this.cardlist[4].value = response.rows[0].dsf;
        // this.cardlist[5].value = response.rows[0].yfs2;
        this.yfsvalue = response.rows[0].yfs;
        this.loading = false;
        this.userList.forEach((item) => {
          let idArray = null;
          if (item.endtime) {
            item.endDay = this.daysBetween(item.endtime);
          }
          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.total = response.total;
      });
    },
    // 查看门诊随访详情
@@ -716,7 +1684,7 @@
        this.options = [];
      }
    },
    // 门诊随访状态修改
    // 影像随访状态修改
    handleStatusChange(row) {
      let text = row.status === "0" ? "启用" : "停用";
      this.$modal
@@ -731,11 +1699,7 @@
          row.status = row.status === "0" ? "1" : "0";
        });
    },
    // 取消按钮
    cancel() {
      this.addalteropen = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
@@ -755,23 +1719,165 @@
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
    handleQuery(refresh) {
      if (this.topqueryParams.searchscope == 3) {
        this.topqueryParams.leaveldeptcodes = store.getters.belongDepts.map(
          (obj) => obj.deptCode
        );
        this.topqueryParams.leavehospitaldistrictcodes =
          store.getters.belongWards.map((obj) => obj.districtCode);
      }
      this.topqueryParams.pageNum = 1;
      this.getList();
      // 判断是不是工作台快捷查询
      if (this.errtype != 2) {
        this.topqueryParams.startOutHospTime = this.dateRange[0];
        this.topqueryParams.endOutHospTime = this.dateRange[1];
        this.topqueryParams.startSendDateTime = this.dateRangefs[0];
        this.topqueryParams.endSendDateTime = this.dateRangefs[1];
      }
      this.getList(refresh);
    },
    // 患者范围处理
    handleChange(value) {
      console.log("选择的患者范围:", value);
      // 清空之前的查询参数
      this.topqueryParams.leavehospitaldistrictcodes = [];
      this.topqueryParams.leaveldeptcodes = [];
      this.topqueryParams.searchscope = null;
      if (!value || value.length === 0) {
        return;
      }
      let type = value[0];
      let code = value.slice(-1)[0];
      if (type == 1) {
        this.topqueryParams.leaveldeptcodes.push(code);
        this.topqueryParams.leavehospitaldistrictcodes = [];
        this.topqueryParams.searchscope = 1;
      } else if (type == 2) {
        this.topqueryParams.leavehospitaldistrictcodes.push(code);
        this.topqueryParams.leaveldeptcodes = [];
        this.topqueryParams.searchscope = 2;
      } else {
        this.topqueryParams.searchscope = 3;
      }
    },
    // 服务状态变更处理
    handleServiceStatusChange(value) {
      // 清空选择
      if (value === null || value === undefined || value === "") {
        this.topqueryParams.sendstateView = null;
        this.topqueryParams.sendstate = null;
        return;
      }
      console.log(value, "value");
      // 一级节点的值(大于等于10)
      if (value >= 10) {
        // 选中了一级
        switch (value) {
          case 10:
            this.topqueryParams.sendstateView = 1; // 待随访
            break;
          case 20:
            this.topqueryParams.sendstateView = 2; // 已完成
            break;
          case 30:
            this.topqueryParams.sendstateView = 3; // 无需随访
            break;
        }
        this.topqueryParams.sendstate = null;
      } else {
        // 选中了二级(具体状态)
        this.topqueryParams.sendstateView = null;
        this.topqueryParams.sendstate = value;
      }
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.topqueryParams.deptId = undefined;
      this.$refs.tree.setCurrentKey(null);
      this.handleQuery();
      this.dateRangefs = [];
      this.serviceStatusValue = 10;
      this.topqueryParams = {
        pageNum: 1,
        pageSize: 10,
        sendstateView: 1,
        sort: 2, //0 出院时间(正序)    1 出院时间(倒序)   2 发送时间(正序)    3 发送时间(倒序)
        serviceType: 2,
        searchscope: 3,
        visitCount: 1,
        scopetype: [],
        leaveldeptcodes: [],
        leavehospitaldistrictcodes: [],
      };
      this.handleQuery(1);
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.userId);
      this.single = selection.length != 1;
      this.multiple = !selection.length;
    handleSelectionChange(rows) {
      // ✅ 如果是恢复选中状态触发的,直接返回
      if (this.isRestoring) {
        console.log("正在恢复选中状态,跳过 handleSelectionChange");
        return;
      }
      console.log("handleSelectionChange 被触发,选中行数:", rows.length);
      // 只做添加操作
      rows.forEach((row) => {
        this.selectedRowMap.set(row.id, {
          ...row,
          authenticity: row.authenticity || 0,
          weekFinish: row.weekFinish || 0,
          standard: row.standard || 0,
          timeliness: row.timeliness || 0,
          library: row.library || 0,
          environment: row.environment || 0,
          doctorSatisfaction: row.doctorSatisfaction || 0,
          nurseSatisfaction: row.nurseSatisfaction || 0,
        });
      });
      this.selectedRows = Array.from(this.selectedRowMap.values());
      this.multiple = this.selectedRows.length === 0;
    },
    // 计算总分
    calculateTotal(row) {
      return (
        (row.authenticity || 0) +
        (row.weekFinish || 0) +
        (row.standard || 0) +
        (row.timeliness || 0) +
        (row.library || 0) +
        (row.environment || 0) +
        (row.doctorSatisfaction || 0) +
        (row.nurseSatisfaction || 0)
      );
    },
    // 保存评分
    saveScores() {
      this.selectedRows.forEach((item) => {
        item.createBy = null;
        item.patName = item.sendname;
        item.hospitaldistrictname = item.leavehospitaldistrictname;
      });
      addsatisfaction(this.selectedRows).then((res) => {
        if (res.code == 200) {
          this.$message.success("评分保存成功");
          this.scoreDialogVisible = false;
          this.selectedRows = [];
          this.$refs.userform.clearSelection();
        } else {
          this.$modal.msgWarning("评分保存失败");
          this.scoreDialogVisible = false;
          this.selectedRows = [];
          this.$refs.userform.clearSelection();
        }
      });
      // 这里可以添加保存逻辑,如调用API保存评分
    },
    //删除选项
    handleClose(tag) {
@@ -803,6 +1909,38 @@
        },
      });
    },
    //患者360跳转
    gettoken360(sfzh, drcode, drname, id) {
      const orgname = localStorage.getItem("orgname");
      if (orgname == "南华大学附属第一医院") {
        query360PatInfonh(id).then((res) => {
          if (res.data) {
            window.open(res.data, "_blank");
          } else {
            this.$modal.msgWarning("360查询无结果");
          }
        });
        return;
      } else if (
        orgname == "第一人民医院湖滨院区" ||
        orgname == "第一人民医院吴山院区"
      ) {
        let url = `http://192.200.81.189:9100/blj/view?BINGRENID=${id}&YONGHUID=DBA`;
        window.open(url, "_blank");
        return;
      }
      this.postData.YeWuXX.BingRenXX.ZhengJianHM = sfzh;
      query360PatInfo(this.postData).then((res) => {
        if (res.data.url) {
          window.open(res.data.url, "_blank");
          // this.linkUrl = res.data.url;
        } else {
          this.$modal.msgWarning("360查询无结果");
        }
      });
    },
    /** 重置密码按钮操作 */
    handleResetPwd(row) {
@@ -820,24 +1958,28 @@
        })
        .catch(() => {});
    },
    // 取消按钮
    cancel() {
      this.Labelchange = false;
      this.reset();
    },
    /** 提交按钮 */
    submitForm: function () {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.userId != undefined) {
            updateUser(this.form).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
          this.form.isoperation = 2;
          this.form.notrequiredFlag = 1;
          alterpatient(this.form)
            .then((response) => {
              console.log(response);
            })
            .then(() => {
              this.getList(1);
              this.$modal.msgSuccess("患者过滤成功");
            });
          } else {
            addUser(this.form).then((response) => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
          this.reset();
          this.Labelchange = false;
        }
      });
    },
@@ -850,7 +1992,7 @@
          return delUser(userIds);
        })
        .then(() => {
          this.getList();
          this.getList(1);
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
@@ -863,7 +2005,7 @@
          return console.log("停止成功");
        })
        .then(() => {
          this.getList();
          this.getList(1);
          this.$modal.msgWarning("停止成功");
        })
        .catch(() => {});
@@ -876,7 +2018,7 @@
          return console.log("开启成功");
        })
        .then(() => {
          this.getList();
          this.getList(1);
          this.$modal.msgSuccess("开启成功");
        })
        .catch(() => {});
@@ -889,7 +2031,7 @@
          return console.log("选中成功");
        })
        .then(() => {
          this.getList();
          this.getList(1);
          this.$modal.msgSuccess("重置成功");
        })
        .catch(() => {});
@@ -900,22 +2042,238 @@
    },
    // 跳转详情页
    Seedetails(row) {
      let type = "";
      console.log(row, "rwo");
      if (row.type == 1) {
        type = 1;
      }
      this.$router.push({
        path: "/followvisit/record/detailpage/",
        query: { taskid: row.taskid, patid: row.patid },
        query: {
          taskid: row.taskid,
          patid: row.patid,
          id: row.id,
          Voicetype: type,
          visitCount: this.topqueryParams.visitCount,
        },
      });
    },
    // 导入按钮
    toleadExport() {},
    // 再次随访
    followupvisit(row) {
      this.zcform = row;
      this.zcform.endtime = this.formatTime(this.zcform.endtime);
      this.dialogFormVisible = true;
    },
    onSubmit() {},
    // 暂停服务
    handlestop(row) {
      let objson = row;
      this.$modal
        .confirm(
          '是否确认暂停任务名称为"' +
            row.taskName +
            '患者名称为"' +
            row.sendname +
            '"的数据项?'
        )
        .then(() => {
          getTaskservelist({
            patid: row.patid,
            taskid: row.taskid,
          }).then((res) => {
            if (res.code == 200) {
              objson.sendstate = 4;
              objson.remark = "服务暂停";
              Editsingletaskson(objson).then((res) => {
                if (res.code) {
                  this.$modal.msgSuccess("记录成功");
                  this.getList(1);
                }
              });
            }
          });
        })
        .catch(() => {});
    },
    // 患者过滤触发
    handleUpdate(row) {
      particularpatient(row.patid).then((response) => {
        this.form = response.data;
        this.form.filterDrname = store.getters.nickName;
      });
      this.amendtag = true;
      this.Labelchange = true;
    },
    // 便捷按钮
    toleadExport(too) {
      console.log(too, "too");
      if (too == 1) {
        this.topqueryParams.sendstate = 4;
        this.topqueryParams.excep = null;
      } else if (too == 2) {
        this.topqueryParams.excep = 1;
        this.topqueryParams.sendstate = null;
      } else if (too == 3) {
        this.topqueryParams.endSendDateTime = this.formatDateToYYYYMMDDHHMMSS(
          this.getEndOfDay()
        );
        console.log(1111, this.topqueryParams.endSendDateTime);
        this.topqueryParams.excep = null;
        this.topqueryParams.sendstate = 2;
        this.topqueryParams.scopetype = null;
      } else if (too == 4) {
        this.topqueryParams.excep = null;
        this.topqueryParams.sendstate = 5;
        this.topqueryParams.scopetype = null;
      } else if (too == 5) {
        this.topqueryParams.excep = null;
        this.topqueryParams.sendstate = null;
        this.topqueryParams.scopetype = null;
      }
      this.handleQuery(1);
    },
    /** 导出按钮操作 */
    handleExport() {
      const originalPageNum = this.topqueryParams.pageNum;
      const originalPageSize = this.topqueryParams.pageSize;
      this.topqueryParams.pageNum = null;
      this.topqueryParams.pageSize = null;
      this.topqueryParams.subIdList = this.selectedRows.map((item) => item.id);
      this.download(
        "system/user/export",
        "smartor/serviceSubtask/patItemExport",
        {
          ...this.topqueryParams,
        },
        `user_${new Date().getTime()}.xlsx`
      ).finally(() => {
        // 导出后恢复分页参数
        this.topqueryParams.pageNum = originalPageNum;
        this.topqueryParams.pageSize = originalPageSize;
        this.getList();
      });
    },
    // 异常列渲染
    tableRowClassName({ row, rowIndex }) {
      if (row.excep == 1) {
        return "warning-row";
      } else if (row.excep == 2) {
        return "remind-row";
      }
      return "";
    },
    restoreSelection() {
      if (!this.$refs.userform) {
        console.log("表格引用不存在");
        return;
      }
      console.log("执行 restoreSelection");
      // 清除当前页的所有选中状态
      this.$refs.userform.clearSelection();
      // 找出当前页中哪些行是被选中的
      const toBeSelected = this.userList.filter((row) =>
        this.selectedRowMap.has(row.id)
      );
      console.log("需要恢复的行数:", toBeSelected.length);
      // 重新选中这些行
      toBeSelected.forEach((row) => {
        this.$refs.userform.toggleRowSelection(row, true);
      });
    },
    // ✅ 处理表头全选事件
    handleSelectAll(selection) {
      console.log("全选事件触发,选中行数:", selection.length);
      // 如果 selection 长度等于当前页行数,说明是全选
      if (selection.length === this.userList.length) {
        // 全选当前页
        this.userList.forEach((row) => {
          this.selectedRowMap.set(row.id, {
            ...row,
            authenticity: row.authenticity || 0,
            weekFinish: row.weekFinish || 0,
            standard: row.standard || 0,
            timeliness: row.timeliness || 0,
            library: row.library || 0,
            environment: row.environment || 0,
            doctorSatisfaction: row.doctorSatisfaction || 0,
            nurseSatisfaction: row.nurseSatisfaction || 0,
          });
        });
      } else {
        // 取消全选:清除当前页的选中状态
        this.userList.forEach((row) => {
          this.selectedRowMap.delete(row.id);
        });
      }
      // 更新 selectedRows
      this.selectedRows = Array.from(this.selectedRowMap.values());
      this.multiple = this.selectedRows.length === 0;
    },
    // 清除所有选中
    clearAllSelection() {
      this.selectedRowMap.clear();
      this.selectedRows = [];
      this.multiple = true;
      if (this.$refs.userform) {
        this.$refs.userform.clearSelection();
      }
    },
    // 获取选中数量
    getSelectedCount() {
      return this.selectedRowMap.size;
    },
    // 创建再次随访服务
    setupsubtask() {
      this.$refs["zcform"].validate((valid) => {
        if (valid) {
          this.zcform.remark =
            this.zcform.remark + "【" + this.getCurrentTime() + "】";
          let form = structuredClone(this.zcform);
          form.visitTime = this.formatTime(form.date1);
          form.finishtime = "";
          if (form.resource) {
            if (form.resource == 2) {
              form.serviceType = 13;
            }
          } else {
            this.$modal.msgError("未选择随访方式");
          }
          form.id = null;
          form.sendstate = 2;
          form.preachform = form.preachformson;
          form.longTask = 0;
          addserviceSubtask(form).then((res) => {
            if (res.code == 200) {
              this.$modal.msgSuccess("创建成功");
            } else {
              this.$modal.msgError("创建失败");
            }
            this.dialogFormVisible = false;
          });
        }
      });
    },
    getCurrentTime() {
      const now = new Date();
      const year = now.getFullYear();
      const month = String(now.getMonth() + 1).padStart(2, "0");
      const day = String(now.getDate()).padStart(2, "0");
      const hours = String(now.getHours()).padStart(2, "0");
      const minutes = String(now.getMinutes()).padStart(2, "0");
      const seconds = String(now.getSeconds()).padStart(2, "0");
      return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
    },
  },
};
@@ -931,6 +2289,12 @@
.document {
  // width: 100px;
  height: 50px;
}
::v-deep.el-table .warning-row {
  background: #eec4c4;
}
::v-deep.el-table .remind-row {
  background: #fcf5aa;
}
.documentf {
@@ -1010,6 +2374,34 @@
    }
  }
}
::v-deep.leftvlue .el-card__body {
  background: #f2f8ff;
  color: #324a9b;
}
::v-deep.leftvlue .el-card__body:hover {
  background: #3664d9;
  color: #fff;
  cursor: pointer; /* 鼠标悬浮时变为手形 */
}
::v-deep.errleftvlue .el-card__body {
  background: #fdd0d7;
}
::v-deep.errleftvlue .el-card__body:hover {
  background: #f88d96;
  cursor: pointer; /* 鼠标悬浮时变为手形 */
}
::v-deep.jgleftvlue .el-card__body:hover {
  background: #f7f075;
  cursor: pointer; /* 鼠标悬浮时变为手形 */
}
::v-deep.ysfleftvlue .el-card__body {
  background: #d0fdd8;
}
::v-deep.ysfleftvlue .el-card__body:hover {
  background: #0abc54;
  cursor: pointer; /* 鼠标悬浮时变为手形 */
}
.button-bb {
  font-weight: 500;
  background-color: #2ba05c;
@@ -1026,13 +2418,13 @@
}
.button-sc {
  font-weight: 500;
  background-color: #dd302a;
  background-color: #b3a21f;
  padding: 5px;
  border-radius: 1px;
  color: #ffffff;
}
.button-zx {
  background: #4fabe9;
  background: #324a9b;
  padding: 5px;
  border-radius: 1px;
  color: #ffffff;
@@ -1043,11 +2435,82 @@
    font-size: 24px;
  }
}
.purple-button {
  background-color: #7e22ce;
  border-color: #7e22ce;
  color: #fff;
}
.purple-button:hover,
.purple-button:focus {
  background-color: #9333ea;
  border-color: #9333ea;
}
.purple-button:active {
  background-color: #6b21a8;
  border-color: #6b21a8;
}
.button-textxga {
  color: #de7897;
}
.purple-button.is-disabled {
  background-color: #d8b4fe;
  border-color: #d8b4fe;
  opacity: 1; /* 保持禁用状态透明度 */
}
.statistics-tooltip {
  background: #ffffff !important;
  color: #1976d2 !important;
  border: 1px solid #bbdefb !important;
  border-radius: 8px !important;
  padding: 10px 14px !important;
  font-size: 13px !important;
  line-height: 1.6 !important;
  box-shadow: 0 4px 12px rgba(25, 118, 210, 0.15) !important;
}
.statistics-tooltip .popper__arrow {
  border-bottom-color: #bbdefb !important;
}
.statistics-tooltip .popper__arrow::after {
  border-bottom-color: #ffffff !important;
}
// 选项字体放大
// ::v-deep.el-checkbox-group {
//   span {
//     font-size: 24px;
//   }
// }
.filter-warning {
  margin-top: 8px;
  padding: 10px 14px;
  background: #fff7e6;
  border: 1px solid #ffe58f;
  border-radius: 6px;
  color: #d46b08;
  font-size: 18px;
  line-height: 1.6;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}
.filter-warning .el-icon-warning-outline {
  font-size: 16px;
  color: #faad14;
  flex-shrink: 0;
  margin-top: 2px;
}
::v-deep .el-table__row.selected-row:hover > td {
  background-color: #e6f7ff !important;
}
/* 选中信息显示 */
.selected-info {
  padding: 10px 0;
  font-size: 14px;
  color: #666;
}
</style>