<template>
    <el-dialog v-model="dialog" title="进度">
        <el-progress :percentage="percentage"/>
    </el-dialog>
</template>

<script setup name='ProgressBar'>

import {setCallback} from "@/utils/websocket";
import {makePercentage} from "@/components/progress/progUtils";
import sleep from "@/utils/sleep";

const percentage = ref(0)
const dialog = ref(false)

onMounted(() => {
    setCallback('emrRule', (data) => {
        dialog.value = true
        percentage.value = makePercentage(data.currentIndex, data.count)
        if (percentage.value === 100) {
            sleep(1000).then(() => {
                dialog.value = false
            })
        }
    });
})
</script>

<style scoped lang="scss">

</style>
