<template>
    <div>
        <div>
            <el-dialog v-model="dialogVisible" title="图片查看" width="30%" @close="closes">
                <h1 v-if="picChange==''">暂无图片信息</h1>
                <img v-else :src="picChange" alt="">
                <template #footer>
                    <span class="dialog-footer">
                        <el-button @click="cancels">取消</el-button>
                    </span>
                </template>
            </el-dialog>
        </div>
    </div>
</template>

<script>
import { ref, onMounted, toRefs, reactive } from 'vue';
import { ElMessage } from 'element-plus';
export default {
    props: {
        picModal: {
            type: Boolean,
            required: true
        },
        needList: {
            type: Object,
            required: true
        }
    },
    setup(props, { emit }) {
        let dialogVisible = ref(false)
        let result = props.picModal
        let newList = props.needList
        let picChange = ref('')
        // let showPic = ref(require(picChange + ''))
        let { cancels } = toRefs(props)
        function lineList() {
            if (newList.pic === '') {
                picChange.value = ''
            } else {
                picChange.value = require(newList.pic)
            }
            dialogVisible.value = result
        }
        function canBack() {
            dialogVisible.value = false
            emit("picBack", dialogVisible.value)
        }
        onMounted(() => {
            lineList()
        })
        return {
            dialogVisible,
            lineList,
            cancels: canBack,
            closes: canBack,
            // showPic,
            picChange
        }
    }
}
</script>

<style scoped></style>