<template>
    <el-alert title="lic已失效，请通过mac地址，重新导入lic文件" type="warning" :closable='false' center />
    <div class='app-container'>
        mac地址：{{ macAddress }}
        <el-upload v-model:file-list="uploadData.fileList" :action="uploadData.action" accept=".tmp,.lqlic"
            :show-file-list="false" style="width: 100px; margin-top: 20px;" :on-success="handleSuccess">
            <el-button type="primary">导入lic文件</el-button>
        </el-upload>
    </div>
</template>

<script setup lang='ts'>
import { ref, reactive } from 'vue'
import { getMacAddress } from '@/services/api/login/login'
import { ElMessage } from 'element-plus'

const macAddress = ref()
const uploadData = reactive({
    fileList: undefined,
    action: '/admin/api/lic/info/file/import'
})


const handleSuccess = (res: any, uploadFile: any, uploadFiles: any) => {
    if (res.code === 200) {
        window.location.href = '/#/login'
        sessionStorage.clear()
        ElMessage({ type: 'success', message: '导入成功！' })
    } else return ElMessage({ type: 'error', message: res.msg })
}

getMacAddress().then((res: any) => {
    if (res.code === 200) {
        macAddress.value = res.data.macAddress
    }
})

</script>
 
<style lang = "scss" scoped>
.app-container {
    display: flex;
    flex-direction: column;
    margin: 10% auto;
    justify-content: center;
    align-items: center;
}
</style>