<template>
    <xc-table :local-data="props.data"
              :final-height="getWindowSize.h  - (yzHeaderSize) - 100 "
              @row-click="dianJiaJianChaXiangQing">
        <el-table-column label="项目名称" prop="orderName" show-overflow-tooltip></el-table-column>
        <el-table-column label="接受" prop="receiveFlagName" show-overflow-tooltip></el-table-column>
        <el-table-column label="时间" prop="startTime">
            <template #default="{row}">
                {{ getFormatDatetime(row.startTime, 'YY-MM-DD HH:mm') }}
            </template>
        </el-table-column>
        <el-table-column label="操作" width="120">
            <template #default="scope">
                <el-button icon="Delete"
                           type="danger"
                           @click.stop="dianJiShanChu(scope.row, scope.$index)"> 删除
                </el-button>
            </template>
        </el-table-column>
    </xc-table>
</template>

<script setup name='CheckApplicationHistory'>
import {computed} from "vue";
import store from "@/store";
import {shanChuJianChaJianYan} from "@/api/zhu-yuan-yi-sheng/jian-yan-jian-cha-shen-qing";
import {ElMessageBox} from "element-plus";
import {getFormatDatetime} from '@/utils/date'
import {getWindowSize} from "@/utils/window-size";
import {yzHeaderSize} from "@/views/hospitalization/zhu-yuan-yi-sheng/public-js/zhu-yuan-yi-sheng";
import XcTable from "@/components/xiao-chan/xc-table/XcTable.vue";

const props = defineProps({
    data: Object,
    returnData: Function,
})

const windowSize = computed(() => {
    return store.state.app.windowSize
})

const dianJiaJianChaXiangQing = (row) => {
    props.returnData(row)
}

const dianJiShanChu = (row, index) => {
    ElMessageBox.confirm(`您确定要删除【${row.orderName}】吗？`, '提示')
        .then(() => {
            shanChuJianChaJianYan(row.reqNo, row.inpatientNo, row.admissTimes).then((res) => {
                props.data.splice(index, 1)
            })
        })
        .catch(() => {
        })
}

</script>

<style scoped lang="scss">

</style>
