<!--
  * 病例表
  *
  * @Author:    HMM
  * @Date:      2024-01-11 15:18:32
  * @Copyright  gdxz
-->
<template>
  <div class="con">
    <a-drawer :title="'查看'" width="75%" :visible="visibleFlag" @cancel="onClose" @close="onClose" :maskClosable="true" :destroyOnClose="true">
      <a-tabs v-model:activeKey="activeKey">
        <a-tab-pane key="1" tab="基本信息">
          <a-descriptions title="" bordered>
            <a-descriptions-item label="患者姓名 " class="required">{{ caseVO.name ? caseVO.name : '--' }}</a-descriptions-item>
            <a-descriptions-item label="患者ID " class="required">{{ caseVO.uid ? caseVO.uid : '--' }}</a-descriptions-item>
            <a-descriptions-item label="性别 " class="required">{{ $smartEnumPlugin.getDescByValue('GENDER_ENUM', caseVO.sex) }}</a-descriptions-item>
            <a-descriptions-item label="年龄 " class="required">{{ caseVO.age ? caseVO.age : '--' }}</a-descriptions-item>
            <a-descriptions-item label="入院时间 " :span="2" class="required">{{
              caseVO.admissionTime ? formateDate(caseVO.admissionTime) : '--'
            }}</a-descriptions-item>

            <a-descriptions-item label="治疗类型（多选） " :span="3" class="required">
              <a-checkbox-group v-model:value="caseVO.caseType">
                <a-checkbox v-for="item in caseTypeOption" :key="item.name" :value="item.value" disabled>{{ item.name }}</a-checkbox>
              </a-checkbox-group>
            </a-descriptions-item>
            <a-descriptions-item label="主要诊断" :span="3" class="required">
              <div class="row">类型（多选）：</div>
              <div class="row">
                <a-checkbox-group v-model:value="caseVO.mainDiagnose.select">
                  <a-checkbox v-for="item in diagnoseOption" :key="item.name" :value="item.value" disabled>{{ item.name }}</a-checkbox>
                </a-checkbox-group>
              </div>
              <div class="row" v-if="caseVO.mainDiagnose.otherValue">其他：</div>
              <div class="row" v-if="caseVO.mainDiagnose.otherValue">
                {{ caseVO.mainDiagnose.otherValue }}
              </div>
              <div class="row">出院诊断照片：</div>
              <div class="row flex"   v-show="caseVO.mainDiagnose.mainDiagnoseImg.split(',').length > 0">
                <imgCell
                 :type="'mainDiagnose'"
                  v-for="img in caseVO.mainDiagnose.mainDiagnoseImg.split(',')"
                  :src="img.indexOf('http') > -1 ? img : fileHost + img"
                  @openEditor="openEditor"
                ></imgCell>
              </div>
            </a-descriptions-item>
            <a-descriptions-item label="患病原因" :span="3" class="required">
              <div class="row">类型（多选）：</div>
              <div class="row">
                <a-checkbox-group v-model:value="caseVO.diseaseCause.select">
                  <a-checkbox v-for="item in patientSickOption" :key="item.name" :value="item.value" disabled>{{ item.name }}</a-checkbox>
                </a-checkbox-group>
              </div>
              <div class="row" v-if="caseVO.diseaseCause.otherValue">其他：</div>
              <div class="row" v-if="caseVO.diseaseCause.otherValue">{{ caseVO.diseaseCause.otherValue }}</div>
            </a-descriptions-item>
            <a-descriptions-item label="诱因" :span="3"  v-if="caseVO.seductionReason">
              <div class="row" v-if="caseVO.seductionReason.inside">肝内类型（多选）：</div>
              <div class="row" v-if="caseVO.seductionReason.inside">
                <a-checkbox-group v-model:value="caseVO.seductionReason.inside.select">
                  <a-checkbox v-for="item in ganneiOption" :key="item.name" :value="item.value" disabled>{{ item.name }}</a-checkbox>
                </a-checkbox-group>
              </div>
              <div class="row" v-if="caseVO.seductionReason.inside && caseVO.seductionReason.inside.otherValue">肝内其他：</div>
              <div class="row" v-if="caseVO.seductionReason.inside && caseVO.seductionReason.inside.otherValue">
                {{ caseVO.seductionReason.inside.otherValue }}
              </div>
              <div class="row" v-if="caseVO.seductionReason.outside">肝外类型（多选）：</div>
              <div class="row" v-if="caseVO.seductionReason.inside">
                <a-checkbox-group v-model:value="caseVO.seductionReason.outside.select">
                  <a-checkbox v-for="item in ganwaiOption" :key="item.name" :value="item.value" disabled>{{ item.name }}</a-checkbox>
                </a-checkbox-group>
              </div>
              <div class="row" v-if="caseVO.seductionReason.outside && caseVO.seductionReason.outside.otherValue">肝外其他：</div>
              <div class="row" v-if="caseVO.seductionReason.outside && caseVO.seductionReason.outside.otherValue">
                {{ caseVO.seductionReason.outside.otherValue }}
              </div>
            </a-descriptions-item>
          </a-descriptions>
        </a-tab-pane>
        <a-tab-pane key="2" tab="临床资料" force-render>
          <!-- <span style="font-size: 15px; color: rgb(131, 130, 130)">
            <exclamation-circle-outlined style="color: chocolate; margin-bottom: 20px" /> 文字/图片(至少上传一项)</span
          > -->
          <a-descriptions title="" bordered>
            <a-descriptions-item label="临床摘要" :span="3" style="white-space: pre-wrap" class="required">
              <div class="row" v-html="caseVO.abstractStr ? caseVO.abstractStr : '--'"></div>
            </a-descriptions-item>
          </a-descriptions>
        </a-tab-pane>
        <a-tab-pane key="3" tab="人工肝治疗">
          <a-descriptions
            :column="2"
            :title="'第' + (index + 1) + '次治疗'"
            bordered
            v-for="(dpm, index) in caseVO.dpmas"
            style="margin-bottom: 20px"
          >
          
            <a-descriptions-item label="治疗时间 " :span="2" class="required">
              {{ formateDate(dpm.treatTime) }}
            </a-descriptions-item>
            <a-descriptions-item label="治疗内容 " :span="2" class="required" v-if="dpm">
              <div class="row">1、模式（单选）：</div>
              <div class="desc">
               
                <a-radio-group v-model:value="dpm.content.mode.select">
                  <a-radio :value="cell.value" disabled v-for="cell in moshiOption">{{ cell.name }}</a-radio>
                </a-radio-group>
              </div>
              <div class="desc" v-if="dpm.content.mode.otherValue">其他：</div>
              <div class="desc" v-if="dpm.content.mode.otherValue">{{ dpm.content.mode.otherValue }}</div>
              <div class="row">
                2、血浆吸附处理量：<span class="dot">{{ dpm.content.plasma.handle }}</span
                >ml，血浆置换量：<span class="dot">{{ dpm.content.plasma.replace }}</span
                >ml
              </div>
              <div class="row">3、抗凝剂量(选填)</div>
              <div class="desc">
                <a-checkbox-group v-model:value="dpm.content.dose.select">
                  <a-row>
                    <a-checkbox value="1"
                     disabled
                      >肝素（首剂<span class="dot">
                        {{ formatValue(dpm.content.dose.heparin.firstDose) }}
                        </span
                      >（<a-radio-group style="margin-left: 8px;" v-model:value="dpm.content.dose.heparin.firstDoseUnit">
                          <a-radio value="1" disabled>IU</a-radio><a-radio value="2" disabled>mg</a-radio></a-radio-group>） ，追加<span class="dot">{{ formatValue(dpm.content.dose.heparin.append) }}</span
                      >（<a-radio-group style="margin-left: 8px;" v-model:value="dpm.content.dose.heparin.appendUnit">
                          <a-radio value="1" disabled>IU</a-radio>
                          <a-radio value="2" disabled>mg</a-radio>
                        </a-radio-group>））</a-checkbox
                    >
                  </a-row>
                  <a-row>
                    <a-checkbox value="2"  disabled
                      >低分子肝素<span class="dot">{{ formatValue(dpm.content.dose.lowHeparin.value) }}</span
                      >（IU）</a-checkbox
                    >
                  </a-row>
                  <a-row>
                    <a-checkbox value="3"  disabled
                      >枸橼酸（血液流速<span class="dot">{{ formatValue(dpm.content.dose.citricAcid.bloodFlowRate) }}</span
                      >ml/min，枸橼酸钠流速<span class="dot">{{ formatValue(dpm.content.dose.citricAcid.citricAcidFlowRate) }}</span
                      >ml/h，钙剂（<span>
                        <a-radio-group style="margin-left: 8px;" v-model:value="dpm.content.dose.citricAcid.calciumAgent.select">
                          <a-radio :value="1" disabled>10%葡萄糖酸钙</a-radio>
                          <a-radio :value="2" disabled>5%氯化钙</a-radio>
                        </a-radio-group> </span
                      >）<span class="dot">{{ formatValue(dpm.content.dose.citricAcid.calciumAgent.value) }}</span
                      >ml/h）</a-checkbox
                    >
                  </a-row>
                  <a-row>
                    <a-checkbox value="4"  disabled
                      >甲磺酸萘莫司他（维持量：<span class="dot">{{ formatValue(dpm.content.dose.nafamostat.value) }}</span
                      >mg/h）</a-checkbox
                    >
                   
                  </a-row>
                  <a-row>
                     <a-checkbox value="-1"  disabled
                      >其他（名称：<span class="dot other">{{ formatValue(dpm.content.dose.other.name) }}</span
                      >&nbsp;&nbsp;剂量:<span class="dot other">{{ formatValue(dpm.content.dose.other.value) }}</span
                      >）</a-checkbox
                    >
                  </a-row>
                </a-checkbox-group>
              </div>
            </a-descriptions-item>
            <a-descriptions-item label="治疗图片 " :span="2" class="required">
               <div class="row flex">
                <imgCell
                 :type="'dpmas'"
                 :dpmasId="dpm.dpmasId"
                 :imgIndex="imgindex"
                  v-for="(img,imgindex) in dpm.dpmasImg.split(',')"
                  :src="img.indexOf('http') > -1 ? img : fileHost + img"
                  @openEditor="openEditor"
                ></imgCell>
               </div>
            </a-descriptions-item>
          </a-descriptions>
        </a-tab-pane>
        <a-tab-pane key="4" tab="实验室检测">
          <a-descriptions title="" bordered :column="caseVO.dpmas.length>1?3:2">
            <a-descriptions-item label="首次治疗前检测时间 " :span="3" class="required">
              {{  formateDate(caseVO.headTime) }}
            </a-descriptions-item>
            <a-descriptions-item label="首次治疗后检测时间 " :span="3" class="required">
              {{  formateDate(caseVO.afterTime) }}
            </a-descriptions-item>
            <a-descriptions-item label="最后一次治疗后检测时间 " :span="3" class="required" v-if="caseVO.dpmas.length>1">
              {{  formateDate(caseVO.lastTime)}}
            </a-descriptions-item>
            <a-descriptions-item label="首次治疗前总胆红素" class="required">{{ caseVO.headTb ? caseVO.headTb : '--' }} umol/L</a-descriptions-item>
            <a-descriptions-item label="首次治疗后总胆红素" class="required">{{ caseVO.afterTb ? caseVO.afterTb : '--' }} umol/L</a-descriptions-item>
            <a-descriptions-item v-if="caseVO.dpmas.length>1" label="最后一次治疗后总胆红素" class="required"
              >{{ caseVO.lastTb ? caseVO.lastTb : '--' }} umol/L</a-descriptions-item
            >

            <a-descriptions-item label="首次治疗前直接胆红素">{{ caseVO.headDb ? caseVO.headDb : '--' }} umol/L</a-descriptions-item>
            <a-descriptions-item label="首次治疗后直接胆红素">{{ caseVO.afterDb ? caseVO.afterDb : '--' }} umol/L</a-descriptions-item>
            <a-descriptions-item v-if="caseVO.dpmas.length>1" label="最后一次治疗后直接胆红素">{{ caseVO.lastDb ? caseVO.lastDb : '--' }} umol/L</a-descriptions-item>

            <!-- <a-descriptions-item label="首次治疗前间接胆红素">{{ caseVO.headIb ? caseVO.headIb : '--' }} umol/L</a-descriptions-item>
            <a-descriptions-item label="首次治疗后间接胆红素">{{ caseVO.afterIb ? caseVO.afterIb : '--' }} umol/L</a-descriptions-item>
            <a-descriptions-item v-if="caseVO.dpmas.length>1" label="最后一次治疗后间接胆红素">{{ caseVO.lastIb ? caseVO.lastIb : '--' }} umol/L</a-descriptions-item> -->

            <a-descriptions-item label="首次治疗前丙氨酸氨基转移酶" class="required"
              >{{ caseVO.headAlt ? caseVO.headAlt : '--' }} U/L</a-descriptions-item
            >
            <a-descriptions-item label="首次治疗后丙氨酸氨基转移酶" class="required"
              >{{ caseVO.afterAlt ? caseVO.afterAlt : '--' }} U/L</a-descriptions-item
            >
            <a-descriptions-item v-if="caseVO.dpmas.length>1" label="最后一次治疗后丙氨酸氨基转移酶" class="required"
              >{{ caseVO.lastAlt ? caseVO.lastAlt : '--' }} U/L</a-descriptions-item
            >

            <a-descriptions-item label="首次治疗前天门冬氨酸氨基转移酶" class="required"
              >{{ caseVO.headAst ? caseVO.headAst : '--' }} U/L</a-descriptions-item
            >
            <a-descriptions-item label="首次治疗后天门冬氨酸氨基转移酶" class="required"
              >{{ caseVO.afterAst ? caseVO.afterAst : '--' }} U/L</a-descriptions-item
            >
            <a-descriptions-item v-if="caseVO.dpmas.length>1" label="最后一次治疗后天门冬氨酸氨基转移酶" class="required"
              >{{ caseVO.lastAst ? caseVO.lastAst : '--' }} U/L</a-descriptions-item
            >

            <a-descriptions-item label="首次治疗前白蛋白" class="required">{{ caseVO.headAlb ? caseVO.headAlb : '--' }} g/L</a-descriptions-item>
            <a-descriptions-item label="首次治疗后白蛋白" class="required">{{ caseVO.afterAlb ? caseVO.afterAlb : '--' }} g/L</a-descriptions-item>
            <a-descriptions-item v-if="caseVO.dpmas.length>1" label="最后一次治疗后白蛋白" class="required">{{ caseVO.lastAlb ? caseVO.lastAlb : '--' }} g/L</a-descriptions-item>
              <a-descriptions-item label="首次治疗前国际标准化比值 " class="required"
              >{{ caseVO.headInr ? caseVO.headInr : '--' }}</a-descriptions-item
            >
            <a-descriptions-item label="首次治疗后国际标准化比值 " class="required"
              >{{ caseVO.afterInr ? caseVO.afterInr : '--' }}</a-descriptions-item
            >
            <a-descriptions-item v-if="caseVO.dpmas.length>1" label="最后一次治疗后国际标准化比值 " class="required"
              >{{ caseVO.lastInr ? caseVO.lastInr : '--' }} </a-descriptions-item
            >

            <a-descriptions-item label="首次治疗前凝血酶原活动度">{{ caseVO.headPta ? caseVO.headPta : '--' }} %</a-descriptions-item>
            <a-descriptions-item label="首次治疗后凝血酶原活动度">{{ caseVO.afterPta ? caseVO.afterPta : '--' }} %</a-descriptions-item>
            <a-descriptions-item v-if="caseVO.dpmas.length>1" label="最后一次治疗后凝血酶原活动度">{{ caseVO.lastPta ? caseVO.lastPta : '--' }} %</a-descriptions-item>


            <a-descriptions-item label="首次治疗前C反应蛋白">{{ caseVO.headCrp ? caseVO.headCrp : '--' }} mg/L</a-descriptions-item>
            <a-descriptions-item label="首次治疗后C反应蛋白">{{ caseVO.afterCrp ? caseVO.afterCrp : '--' }} mg/L</a-descriptions-item>
            <a-descriptions-item v-if="caseVO.dpmas.length>1" label="最后一次治疗后C反应蛋白">{{ caseVO.lastCrp ? caseVO.lastCrp : '--' }} mg/L</a-descriptions-item>

            <a-descriptions-item label="首次治疗前白介素6">{{ caseVO.headIl6 ? caseVO.headIl6 : '--' }} {{formatIl6Unit(caseVO.il6Unit)}}</a-descriptions-item>
            <a-descriptions-item label="首次治疗后白介素6">{{ caseVO.afterIl6 ? caseVO.afterIl6 : '--' }}{{formatIl6Unit(caseVO.il6Unit)}}</a-descriptions-item>
            <a-descriptions-item v-if="caseVO.dpmas.length>1" label="最后一次治疗后 白介素6">{{ caseVO.lastIl6 ? caseVO.lastIl6 : '--' }}{{formatIl6Unit(caseVO.il6Unit)}}</a-descriptions-item>

            <a-descriptions-item label="首次治疗前肿瘤坏死因子-α">{{ caseVO.headTnf ? caseVO.headTnf : '--' }} {{formatTnfUnit(caseVO.tnfUnit)}}</a-descriptions-item>
            <a-descriptions-item label="首次治疗后肿瘤坏死因子-α">{{ caseVO.afterTnf ? caseVO.afterTnf : '--' }} {{formatTnfUnit(caseVO.tnfUnit)}}</a-descriptions-item>
            <a-descriptions-item v-if="caseVO.dpmas.length>1" label="最后一次治疗后肿瘤坏死因子-α">{{ caseVO.lastTnf ? caseVO.lastTnf : '--' }}{{formatTnfUnit(caseVO.tnfUnit)}}</a-descriptions-item>
            <a-descriptions-item label="生化指标图片" :span="2" class="required">
               <div class="row flex">
                <imgCell
                 :type="'bio'"
                  :imgIndex="index"
                  v-for="(img,index) in caseVO.bioImg.split(',')"
                  :src="img.indexOf('http') > -1 ? img : fileHost + img"
                  @openEditor="openEditor"
                ></imgCell>
               </div>
            </a-descriptions-item>
            <a-descriptions-item label="凝血功能指标图片" :span="2" class="required">
               <div class="row flex">
                <imgCell
                 :type="'coa'"
                  :imgIndex="index"
                  v-for="(img,index) in caseVO.coaImg.split(',')"
                  :src="img.indexOf('http') > -1 ? img : fileHost + img"
                  @openEditor="openEditor"
                ></imgCell>
               </div>
            </a-descriptions-item>
             <a-descriptions-item label="炎症因子指标图片" :span="2"  v-if="caseVO.infImg">
               <div class="row flex">
                <imgCell
                 :type="'inf'"
                  :imgIndex="index"
                  v-for="(img,index) in caseVO.infImg.split(',')"
                  :src="img.indexOf('http') > -1 ? img : fileHost + img"
                  @openEditor="openEditor"
                ></imgCell>
               </div>
            </a-descriptions-item>
          </a-descriptions>
        </a-tab-pane>
        <a-tab-pane key="5" tab="疾病转归">
          <a-descriptions title="" bordered :column="4">
            <a-descriptions-item label="出院时间 " :span="3" class="required">
              {{  formateDate(caseVO.dischargeTime) }}
            </a-descriptions-item>
            <a-descriptions-item label="出院天数 " :span="3" class="required">
              {{ caseVO.day }}
            </a-descriptions-item>
            <a-descriptions-item label="出院情况 " :span="6" class="required">
                <div class="row" v-html="caseVO.dischargeSituation"></div>
            </a-descriptions-item>
            <a-descriptions-item label="出院状态（单选）" :span="6" class="required">
              <a-radio-group v-model:value="caseVO.dischargeStatus">
                <a-radio :value="item.value" disabled v-for="item in hospitalOption">{{ item.name }}</a-radio>
              </a-radio-group>
            </a-descriptions-item>
          </a-descriptions>
        </a-tab-pane>
      </a-tabs>
      <template #footer>
        <a-space v-if="caseVO.status == 0">
          <a-button @click="cancelExamine">审核拒绝</a-button>
          <a-button type="primary" @click="examine">审核通过</a-button>
        </a-space>
      </template>
    </a-drawer>

    <a-modal v-model:visible="cancelExamineVisible" title="输入原因" @ok="submitCancelExamine">
      <a-textarea v-model:value="current_reason" placeholder="输入不通过原因" :auto-size="{ minRows: 2, maxRows: 8 }" />
    </a-modal>
  </div>
  <a-modal v-model:visible="showEdit" title="编辑图片" width="100%" wrap-class-name="my-full-modal" @ok="handleOk">
    <div class="editorcon">
      <!-- <a-image
    :width="200"
    :src="newSrc"
  /> -->
      <div class="save" @click="saveEditor">
        <a-button type="primary" shape="round">
          <template #icon>
            <save-outlined />
          </template>
          保存
        </a-button>
      </div>
      <imgEditor ref="imgEditorRef" :dpmasId="current_dpmasId" :imgIndex="imgIndex" :caseId="current_caseId" :caseObj="caseVO"  v-if="showEdit" @freshDetail="freshDetail" :imgType="imgType"></imgEditor>
    </div>
  </a-modal>
</template>
<script setup>
import { nextTick, ref } from 'vue';
import { message, Modal } from 'ant-design-vue';
import _ from 'lodash';
import { SmartLoading } from '/@/components/framework/smart-loading';
import { caseplatformCaseApi } from '/@/api/business/case/caseplatform-case-api';
import { smartSentry } from '/@/lib/smart-sentry';
import imgCell from './imgCell.vue';
import imgEditor from './imgEditor.vue';
import dayjs from 'dayjs';
import {il6Unit, caseTypeOption, diagnoseOption, patientSickOption, ganneiOption, ganwaiOption, moshiOption, kangningOption, hospitalOption } from './data';
// ---------------- -------- 事件 ------------------------
const imgEditorRef = ref(null);
const showEdit = ref(false);
const emits = defineEmits(['reloadList']);
const cancelExamineVisible = ref(false);
const fileHost = import.meta.env.VITE_APP_FILE_HOST;
const fallbackImg =
  'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMIAAADDCAYAAADQvc6UAAABRWlDQ1BJQ0MgUHJvZmlsZQAAKJFjYGASSSwoyGFhYGDIzSspCnJ3UoiIjFJgf8LAwSDCIMogwMCcmFxc4BgQ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coEnBpNuTuObWMEiLAx1HY0ZQJEmHJ3HNvGCBBhY6jtaMoEiJB0Z29vL6ls58vxPcO8/zfrdo5qvKO+d3Fx8Wu8zf1dW4p/cPzLly/dtv9Ts/EbcvGAHhHyfBIhZ6NSiIBTo0LNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiEC/wGgKKC4YMA4TAAAAABJRU5ErkJggg==';

const activeKey = ref('1');
const imgIndex = ref(0);
const current_reason = ref();
const current_caseId = ref();
const imgType = ref('');
const current_dpmasId = ref(0);
const caseVO = ref({
  name: undefined,
  uid: undefined,
  sex: undefined,
  age: undefined,
  admissionTime: undefined,
  caseType: undefined,
  mainDiagnose: {
    select: [],
    otherValue: '',
    mainDiagnoseImg: '',
  },
  diseaseCause: {
    select: [],
    otherValue: '',
  },
  seductionReason: {
    //基本信息结束
    inside: {
      select: [],
      otherValue: '',
    },
    outside: {
      select: [],
      otherValue: '',
    },
  },
  abstractStr: undefined,
  dpmas: [
    {
      treatTime: '',
      content: {
        mode: {
          // 模式
          select: '',
          otherValue: '',
        },
        plasma: {
          // 血浆
          handle: '',
          replace: '',
        },
        dose: {
          // 抗凝剂量
          select: [],
          heparin: {
            // 肝素
            firstDose: '', //首剂
            append: '', //追加
          },
          lowHeparin: {
            // 低分子肝素
            value: '',
          },
          citricAcid: {
            // 枸橼酸
            bloodFlowRate: '', //血液流速
            citricAcidFlowRate: '', //枸橼酸钠流速
            calciumAgent: {
              // 钙剂
              select: '',
              value: '',
            },
          },
          nafamostat: {
            // 甲磺酸萘莫司他
            value: '',
          },
          other: {
            // 其他
            name: '',
            dose: '',
          },
        },
      },
      dpmasImg: '',
    },
  ],
  headTime: undefined,
  afterTime: undefined,
  lastTime: undefined,
  headTb: undefined,
  afterTb: undefined,
  lastTb: undefined,
  headAlb: undefined,
  afterAlb: undefined,
  lastAlb: undefined,
  headDb: undefined,
  afterDb: undefined,
  lastDb: undefined,
  headPta: undefined,
  afterPta: undefined,
  lastPta: undefined,
  headIb: undefined,
  afterIb: undefined,
  lastIb: undefined,
  headInr: undefined,
  afterInr: undefined,
  lastInr: undefined,
  headAlt: undefined,
  afterAlt: undefined,
  lastAlt: undefined,
  headIl6: undefined,
  afterIl6: undefined,
  lastIl6: undefined,
  headAst: undefined,
  afterAst: undefined,
  lastAst: undefined,
  headTnf: undefined,
  afterTnf: undefined,
  lastTnf: undefined,
  headCrp: undefined,
  afterCrp: undefined,
  lastCrp: undefined,
  checkImg: '',
  dischargeSituation: '',
  dischargeTime: '',
  dischargeStatus: '',
  day: null,
});
// ------------------------ 显示与隐藏 ------------------------
// 是否显示
const visibleFlag = ref(false);

function show(id) {
  getDetail(id);
  current_caseId.value = id;
  visibleFlag.value = true;
}

function onClose() {
  visibleFlag.value = false;
  activeKey.value = '1';
}
const formatJson = (obj) => {
  for (const key in obj) {
    if (key == 'mainDiagnose' || key == 'diseaseCause' || key == 'caseType') {
      obj[key] = JSON.parse(obj[key]);
    }

    if (key == 'seductionReason') {
      obj.seductionReason = JSON.parse(obj.seductionReason);
    }
    if (key == 'dpmas') {
      for (let index = 0; index < obj.dpmas.length; index++) {
        const element = obj.dpmas[index];
        element.content = JSON.parse(element.content);
        if(!element.content.dose){
          element.content.dose={
          // 抗凝剂量
          select: [],
          heparin: {
            // 肝素
            firstDose: '', //首剂
            append: '', //追加
          },
          lowHeparin: {
            // 低分子肝素
            value: '',
          },
          citricAcid: {
            // 枸橼酸
            bloodFlowRate: '', //血液流速
            citricAcidFlowRate: '', //枸橼酸钠流速
            calciumAgent: {
              // 钙剂
              select: '',
              value: '',
            },
          },
          nafamostat: {
            // 甲磺酸萘莫司他
            value: '',
          },
          other: {
            // 其他
            name: '',
            dose: '',
          },
        }
        }
      }
    }
  }
  return obj;
};

// 审核通过
async function examine() {
  Modal.confirm({
    title: '提示',
    content: '确定要审核通过吗?',
    okText: '确认',
    okType: 'danger',
    onOk() {
      SmartLoading.show();
      try {
        console.log(current_caseId.value);
        caseplatformCaseApi.examine(current_caseId.value, 1);
        message.success('操作成功');
      } catch (e) {
        console.log(e);
      } finally {
        SmartLoading.hide();
        visibleFlag.value = false;
        emits('reloadList');
      }
    },
    cancelText: '取消',
    onCancel() {},
  });
}
//格式化之
const formatValue = (val) => {
  if (!val) {
    return '--';
  } else {
    return val;
  }
};
const formatIl6Unit = (val) => {
   if(!val){
    return 'ng/l'
}else{
  let arr=il6Unit.filter(item=>{
    return item.value==val;
  })
  return arr[0].name
 }
}
const formatTnfUnit = (val) => {
   if(!val){
    return 'μg/L'
}else{
   if(val==1){
     return 'μg/L'
   }else if(val==2){
    return 'pg/ml'
   }
 }
}
// 审核拒绝
async function submitCancelExamine() {
  SmartLoading.show();
  try {
    await caseplatformCaseApi.cancelExamine({ caseId: current_caseId.value, reason: current_reason.value });
    message.success('操作成功');
  } catch (e) {
    console.log(e);
  } finally {
    cancelExamineVisible.value = false;
    current_reason.value = undefined;
    current_caseId.value = undefined;
    visibleFlag.value = false;
    SmartLoading.hide();
    emits('reloadList');
  }
}

function cancelExamine() {
  cancelExamineVisible.value = true;
}
// ------------------------ 表单 ------------------------
const freshDetail=()=>{
   showEdit.value=false;
   getDetail(current_caseId.value)
}
async function getDetail(id) {
  SmartLoading.show();
  try {
    let queryResult = await caseplatformCaseApi.getDetail(id);
    caseVO.value = formatJson(queryResult.data);
    console.log(caseVO.value);
  } catch (err) {
    smartSentry.captureError(err);
  } finally {
    SmartLoading.hide();
  }
}
const openEditor = (data) => {
  showEdit.value = true;
  imgType.value = data.type;
  imgIndex.value = data.imgIndex;
  current_dpmasId.value = data.dpmasId;
  nextTick(() => {
    imgEditorRef.value?.init(data.src);
  });
};
const saveEditor = () => {
  imgEditorRef.value?.save();
};



const handleOk = () => {
  showEdit.value = false;
};
const formateDate=(val)=>{
  return dayjs(val).format('YYYY-MM-DD')
};
defineExpose({
  show,
});
</script>
<style  lang="less" scoped>
:deep(.ant-image) {
  margin: 0 0 10px 10px;
}
:deep(th.required:after) {
  display: inline-block;
  margin-right: 4px;
  color: #ff4d4f;
  font-size: 14px;
  font-family: SimSun, sans-serif;
  line-height: 1;
  content: '*';
}
.imgbox {
  display: flex;
}
.desc {
  margin-left: 20px;
}
.desc .dot,
.row .dot {
  // text-decoration: underline;
  color: #1890ff;
  font-size: 16px;
  display: inline-block;
  min-width: 30px;
  line-height: 25px;
  border-bottom:1px solid #1890ff;
  text-align: center;
}
.row .other,.desc .other {
  font-size: 14px;
}
:deep(.ant-radio-disabled.ant-radio-inner::after) {
  background: #1890ff;
}
:deep(.ant-radio-disabled.ant-radio-inner) {
  border-color: #1890ff;
}
:deep(.ant-descriptions-item-content) {
  padding: 16px 13px !important;
}
:deep(.ant-checkbox-wrapper + .ant-checkbox-wrapper) {
  margin-left: 0 !important;
}
.row :deep(p) {
  padding: 0;
  margin: 0;
}
:deep(.ant-descriptions-item-label){
  max-width: 160px;
}
:deep(.ant-checkbox-checked .ant-checkbox-inner),:deep(.ant-radio-checked .ant-radio-inner){
  background-color: #1890ff;
  border-color: #1890ff;
}
:deep(.ant-checkbox-disabled.ant-checkbox-checked .ant-checkbox-inner::after),:deep(.ant-radio-disabled.ant-radio-checked .ant-radio-inner::after){
  border-color:#fff;
}
:deep(.ant-checkbox-disabled + span),:deep(.ant-radio-disabled + span){
  color:#333;
}
:deep(.ant-radio-disabled .ant-radio-inner::after) {
    background-color: #fff;
}
.flex{
  display: flex;
}
</style>