/* eslint-disable */
<template>
  <BaseContainer>
    <template slot="title-container">
      <div class="title" v-if="isDoc">
        {{ TITLE }}
      </div>
    </template>
    <template slot="search-container">
      <el-form :inline="true">
        <!-- 是否加急 -->
        <el-form-item style="margin-bottom: 10px" :label="$t('trials:reviewTrack:table:isUrgent')">
          <el-select v-model="searchData.IsUrgent" clearable style="width: 120px">
            <el-option v-for="item of $d.YesOrNo" :key="'IsUrgent' + item.label" :value="item.value"
              :label="item.label" />
          </el-select>
        </el-form-item>
        <!-- 临床数据是否完备 -->
        <el-form-item style="margin-bottom: 10px" :label="$t('trials:reviewTrack:table:completeClinicalDataEnum')">
          <el-select v-model="searchData.CompleteClinicalDataEnum" clearable style="width: 120px">
            <el-option v-for="item of $d.CompleteClinicalDataEnum" :key="'CompleteClinicalDataEnum' + item.label"
              :value="item.value" :label="item.label" />
          </el-select>
        </el-form-item>
        <!-- 中心编号 -->
        <el-form-item :label="$t('trials:reviewTrack:table:siteCode')">
          <el-select v-model="searchData.TrialSiteId" clearable filterable style="width: 120px">
            <el-option v-for="(item, index) of siteOptions" :key="index" :label="item.TrialSiteCode"
              :value="item.TrialSiteId" />
          </el-select>
        </el-form-item>
        <!-- 受试者编号 -->
        <el-form-item :label="$t('trials:reviewTrack:table:subjectCode')">
          <el-input v-model="searchData.SubjectCode" style="width: 100px" />
        </el-form-item>
        <!-- 任务名称 -->
        <el-form-item style="margin-bottom: 10px" :label="$t('trials:reviewTrack:table:taskName')">
          <el-input v-model="searchData.TaskName" style="width: 100px" clearable />
        </el-form-item>
        <!-- 任务类型 -->
        <el-form-item style="margin-bottom: 10px" :label="$t('trials:reviewTrack:table:taskType')">
          <el-select v-model="searchData.ReadingCategory" clearable style="width: 120px">
            <el-option v-for="item of $d.ReadingCategory" :key="'ReadingCategory' + item.label" :value="item.value"
              :label="item.label" />
          </el-select>
        </el-form-item>
        <!-- 阅片人 -->
        <el-form-item style="margin-bottom: 10px" :label="$t('trials:reviewTrack:table:reader')" v-if="!isDoc">
          <el-select v-model="searchData.DoctorUserId" clearable style="width: 120px">
            <el-option v-for="item of DoctorUserList" :key="'DoctorUserId' + item.DoctorUserId"
              :value="item.DoctorUserId" :label="viewStatus
                ? `${item.UserName}`
                : `${item.UserName}(${item.FullName})`
                " />
          </el-select>
        </el-form-item>
        <!-- 角色 -->
        <!-- <el-form-item style="margin-bottom:10px" :label="$t('trials:reviewTrack:table:role')">
          <el-select v-model="searchData.ArmEnum" clearable style="width:120px;">
            <el-option v-for="item of $d.ArmEnum" :key="'ArmEnum' + item.label" :value="item.value" :label="item.label" />
          </el-select>
        </el-form-item> -->
        <!-- 阅片标准 -->
        <el-form-item style="margin-bottom: 10px" :label="$t('trials:reviewTrack:table:criterionName')">
          <el-select v-model="searchData.TrialReadingCriterionId" clearable style="width: 120px">
            <el-option v-for="item of trialCriterionList"
              :key="'TrialReadingCriterionId' + item.TrialReadingCriterionId" :value="item.TrialReadingCriterionId"
              :label="item.TrialReadingCriterionName" />
          </el-select>
        </el-form-item>
        <!-- 阅片状态 -->
        <el-form-item style="margin-bottom: 10px" :label="$t('trials:reviewTrack:table:readingStatus')"
          v-if="!viewStatus || !isDoc">
          <el-select v-model="searchData.ReadingTaskState" clearable style="width: 120px">
            <el-option v-for="item of $d.ReadingTaskState" :key="'ReadingTaskState' + item.label" :value="item.value"
              :label="item.label" />
          </el-select>
        </el-form-item>
        <!-- 任务状态 -->
        <el-form-item style="margin-bottom: 10px" :label="$t('trials:reviewTrack:table:taskStatus')">
          <el-select v-model="searchData.TaskState" clearable style="width: 120px">
            <el-option v-show="item.value === 0 || item.value === 5" v-for="item of $d.TaskState"
              :key="'TaskState' + item.label" :value="item.value" :label="item.label" />
          </el-select>
        </el-form-item>
        <!-- 分配时间 -->
        <el-form-item style="margin-bottom: 10px" :label="$t('trials:reviewTrack:table:assignTime')">
          <el-date-picker v-model="timeList" value-format="yyyy-MM-dd HH:mm:ss" type="datetimerange"
            :default-time="['00:00:00', '23:59:59']" @change="changeTimeList" />
        </el-form-item>
        <!-- 完成时间 -->
        <el-form-item style="margin-bottom: 10px" :label="$t('trials:reviewTrack:table:signTime')">
          <el-date-picker v-model="timeList2" value-format="yyyy-MM-dd HH:mm:ss" type="datetimerange"
            :default-time="['00:00:00', '23:59:59']" @change="changeTimeList2" />
        </el-form-item>
        <!-- <el-form-item style="margin-bottom:10px" :label="$t('trials:rereadTrack:table:ReReadingApplyState')">
          <el-select v-model="searchData.ReReadingApplyState" clearable style="width:120px;">
            <el-option v-for="item of $d.ReReadingApplyState" :key="'ReReadingApplyState' + item.label" :value="item.value" :label="item.label" />
          </el-select>
        </el-form-item> -->
        <el-form-item style="margin-bottom: 10px">
          <el-button type="primary" icon="el-icon-search" @click="handleSearch">
            {{ $t('common:button:search') }}
          </el-button>
          <el-button type="primary" icon="el-icon-refresh-left" @click="handleReset">
            {{ $t('common:button:reset') }}
          </el-button>
          <!--导出-->
          <el-button v-if="!viewStatus" type="primary" icon="el-icon-download" @click="handleExport">
            {{ $t('common:button:export') }}
          </el-button>
          <!-- 阅片结果 -->
          <el-button v-if="!viewStatus" type="primary" icon="el-icon-download" @click="handleReviewResults">
            {{ $t('trials:readingTracking:button:reviewResults') }}
          </el-button>
          <el-button v-if="!viewStatus" type="primary" icon="el-icon-info" @click="handleViewRecord">
            {{ $t('common:button:failureRecord') }}
          </el-button>
          <!-- 靶段标注 -->
          <el-button type="primary" v-if="hasIVUSOROCT" v-hasPermi="['role:pm', 'role:apm']"
            @click="handleTargetSection">
            {{ $t('trials:pendingReadingTasks:button:TargetSection') }}
          </el-button>
          <!--          <el-button type="primary" @click="openReadingRules">-->
          <!--            阅片任务规则-->
          <!--          </el-button>-->
          <!--          <el-button type="primary" @click="openRefereeAllocation">-->
          <!--            设置裁判触发规则-->
          <!--          </el-button>-->
        </el-form-item>
      </el-form>
    </template>
    <template slot="main-container">
      <el-table v-adaptive="{ bottomOffset: 60 }" v-loading="loading" :data="list" stripe height="100"
        @sort-change="handleSortChange">
        <!-- 是否加急 -->
        <el-table-column prop="IsUrgent" :label="$t('trials:reviewTrack:table:isUrgent')" width="120" sortable="custom"
          align="center" style="position: relative">
          <template slot-scope="scope">
            <i class="el-icon-question fbBox" @click.stop="openFeedBack(scope.row)" v-if="scope.row.IsHaveFeedBack"></i>
            <!-- <el-tag v-if="scope.row.IsUrgent" type="danger">{{ $fd('YesOrNo', scope.row.IsUrgent) }}</el-tag>
            <el-tag v-else type="primary">{{ $fd('YesOrNo', scope.row.IsUrgent) }}</el-tag> -->
            <el-tooltip placement="top">
              <div slot="content">
                <span>{{
                  `${$t('trials:reviewTrack:label:taskUrgentType')}${$fd(
                    'TaskUrgentType',
                    scope.row.TaskUrgentType
                  )}`
                }}</span><br />
                <span>{{
                  scope.row.TaskUrgentRemake
                    ? `${$t('trials:reviewTrack:label:taskUrgentRemake')}${scope.row.TaskUrgentRemake
                    }`
                    : ''
                }}</span>
              </div>
              <div>
                <el-button :disabled="!(
                  !scope.row.TaskState &&
                  (scope.row.ReadingTaskState === 0 ||
                    scope.row.ReadingTaskState === 1)
                ) || !scope.row.IsCanEditUrgentState
                  " v-if="scope.row.IsUrgent" type="danger" size="mini" @click="changeUrgentStatus(scope.row)">{{
                    $fd('YesOrNo', scope.row.IsUrgent) }}</el-button>
              </div>
            </el-tooltip>
            <el-button :disabled="!(
              !scope.row.TaskState &&
              (scope.row.ReadingTaskState === 0 ||
                scope.row.ReadingTaskState === 1)
            ) || !scope.row.IsCanEditUrgentState
              " v-if="!scope.row.IsUrgent" type="primary" size="mini" @click="changeUrgentStatus(scope.row)">{{
                $fd('YesOrNo', scope.row.IsUrgent) }}</el-button>
          </template>
        </el-table-column>
        <!-- 临床数据是否完备 -->
        <el-table-column prop="CompleteClinicalDataEnum"
          :label="$t('trials:reviewTrack:table:completeClinicalDataEnum')" width="160" show-overflow-tooltip>
          <template slot-scope="scope">
            <span v-if="scope.row.CompleteClinicalDataEnum === -1">
              {{
                $fd(
                  'CompleteClinicalDataEnum',
                  scope.row.CompleteClinicalDataEnum
                )
              }}
            </span>
            <el-button type="text" v-else @click="handleView(scope.row)">
              {{
                $fd(
                  'CompleteClinicalDataEnum',
                  scope.row.CompleteClinicalDataEnum
                )
              }}
            </el-button>
          </template>
        </el-table-column>
        <!-- 中心编号 -->
        <el-table-column prop="TrialSiteCode" :label="$t('trials:reviewTrack:table:siteCode')" width="100"
          sortable="custom" show-overflow-tooltip />
        <!-- 受试者编号 -->
        <el-table-column prop="SubjectCode" :label="$t('trials:reviewTrack:table:subjectCode')" min-width="150"
          sortable="custom" show-overflow-tooltip>
          <template slot-scope="scope">
            <span v-if="
              scope.row.BlindSubjectCode &&
              scope.row.BlindSubjectCode !== scope.row.SubjectCode
            ">
              {{ `${scope.row.SubjectCode}/${scope.row.BlindSubjectCode}` }}
            </span>
            <span v-else>{{ scope.row.SubjectCode }}</span>
            <!-- 终止 -->
            <span v-if="scope.row.IsSubjectQuit" class="status-primary-circle">
              {{ $t('trials:crcUpload:label:ISQ') }}
            </span>
          </template>
        </el-table-column>
        <!-- 任务名称 -->
        <el-table-column prop="VisitTaskNum" :label="$t('trials:reviewTrack:table:taskName')" width="140"
          sortable="custom" show-overflow-tooltip>
          <template slot-scope="scope">
            <span v-if="
              scope.row.TaskBlindName &&
              scope.row.TaskName !== scope.row.TaskBlindName
            ">
              {{ `${scope.row.TaskName}/${scope.row.TaskBlindName}` }}
            </span>
            <span v-else>{{ scope.row.TaskName }}</span>
          </template>
        </el-table-column>
        <!-- 盲态任务标识 -->
        <!-- <el-table-column
          prop="TaskBlindName"
          :label="$t('trials:reviewTrack:table:blindName')"
          width="160"
          sortable="custom"
          show-overflow-tooltip
        /> -->
        <!-- 任务类型 -->
        <el-table-column prop="ReadingCategory" :label="$t('trials:reviewTrack:table:taskType')" width="140"
          sortable="custom" show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag v-if="scope.row.ReadingCategory === 1" type="primary">{{
              $fd('ReadingCategory', scope.row.ReadingCategory)
            }}</el-tag>
            <el-tag v-if="scope.row.ReadingCategory === 2" type="info">{{
              $fd('ReadingCategory', scope.row.ReadingCategory)
            }}</el-tag>
            <el-tag v-if="scope.row.ReadingCategory === 4" type="danger">{{
              $fd('ReadingCategory', scope.row.ReadingCategory)
            }}</el-tag>
            <el-tag v-if="scope.row.ReadingCategory === 5" type="warning">{{
              $fd('ReadingCategory', scope.row.ReadingCategory)
            }}</el-tag>
          </template>
        </el-table-column>
        <!-- 阅片人 -->
        <el-table-column prop="UserName" :label="$t('trials:reviewTrack:table:reader')" width="130" sortable="custom"
          show-overflow-tooltip>
          <template v-if="scope.row.TaskAllocationState" slot-scope="scope">
            <span v-if="viewStatus">{{ scope.row.UserName }}</span>
            <span v-else>{{ scope.row.UserName }}({{ scope.row.FullName }})</span>
          </template>
        </el-table-column>
        <!-- 角色 -->
        <!-- <el-table-column
          prop="ArmEnum"
          :label="$t('trials:reviewTrack:table:role')"
          width="100"
          sortable="custom"
          show-overflow-tooltip
        >
          <template slot-scope="scope">
            <el-tag v-if="scope.row.ArmEnum === 0" type="primary">{{ $fd('ArmEnum', scope.row.ArmEnum) }}</el-tag>
            <el-tag v-if="scope.row.ArmEnum === 1" type="primary">{{ $fd('ArmEnum', scope.row.ArmEnum) }}</el-tag>
            <el-tag v-if="scope.row.ArmEnum === 2" type="success">{{ $fd('ArmEnum', scope.row.ArmEnum) }}</el-tag>
            <el-tag v-if="scope.row.ArmEnum === 3" type="info">{{ $fd('ArmEnum', scope.row.ArmEnum) }}</el-tag>
            <el-tag v-if="scope.row.ArmEnum === 4" type="danger">{{ $fd('ArmEnum', scope.row.ArmEnum) }}</el-tag>
            <el-tag v-if="scope.row.ArmEnum === 5" type="warning">{{ $fd('ArmEnum', scope.row.ArmEnum) }}</el-tag>
          </template>
        </el-table-column> -->
        <!-- 阅片标准 -->
        <el-table-column prop="TrialReadingCriterionName" :label="$t('trials:reviewTrack:table:criterionName')"
          min-width="180" sortable="custom" show-overflow-tooltip />
        <!-- 阅片状态 -->
        <el-table-column prop="ReadingTaskState" :label="$t('trials:reviewTrack:table:readingStatus')" width="160"
          sortable="custom" show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag v-if="scope.row.ReadingTaskState === 2" type="primary">{{
              $fd('ReadingTaskState', scope.row.ReadingTaskState)
            }}</el-tag>
            <el-tag v-else type="danger">{{
              $fd('ReadingTaskState', scope.row.ReadingTaskState)
            }}</el-tag>
          </template>
        </el-table-column>
        <!-- 分配时间 -->
        <el-table-column prop="AllocateTime" :label="$t('trials:reviewTrack:table:assignTime')" width="180"
          sortable="custom" show-overflow-tooltip />
        <!-- 建议完成时间 -->
        <el-table-column prop="SuggesteFinishedTime" :label="$t('trials:reviewTrack:table:suggesteFinishedTime')"
          width="210" sortable="custom" show-overflow-tooltip />
        <!-- 阅片完成时间 -->
        <el-table-column prop="SignTime" :label="$t('trials:reviewTrack:table:signTime')" min-width="180"
          sortable="custom" show-overflow-tooltip />
        <el-table-column prop="ReadingDuration" :label="$t('trials:reviewTrack:table:readingDuration')" width="140"
          show-overflow-tooltip />
        <!-- 任务状态 -->
        <el-table-column prop="TaskState" :label="$t('trials:reviewTrack:table:taskStatus')" width="160"
          sortable="custom" show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag v-if="scope.row.TaskState === 0" type="primary">{{
              $fd('TaskState', scope.row.TaskState)
            }}</el-tag>
            <el-tag v-if="scope.row.TaskState === 1" type="info">{{
              $fd('TaskState', scope.row.TaskState)
            }}</el-tag>
            <el-tag v-if="scope.row.TaskState === 3" type="danger">{{
              $fd('TaskState', scope.row.TaskState)
            }}</el-tag>
            <el-tag v-if="scope.row.TaskState === 4" type="warning">{{
              $fd('TaskState', scope.row.TaskState)
            }}</el-tag>
            <el-tag v-if="scope.row.TaskState === 5" type="danger">{{
              $fd('TaskState', scope.row.TaskState)
            }}</el-tag>
          </template>
        </el-table-column>

        <!-- 申请状态 -->
        <!-- <el-table-column
          prop="ReReadingApplyState"
          :label="$t('trials:reviewTrack:table:applyStatus')"
          min-width="140"
          sortable="custom"
          show-overflow-tooltip
        >
          <template slot-scope="scope">
            <el-tag v-if="scope.row.ReReadingApplyState === 4 || scope.row.ReReadingApplyState === 5" type="danger">{{ $fd('ReReadingApplyState', scope.row.ReReadingApplyState) }}</el-tag>
            <el-tag v-if="scope.row.ReReadingApplyState === 2" type="primary">{{ $fd('ReReadingApplyState', scope.row.ReReadingApplyState) }}</el-tag>
            <el-tag v-if="scope.row.ReReadingApplyState === 3" type="warning">{{ $fd('ReReadingApplyState', scope.row.ReReadingApplyState) }}</el-tag>
          </template>
        </el-table-column> -->
        <el-table-column fixed="right" :label="$t('common:action:action')" width="220">
          <template slot-scope="scope">
            <!-- 查看阅片结果 -->
            <el-button :disabled="scope.row.ReadingTaskState !== 2" icon="el-icon-view" circle
              :title="$t('trials:reviewTrack:action:viewResults')" @click="lookReadingResults(scope.row)" />
            <!-- 申请重阅 -->
            <el-button :disabled="scope.row.ReadingCategory !== 1 ||
              (scope.row.TaskState !== 0 && scope.row.TaskState !== 5) ||
              scope.row.ReadingTaskState !== 2 ||
              scope.row.ReReadingApplyState === 2 ||
              scope.row.ReReadingApplyState === 4 ||
              scope.row.ReReadingApplyState === 5 || (scope.row.ReadingTaskState !== 2 && scope.row.IsSubjectQuit)
              " v-if="
                hasPermi(['trials:trials-panel:readingTracking:edit']) && !isDoc
              " icon="el-icon-collection" circle :title="$t('trials:reviewTrack:action:applyReread')"
              @click="openApplyReReading(scope.row)" />
            <!-- 退回重阅历史 -->
            <el-button
              :disabled="!scope.row.ReReadingApplyState || (scope.row.ReadingTaskState !== 2 && scope.row.IsSubjectQuit)"
              icon="el-icon-toilet-paper" v-if="!isDoc" circle
              :title="$t('trials:reviewTrack:action:backToRereadHistory')" @click="reReadingHistory(scope.row, 1)" />
            <!-- 退回 -->
            <el-button :disabled="scope.row.ReadingTaskState === 2 ||
              scope.row.ReadingCategory !== 1 ||
              scope.row.TaskState !== 0 ||
              scope.row.IsManualGeneration || (scope.row.ReadingTaskState !== 2 && scope.row.IsSubjectQuit)
              " v-if="
                hasPermi(['trials:trials-panel:readingTracking:edit']) && !isDoc
              " icon="el-icon-back" circle :title="$t('trials:reviewTrack:action:back')"
              @click="openReReadingOrBackList(scope.row)" />
            <!-- 退回已影响任务列表 -->
            <!-- <el-button
              :disabled="!scope.row.IsPMSetBack"
              icon="el-icon-document-copy"
              circle
              :title="$t('trials:reviewTrack:action:backToTaskList')"
              @click="getInfluencedTaskList(scope.row)"
            /> -->
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页组件 -->
      <pagination class="page" :total="total" :page.sync="searchData.PageIndex" :limit.sync="searchData.PageSize"
        @pagination="getList" />
      <div class="remark">
        <span class="status-primary-circle">
          {{ $t('trials:crcUpload:label:ISQ') }}
        </span>
        <span>: {{ $t('trials:crcUpload:label:IsSubjectQuit') }}</span>
      </div>
      <!-- 阅片任务规则 -->
      <el-dialog title="阅片任务规则" :visible.sync="ReadingRulesVisible" width="500px" :close-on-click-modal="false"
        custom-class="base-dialog-wrapper">
        <div class="base-dialog-body" style="position: relative">
          <el-form ref="signForm" size="small" label-width="160px">
            <!-- 呈现对象 -->
            <el-form-item label="呈现对象">
              <el-radio-group v-model="ReadingRulesInfo.ReadingTaskViewEnum">
                <el-radio v-for="item of $d.TaskAllocateObj" :key="'TaskAllocateObjEnum' + item.value"
                  :label="item.value" :disabled="item.value === 1">{{ item.label }}</el-radio>
              </el-radio-group>
            </el-form-item>
            <!-- 呈现顺序 -->
            <el-form-item label="呈现顺序">
              <el-radio-group v-model="ReadingRulesInfo.IsReadingTaskViewInOrder">
                <el-radio v-for="item of $d.IsReadingTaskViewInOrder" :key="'TaskAllocateObjEnum' + item.value"
                  :label="item.value">{{ item.label }}</el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item v-if="
              ReadingRulesInfo.ReadingTaskViewEnum === 0 &&
              ReadingRulesInfo.IsReadingTaskViewInOrder
            " label="是否展示受试者信息">
              <el-radio-group v-model="ReadingRulesInfo.IsReadingShowSubjectInfo">
                <el-radio v-for="item of $d.YesOrNo" :key="'IsReadingShowSubjectInfo' + item.value"
                  :label="item.value">{{
                    item.label }}</el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item v-if="
              ReadingRulesInfo.ReadingTaskViewEnum === 0 &&
              ReadingRulesInfo.IsReadingTaskViewInOrder
            " label="是否可以查看既往结果">
              <el-radio-group v-model="ReadingRulesInfo.IsReadingShowPreviousResults">
                <el-radio v-for="item of $d.YesOrNo" :key="'IsReadingShowPreviousResults' + item.value"
                  :label="item.value">{{
                    item.label }}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-form>
        </div>
        <div class="base-dialog-footer" style="text-align: right; margin-top: 10px">
          <!-- 取消 -->
          <el-button :disabled="btnLoading" size="small" type="primary" @click="handleCancel">
            {{ $t('common:button:cancel') }}
          </el-button>
          <!-- 保存 -->
          <el-button size="small" type="primary" :loading="btnLoading" @click="handleSave">
            {{ $t('common:button:save') }}
          </el-button>
        </div>
      </el-dialog>
      <el-dialog v-if="RefereeAllocationVisible" title="裁判触发规则" :visible.sync="RefereeAllocationVisible" width="1200px"
        append-to-body :close-on-click-modal="false" custom-class="base-dialog-wrapper">
        <RefereeRules />
        <div class="base-dialog-footer" style="text-align: right; margin-top: 10px">
          <!-- 取消 -->
          <el-button :disabled="btnLoading" size="small" type="primary" @click="RefereeAllocationVisible = false">
            {{ $t('common:button:cancel') }}
          </el-button>
        </div>
      </el-dialog>
      <!-- 申请重阅 -->
      <el-dialog v-if="ApplyforReasonVisible" :title="$t('trials:reviewTrack:dialog:applyReread')"
        :visible.sync="ApplyforReasonVisible" width="1460px" append-to-body :close-on-click-modal="false"
        custom-class="base-dialog-wrapper">
        <el-form ref="reasonForm" :rules="rules" :model="ApplyforReasonForm" class="demo-ruleForm" size="small"
          label-width="180px">
          <p>{{ $t('trials:reviewTrack:applyReread:title2').replace('xxx', rowData.SubjectCode).replace('yyy', rowData.TaskBlindName) }}</p>
          <!-- 申请原因 -->
          <el-divider content-position="left">
            {{ $t('trials:reviewTrack:applyReread:title:applyReason') }}
          </el-divider>
          <!-- 申请原因 -->
          <el-form-item :label="$t('trials:reviewTrack:applyReread:title:applyReason')" prop="Type" :rules="[
            { required: true, message: $t('common:ruleMessage:select') },
          ]">
            <el-radio-group v-model="ApplyforReasonForm.Type">
              <!-- 图像重传 -->
              <el-radio :label="1">{{
                $t('trials:reviewTrack:applyReread:title:ImageRetransfer')
              }}</el-radio>
              <!-- 其他 -->
              <el-radio :label="2">{{
                $t('trials:reviewTrack:applyReread:title:other')
              }}</el-radio>
            </el-radio-group>
          </el-form-item>
          <!-- 备注 -->
          <el-form-item v-if="ApplyforReasonForm.Type === 2" :label="$t('trials:reviewTrack:applyReread:title:remark')"
            prop="RequestReReadingReason">
            <el-input v-model="ApplyforReasonForm.RequestReReadingReason" style="width: 400px" type="textarea"
              :autosize="{ minRows: 2, maxRows: 4 }" :placeholder="$t('common:ruleMessage:specify')" maxlength="500"
              show-word-limit />
          </el-form-item>
        </el-form>
        <!-- 影响的任务列表 -->
        <el-divider content-position="left">{{
          $t('trials:reviewTrack:applyReread:title:influencesList')
        }}</el-divider>
        <div style="
            padding: 10px;
            border: 1px solid #e0e0e0;
            max-height: 650px;
            overflow-y: auto;
          ">
          <el-table v-loading="loading" :data="InfluenceTaskList" stripe height="100" style="min-height: 400px">
            <!-- 任务编号 -->
            <el-table-column prop="TaskCode" :label="$t('trials:reviewTrack:table:taskCode')" min-width="100"
              show-overflow-tooltip />
            <!-- 中心编号 -->
            <el-table-column prop="TrialSiteCode" :label="$t('trials:reviewTrack:table:siteCode')" min-width="100"
              show-overflow-tooltip />
            <!-- 受试者编号 -->
            <el-table-column prop="SubjectCode" :label="$t('trials:reviewTrack:table:subjectCode')" min-width="120"
              show-overflow-tooltip />
            <!-- 任务名称 -->
            <el-table-column prop="VisitTaskNum" :label="$t('trials:reviewTrack:table:taskName')" min-width="120"
              show-overflow-tooltip>
              <template slot-scope="scope">
                {{ scope.row.TaskName }}
              </template>
            </el-table-column>
            <!-- 盲态任务标识 -->
            <el-table-column prop="TaskBlindName" :label="$t('trials:reviewTrack:table:blindName')" min-width="120"
              show-overflow-tooltip />
            <!-- 阅片标准 -->
            <el-table-column prop="TrialReadingCriterionName" :label="$t('trials:reviewTrack:table:criterionName')"
              min-width="100" show-overflow-tooltip>
            </el-table-column>
            <!-- 任务状态 -->
            <el-table-column prop="TaskState" :label="$t('trials:reviewTrack:table:taskStatus')" min-width="100"
              show-overflow-tooltip>
              <template slot-scope="scope">
                <el-tag v-if="scope.row.TaskState === 0" type="primary">{{
                  $fd('TaskState', scope.row.TaskState)
                }}</el-tag>
                <el-tag v-if="scope.row.TaskState === 1" type="info">{{
                  $fd('TaskState', scope.row.TaskState)
                }}</el-tag>
                <el-tag v-if="scope.row.TaskState === 3" type="danger">{{
                  $fd('TaskState', scope.row.TaskState)
                }}</el-tag>
                <el-tag v-if="scope.row.TaskState === 4" type="warning">{{
                  $fd('TaskState', scope.row.TaskState)
                }}</el-tag>
                <el-tag v-if="scope.row.TaskState === 5" type="danger">{{
                  $fd('TaskState', scope.row.TaskState)
                }}</el-tag>
              </template>
            </el-table-column>
            <!-- 任务类型 -->
            <el-table-column prop="ReadingCategory" min-width="100" :label="$t('trials:reviewTrack:table:taskType')"
              show-overflow-tooltip>
              <template slot-scope="scope">
                <el-tag v-if="scope.row.ReadingCategory === 1" type="primary">{{
                  $fd('ReadingCategory', scope.row.ReadingCategory)
                }}</el-tag>
                <el-tag v-if="scope.row.ReadingCategory === 2" type="info">{{
                  $fd('ReadingCategory', scope.row.ReadingCategory)
                }}</el-tag>
                <el-tag v-if="scope.row.ReadingCategory === 4" type="danger">{{
                  $fd('ReadingCategory', scope.row.ReadingCategory)
                }}</el-tag>
                <el-tag v-if="scope.row.ReadingCategory === 5" type="warning">{{
                  $fd('ReadingCategory', scope.row.ReadingCategory)
                }}</el-tag>
              </template>
            </el-table-column>
            <!-- 阅片状态 -->
            <el-table-column prop="ReadingTaskState" :label="$t('trials:reviewTrack:table:readingStatus')"
              min-width="100" show-overflow-tooltip>
              <template slot-scope="scope">
                <el-tag v-if="scope.row.ReadingTaskState === 2" type="primary">{{
                  $fd('ReadingTaskState', scope.row.ReadingTaskState)
                }}</el-tag>
                <el-tag v-else type="danger">{{
                  $fd('ReadingTaskState', scope.row.ReadingTaskState)
                }}</el-tag>
              </template>
            </el-table-column>
            <!-- 生效后影响 -->
            <el-table-column prop="OptType" :label="$t('trials:reviewTrack:applyReread:title:postEffectiveImpacts')
              " min-width="100" show-overflow-tooltip>
              <template slot-scope="scope">
                <el-tag v-if="scope.row.OptType === 0" type="primary">{{
                  $fd('ReReadingOrBackOptType', scope.row.OptType)
                }}</el-tag>
                <el-tag v-if="scope.row.OptType === 1" type="danger">{{
                  $fd('ReReadingOrBackOptType', scope.row.OptType)
                }}</el-tag>
                <el-tag v-if="scope.row.OptType === 2" type="warning">{{
                  $fd('ReReadingOrBackOptType', scope.row.OptType)
                }}</el-tag>
              </template>
            </el-table-column>
            <!-- 阅片人 -->
            <el-table-column prop="UserName" :label="$t('trials:reviewTrack:table:reader')" min-width="160"
              show-overflow-tooltip>
              <template v-if="scope.row.DoctorUser" slot-scope="scope">
                {{ scope.row.DoctorUser.UserName }}({{
                  scope.row.DoctorUser.FullName
                }})
              </template>
            </el-table-column>
          </el-table>
          <div style="font-size: 12px; color: #f66; margin-top: 10px" v-if="ReReadingOtherInfo.IsIRAppyTaskInfluenced">
            <!-- 注意！列表中存在IR已申请重阅的任务！ -->
            {{ $t('trials:reviewTrack:applyReread:title:msg1') }}
          </div>
        </div>
        <div slot="footer" class="dialog-footer">
          <!-- 取消 -->
          <el-button :disabled="btnLoading" size="small" type="primary" @click="
            ApplyforReasonVisible = false
          ApplyforReasonForm = { Type: null, RequestReReadingReason: null }
            ">
            {{ $t('common:button:cancel') }}
          </el-button>
          <!-- 保存 -->
          <el-button :loading="btnLoading" size="small" type="primary" @click="applyReReading">
            {{ $t('common:button:save') }}
          </el-button>
        </div>
      </el-dialog>
      <!-- 退回影响任务列表/已影响任务列表 -->
      <el-dialog v-if="ReReadingOrBackVisible" :title="opentype === 'read'
        ? $t('trials:reviewTrack:action:back')
        : $t('trials:reviewTrack:dialog:impactList')
        " :visible.sync="ReReadingOrBackVisible" width="1460px" append-to-body :close-on-click-modal="false"
        custom-class="base-dialog-wrapper">
        <el-form ref="backReasonForm" :rules="rules" :model="backforReasonForm" class="demo-ruleForm" size="small"
          label-width="180px">
          <p>{{ $t('trials:reviewTrack:applyReread:title1').replace('xxx', rowData.SubjectCode).replace('yyy', rowData.TaskBlindName) }}</p>
          <!-- 申请原因 -->
          <el-divider content-position="left">
            {{ $t('trials:reviewTrack:applyReread:title:backReason') }}
          </el-divider>
          <!-- 申请原因 -->
          <el-form-item :label="$t('trials:reviewTrack:applyReread:title:backReason')" prop="pmBackReason" :rules="[
            { required: true, message: $t('common:ruleMessage:specify') },
          ]">
            <el-input v-model="backforReasonForm.pmBackReason" style="width: 400px" type="textarea"
              :autosize="{ minRows: 2, maxRows: 4 }" :placeholder="$t('common:ruleMessage:specify')" maxlength="500"
              show-word-limit />
          </el-form-item>
        </el-form>
        <!-- 影响的任务列表 -->
        <el-divider content-position="left">{{
          $t('trials:reviewTrack:dialog:backImpactList')
        }}</el-divider>
        <div class="base-dialog-body">
          <el-table v-loading="loading" :data="InfluenceTaskList" stripe height="100" style="min-height: 400px">
            <!-- 任务编号 -->
            <el-table-column prop="TaskCode" :label="$t('trials:reviewTrack:table:taskCode')" min-width="100"
              show-overflow-tooltip />
            <!-- 中心编号 -->
            <el-table-column prop="TrialSiteCode" :label="$t('trials:reviewTrack:table:siteCode')" min-width="100"
              show-overflow-tooltip />
            <!-- 受试者编号 -->
            <el-table-column prop="SubjectCode" :label="$t('trials:reviewTrack:table:subjectCode')" min-width="120"
              show-overflow-tooltip>
              <template slot-scope="scope">
                <span v-if="
                  scope.row.BlindSubjectCode &&
                  scope.row.BlindSubjectCode !== scope.row.SubjectCode
                ">
                  {{ `${scope.row.SubjectCode}/${scope.row.BlindSubjectCode}` }}
                </span>
                <span v-else>{{ scope.row.SubjectCode }}</span>
              </template>
            </el-table-column>
            <!-- 任务名称 -->
            <el-table-column prop="VisitTaskNum" :label="$t('trials:reviewTrack:table:taskName')" min-width="120"
              show-overflow-tooltip v-if="!isDoc">
              <template slot-scope="scope">
                <span v-if="
                  scope.row.TaskBlindName &&
                  scope.row.TaskName !== scope.row.TaskBlindName
                ">
                  {{ `${scope.row.TaskName}/${scope.row.TaskBlindName}` }}
                </span>
                <span v-else>{{ scope.row.TaskName }}</span>
              </template>
            </el-table-column>
            <!-- 盲态任务标识 -->
            <!-- <el-table-column
              prop="TaskBlindName"
              :label="$t('trials:reviewTrack:table:blindName')"
              min-width="120"
              show-overflow-tooltip
            /> -->
            <!-- 阅片标准 -->
            <el-table-column prop="TrialReadingCriterionName" :label="$t('trials:reviewTrack:table:criterionName')"
              min-width="100" show-overflow-tooltip>
            </el-table-column>
            <!-- 任务状态 -->
            <el-table-column prop="TaskState" :label="$t('trials:reviewTrack:table:taskStatus')" min-width="100"
              show-overflow-tooltip>
              <template slot-scope="scope">
                <el-tag v-if="scope.row.TaskState === 0" type="primary">{{
                  $fd('TaskState', scope.row.TaskState)
                }}</el-tag>
                <el-tag v-if="scope.row.TaskState === 1" type="info">{{
                  $fd('TaskState', scope.row.TaskState)
                }}</el-tag>
                <el-tag v-if="scope.row.TaskState === 3" type="danger">{{
                  $fd('TaskState', scope.row.TaskState)
                }}</el-tag>
                <el-tag v-if="scope.row.TaskState === 4" type="warning">{{
                  $fd('TaskState', scope.row.TaskState)
                }}</el-tag>
                <el-tag v-if="scope.row.TaskState === 5" type="danger">{{
                  $fd('TaskState', scope.row.TaskState)
                }}</el-tag>
              </template>
            </el-table-column>
            <!-- 任务类型 -->
            <el-table-column prop="ReadingCategory" min-width="100" :label="$t('trials:reviewTrack:table:taskType')"
              show-overflow-tooltip>
              <template slot-scope="scope">
                <el-tag v-if="scope.row.ReadingCategory === 1" type="primary">{{
                  $fd('ReadingCategory', scope.row.ReadingCategory)
                }}</el-tag>
                <el-tag v-if="scope.row.ReadingCategory === 2" type="info">{{
                  $fd('ReadingCategory', scope.row.ReadingCategory)
                }}</el-tag>
                <el-tag v-if="scope.row.ReadingCategory === 4" type="danger">{{
                  $fd('ReadingCategory', scope.row.ReadingCategory)
                }}</el-tag>
                <el-tag v-if="scope.row.ReadingCategory === 5" type="warning">{{
                  $fd('ReadingCategory', scope.row.ReadingCategory)
                }}</el-tag>
              </template>
            </el-table-column>
            <!-- 阅片状态 -->
            <el-table-column prop="ReadingTaskState" :label="$t('trials:reviewTrack:table:readingStatus')"
              min-width="100" show-overflow-tooltip>
              <template slot-scope="scope">
                <el-tag v-if="scope.row.ReadingTaskState === 2" type="primary">{{
                  $fd('ReadingTaskState', scope.row.ReadingTaskState)
                }}</el-tag>
                <el-tag v-else type="danger">{{
                  $fd('ReadingTaskState', scope.row.ReadingTaskState)
                }}</el-tag>
              </template>
            </el-table-column>
            <!-- 生效后影响 -->
            <el-table-column prop="OptType" :label="$t('trials:reviewTrack:applyReread:title:postEffectiveImpacts')
              " min-width="100" show-overflow-tooltip>
              <template slot-scope="scope">
                <el-tag v-if="scope.row.OptType === 0" type="primary">{{
                  $fd('ReReadingOrBackOptType', scope.row.OptType)
                }}</el-tag>
                <el-tag v-if="scope.row.OptType === 1" type="danger">{{
                  $fd('ReReadingOrBackOptType', scope.row.OptType)
                }}</el-tag>
                <el-tag v-if="scope.row.OptType === 2" type="warning">{{
                  $fd('ReReadingOrBackOptType', scope.row.OptType)
                }}</el-tag>
              </template>
            </el-table-column>
            <!-- 阅片人 -->
            <el-table-column prop="UserName" :label="$t('trials:reviewTrack:table:reader')" min-width="160"
              show-overflow-tooltip>
              <template v-if="scope.row.DoctorUser" slot-scope="scope">
                {{ scope.row.DoctorUser.UserName }}({{
                  scope.row.DoctorUser.FullName
                }})
              </template>
            </el-table-column>
          </el-table>
          <div style="font-size: 12px; color: #f66; margin-top: 10px" v-if="ReReadingOtherInfo.IsIRAppyTaskInfluenced">
            <!-- 注意！列表中存在IR已申请重阅的任务！ -->
            {{ $t('trials:reviewTrack:applyReread:title:msg1') }}
          </div>
        </div>
        <div slot="footer" class="dialog-footer" v-if="opentype === 'read'">
          <!-- 取消 -->
          <el-button :disabled="btnLoading" size="small" type="primary"
            @click="ReReadingOrBackVisible = false, backforReasonForm = { pmBackReason: null }">
            {{ $t('common:button:cancel') }}
          </el-button>
          <!-- 确定 -->
          <el-button :loading="btnLoading" size="small" type="primary" @click="PMSetTaskBack">
            {{ $t('trials:reviewTrack:impactList:save') }}
          </el-button>
        </div>
      </el-dialog>
      <el-dialog v-if="clinicalDataVisible" :title="`${$t('trials:readingPeriod:dialogTitle:clinicalData')}(${rowData.SubjectCode
        }|${rowData.TaskName}|${rowData.TrialReadingCriterionName})`" :visible.sync="clinicalDataVisible"
        :close-on-click-modal="false" append-to-body width="70%">
        <ClinicalData :trial-reading-criterion-id="TrialReadingCriterionId" :data="currentData" :showUpdateStatusBtn="rowData.ReadingCategory === 2 || rowData.ReadingCategory === 5"/>
      </el-dialog>
      <el-dialog v-if="exportVisible" v-dialogDrag :title="$t('trials:reviewTrack:button:export')"
        :visible.sync="exportVisible" :close-on-click-modal="false" width="60%" append-to-body>
        <ReviewResults :data="searchData" />
      </el-dialog>

      <!-- 设置加急状态 -->
      <el-dialog v-if="urgentVisible" :visible.sync="urgentVisible" :close-on-click-modal="false"
        :title="$t('trials:qcCheck:dialogTitle:setUrgent')" width="600px" custom-class="base-dialog-wrapper">
        <el-form ref="urgentForm" :model="urgentForm" size="mini" v-loading="dialogLoading" label-width="100px">
          <div class="base-dialog-body">
            <!-- 是否加急 -->
            <el-form-item :label="$t('trials:qcCheck:table:isUrgent')" prop="IsUrgent" :rules="[
              {
                required: true,
                message: $t('common:ruleMessage:select'),
                trigger: 'blur',
              },
            ]">
              <el-radio-group v-model="urgentForm.IsUrgent" @change="handleIsUrgentChange">
                <el-radio v-for="item of $d.YesOrNo" :key="`IsUrgent${item.value}`" :label="item.value">
                  {{ item.label }}
                </el-radio>
              </el-radio-group>
            </el-form-item>
            <!-- 加急原因 -->
            <el-form-item v-if="urgentForm.IsUrgent" :label="$t('trials:reviewTrack:message:urgentReason')"
              prop="TaskUrgentType" :rules="[
                {
                  required: true,
                  message: $t('common:ruleMessage:select'),
                  trigger: 'blur',
                },
              ]">
              <el-radio-group v-model="urgentForm.TaskUrgentType" @change="handleTaskUrgentTypeChange">
                <template v-for="item of $d.TaskUrgentType">
                  <el-radio :key="`TaskUrgentType${item.value}`" :label="item.value" v-if="
                    !(!OtherInfo.IsPDProgressView && item.value === 2) &&
                    !(
                      !OtherInfo.IsEnrollementQualificationConfirm &&
                      item.value === 1
                    )
                  " :disabled="(rowData.VisitTaskNum === 0 && item.value === 2) ||
                    (rowData.VisitTaskNum !== 0 && item.value === 1)
                    ">
                    {{ item.label }}
                  </el-radio>
                </template>
              </el-radio-group>
            </el-form-item>
            <!-- 备注 -->
            <el-form-item :label="$t('trials:reviewTrack:message:urgentReasonNote')"
              v-if="urgentForm.TaskUrgentType === 4" prop="TaskUrgentRemake" :rules="[
                {
                  required: true,
                  message: $t('common:ruleMessage:specify'),
                  trigger: 'blur',
                },
              ]">
              <el-input type="textarea" v-model="urgentForm.TaskUrgentRemake" :autosize="{ minRows: 2, maxRows: 4 }">
              </el-input>
            </el-form-item>
          </div>
          <div class="base-dialog-footer" style="text-align: right; margin-top: 10px">
            <el-form-item>
              <!-- 取消 -->
              <el-button size="small" type="primary" @click="urgentVisible = false">
                {{ $t('common:button:cancel') }}
              </el-button>
              <!-- 保存 -->
              <el-button size="small" type="primary" @click="handleSaveUrgentStatus">
                {{ $t('common:button:save') }}
              </el-button>
            </el-form-item>
          </div>
        </el-form>
      </el-dialog>
      <el-dialog v-if="recordVisible" :title="$t('trials:readingTracking:title:failureRecord')"
        :visible.sync="recordVisible" width="1200px" :fullscreen="true" append-to-body :close-on-click-modal="false"
        custom-class="base-dialog-wrapper">
        <RecordList />
      </el-dialog>
      <el-dialog :title="$t('trials:pendingReadingTasks:button:TargetSection')" :visible.sync="TargetSection_visible"
        :fullscreen="true">
        <TargetSection v-if="TargetSection_visible" :TrialReadingCriterionId="TrialReadingCriterionId" :forbid="true"
          :trialCriterionList="trialCriterionList" />
      </el-dialog>
    </template>
  </BaseContainer>
</template>
<script>
import { getTrialSiteSelect, setTaskUrgent } from '@/api/trials'
import {
  getTrialCriterionList,
  PMSetTaskBack,
  getInfluencedTaskList,
  getReReadingOrBackInfluenceTaskList,
  getReadingTaskList,
  configTrialReadingTaskViewRule,
  getDoctorUserSelectList,
  applyReReading,
} from '@/api/trials/reading'
import { getReadingTaskList_Export } from '@/api/export'
import { getToken } from '@/utils/auth'
import { changeURLStatic } from '@/utils/history.js'
import BaseContainer from '@/components/BaseContainer'
import Pagination from '@/components/Pagination'
import RefereeRules from './components/RefereeRules.vue'
import ReviewResults from './components/ReviewResults'
import ClinicalData from '../../subject/reading-period/components/ClinicalData' 
import RecordList from './components/RecordList.vue'
import TargetSection from "@/views/trials/trials-panel/reading/reading-task/components/TargetSection"
const searchDataDefault = () => {
  return {
    PageIndex: 1,
    PageSize: 20,
    Asc: true,
    SortField: '',
    TrialId: null,
    TrialSiteId: null,
    SubjectId: null,
    SubjectCode: null,
    IsUrgent: null,
    TaskName: null,
    TaskState: null,
    DoctorUserId: null,
    ReadingCategory: null,
    TaskAllocationState: null,
    BeginAllocateDate: null,
    EndAllocateDate: null,
    ReadingTaskState: null,
    CompleteClinicalDataEnum: null,
    BeginSignTime: null,
    EndSignTime: null,
    IsEffect: true,
    TrialReadingCriterionId: null,
    // ArmEnum: null
  }
}
export default {
  name: 'TrialsNotice',
  components: {
    BaseContainer,
    Pagination,
    RefereeRules,
    ClinicalData,
    ReviewResults,
    RecordList,
    TargetSection
  },
  props: {
    AllocationReadingCategory: {
      type: String,
    },
    AllocationSubjectCode: {
      type: String,
    },
    isDoc: {
      type: Boolean,
      default: false,
    },
    TITLE: {
      type: String,
      default: '',
    },
    viewStatus: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      searchData: searchDataDefault(),
      exportVisible: false,
      maxLength: 0,
      list: [],
      siteOptions: [],
      total: 0,
      SubjectAssignListTotal: 0,
      loading: false,
      ReadingRulesVisible: false,
      ApplyforReasonVisible: false,
      ReReadingOrBackVisible: false,
      clinicalDataVisible: false,
      InfluenceTaskList: [],
      ApplyforReasonForm: {
        Type: null,
        RequestReReadingReason: null,
      },
      backforReasonForm: {
        pmBackReason: null
      },
      rules: {
        Type: [
          {
            required: true,
            message: this.$t('common:ruleMessage:specify'),
            trigger: 'blur',
          },
        ],
        RequestReReadingReason: [
          {
            required: true,
            message: this.$t('common:ruleMessage:specify'),
            trigger: 'blur',
          },
        ],
        pmBackReason: [
          {
            required: true,
            message: this.$t('common:ruleMessage:specify'),
            trigger: 'blur',
          },
        ],
      },
      RefereeAllocationVisible: false,
      trialId: this.$route.query.trialId,
      currentData: {},
      param: {},
      DoctorUserList: [],
      TaskAllocationRuleList: [],
      btnLoading: false,
      value: true,
      value1: true,
      ReadingType: null,
      ReadingRulesInfo: {
        TrialId: this.$route.query.trialId,
        ReadingTaskViewEnum: 0,
        IsReadingTaskViewInOrder: false,
        IsReadingShowSubjectInfo: null,
        IsReadingShowPreviousResults: null,
      },
      // rules: {
      //   DoctorUserId: [{ required: true, message: this.$t('common:ruleMessage:select'), trigger: 'blur' }]
      // },
      title: '',
      rowData: {},
      timeList: [],
      timeList2: [],
      SubjectAssignList: [],
      SubjectAssignSelectList: [],
      TaskAllocationRuleSelectList: [],
      readVisible: false,
      TaskOptType: null,
      OtherInfo: null,
      trialCriterionList: [],
      ReReadingOtherInfo: {
        IsIRAppyTaskInfluenced: false,
      },
      TrialReadingCriterionId: null,
      urgentVisible: false,
      urgentForm: {
        VisitTaskId: '',
        IsUrgent: null,
        TaskUrgentType: null,
        TaskUrgentRemake: null,
      },
      dialogLoading: false,
      openWindow: null,
      recordVisible: false,

      TargetSection_visible: false
    }
  },
  computed: {
    hasIVUSOROCT() {
      return this.trialCriterionList.some(item => item.CriterionType === 19 || item.CriterionType === 20)
    }
  },
  mounted() {
    this.searchData.ReadingCategory = this.AllocationReadingCategory
    this.searchData.SubjectCode = this.AllocationSubjectCode
    if (this.$route.query.SubjectCode) {
      this.searchData.SubjectCode = this.$route.query.SubjectCode
      this.searchData.TrialReadingCriterionId = this.$route.query
        .TrialReadingCriterionId
        ? this.$route.query.TrialReadingCriterionId
        : null
      this.searchData.DoctorUserId = this.$route.query.DoctorUserId
        ? this.$route.query.DoctorUserId
        : null
      this.searchData.TaskName = this.$route.query.TaskName
        ? this.$route.query.TaskName
        : null
      changeURLStatic('SubjectCode', '')
      changeURLStatic('TrialReadingCriterionId', '')
      changeURLStatic('TaskName', '')
      changeURLStatic('DoctorUserId', '')
    }
    this.searchData.ReadingCategory = this.AllocationReadingCategory
    this.getList()
    this.getSite()
    this.getDoctorUserSelectList()
    this.getTrialCriterionList()
  },
  beforeDestroy() {
    if (this.openWindow) {
      this.openWindow.close()
    }
  },
  methods: {
    handleTargetSection() {
      this.TrialReadingCriterionId = this.trialCriterionList.find(item => item.CriterionType === 19 || item.CriterionType === 20).TrialReadingCriterionId
      this.TargetSection_visible = true
    },
    // 打开意见反馈
    openFeedBack(row) {
      this.$FB({
        type: 'detail',
        visitTaskId: row.Id,
        callBack: () => {
          this.getList()
        },
      })
    },
    async handleExport() {
      this.loading = true
      try {
        await getReadingTaskList_Export(this.searchData)
        this.loading = false
      } catch (e) {
        this.loading = false
      }
    },
    handleReviewResults() {
      this.exportVisible = true
    },
    handleView(row) {
      this.TrialReadingCriterionId = row.TrialReadingCriterionId
      this.rowData = { ...row }
      this.currentData = {
        Id: row.SourceSubjectVisitId || row.SouceReadModuleId,
        SubjectId: row.SubjectId,
        IsVisit: row.SourceSubjectVisitId ? true : false,
        TrialId: row.TrialId,
        IsBaseLine: row.VisitTaskNum === 0 ? true : false,
        TrialReadingCriterionId: row.TrialReadingCriterionId,
      }
      this.clinicalDataVisible = true
    },
    getTrialCriterionList() {
      getTrialCriterionList(this.trialId)
        .then((res) => {
          this.trialCriterionList = res.Result
        })
        .catch(() => { })
    },
    getInfluencedTaskList(row) {
      this.loading = true
      this.opentype = 'look'
      this.rowData = { ...row }
      getInfluencedTaskList(row.Id).then((res) => {
        this.InfluenceTaskList = res.Result
        this.ReReadingOrBackVisible = true
        this.loading = false
      })
    },
    async PMSetTaskBack() {
      try {
        let validate = await this.$refs.backReasonForm.validate()
        console.log(validate, 'validate')
        if (!validate) return false
        // let data = Object.assign({}, this.backReasonForm)
        this.loading = true
        let res = await PMSetTaskBack(this.trialId, this.rowData.Id, this.backforReasonForm.pmBackReason)
        this.loading = false
        if (res.IsSuccess) {
          this.loading = false
          this.ReReadingOrBackVisible = false
          this.getList()
          // '退回成功'
          this.$message.success(
            this.$t('trials:reviewTrack:message:returnedSuccessfully')
          )
        }
      } catch (err) {
        this.loading = false
        console.log(err)
      }
      // this.loading = true
      // PMSetTaskBack(this.trialId, this.rowData.Id)
      //   .then((res) => {
      //     this.loading = false
      //     this.ReReadingOrBackVisible = false
      //     this.getList()
      //     // '退回成功'
      //     this.$message.success(
      //       this.$t('trials:reviewTrack:message:returnedSuccessfully')
      //     )
      //   })
      //   .catch(() => {
      //     this.loading = false
      //   })
    },
    openReReadingOrBackList(row) {
      this.loading = true
      this.rowData = { ...row }
      this.opentype = 'read'
      getReReadingOrBackInfluenceTaskList(row.Id, false)
        .then((res) => {
          this.InfluenceTaskList = res.Result
          this.ReReadingOtherInfo = res.OtherInfo
          this.backforReasonForm = {
            pmBackReason: null
          }
          this.ReReadingOrBackVisible = true
          this.loading = false
        })
        .catch(() => {
          this.loading = false
        })
    },
    // 查看阅片结果
    lookReadingResults(row) {
      if (this.openWindow) {
        this.openWindow.close()
      }
      var token = getToken()
      var path
      if (row.ReadingTool === 0 || row.ReadingTool === 2 || row.ReadingTool === 3) {
        path = `/readingDicoms?TrialReadingCriterionId=${row.TrialReadingCriterionId}&trialId=${this.trialId}&subjectCode=${row.SubjectCode}&subjectId=${row.SubjectId}&visitTaskId=${row.Id}&isReadingTaskViewInOrder=${row.IsReadingTaskViewInOrder}&criterionType=${row.CriterionType}&readingTool=${row.ReadingTool}&TokenKey=${token}`
      } else {
        path = `/noneDicomReading?TrialReadingCriterionId=${row.TrialReadingCriterionId}&trialId=${this.trialId}&subjectCode=${row.SubjectCode}&subjectId=${row.SubjectId}&visitTaskId=${row.Id}&isReadingTaskViewInOrder=${row.IsReadingTaskViewInOrder}&criterionType=${row.CriterionType}&readingTool=${row.ReadingTool}&TokenKey=${token}`
      }
      // const routeData = this.$router.resolve({
      //   path: `/readingPage?subjectId=${row.SubjectId}&trialId=${row.TrialId}&visitTaskId=${row.Id}&TokenKey=${token}`
      // })
      this.openWindow = window.open(path, '_blank')
    },
    openApplyReReading(row) {
      this.rowData = { ...row }
      this.loading = true
      getReReadingOrBackInfluenceTaskList(row.Id, true)
        .then((res) => {
          this.InfluenceTaskList = res.Result
          this.ReReadingOtherInfo = res.OtherInfo
          this.ApplyforReasonVisible = true
          this.ApplyforReasonForm = {
            Type: null,
            Remake: null,
          }
          this.loading = false
        })
        .catch(() => {
          this.loading = false
        })
    },
    // 申请重阅
    applyReReading() {
      this.$refs.reasonForm.validate((valid) => {
        if (!valid) return
        this.loading = true
        this.btnLoading = true
        var params = {
          TaskIdList: [this.rowData.Id],
          TrialId: this.$route.query.trialId,
          RequestReReadingType: 2,
          RequestReReadingReason:
            this.ApplyforReasonForm.Type === 2
              ? this.ApplyforReasonForm.RequestReReadingReason
              : this.$t('trials:reviewTrack:message:ImageRetransfer'), //图像重传
        }
        applyReReading(params)
          .then((res) => {
            this.loading = false
            this.btnLoading = false
            // '申请重阅成功'
            this.$message.success(
              this.$t('trials:reviewTrack:message:applyedSuccessfully')
            )
            this.getList()
            this.ApplyforReasonVisible = false
          })
          .catch(() => {
            this.loading = false
            this.btnLoading = false
          })
      })
    },
    // 重阅历史
    reReadingHistory(row) {
      this.$router.push({
        path: `/trials/trials-panel/reading/reReadingTracking?trialId=${this.$route.query.trialId}&trialCode=${this.$route.query.trialCode}&researchProgramNo=${this.$route.query.researchProgramNo}&TrialSiteId=${row.TrialSiteId}&SubjectCode=${row.SubjectCode}&TaskName=${row.TaskName}&DoctorUserId=${row.DoctorUserId}`,
      })
    },
    openRefereeAllocation() {
      this.RefereeAllocationVisible = true
    },
    openReadingRules() {
      this.ReadingRulesVisible = true
    },
    handleCancel() {
      this.ReadingRulesVisible = false
    },
    handleSave() {
      this.btnLoading = true
      this.loading = true
      var params = Object.assign({}, this.ReadingRulesInfo)
      params.TrialId = this.$route.query.trialId
      configTrialReadingTaskViewRule(params)
        .then((res) => {
          this.btnLoading = false
          this.loading = false
          this.ReadingRulesVisible = false
          this.getList()
          // '保存成功'
          this.$message.success(this.$t('common:message:savedSuccessfully'))
        })
        .catch(() => {
          this.btnLoading = false
          this.loading = false
        })
    },
    getDoctorUserSelectList() {
      getDoctorUserSelectList(this.$route.query.trialId).then((res) => {
        this.DoctorUserList = res.Result
        if (this.DoctorUserList.length > 0) {
          this.ReadingType = this.DoctorUserList[0].ReadingType
        } else {
        }
      })
    },
    getList() {
      this.searchData.TrialId = this.$route.query.trialId
      if (this.isDoc && this.viewStatus) {
        this.searchData.ReadingTaskState = 2
      }
      this.loading = true
      getReadingTaskList(this.searchData)
        .then((res) => {
          this.loading = false
          this.OtherInfo = res.OtherInfo
          this.ReadingRulesInfo = Object.assign({}, this.OtherInfo)
          this.list = res.Result.CurrentPageData
          this.total = res.Result.TotalCount
        })
        .catch(() => {
          this.loading = false
        })
    },
    handleViewRecord() {
      this.recordVisible = true
    },
    handleSearch() {
      this.searchData.PageIndex = 1
      this.getList()
    },
    handleReset() {
      this.searchData = searchDataDefault()
      this.timeList = []
      this.timeList2 = []
      this.getList()
    },
    getSite() {
      getTrialSiteSelect(this.trialId).then((res) => {
        this.siteOptions = res.Result
      })
    },
    changeTimeList() {
      if (this.timeList) {
        this.searchData.BeginAllocateDate = this.timeList[0]
        this.searchData.EndAllocateDate = this.timeList[1]
      } else {
        this.searchData.BeginAllocateDate = null
        this.searchData.EndAllocateDate = null
      }
    },
    changeTimeList2() {
      if (this.timeList2) {
        this.searchData.BeginSignTime = this.timeList2[0]
        this.searchData.EndSignTime = this.timeList2[1]
      } else {
        this.searchData.BeginSignTime = null
        this.searchData.EndSignTime = null
      }
    },
    changeUrgentStatus(row) {
      this.rowData = { ...row }
      this.urgentForm.VisitTaskId = row.Id
      this.urgentForm.IsUrgent = row.IsUrgent
      this.urgentForm.TaskUrgentType = row.TaskUrgentType
      this.urgentForm.TaskUrgentRemake = row.TaskUrgentRemake
      this.urgentVisible = true
    },
    handleTaskUrgentTypeChange(val) {
      if (val !== 4) {
        this.urgentForm.TaskUrgentRemake = null
      }
    },
    handleIsUrgentChange(val) {
      if (!val) {
        this.urgentForm.TaskUrgentType = null
        this.urgentForm.TaskUrgentRemake = null
      }
    },
    handleSaveUrgentStatus() {
      this.$refs.urgentForm.validate((valid) => {
        if (!valid) return
        this.dialogLoading = true
        setTaskUrgent(this.urgentForm)
          .then((res) => {
            this.dialogLoading = false
            this.urgentVisible = false
            this.getList()
          })
          .catch(() => {
            this.dialogLoading = false
          })
      })
    },
    // 排序
    handleSortChange(column) {
      if (column.order === 'ascending') {
        this.searchData.Asc = true
      } else {
        this.searchData.Asc = false
      }
      this.searchData.SortField = column.prop
      this.searchData.PageIndex = 1
      this.getList()
    },
  },
}
</script>
<style lang="scss" scoped>
.remark {
  position: absolute;
  left: 5px;
  bottom: 7px;
  font-size: 12px;
}

.status-primary-circle {
  display: inline-block;
  width: 20px;
  height: 20px;
  text-align: center;
  line-height: 18px;
  border-radius: 50%;
  border: 1px solid #f56c6c;
  color: #f56c6c;
  font-size: 10px;
}

.title {
  line-height: 40px;
  font-weight: bold;
  margin-bottom: 10px;
}

::v-deep .hidden-row {
  display: none;
}

::v-deep .el-dialog__body {
  padding: 15px 20px;
}

::v-deep .el-tag--danger.el-tag--dark {
  // background-color: #f56c6c!important;
  border-color: none !important;
  // color: #fff!important;
}

::v-deep #TaskAllocationRuleList thead .el-checkbox__inner {
  display: none;
}

::v-deep .el-descriptions-item__label.has-colon:after {
  display: none;
}

.fbBox {
  // float: left;
  position: absolute;
  top: 25%;
  left: 5px;
  font-size: 28px;
  color: #f56c6c;
  cursor: pointer;
}
</style>
