<template>
    <div>
        <div class="bigBox">
            <el-dialog v-model="dialogVisible" title="删除" width="30%" @close="closes">
                <span>确定删除吗？</span>
                <template #footer>
                    <span class="dialog-footer">
                        <el-button @click="cancels">取消</el-button>
                        <el-button type="primary" @click="sureDel">确认</el-button>
                    </span>
                </template>
            </el-dialog>
        </div>
    </div>
</template>

<script>
import systemRow from '@/api/systemRow';
import { ref, onMounted, toRefs } from 'vue';
import { ElMessage } from 'element-plus';
export default {
    props: {
        delModal: {
            type: Boolean,
            required: true
        },
        delId: {
            type: String,
            required: true
        },
        searchSystem:{
            type:Function,
            required:true
        }
    },
    setup(props, { emit }) {
        let result = props.delModal
        let deleteId = props.delId
        let { cancels, sureDel } = toRefs(props)
        let dialogVisible = ref(false)
        function lineList() {
            dialogVisible.value = result
        }
        function backTo() {
            dialogVisible.value = false
            emit("delBack", dialogVisible.value)
        }
        function getSure() {
            systemRow.delRow({ id: deleteId }).then(res => {
                if (res.returncode == 200) {
                    ElMessage({
                        type: "success",
                        message: "删除成功!"
                    })
                    dialogVisible.value = false
                    emit("delBack", dialogVisible.value)
                    props.searchSystem()
                }
            })
        }
        onMounted(() => {
            lineList()
        })
        return {
            dialogVisible,
            lineList,
            cancels: backTo,
            sureDel: getSure,
            closes: backTo,
        }
    }
}
</script>

<style lang="scss" scoped></style>