import.vue 2.68 KB
<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.msg, '提示', {
      confirmButtonText: '好的'
    })
  } else {
    if(res.data.repeatInSystemColumn){
      proxy.$modal.msgError(`${res.data.repeatInSystemColumn}系统中已存在`)
    }
    if(res.data.errCountryColumn){
      proxy.$modal.msgError(`${res.data.errCountryColumn}所属国家有误`)
    }
    if(res.data.errIdcTypeColumn){
      proxy.$modal.msgError(`${res.data.errIdcTypeColumn}证件号错误`)
    }
    if(res.data.errSexColumn){
      proxy.$modal.msgError(`${res.data.errSexColumn}性别错误`)
    }
    if(res.data.incompleteColumn){
      proxy.$modal.msgError(`${res.data.incompleteColumn}必填项未完成`)
    }
    if(res.data.repeatInFileColumn){
      proxy.$modal.msgError(`${res.data.repeatInFileColumn}文件内重复`)
    }

  }

  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>