

<template>
<Mask :is-show="show" :top="100" :height="600" :width="1200">
  <CloseBtn @click="close"></CloseBtn>
    <div class="container-wrapper">
      <div class="table">
        <el-table :data="detailList" max-height="500px" highlight-current-row>
          <el-table-column label="人员编号" prop="psnNo" show-overflow-tooltip></el-table-column>
          <el-table-column label="就诊ID" prop="mdtrtId" show-overflow-tooltip></el-table-column>
          <el-table-column label="结算ID" prop="setlId" show-overflow-tooltip></el-table-column>
          <el-table-column label="备注" prop="memo" width="200px"></el-table-column>
          <el-table-column label="发送方报文ID" prop="msgid" show-overflow-tooltip></el-table-column>
          <el-table-column label="对账结果" prop="stmtRslt" >
            <template #default="scope">
              {{getReconciliationResult(scope.row.stmtRslt)}}
            </template>
          </el-table-column>
          <el-table-column label="退费标识" prop="refdSetlFlag">
            <template #default="scope">
              <el-tag v-if="scope.row.refdSetlFlag === '1'" type="danger" >退费</el-tag>
              <el-tag v-else type="success">收费</el-tag>
            </template>
          </el-table-column>
          <el-table-column label="医疗费总额" prop="medfeeSumamt"></el-table-column>
          <el-table-column label="基金支付总额" prop="fundPaySumamt"></el-table-column>
          <el-table-column label="个人账号支出" prop="acctPay"></el-table-column>
          <el-table-column label="操作" prop="acctRcv">
            <template #default="scope">
              <el-button type="primary" @click="openReversalEdit(scope.row)" link v-if="scope.row.memo">冲正</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>

    </div>
  <ReversalEdit ref="reversalEdit"></ReversalEdit>
</Mask>
</template>
<script setup lang="ts">

import Mask from "@/components/Mask.vue";
import {nextTick, ref} from "vue";
import CloseBtn from "@/components/CloseBtn.vue";
import {reconciliationResult} from "@/assets/config/constants.ts"
import ReversalEdit from "@/components/social/reconciliation/ReversalEdit.vue";

// 定义类型
interface DetailItem {
  psnNo: string;
  mdtrtId: string;
  setlId: string;
  memo?: string;
  msgid: string;
  stmtRslt: keyof typeof reconciliationResult; // 确保 stmtRslt 是 reconciliationResult 的键
  refdSetlFlag: string;
  medfeeSumamt: number;
  fundPaySumamt: number;
  acctPay: number;
  acctRcv: string;
}


const show = ref(false);
const close = () => {
  show.value = false;
};
const detailList = ref<DetailItem[]>([]);
const open = (list : any[])=>{
  detailList.value = list;
  show.value = true;
}

const getReconciliationResult = (key: keyof typeof reconciliationResult | undefined): string => {
  return key !== undefined && reconciliationResult[key] !== undefined
      ? reconciliationResult[key]
      : "未知结果";
};
const reversalEdit = ref();
const openReversalEdit = (item: DetailItem) => {
  nextTick(()=>{
    let reversalData = {
      psnNo: item.psnNo,
      omsgid: item.msgid,
      oinfno: item.refdSetlFlag == "1"?"2103":"2102A"
    }
    reversalEdit.value.open(reversalData);
  })

};
defineExpose({open})
</script>
<style scoped lang="scss">
  .container-wrapper{
    .table{
      margin-top: 20px;
    }
  }
</style>