<template>
  <div>
    <span class="title">
      {{ $t('trials:inspection:title:pullImage') }}
      <span>{{ tip }}</span>
    </span>
    <div class="search">
      <el-form :inline="true" class="base-search-form">
        <!-- pacsDicomAEId -->
        <el-form-item class="my_multiple" :label="$t('trials:inspection:pullImage:search:pacsDicomAEId')">
          <el-select v-model="searchData.PacsDicomAEId" style="width: 140px" @change="pacsDicomAEIdChange">
            <el-option v-for="(item, index) of AElist" :key="index.Id" :label="item.CalledAE" :value="item.Id">
            </el-option>
          </el-select>
        </el-form-item>
        <!-- patientID -->
        <el-form-item class="my_multiple" :label="$t('trials:inspection:pullImage:search:patientID')">
          <el-input v-model="searchData.PatientID" clearable style="width: 100px" :maxlength="400"></el-input>
        </el-form-item>
        <!-- patientName -->
        <el-form-item class="my_multiple" :label="$t('trials:inspection:pullImage:search:patientName')">
          <el-input v-model="searchData.PatientName" clearable style="width: 100px" :maxlength="400"></el-input>
        </el-form-item>
        <!-- modalitiesInStudy -->
        <el-form-item :label="$t('trials:inspection:pullImage:search:modalitiesInStudy')">
          <el-select v-model="searchData.ModalitiesInStudyList" placeholder="" clearable multiple collapse-tags
            style="width: 140px">
            <el-option v-for="item in ModalityList" :key="item" :label="item" :value="item" />
          </el-select>
        </el-form-item>
        <!-- studyDate -->
        <el-form-item :label="$t('trials:inspection:pullImage:search:studyDate')">
          <el-date-picker v-model="StudyDate" type="daterange" range-separator="-"
            :start-placeholder="$t('trials:uploadClinicalData:table:beginDate')"
            :end-placeholder="$t('trials:uploadClinicalData:table:endDate')" value-format="yyyyMMdd"
            :picker-options="pickerOptions">
          </el-date-picker>
        </el-form-item>
        <el-form-item>
          <!-- 查询 -->
          <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 type="primary" :disabled="!multipleSelection || multipleSelection.length <= 0"
            @click="openGroup(null, 2)">
            {{ $t('trials:inspection:button:pull') }}
          </el-button>
          <!-- 转发 -->
          <el-button type="primary" v-if="IsSupportThirdService"
            :disabled="!multipleSelection || multipleSelection.length <= 0" @click="openTranspond(multipleSelection)">
            {{ $t('trials:inspection:button:transpond') }}
          </el-button>
        </el-form-item>
      </el-form>
    </div>
    <!--检查列表-->
    <el-table ref="viewStudyList" v-loading="loading" v-adaptive="{ bottomOffset: 60 }" :data="PageList" stripe
      height="100" @sort-change="handleSortByColumn" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" />
      <el-table-column type="index" width="50">
        <template slot-scope="scope">
          <span style="
              display: flex;
              align-items: center;
              justify-content: flex-end;
            ">
            <el-tooltip class="item" effect="dark" :content="$t('trials:inspection:pullImage:tip:has')" placement="top"
              style="margin-right: 3px">
              <i v-if="scope.row.IsStudyExist" class="el-icon-success icon-i"></i>
            </el-tooltip>
            <span>{{ scope.$index + 1 }}</span>
          </span>
        </template>
      </el-table-column>
      <!--patientID-->
      <el-table-column prop="PatientID" :label="$t('trials:inspection:pullImage:table:patientID')" show-overflow-tooltip
        min-width="120" sortable="custom" />
      <!--patientName-->
      <el-table-column prop="PatientName" :label="$t('trials:inspection:pullImage:table:patientName')"
        show-overflow-tooltip min-width="120" sortable="custom" />
      <!--patientSex-->
      <el-table-column prop="PatientSex" :label="$t('trials:inspection:pullImage:table:patientSex')"
        show-overflow-tooltip min-width="80" sortable="custom">
        <template slot-scope="scope">
          <span>{{ $fd('Sex', scope.row.PatientSex) }}</span>
        </template>
      </el-table-column>
      <!--patientBirthDate-->
      <el-table-column prop="PatientBirthDate" :label="$t('trials:inspection:pullImage:table:patientBirthDate')"
        show-overflow-tooltip min-width="120" sortable="custom" />
      <!--studyID-->
      <!-- <el-table-column
        prop="StudyID"
        :label="$t('trials:inspection:pullImage:table:studyID')"
        show-overflow-tooltip
        min-width="120"
      /> -->
      <!--AccessionNumber-->
      <el-table-column prop="AccessionNumber" :label="$t('trials:inspection:pullImage:table:AccessionNumber')"
        show-overflow-tooltip min-width="120" sortable="custom" />
      <!--modalitiesInStudy-->
      <el-table-column prop="ModalitiesInStudy" :label="$t('trials:inspection:pullImage:table:modalitiesInStudy')"
        show-overflow-tooltip min-width="120" sortable="custom" />
      <!--studyDate-->
      <el-table-column prop="StudyDate" :label="$t('trials:inspection:pullImage:table:studyDate')" show-overflow-tooltip
        min-width="120" sortable="custom" />
      <!--studyTime-->
      <el-table-column prop="StudyTime" :label="$t('trials:inspection:pullImage:table:studyTime')" show-overflow-tooltip
        min-width="120" sortable="custom" />
      <!--bodyPartExamined-->
      <!-- <el-table-column
        prop="BodyPartExamined"
        :label="$t('trials:inspection:pullImage:table:bodyPartExamined')"
        show-overflow-tooltip
        min-width="120"
        sortable="custom"
      /> -->
      <!--studyDescription-->
      <el-table-column prop="StudyDescription" :label="$t('trials:inspection:pullImage:table:studyDescription')"
        show-overflow-tooltip min-width="120" sortable="custom" />
      <!--studyInstanceUID-->
      <el-table-column prop="StudyInstanceUID" :label="$t('trials:inspection:pullImage:table:studyInstanceUID')"
        show-overflow-tooltip min-width="120" sortable="custom" />
      <!--课题组-->
      <el-table-column prop="ViewHospitalGroupList"
        :label="$t('trials:inspection:pullImage:table:ViewHospitalGroupList')" show-overflow-tooltip min-width="100">
        <template slot-scope="scope">
          <span>{{
            scope.row.ViewHospitalGroupList && scope.row.ViewHospitalGroupList.length > 0 ?
              scope.row.ViewHospitalGroupList.map(item => item.Name).join(', ') : ''}}</span>
        </template>
      </el-table-column>
      <!--操作-->
      <el-table-column :label="$t('common:action:action')" min-width="160" fixed="right">
        <template slot-scope="scope">
          <el-button circle icon="el-icon-refresh" class="refreshBtn" :title="$t('trials:inspection:button:pull')"
            @click.stop="openGroup(scope.row, 2)" />
          <el-button circle icon="el-icon-edit-outline" :title="$t('trials:inspection:button:collect')"
            v-if="scope.row.IsStudyExist" @click.stop="openGroup(scope.row, 1)" />
          <!-- 转发 -->
          <el-button circle icon="el-icon-position" :title="$t('trials:inspection:button:transpond')"
            v-if="IsSupportThirdService" @click="openTranspond([scope.row])" />
        </template>
      </el-table-column>
    </el-table>

    <!-- 分页组件 -->
    <pagination class="page" :total="total" :page.sync="PageIndex" :limit.sync="PageSize" @pagination="paging" />
    <base-model v-if="group_model.visible" :config="group_model">
      <template slot="dialog-body">
        <el-form ref="groupFrom" :model="form" :rules="rules" label-width="100px" size="small">
          <el-form-item :label="$t('trials:externalStaff:table:lastName')" prop="LastName" v-show="false">
            <el-input clearable />
          </el-form-item>
          <!-- 用户类型 -->
          <el-form-item :label="$t('trials:externalStaff:table:hospitalGroupIdList')" prop="HospitalGroupIdList">
            <el-select v-model="form.HospitalGroupIdList" style="width: 100%" multiple clearable>
              <el-option v-for="item of hospitalGroupList" :key="item.Id" :label="item.Name" :value="item.Id">
                <!-- <span>{{ item.UserType }}</span> -->
              </el-option>
            </el-select>
          </el-form-item>
        </el-form>
      </template>
      <template slot="dialog-footer">
        <!-- 取消 -->
        <el-button size="small" type="primary" :disabled="btnLoading" @click="handleCancelGroup">
          {{ $t("common:button:cancel") }}
        </el-button>
        <!-- 保存 -->
        <el-button size="small" type="primary" :loading="btnLoading" @click="pullImage">
          {{ $t("common:button:save") }}
        </el-button>
      </template>
    </base-model>
    <base-model v-if="transpond_model.visible" :config="transpond_model">
      <template slot="dialog-body">
        <el-form ref="transpondFrom" :model="transpondForm" :rules="transpondRules" label-width="100px" size="small">
          <el-form-item :label="$t('trials:externalStaff:table:lastName')" prop="LastName" v-show="false">
            <el-input clearable />
          </el-form-item>
          <!-- AE -->
          <el-form-item :label="$t('trials:externalStaff:table:DestinationAE')" prop="HospitalGroupIdList">
            <el-select v-model="transpondForm.DestinationAE" style="width: 100%" clearable placeholder="">
              <el-option v-for="item of transpondAElist" :key="item.Id" :label="item.CalledAE" :value="item.CalledAE">
                <!-- <span>{{ item.UserType }}</span> -->
              </el-option>
            </el-select>
          </el-form-item>
        </el-form>
      </template>
      <template slot="dialog-footer">
        <!-- 取消 -->
        <el-button size="small" type="primary" :disabled="btnLoading" @click="handleCancelGroup">
          {{ $t("common:button:cancel") }}
        </el-button>
        <!-- 保存 -->
        <el-button size="small" type="primary" :loading="btnLoading" @click="transpondImage">
          {{ $t("trials:inspection:pullImage:button:transpond") }}
        </el-button>
      </template>
    </base-model>
  </div>
</template>
<script>
import Pagination from '@/components/Pagination'
import {
  getCFindStudyList,
  cmoveStudyList,
  cMoveVerify,
} from '@/api/inspection.js'
import { getDicomAEList } from '@/api/dicomAE.js'
import BaseModel from '@/components/BaseModel'
import { modifySCPStudyHospitalGroup } from '@/api/admin.js'
const defaultSearchData = () => {
  return {
    PacsDicomAEId: null,
    PatientID: null,
    PatientName: null,
    ModalitiesInStudyList: null,
    StudyDate: null,

    PatientSex: null,
    PatientBirthDate: null,
    StudyID: null,
    StudyTime: null,
    BodyPartExamined: null,
    StudyDescription: null,
    StudyInstanceUID: null,
    AccessionNumber: null,
  }
}
export default {
  name: 'byPatient',
  components: { Pagination, BaseModel },
  props: {
    calledAeList: {
      required: true,
      default: () => {
        return []
      },
    },
    callingAeList: {
      required: true,
      default: () => {
        return []
      },
    },
  },
  data() {
    return {
      // 查询
      searchData: defaultSearchData(),
      ModalityList: [],
      timeFrame: null,
      MaxStudyCount: null,
      PatientBirthDate: [],
      StudyDate: [],
      // 可加入项目列表
      loading: false,
      list: [],
      PageList: [],
      total: 0,
      PageIndex: 1,
      PageSize: 50,
      AElist: [],
      multipleSelection: [],

      group_model: {
        visible: false,
        title: this.$t('trials:inspection:dialogTitle:collect'),
        width: '400px',
        appendToBody: true
      },
      form: {
        HospitalGroupIdList: [],
      },
      rules: {
        HospitalGroupIdList: [
          {
            required: true,
            type: "array",
            message: this.$t('common:ruleMessage:specify'),
            trigger: ['blur', 'change']
          }
        ]
      },
      btnLoading: false,
      hospitalGroupList: [],
      groupStatus: 1,

      IsSupportThirdService: false,
      transpond_model: {
        visible: false,
        title: this.$t('trials:inspection:dialogTitle:transpond'),
        width: '400px',
        appendToBody: true
      },
      transpondForm: {
        StudyInstanceUIDList: [],
        DestinationAE: null
      },
      transpondRules: {
        DestinationAE: [
          {
            required: true,
            type: "array",
            message: this.$t('common:ruleMessage:select'),
            trigger: ['blur', 'change']
          }
        ]
      },
      transpondAElist: []
    }
  },
  computed: {
    pickerOptions() {
      return {
        shortcuts: [
          {
            text: this.$t('trials:inspection:pullImage:picker:today'),
            onClick: (picker) => {
              const end = new Date()
              const start = new Date()
              // picker.$emit('pick', [start, end])
              this.StudyDate = [start, end]
            },
          },
          {
            text: this.$t('trials:inspection:pullImage:picker:week'),
            onClick: (picker) => {
              const end = new Date()
              const start = new Date()
              if (!this.timeFrame || this.timeFrame > 3) {
                start.setTime(start.getTime() - 3600 * 1000 * 24 * 2)
              } else {
                start.setTime(
                  start.getTime() - 3600 * 1000 * 24 * (this.timeFrame - 1)
                )
              }

              // picker.$emit('pick', [start, end])
              this.StudyDate = [start, end]
            },
          },
          {
            text: this.$t('trials:inspection:pullImage:picker:month'),
            onClick: (picker) => {
              const end = new Date()
              const start = new Date()
              let month = this.$moment().subtract(1, 'months')
              let day = this.$moment().diff(month, 'day')
              if (!this.timeFrame || this.timeFrame > day) {
                start.setTime(start.getTime() - 3600 * 1000 * 24 * (day - 1))
              } else {
                start.setTime(
                  start.getTime() - 3600 * 1000 * 24 * (this.timeFrame - 1)
                )
              }
              // picker.$emit('pick', [start, end])
              this.StudyDate = [start, end]
            },
          },
          {
            text: this.$t('trials:inspection:pullImage:picker:trimester'),
            onClick: (picker) => {
              const end = new Date()
              const start = new Date()
              let month = this.$moment().subtract(3, 'months')
              let day = this.$moment().diff(month, 'day')
              if (!this.timeFrame || this.timeFrame > day) {
                start.setTime(start.getTime() - 3600 * 1000 * 24 * (day - 1))
              } else {
                start.setTime(
                  start.getTime() - 3600 * 1000 * 24 * (this.timeFrame - 1)
                )
              }
              // picker.$emit('pick', [start, end])
              this.StudyDate = [start, end]
            },
          },
        ],
        disabledDate: (time) => {
          if (!this.timeFrame) return false
          let curDate = new Date().getTime()
          let three = this.timeFrame * 24 * 3600 * 1000
          let threeMonths = curDate - three
          return time.getTime() >= Date.now() || time.getTime() <= threeMonths
        },
      }
    },
    tip() {
      if (!this.searchData.PacsDicomAEId) return ''
      let message = `( ${this.$t('trials:inspection:pullImage:PacsTip')} )`
      message = message.replace(
        'xxx',
        this.AElist.find((item) => item.Id === this.searchData.PacsDicomAEId)
          .CalledAE
      )
      if (!this.timeFrame) {
        message = message.replace(
          'yyy',
          this.$t('trials:inspection:pullImage:unlimit')
        )
      } else {
        message = message.replace(
          'yyy',
          `${this.timeFrame}${this.$t('trials:inspection:unit:day')}`
        )
      }
      if (!this.MaxStudyCount) {
        message = message.replace(
          'zzz',
          this.$t('trials:inspection:pullImage:unlimit')
        )
      } else {
        message = message.replace(
          'zzz',
          `${this.MaxStudyCount}${this.$t('trials:inspection:unit:article')}`
        )
      }
      message = message.replace('kkk', this.ModalityList.join('，'))
      return message
    },
  },
  created() {
    this.getAEList(false, true)
  },
  methods: {
    openTranspond(arr) {
      this.getTranspondAEList();
      this.transpondForm.StudyInstanceUIDList = []
      this.transpondForm.DestinationAE = null
      this.transpondForm.StudyInstanceUIDList = arr.map(
        (item) => item.StudyInstanceUID
      )
      this.transpond_model.visible = true

    },
    pacsDicomAEIdChange(val, f = false) {
      let pacs = this.AElist.find((item) => item.Id === val)
      this.ModalityList = pacs.ModalityList
      this.timeFrame = pacs.PacsSearchMaxDays
      this.MaxStudyCount = pacs.MaxStudyCount
      if (!f) {
        this.handleReset()
      }
    },
    // 验证pacs
    async cMoveVerify(data) {
      try {
        let res = await cMoveVerify(data)
        if (res.IsSuccess) {
          return res.Result
        }
        return false
      } catch (err) {
        console.log(err)
        return false
      }
    },
    async getList() {
      if (!this.searchData.PacsDicomAEId)
        return this.$message.warning(
          this.$t('trials:inspection:pullImage:message:mustPacsDicomAEId')
        )
      let data = {}
      Object.keys(this.searchData).forEach((key) => {
        data[key] = this.searchData[key]
      })
      if (this.StudyDate && this.StudyDate[0] && this.StudyDate[1]) {
        data.StudyDate =
          this.$moment(this.StudyDate[0]).format('YYYYMMDD') +
          '-' +
          this.$moment(this.StudyDate[1]).format('YYYYMMDD')
      } else {
        data.StudyDate = null
      }
      try {
        this.loading = true
        let res = await getCFindStudyList(data)
        this.loading = false
        if (res.IsSuccess) {
          this.list = res.Result
          this.total = res.Result.length
          this.paging()
          let MaxStudyCount = this.MaxStudyCount || 50
          if (this.total >= MaxStudyCount) {
            let message = this.$t(
              'trials:inspection:pullImage:confirm:limit50'
            ).replace('xxx', MaxStudyCount)
            this.$confirm(message, '', {
              type: 'warning',
              showCancelButton: false,
            })
          }
        }
      } catch (err) {
        this.loading = false
        console.log(err)
      }
    },
    // 获取列表
    async getAEList(f = false, isFirst = false) {
      let data = {
        CalledAE: null,
        IP: null,
        Port: null,
        PacsTypeEnum: 2,
        IsTestOK: true,
        PageIndex: 1,
        PageSize: 1000,
        SortField: 'CreateTime',
        Asc: false,
      }
      try {
        this.loading = true
        let res = await getDicomAEList(data)
        this.loading = false
        if (res.IsSuccess) {
          this.IsSupportThirdService = res.OtherInfo.IsSupportThirdService
          this.AElist = res.Result.CurrentPageData
          if (this.AElist.length > 0) {
            if (!f) {
              this.searchData.PacsDicomAEId = this.AElist[0].Id
              this.ModalityList = this.AElist[0].ModalityList
              this.timeFrame = this.AElist[0].PacsSearchMaxDays
              this.MaxStudyCount = this.AElist[0].MaxStudyCount
              this.searchData.ModalitiesInStudyList = [this.ModalityList[0]]
              this.StudyDate = [new Date(), new Date()]
            } else {
              this.pacsDicomAEIdChange(this.searchData.PacsDicomAEId, true)
            }
            if (!isFirst) {
              this.getList()
            }
          }
        }
      } catch (err) {
        console.log(err)
      }
    },
    // 获取列表
    async getTranspondAEList() {
      let data = {
        CalledAE: null,
        IP: null,
        Port: null,
        PacsTypeEnum: 3,
        IsTestOK: null,
        PageIndex: 1,
        PageSize: 1000,
        SortField: 'CreateTime',
        Asc: false,
      }
      try {
        this.loading = true
        let res = await getDicomAEList(data)
        this.loading = false
        if (res.IsSuccess) {
          this.transpondAElist = res.Result.CurrentPageData
        }
      } catch (err) {
        console.log(err)
      }
    },
    // 分页
    paging() {
      this.PageList = []
      if (!this.list || this.list.length <= 0) return false
      this.PageList = this.list.slice(
        (this.PageIndex - 1) * this.PageSize,
        this.PageIndex * this.PageSize
      )
    },
    // 查询
    handleSearch() {
      //   this.searchData.PageIndex = 1
      this.getAEList(true)
    },
    // 重置
    handleReset() {
      this.reset()
      this.getAEList(true)
    },
    // 初始化
    reset() {
      //   this.searchData = defaultSearchData()
      Object.keys(this.searchData).forEach((key) => {
        if (key !== 'PacsDicomAEId') {
          this.searchData[key] = null
        }
      })
      // this.PatientBirthDate = []
      this.StudyDate = []
      // this.StudyTime = [new Date(new Date().getTime() - 10800000), new Date()]
    },
    // 表格排序
    handleSortByColumn(sort) {
      if (sort.order === 'ascending') {
        this.list.sort((a, b) => (a[sort.prop] > b[sort.prop] ? 1 : -1))
      }
      if (sort.order === 'descending') {
        this.list.sort((a, b) => (b[sort.prop] > a[sort.prop] ? 1 : -1))
      }
      this.paging()
    },
    async handleSaveGroup() {
      try {
        let validate = await this.$refs.groupFrom.validate()
        if (!validate) return false
        let ScPstudyIdList = []
        let row = this.currentData
        if (!row) {
          if (this.multipleSelection.length <= 0) return false
          ScPstudyIdList = this.multipleSelection.map(item => item.SCPStudyId)
        } else {
          ScPstudyIdList = [this.currentData.SCPStudyId]
        }
        let data = {
          ScPstudyIdList,
          AddOrDelete: 1,
          HospitalGroupIdList: this.form.HospitalGroupIdList
        }
        this.btnLoading = true
        let res = await modifySCPStudyHospitalGroup(data)
        this.btnLoading = false
        if (res.IsSuccess) {
          this.$message.success(this.$t('common:message:savedSuccessfully'))
          this.handleCancelGroup()
          this.getList()
        }
      } catch (err) {
        console.log(err)
        this.btnLoading = false
      }
    },
    handleCancelGroup() {
      this.form.HospitalGroupIdList = []
      this.groupStatus = 1
      this.group_model.visible = false
      this.transpond_model.visible = false
    },
    openGroup(row, type = 1) {
      this.currentData = row
      this.groupStatus = type
      if (row) {
        this.hospitalGroupList = row.CurrentUserHospitalGroupList
      } else {
        this.hospitalGroupList = this.multipleSelection[0].CurrentUserHospitalGroupList
      }
      if (type === 1) {
        this.group_model.title = this.$t('trials:inspection:dialogTitle:collect')
      } else {
        this.group_model.title = this.$t('trials:inspection:dialogTitle:pull')
        if (this.hospitalGroupList.length === 1) {
          this.form.HospitalGroupIdList = [this.hospitalGroupList[0].Id]
          return this.pullImage()
        }
      }
      this.group_model.visible = true
    },
    // 转发
    async transpondImage() {
      try {
        let validate = await this.$refs.transpondFrom.validate()
        if (!validate) return false
        let data = {
          PacsDicomAEId: this.searchData.PacsDicomAEId,
          DestinationAE: this.transpondForm.DestinationAE,
          StudyInstanceUIDList: this.transpondForm.StudyInstanceUIDList
          //   studyIDList: [row.StudyID],
        }
        this.loading = true
        this.btnLoading = true
        let res = await cmoveStudyList(data)
        this.loading = false
        this.btnLoading = false
        if (res.IsSuccess) {
          this.$message.success(
            this.$t('trials:inspection:pullImage:message:transpondSuccess')
          )
          this.handleCancelGroup()
        }
      } catch (err) {
        this.loading = false
        this.btnLoading = false
        console.log(err)
      }
    },
    // 拉取pacs数据
    async pullImage() {
      try {
        if (this.$refs.groupFrom) {
          let validate = await this.$refs.groupFrom.validate()
          if (!validate) return false
        }
        if (this.groupStatus === 1) return this.handleSaveGroup()
        let row = this.currentData
        let data = {
          PacsDicomAEId: this.searchData.PacsDicomAEId,
          HospitalGroupIdList: this.form.HospitalGroupIdList
          //   studyIDList: [row.StudyID],
        }
        if (row) {
          data.StudyInstanceUIDList = [row.StudyInstanceUID]
        } else {
          data.StudyInstanceUIDList = this.multipleSelection.map(
            (item) => item.StudyInstanceUID
          )
        }
        let r = await this.cMoveVerify(data)
        if (!r) return false
        let isPullList = []
        Object.keys(r).forEach((key) => {
          if (r[key]) {
            isPullList.push(key)
          }
        })
        let message = this.$t('trials:inspection:pullImage:confirm:pull')
        let patientMessage = ''
        if (isPullList.length > 0) {
          isPullList.forEach((key) => {
            patientMessage += `患者：${r[key].PatientName}，检查申请号：${r[key].AccessionNumber}<br/>`
          })
          if (patientMessage) {
            message =
              patientMessage +
              '<br/>' +
              this.$t('trials:inspection:pullImage:message:isHasPull') +
              '，' +
              message
          }
        }
        let confirm = await this.$confirm(message, '', {
          dangerouslyUseHTMLString: true,
        })
        if (!confirm) return false

        this.loading = true
        this.btnLoading = true
        let res = await cmoveStudyList(data)
        this.loading = false
        this.btnLoading = false
        if (res.IsSuccess) {
          this.$message.success(
            this.$t('trials:inspection:pullImage:message:pullSuccess')
          )
          this.handleCancelGroup()
        }
      } catch (err) {
        this.loading = false
        this.btnLoading = false
        console.log(err)
      }
    },
    handleSelectionChange(val) {
      this.multipleSelection = val
    },
  },
}
</script>
<style lang="scss" scoped>
.icon-i {
  color: #67c23a;
  cursor: pointer;
}

.refreshBtn {
  // transform: rotate(0);
  transition: 0.5s;

  &:hover {
    transform: rotate(180deg);
    transition: 0.5s;
  }
}
</style>