<template>
  <xc-table :local-data="reqData" :height="220">
    <el-table-column label="操作" fixed="left" width="150">
      <template #header>
        <el-button type="primary" icon="Search" title="查询数据" @click="queryData"/>
      </template>
      <template #default="{row}">
        <el-button type="success" icon="Check" title="通过" @click="adoptClick(row.patNo)"/>
        <el-button type="danger" icon="Close" title="拒绝" @click="refuseClick(row.patNo)"/>
      </template>
    </el-table-column>
    <el-table-column label="住院号" prop="patNo" width="70"/>
    <el-table-column label="修改时间" prop="editDate" width="80"/>
    <el-table-column label="状态" prop="reqStatusName" width="50">
      <template #default="{row}">
        <span v-html="row.reqStatusHtml"></span>
      </template>
    </el-table-column>
    <el-table-column label="申请备注" prop="reqRemarks" show-overflow-tooltip/>
    <el-table-column label="审核备注" prop="reviewNotes" show-overflow-tooltip/>
  </xc-table>
</template>

<script setup name='EmrToExamine'>

import XcTable from "@/components/xiao-chan/xc-table/XcTable.vue";
import {adoptEmrDisReq, getDisReqEmr, refuseEmrDisReq} from "@/api/zhu-yuan-yi-sheng/emr-patient";
import {ElMessageBox} from "element-plus";

let reqData = $ref([])

const queryData = () => {
  getDisReqEmr(2).then((res) => {
    reqData = res
  })
}


const adoptClick = (patNo) => {
  adoptEmrDisReq(patNo).then((res) => {
    queryData()
  })
}

const refuseClick = (patNo) => {
  ElMessageBox.prompt('驳回信息', '提示', {
    type: 'warning',
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    inputPattern: /\S/,
    inputErrorMessage: '驳回信息不能为空且不得超过 100 字 (∩•̀ω•́)⊃-*⋆',
  }).then(({value}) => {
    refuseEmrDisReq(patNo, value).then((res) => {
      queryData()
    })
    console.log(value)
  })
}

onMounted(() => {
  queryData()
})

</script>

<style scoped lang="scss">

</style>
