Files
school-developer/src/views/professional/teacherbase/import-teacherInfo.vue
zhoutianchi 6a4c47f6fa 1
2026-02-06 15:15:11 +08:00

94 lines
2.4 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<el-dialog v-model="visible" title="导入职工信息" width="600" append-to-body>
<el-alert
type="warning"
:closable="false"
show-icon
style="margin-bottom: 20px;">
<template #title>
<span> 可先导出教职工信息,按照导出信息的模板填入职工数据,再执行导入</span>
</template>
</el-alert>
<!-- <div style="text-align: center; margin-bottom: 20px;">-->
<!-- <a href="excel/dictlist.xlsx" rel="external nofollow" download="职工信息字典下载" style="text-decoration: none;">-->
<!-- <el-button type="success" :icon="Download">下载字典文件</el-button>-->
<!-- </a>-->
<!-- </div>-->
<el-upload
class="upload-demo"
action="/professional/file/makeImportTeacherInfoSimpleTask"
:headers="headers"
:accept="'.xls,.xlsx'"
:on-success="handleUploadSuccess"
:on-error="handleAvatarError"
drag>
<el-icon class="el-icon--upload"><upload-filled /></el-icon>
<div class="el-upload__text">
将文件拖到此处<em>点击上传</em>
</div>
<template #tip>
<div class="el-upload__tip">
只能上传 .xls .xlsx 格式的 Excel 文件
</div>
</template>
</el-upload>
</el-dialog>
</template>
<script setup lang="ts">
import { ref, computed } from 'vue'
import { ElNotification } from 'element-plus'
import { Download, UploadFilled } from '@element-plus/icons-vue'
import { Session } from '/@/utils/storage'
// 响应式数据
const visible = ref(false)
// 计算属性
const headers = computed(() => {
return {
"Authorization": 'Bearer ' + Session.getToken()
}
})
// 方法
const init = () => {
visible.value = true
}
const handleUploadSuccess = () => {
visible.value = false
ElNotification({
title: '成功',
message: '导入成功',
type: 'success',
})
}
const handleAvatarError = (err: any) => {
const result = JSON.parse(err.message)
if (result.code == "1") {
ElNotification.error({
title: '错误',
message: result.msg,
duration: 30000
})
}
}
// 暴露方法给父组件
defineExpose({
init
})
</script>
<style scoped lang="scss">
.upload-demo {
:deep(.el-upload-dragger) {
width: 100%;
}
}
</style>