<template>
  <el-dialog
    title="医嘱列表"
    v-model="props.open"
    width="1300px"
    append-to-body
    destroy-on-close
    @close="close"
    @open="openDialog"
  >
    <div>
      <!-- <el-row :gutter="24" class="mb8">
        <el-col :span="12">
          <el-input
            v-model="queryParams.searchKey"
            placeholder="诊断名称/拼音码"
            clearable
            style="width: 100%; margin-bottom: 10px"
            @keyup.enter="queryDiagnosisUse"
          >
            <template #append>
              <el-button icon="Search" @click="queryDiagnosisUse" />
            </template>
          </el-input>
        </el-col>
      </el-row> -->
      <el-table
        ref="refundListRef"
        :data="props.adviceList"
        row-key="paymentId"
        row-class-name="parent-row"
        v-loading="tableLoading"
        border
        max-height="600"
      >
        <el-table-column type="index" align="center"/>
        <el-table-column label="医嘱" align="center" prop="adviceName" width="200" />
        <el-table-column label="状态" align="center" prop="" width="90">
          <template #default="scope">
            <el-tag v-if="scope.row.statusEnum == 2" type="success">已签发</el-tag>
            <el-tag v-else-if="!scope.row.requestId && scope.row.statusEnum == 1" type="warning">
              待保存
            </el-tag>
            <el-tag v-else-if="scope.row.statusEnum == 1" type="primary">待签发</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="单次剂量" align="center" prop="">
          <template #default="scope">
            {{ scope.row.dose ? scope.row.dose + ' ' + scope.row.doseUnitCode_dictText : '' }}
          </template>
        </el-table-column>
        <el-table-column label="总量" align="center" prop="">
          <template #default="scope">
            {{ scope.row.quantity ? scope.row.quantity + ' ' + scope.row.unitCode_dictText : '' }}
          </template>
        </el-table-column>
        <el-table-column label="总金额" align="right" prop="" header-align="center" width="100">
          <template #default="scope">
            <span style="text-align: right">
              {{ scope.row.totalPrice ? Number(scope.row.totalPrice).toFixed(2) + ' 元' : '-' }}
            </span>
          </template>
        </el-table-column>
        <el-table-column label="药房/科室" align="center" prop="" width="180">
          <template #default="scope">
            {{ scope.row.positionName }}
          </template>
        </el-table-column>
        <el-table-column label="频次/用法" align="center" prop="" width="180">
          <template #default="scope">
            <span style="text-align: right">
              {{
                scope.row.rateCode_dictText
                  ? scope.row.rateCode_dictText +
                    ' ' +
                    scope.row.dispensePerDuration +
                    '天' +
                    ' ' +
                    scope.row.methodCode_dictText
                  : ''
              }}
            </span>
          </template>
        </el-table-column>
        <el-table-column label="注射药品" align="center" prop="" width="80">
          <template #default="scope">
            {{ scope.row.injectFlag_enumText || '-' }}
          </template>
        </el-table-column>
        <el-table-column label="皮试" align="center" prop="" width="80">
          <template #default="scope">
            {{ scope.row.skinTestFlag_enumText || '-' }}
          </template>
        </el-table-column>
        <el-table-column label="诊断" align="center" prop="diagnosisName" width="150">
          <template #default="scope">
            {{ scope.row.diagnosisName || scope.row.conditionDefinitionName }}
          </template>
        </el-table-column>
      </el-table>
    </div>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="close">取 消</el-button>
      </div>
    </template>
  </el-dialog>
</template>
  
<script setup>
const props = defineProps({
  open: {
    type: Boolean,
    default: false,
  },
  adviceList: {
    type: [],
    default: [],
  },
});
const emit = defineEmits(['close']);

function close() {
  emit('close');
}
</script>

<style lang="scss" scoped>
.sub-table-wrapper {
  padding: 16px 55px;
  background: #f9fafe;

  .nested-sub-table {
    border: 1px solid #e8e8f3;
    border-radius: 2px;

    // :deep(.sub-cell) {
    //   background: #ffffff !important;
    //   padding: 12px 16px;
    // }
  }
}
:deep(.parent-row) {
  td {
    // background: #e8ece6 !important;  /* 浅蓝色背景 */
    // border-color: #e4e7ed !important;
    height: 48px;
  }
}

.footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-top: 1px solid #ebeef5;

  .total {
    margin-left: 20px;
    color: #f56c6c;
    font-weight: 500;
  }
}
</style>