import.vue
2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<template>
<el-dialog v-model="show" :title="title" width="500px" close-icon="CircleClose"
append-to-body :close-on-click-modal="false" class="pcloginpop" center>
<el-form ref="dialogRef" label-width="100px">
<el-form-item :label="language==0?'下载模板':'Download template'">
<el-link href="/file/UserImport-ch.xlsx" v-if="language==0" type="primary" target="_blank">人员模板</el-link>
<el-link href="/file/UserImport-en.xlsx" v-else type="primary" target="_blank">Personnel template</el-link>
</el-form-item>
<el-form-item :label="language==0?'上传模板':'Upload template'" prop="discount">
<fileImport ref="upload" name="excel" :action="action" @uploadSuccess="uploadSuccess" />
</el-form-item>
</el-form>
</el-dialog>
</template>
<script setup>
import { getCurrentInstance } from '@vue/runtime-core'
import { reactive, ref, watch } from 'vue'
import { toRefs } from '@vueuse/shared'
import * as match from '@/apiPc/match'
import { ElMessage, ElMessageBox } from 'element-plus'
const { proxy } = getCurrentInstance()
import useUserStore from '@/store/modules/user'
const emit = defineEmits(['submitForm'])
import cache from "@/plugins/cache"
const language = ref(cache.local.get('language') || 0)
const action = ref('')
const accept = ref('.xlsx')
const title = ref('')
const show = ref(false)
const userStore = useUserStore()
let groupId = 0
if(useUserStore().group){
groupId = useUserStore().group.id
}
function uploadSuccess(res) {
console.log(res)
cancel()
if (res.code == 500) {
ElMessageBox.alert(res.data, '提示', {
confirmButtonText: '好的'
})
} else {
proxy.$modal.msgSuccess(`${res.msg}`)
}
emit('uploadSuccess')
proxy.$refs['upload'].handleClear()
}
const open = (params) => {
show.value = true
title.value = params.title
action.value = `/systemj/personInfo/importPerson/${groupId}`
}
defineExpose({
open
})
function cancel() {
show.value = false
}
</script>
<style scoped>
:deep(.el-upload__tip) {
display: none
}
</style>