<template>
  <div class="ImageReviewTask-list app-container">
    <el-collapse v-model="activeNames">
      <!-- <el-collapse-item
        title="Image Quality Assessment"
        name="ImageQualityAssessment"
      > -->
      <el-form ref="qualifiedForm" :model="reportResult">
        <el-form-item
          prop="Qualified"
          label="Qualified for Review:"
          label-width="200px"
          :rules="[{ required: true, message: '', trigger: 'blur' }]"
        >
          <el-radio-group
            v-model="reportResult.Qualified"
            :disabled="isReportSaved"
          >
            <el-radio :label="true">Qualified</el-radio>
            <el-radio :label="false">Non-Qualified</el-radio>
          </el-radio-group>

          <div v-if="reportResult.Qualified===false">
            <el-radio-group
              v-model="reportResult.AffectRead"
              :disabled="isReportSaved"
            >
              <el-radio :label="true">Affect</el-radio>
              <el-radio :label="false">Non-Affect</el-radio>
            </el-radio-group>

            <el-input
              v-model="reportResult.AffectReadNote"
              type="textarea"
              :rows="4"
              placeholder="Please input Reason Or Note"
            />
          </div>
        </el-form-item>
      </el-form>
      <!-- </el-collapse-item> -->

      <el-collapse-item
        title="Non-nodular Target Lesions (Non-lymph Node Target Lesions)"
        name="Non-lymphNodeTarget"
        disabled
      >
        <el-table
          ref="Non-lymphNodeTarget"
          :data="NonlymphNodeTargetList"
          stripe
          size="small"
        >
          <el-table-column type="index" width="60" />
          <el-table-column
            prop="TULNKID"
            label="Lesion No"
            show-overflow-tooltip
            min-width="100"
          />
          <el-table-column
            prop="Anatomy"
            label="Anatomy"
            show-overflow-tooltip
            min-width="100"
          >
            <template slot-scope="scope">{{
              scope.row.TULOC + ' ' + scope.row.TULAT + ' ' + scope.row.TUDIR
            }}</template>
          </el-table-column>
          <el-table-column
            prop="TRORRES"
            label="Long Axis Measurement(mm)"
            show-overflow-tooltip
            min-width="150"
          />
          <el-table-column label="Anatomy Description" min-width="100">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.LocDescription"
                type="text"
                placeholder=""
                size="small"
                :disabled="isReportSaved"
              />
            </template>
          </el-table-column>

          <el-table-column
            prop="Note"
            label="Comments"
            show-overflow-tooltip
            min-width="100"
          >
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.Note"
                type="text"
                placeholder=""
                size="small"
                :disabled="isReportSaved"
              />
            </template>
          </el-table-column>
        </el-table>
      </el-collapse-item>

      <el-collapse-item
        title="Nodular Target Lesions (Lymph Node Target Lesions)"
        name="LymphNodeTarget"
        disabled
      >
        <el-table
          ref="Non-lymphNodeTarget"
          :data="LymphNodeTargetList"
          stripe
          size="small"
        >
          <el-table-column type="index" width="60" />
          <el-table-column
            prop="TULNKID"
            label="Lesion No"
            show-overflow-tooltip
            min-width="100"
          />
          <el-table-column
            prop="Anatomy"
            label="Anatomy"
            show-overflow-tooltip
            min-width="100"
          >
            <template slot-scope="scope">{{
              scope.row.TULOC + ' ' + scope.row.TULAT + ' ' + scope.row.TUDIR
            }}</template>
          </el-table-column>
          <el-table-column
            prop="TRORRES"
            label="Short  Axis Measurement(mm)"
            show-overflow-tooltip
            min-width="150"
          />
          <el-table-column
            prop="LocDescription"
            label="Anatomy Description"
            min-width="100"
          >
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.LocDescription"
                type="text"
                placeholder=""
                size="small"
                :disabled="isReportSaved"
              />
            </template>
          </el-table-column>

          <el-table-column
            prop="Note"
            label="Comments"
            show-overflow-tooltip
            min-width="100"
          >
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.Note"
                type="text"
                placeholder=""
                size="small"
                :disabled="isReportSaved"
              />
            </template>
          </el-table-column>
        </el-table>
      </el-collapse-item>

      <el-collapse-item
        title="Non-target Lesion"
        name="Non-targetLesion"
        disabled
      >
        <el-table
          ref="Non-lymphNodeTarget"
          :data="NontargetLesionList"
          stripe
          size="small"
        >
          <el-table-column type="index" width="60" />
          <el-table-column
            prop="TULNKID"
            label="Lesion No"
            show-overflow-tooltip
            min-width="100"
          />
          <el-table-column
            prop="Anatomy"
            label="Anatomy"
            show-overflow-tooltip
            min-width="100"
          >
            <template slot-scope="scope">{{
              scope.row.TULOC + ' ' + scope.row.TULAT + ' ' + scope.row.TUDIR
            }}</template>
          </el-table-column>

          <el-table-column
            prop="LocDescription"
            label="Anatomy Description"
            show-overflow-tooltip
            min-width="100"
          >
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.LocDescription"
                type="text"
                placeholder=""
                size="small"
                :disabled="isReportSaved"
              />
            </template>
          </el-table-column>

          <el-table-column
            prop="Note"
            label="Comments"
            show-overflow-tooltip
            min-width="100"
            :disabled="isReportSaved"
          >
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.Note"
                type="text"
                placeholder=""
                size="small"
              />
            </template>
          </el-table-column>
        </el-table>
      </el-collapse-item>

      <el-collapse-item
        title="Measurements Calculation"
        name="MeasurementsCalculation"
        disabled
      >
        <el-row :gutter="20">
          <el-col
            :span="6"
          ><div class="grid-content bg-purple">
            <span style="margin-left: 10px">SOD(mm):</span>
            <el-input v-model="SOD" disabled /></div></el-col>
          <el-col
            :span="6"
            :offset="6"
          ><div class="grid-content bg-purple">
            <span style="margin-left: 10px">Non-nodular Lesions SOD(mm):</span>
            <el-input v-model="NonnodularLesionsSOD" disabled /></div></el-col>
        </el-row>
      </el-collapse-item>

      <el-collapse-item
        title="Disease Situation"
        name="DiseaseSituation"
        disabled
      >
        <el-form ref="situationForm" :model="reportResult" label-width="100px">
          <el-form-item
            prop="DiseaseSituation"
            label="Disease present or absent:"
            label-width="200px"
            :rules="[{ required: true, message: '', trigger: 'blur' }]"
          >
            <el-radio-group
              v-model="reportResult.DiseaseSituation"
              :disabled="isReportSaved"
            >
              <el-radio :label="1">Present</el-radio>
              <el-radio :label="2">Absent</el-radio>
              <el-radio :label="3">NE</el-radio>
            </el-radio-group>
          </el-form-item>

          <el-form-item prop="Comments" label="Comments">
            <el-input
              v-model="reportResult.Comment"
              type="textarea"
              :rows="2"
              style="margin: 10px"
              placeholder="Comment"
              :disabled="isReportSaved"
            />
          </el-form-item>
        </el-form>

        <!-- <div style="margin: 10px 0px">
          <span style="margin-left: 10px">Disease present or absent:</span>
          <el-radio-group
            v-model="reportResult.DiseaseSituation"
            :disabled="isReportSaved"
          >
            <el-radio :label="1">Present</el-radio>
            <el-radio :label="2">Absent</el-radio>
            <el-radio :label="3">NE</el-radio>
          </el-radio-group>

          <el-input
            type="textarea"
            :rows="2"
            style="margin: 10px"
            placeholder="Comment"
            v-model="reportResult.Comment"
            :disabled="isReportSaved"
          >
          </el-input>
        </div> -->
      </el-collapse-item>
    </el-collapse>
    <div id="footer">
      <el-button
        type="primary"
        style="float: left; margin-left: 500px"
        :disabled="isReportSaved"
        @click="addBaseLine"
      >Save</el-button>
      <el-button
        type="primary"
        style="float: left; margin-left: 600px"
        :disabled="isReportSaved"
        @click="submiteReport"
      >Submit Report</el-button>
    </div>
  </div>
</template>
<script>
import {
  addBaseLineLesion,
  getBLLineLesion,
  submiteReport,
  saveImageLabelList
} from '@/api/reading'
export default {
  name: 'WorkloadTask',
  data() {
    return {
      isReportSaved: false,
      pageTPInfo: '',
      activeNames: [
        'ImageQualityAssessment',
        'Non-lymphNodeTarget',
        'LymphNodeTarget',
        'Non-targetLesion',
        'MeasurementsCalculation',
        'DiseaseSituation'
      ],

      NonlymphNodeTargetEditVisible: false,
      LymphNodeTargetEditVisible: false,
      NontargetLesionEditVisible: false,

      lymphNodeTargetFormModel: {},
      nonlymphNodeTargetFormModel: {},
      nontargetLesionFormModel: {},
      NonlymphNodeTargetList: [
        // {
        //   TULNKID: '',
        //   TULOC: 'lung',
        //   TULAT: ' left',
        //   TUDIR: 'lower lobe',
        //   TRORRES: '10',
        //   LocDescription: 'Tumor Identification',
        //   Note: 'cc'
        // }
      ],
      LymphNodeTargetList: [
        // {
        //   TULNKID: 'T05',
        //   TULOC: 'lymph node hilum of liver',
        //   TULAT: ' ',
        //   TUDIR: '',
        //   TRORRES: '27.7',
        //   LocDescription: 'Tumor Identification',
        //   Note: 'cc'
        // },
      ],
      NontargetLesionList: [],

      imageLabelList: [],
      imageDataHasUpdate: false,

      reportResult: {
        TpCode: '',
        Qualified: '',
        DiseaseProgression: '',
        NotEvaluable: '',
        Timepoint: '',
        TrialCode: '',
        SubjectCode: '',
        VisitNum: '',
        VisitName: '',
        DiseaseSituation: '',
        Comment: '',
        TPId: '',
        DicomStudyId: ''
      }
    }
  },
  computed: {
    // 计算属性的 getter
    SOD: function() {
      var sum = 0
      this.NonlymphNodeTargetList.forEach((t) => (sum += parseInt(t.TRORRES)))
      this.LymphNodeTargetList.forEach((t) => (sum += parseInt(t.TRORRES)))
      return sum
    },
    NonnodularLesionsSOD: function() {
      var sum = 0
      this.NonlymphNodeTargetList.forEach((t) => (sum += parseInt(t.TRORRES)))
      return sum
    }
  },

  created() {
    this.pageTPInfo = this.$route.query

    this.reportResult.TpCode = this.pageTPInfo.WorkloadCode
    this.reportResult.TrialCode = this.pageTPInfo.TrialCode
    this.reportResult.SubjectCode = this.pageTPInfo.SubjectCode
    this.reportResult.VisitNum = this.pageTPInfo.VisitNum
    this.reportResult.VisitName = this.pageTPInfo.VisitName
    this.reportResult.TPId = this.pageTPInfo.WorkloadId
    this.reportResult.DicomStudyId = this.pageTPInfo.StudyId

    this.isReportSaved = this.pageTPInfo.Status === 80

    this.getBLLineLesion()
  },

  mounted() {
    var that = this
    window.addEventListener('storage', function(e) {
      // 判断是影像界面 设置了数据  设置的key而且一定是'measureData' 防止其他界面操作localStorage 从而进入
      if (e.url.indexOf('baseLine') !== -1 && e.key === 'measureData') {
        var measureData = JSON.parse(e.newValue)
        var tpData = measureData[that.pageTPInfo.WorkloadCode]

        if (measureData) {
          that.imageDataHasUpdate = true
          that.imageLabelList = []
          tpData.forEach((t) => that.imageLabelList.push(t))

          var lesionType1 = tpData.filter((t) => t.lesionType === 1)
          var lesionType2 = tpData.filter((t) => t.lesionType === 2)
          var lesionType3 = tpData.filter((t) => t.lesionType === 3)

          // that.NonlymphNodeTargetList = []
          if (lesionType1.length > 0) {
            lesionType1.forEach((element) => {
              var location = element.lesionLocation.split('-')
              element.TRORRES = element.lesionValue.substring(
                0,
                element.lesionValue.length - 2
              )
              element.TULOC = location[0] || ''
              element.TULAT = location[1] || ''
              element.TUDIR = location[2] || ''

              var old = that.NonlymphNodeTargetList.filter(
                (t) =>
                  t.lesionValue === element.lesionValue &&
                  t.lesionLocation === element.lesionLocation
              )[0]
              if (old) {
                element.LocDescription = old.LocDescription
                element.Note = old.Note
              }
            })

            that.NonlymphNodeTargetList = lesionType1
          }

          // that.LymphNodeTargetList = []
          if (lesionType2.length > 0) {
            lesionType2.forEach((element) => {
              var location = element.lesionLocation.split('-')
              element.TRORRES = element.lesionValue.substring(
                0,
                element.lesionValue.length - 2
              )
              element.TULOC = location[0] || ''
              element.TULAT = location[1] || ''
              element.TUDIR = location[2] || ''

              var old = that.LymphNodeTargetList.filter(
                (t) =>
                  t.lesionValue === element.lesionValue &&
                  t.lesionLocation === element.lesionLocation
              )[0]
              if (old) {
                element.LocDescription = old.LocDescription
                element.Note = old.Note
              }
            })
            that.LymphNodeTargetList = lesionType2
          }

          // that.NontargetLesionList = []
          if (lesionType3.length > 0) {
            lesionType3.forEach((element) => {
              var location = element.lesionLocation.split('-')
              element.TULOC = location[0] || ''
              element.TULAT = location[1] || ''
              element.TUDIR = location[2] || ''

              var old = that.NontargetLesionList.filter(
                (t) => t.lesionLocation === element.lesionLocation
              )[0]
              if (old) {
                element.LocDescription = old.LocDescription
                element.Note = old.Note
              }
            })
            that.NontargetLesionList = lesionType3
          }

          // 删除localStorage本次数据
          delete measureData[that.pageTPInfo.WorkloadCode]
          localStorage.setItem('measureData', JSON.stringify(measureData))
        }
      }
    })
  },

  methods: {
    getBLLineLesion() {
      var that = this
      getBLLineLesion(
        this.pageTPInfo.TrialCode,
        this.pageTPInfo.SubjectCode,
        this.pageTPInfo.WorkloadCode
      ).then((res) => {
        if (res.Result.LesionInformation.length > 0) {
          that.NonlymphNodeTargetList = res.Result.LesionInformation.filter(
            (t) => t.LesionType === 1
          )
          that.LymphNodeTargetList = res.Result.LesionInformation.filter(
            (t) => t.LesionType === 2
          )
          that.NontargetLesionList = res.Result.LesionInformation.filter(
            (t) => t.LesionType === 3
          )
        }
        if (res.Result.ReportResult) {
          that.reportResult = res.Result.ReportResult
        }

        that.reportResult.TpCode = this.pageTPInfo.WorkloadCode
      })
    },

    addBaseLine() {
      var that = this
      this.$refs.qualifiedForm.validate((valid) => {
        if (valid) {
          this.$refs.situationForm.validate((valid) => {
            if (valid) {
              // 验证规则 靶病灶 总数量不大于5，每个器官不多于2
              var errorMsgArray = []

              if (that.NonlymphNodeTargetList.length + that.LymphNodeTargetList.length > 5) {
                errorMsgArray.push('The number of target lesions should not exceed 5 .')
              }

              var TULOCArray1 = that.NonlymphNodeTargetList.map((obj, index) => {
                if (obj.TULOC) return obj.TULOC
              })

              var TULOCArray2 = that.LymphNodeTargetList.map((obj, index) => {
                if (obj.TULOC) return obj.TULOC
              })

              var TULOCArray = TULOCArray1.concat(TULOCArray2)

              // 统计每个器官的数量，并返回最高的次数
              var top = that.getCount(TULOCArray, 1)

              if (top[0].count > 2) {
                errorMsgArray.push('The number of lesions in the same organ should not exceed 2 ')

                var tips = errorMsgArray.join('\n')
                this.$alert(tips, 'target lesion', {
                  confirmButtonText: '确定'
                })
                // return
              }

              var postArray = []
              // 非淋巴结靶病灶
              this.NonlymphNodeTargetList.forEach((element) => {
                postArray.push({
                  LesionType: 1, // 病灶类型
                  STUDYID: this.pageTPInfo.TrialCode, // 项目Id
                  USUBJID: this.pageTPInfo.SubjectCode, // 受试者Id
                  TUSPID: this.pageTPInfo.Sponsor,
                  //  TUSEQ="" //病灶序号 不传递
                  // TUGRPID:"",//病灶分组
                  // TUREFID:"" //医学影像 ID
                  // TULNKID:"" //关联测量结果，及TUGRPID一起，标识分裂及合并
                  TUTESTCD: 'TUMIDENT',
                  TUTEST: 'Tumor Identification',
                  TUORRES: 'TARGET', // 标识结果 1：target 2：None target 3： New
                  TUSTRESC: 'TARGET',
                  TUNAM: 'zhizhun', // /完成肿瘤标识的供应商名称或标识
                  LocDescription: element.LocDescription, // 部位描述
                  TULOC: element.TULOC, // 解剖学位置
                  TULAT: element.TULAT, // 左侧 右侧。。。
                  TUDIR: element.TUDIR, // 方向
                  TUPORTOT: '', // 更详细的分布，安排，分配的修饰语， 比如，全部的，单一的，部分的，多数的。
                  TUMETHOD: '', // 标识肿瘤的方法
                  TUEVAL: '', // 评估者的角色。 例如：研究者，独立评估者。
                  TUEVALID: '', // 这个特定的评估者变量是与 TUEVAL一起使用来提供更详 细的信息
                  TUACPTFL: '', // 双人阅片  这个标帜用来认定能够被接受的一条评估记录。
                  VISITNUM: this.pageTPInfo.VisitNum,
                  VISIT: this.pageTPInfo.VisitName,
                  VISITDY: 0,
                  EPOCH: '', // 时期
                  TUDTC: '', // 检查日期
                  TUDY: 0, // 检查日
                  TRTESTCD: '', // 检查简称
                  TRTEST: '', // 检查项名称
                  TRORRES: element.TRORRES, // 原始结果
                  TRORRESU: '', // 原始单位
                  TRSTRESC: '', // 标准化结果
                  TRSTRESN: 0, // 标准化结果（N）
                  TRSTRESU: '', // // 标准化单位
                  TRSTAT: '', // 未做状态
                  TRREASND: '', // 未做原因
                  Note: element.Note,
                  TRGRPID: '', // 用于关联域内同一受试者的一组相关记录
                  TRDTC: '', // 检查日期
                  TRDY: 0 // 检查日
                })
              })

              // 淋巴结靶病灶
              this.LymphNodeTargetList.forEach((element) => {
                postArray.push({
                  LesionType: 2, // 病灶类型
                  STUDYID: this.pageTPInfo.TrialCode, // 项目Id
                  USUBJID: this.pageTPInfo.SubjectCode, // 受试者Id
                  TUSPID: this.pageTPInfo.Sponsor,
                  //  TUSEQ="" //病灶序号 不传递
                  // TUGRPID:"",//病灶分组
                  // TUREFID:"" //医学影像 ID
                  // TULNKID:"" //关联测量结果，及TUGRPID一起，标识分裂及合并
                  TUTESTCD: 'TUMIDENT',
                  TUTEST: 'Tumor Identification',
                  TUORRES: 'TARGET', // 标识结果 1：target 2：None target 3： New
                  TUSTRESC: 'TARGET',
                  TUNAM: 'zhizhun', // /完成肿瘤标识的供应商名称或标识
                  LocDescription: element.LocDescription, // 部位描述
                  TULOC: element.TULOC, // 解剖学位置
                  TULAT: element.TULAT, // 左侧 右侧。。。
                  TUDIR: element.TUDIR, // 方向
                  TUPORTOT: '', // 更详细的分布，安排，分配的修饰语， 比如，全部的，单一的，部分的，多数的。
                  TUMETHOD: '', // 标识肿瘤的方法
                  TUEVAL: '', // 评估者的角色。 例如：研究者，独立评估者。
                  TUEVALID: '', // 这个特定的评估者变量是与 TUEVAL一起使用来提供更详 细的信息
                  TUACPTFL: '', // 双人阅片  这个标帜用来认定能够被接受的一条评估记录。
                  VISITNUM: this.pageTPInfo.VisitNum,
                  VISIT: this.pageTPInfo.VisitName,
                  VISITDY: 0,
                  EPOCH: '', // 时期
                  TUDTC: '', // 检查日期
                  TUDY: 0, // 检查日
                  TRTESTCD: '', // 检查简称
                  TRTEST: '', // 检查项名称
                  TRORRES: element.TRORRES, // 原始结果
                  TRORRESU: '', // 原始单位
                  TRSTRESC: '', // 标准化结果
                  TRSTRESN: 0, // 标准化结果（N）
                  TRSTRESU: '', // // 标准化单位
                  TRSTAT: '', // 未做状态
                  TRREASND: '', // 未做原因
                  Note: element.Note,
                  TRGRPID: '', // 用于关联域内同一受试者的一组相关记录
                  TRDTC: '', // 检查日期
                  TRDY: 0 // 检查日
                })
              })

              // 非靶病灶
              this.NontargetLesionList.forEach((element) => {
                postArray.push({
                  LesionType: 3, // 病灶类型
                  STUDYID: this.pageTPInfo.TrialCode, // 项目Id
                  USUBJID: this.pageTPInfo.SubjectCode, // 受试者Id
                  TUSPID: this.pageTPInfo.Sponsor,
                  //  TUSEQ="" //病灶序号 不传递
                  // TUGRPID:"",//病灶分组
                  // TUREFID:"" //医学影像 ID
                  // TULNKID:"" //关联测量结果，及TUGRPID一起，标识分裂及合并
                  TUTESTCD: 'TUMIDENT',
                  TUTEST: 'Tumor Identification',
                  TUORRES: 'None TARGET', // 标识结果 1：target 2：None target 3： New
                  TUSTRESC: 'None TARGET',
                  TUNAM: 'zhizhun', // /完成肿瘤标识的供应商名称或标识
                  LocDescription: element.LocDescription, // 部位描述
                  TULOC: element.TULOC, // 解剖学位置
                  TULAT: element.TULAT, // 左侧 右侧。。。
                  TUDIR: element.TUDIR, // 方向
                  TUPORTOT: '', // 更详细的分布，安排，分配的修饰语， 比如，全部的，单一的，部分的，多数的。
                  TUMETHOD: '', // 标识肿瘤的方法
                  TUEVAL: '', // 评估者的角色。 例如：研究者，独立评估者。
                  TUEVALID: '', // 这个特定的评估者变量是与 TUEVAL一起使用来提供更详 细的信息
                  TUACPTFL: '', // 双人阅片  这个标帜用来认定能够被接受的一条评估记录。
                  VISITNUM: this.pageTPInfo.VisitNum,
                  VISIT: this.pageTPInfo.VisitName,
                  VISITDY: 0,
                  EPOCH: '', // 时期
                  TUDTC: '', // 检查日期
                  TUDY: 0, // 检查日
                  TRTESTCD: '', // 检查简称
                  TRTEST: '', // 检查项名称
                  TRORRES: element.TRORRES, // 原始结果
                  TRORRESU: '', // 原始单位
                  TRSTRESC: '', // 标准化结果
                  TRSTRESN: 0, // 标准化结果（N）
                  TRSTRESU: '', // // 标准化单位
                  TRSTAT: '', // 未做状态
                  TRREASND: '', // 未做原因
                  Note: element.Note,
                  TRGRPID: '', // 用于关联域内同一受试者的一组相关记录
                  TRDTC: '', // 检查日期
                  TRDY: 0 // 检查日
                })
              })

              this.$confirm('Sure fill in all the information?', {
                type: 'warning',
                distinguishCancelAndClose: true,
                confirmButtonText: 'Ok',
                cancelButtonText: 'Cancel'
              }).then(() => {
                addBaseLineLesion({
                  lesionInformation: postArray,
                  reportResult: this.reportResult,
                  sumOfDiameter: this.SOD,
                  sumDiameterOfNonLymphNode: this.NonnodularLesionsSOD
                }).then((res) => {
                  // this.isReportSaved = true;
                  this.getBLLineLesion()

                  this.$message.success('saved successfully')
                })
              })

              if (that.imageDataHasUpdate) {
                that.saveImageLabel()
              }
            }
          })
        }
      })
    },

    saveImageLabel() {
      var param = {}
      param.TpCode = this.pageTPInfo.WorkloadCode
      param.ImageLabelList = []
      this.imageLabelList.forEach((element) => {
        param.ImageLabelList.push({
          StudyId: this.pageTPInfo.StudyId,
          LabelValue: JSON.stringify(element),
          SeriesId: element.seriesId,
          InstanceId: element.instanceId

        })
      })

      saveImageLabelList(param).then((res) => {
        this.imageDataHasUpdate = false
        this.$message.success('saved imgeLable successfully')
      })
    },

    submiteReport() {
      submiteReport(this.pageTPInfo.WorkloadId).then((res) => {
        this.$message.success('Report saved successfully')
        this.isReportSaved = true
      })
    },

    getCount(arr, rank, ranktype) {
      var obj = {}; var k; var arr1 = []
      for (var i = 0, len = arr.length; i < len; i++) {
        k = arr[i]
        if (obj[k]) { obj[k]++ } else { obj[k] = 1 }
      }
      // 保存结果{el-'元素'，count-出现次数}
      for (var o in obj) {
        arr1.push({ el: o, count: obj[o] })
      }
      // 排序（降序）
      arr1.sort(function(n1, n2) {
        return n2.count - n1.count
      })
      // 如果ranktype为1，则为升序，反转数组
      if (ranktype === 1) {
        arr1 = arr1.reverse()
      }
      var rank1 = rank || arr1.length
      return arr1.slice(0, rank1)

      //  getCount([1,2,3,1,2,5,2,4,1,2,6,2,1,3,2])//默认情况，返回所有元素出现的次数
      // getCount([1,2,3,1,2,5,2,4,1,2,6,2,1,3,2],3)//传参（rank=3），只返回出现次数排序前三的
      // getCount([1,2,3,1,2,5,2,4,1,2,6,2,1,3,2],null,1)//传参（ranktype=1,rank=null），升序返回所有元素出现次数
      // getCount([1,2,3,1,2,5,2,4,1,2,6,2,1,3,2],3,1)//传参（rank=3，ranktype=1），只返回出现次数排序（升序）前三的
    }

  }
}
</script>
<style lang="scss">
.ImageReviewTask-list {
  height: 100%;

  .el-collapse-item.is-disabled .el-collapse-item__header {
    color: black;
    font-weight: bold;
  }

  .el-collapse-item__header {
    background-color: #f0f0f0;
    height: 50px;
    line-height: 50px;
    padding: 0 5px;
  }
  .el-collapse-item__wrap {
    padding: 0 5px;
  }
  .el-collapse {
    margin-bottom: 100px;
  }
  #footer {
    position: fixed;
    bottom: 30px;
    width: 100%;
    // height: 30px; /*脚部的高度*/
    // background: #6cf;
    // clear: both;
  }
}
</style>

