|
|
@ -1,7 +1,7 @@ |
|
|
|
<!-- 导入组件 --> |
|
|
|
<template> |
|
|
|
<Dialog v-model="dialogVisible" title="导入" width="600"> |
|
|
|
<el-upload ref="uploadRef" v-model:file-list="fileList" :action="importUrl + '?updateSupport=' + updateSupport" |
|
|
|
<el-upload ref="uploadRef" v-model:file-list="fileList" :action="importUrl + '?mode=' + mode + '&file=' + file + '&updatePart=' + updatePart" |
|
|
|
:auto-upload="false" :disabled="formLoading" :headers="uploadHeaders" :limit="1" :on-error="submitFormError" |
|
|
|
:on-exceed="handleExceed" :on-success="submitFormSuccess" :accept="accept" drag |
|
|
|
style="width:300px;margin:0 auto"> |
|
|
@ -13,7 +13,7 @@ |
|
|
|
<div class="label h-32px mr-26px color-#acaeb3 font-size-14px" style="line-height:32px">导入模式</div> |
|
|
|
<div class=""> |
|
|
|
<div class="radio"> |
|
|
|
<el-radio-group v-model="updateSupport"> |
|
|
|
<el-radio-group v-model="mode"> |
|
|
|
<el-radio :label="1" :disabled="updateIsDisable">更新</el-radio> |
|
|
|
<el-radio :label="2" :disabled="appendIsDisable">追加</el-radio> |
|
|
|
<el-radio :label="3" :disabled="coverIsDisable">覆盖</el-radio> |
|
|
@ -31,7 +31,7 @@ |
|
|
|
<div class="label h-32px mr-26px color-#acaeb3 font-size-14px" style="line-height:32px">部分保存</div> |
|
|
|
<div class=""> |
|
|
|
<div class="switch"> |
|
|
|
<el-switch v-model="isSaveAll" /> |
|
|
|
<el-switch v-model="updatePart" /> |
|
|
|
</div> |
|
|
|
|
|
|
|
<div class="tips color-#acaeb3 font-size-14px"> |
|
|
@ -62,6 +62,7 @@ |
|
|
|
// import * as UserApi from '@/api/system/user' |
|
|
|
import { getAccessToken, getTenantId } from '@/utils/auth' |
|
|
|
import download from '@/utils/download' |
|
|
|
import { log } from 'console' |
|
|
|
|
|
|
|
defineOptions({ name: 'ImportForm' }) |
|
|
|
|
|
|
@ -74,6 +75,7 @@ const importUrl = |
|
|
|
import.meta.env.VITE_BASE_URL + import.meta.env.VITE_API_URL + '/system/user/import' |
|
|
|
const uploadHeaders = ref() // 上传 Header 头 |
|
|
|
const fileList = ref([]) // 文件列表 |
|
|
|
const file = ref('') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -89,7 +91,7 @@ const fileList = ref([]) // 文件列表 |
|
|
|
default:'.xlsx,.xls' |
|
|
|
}, |
|
|
|
// 是否更新已经存在的用户数据.默认值是1 |
|
|
|
updateSupport: { |
|
|
|
mode: { |
|
|
|
type: Number, |
|
|
|
required: false, |
|
|
|
default: 1 |
|
|
@ -113,18 +115,19 @@ const fileList = ref([]) // 文件列表 |
|
|
|
default: false |
|
|
|
}, |
|
|
|
// 是否部门保存,默认是 |
|
|
|
isSaveAll: { |
|
|
|
updatePart: { |
|
|
|
type: Boolean, |
|
|
|
required: false, |
|
|
|
default: true |
|
|
|
}, |
|
|
|
}) |
|
|
|
const { importTemplateData, accept } = toRefs(props) |
|
|
|
const updateSupport = ref(props.updateSupport)//是否更新已经存在的用户数据.默认值是1 |
|
|
|
const importTemplateData= ref(props.importTemplateData) |
|
|
|
const accept= ref(props.accept) |
|
|
|
const mode = ref(props.mode)//是否更新已经存在的用户数据.默认值是1 |
|
|
|
const updateIsDisable = ref(props.updateIsDisable)//更新是否禁用,默认值不禁用 |
|
|
|
const appendIsDisable = ref(props.appendIsDisable)//追加是否禁用,默认值不禁用 |
|
|
|
const coverIsDisable = ref(props.coverIsDisable)//覆盖是否禁用,默认值不禁用 |
|
|
|
const isSaveAll = ref(props.isSaveAll)//是否部门保存 |
|
|
|
const updatePart = ref(props.updatePart)//是否部门保存 |
|
|
|
|
|
|
|
/** 打开弹窗 */ |
|
|
|
const open = () => { |
|
|
@ -135,10 +138,12 @@ defineExpose({ open }) // 提供 open 方法,用于打开弹窗 |
|
|
|
|
|
|
|
/** 提交表单 */ |
|
|
|
const submitForm = async () => { |
|
|
|
|
|
|
|
if (fileList.value.length == 0) { |
|
|
|
message.error('请上传文件') |
|
|
|
return |
|
|
|
} |
|
|
|
file.value = fileList.value[0].name |
|
|
|
// 提交请求 |
|
|
|
uploadHeaders.value = { |
|
|
|
Authorization: 'Bearer ' + getAccessToken(), |
|
|
@ -171,8 +176,10 @@ const submitFormSuccess = (response: any) => { |
|
|
|
text += '< ' + username + ': ' + data.failureUsernames[username] + ' >' |
|
|
|
} |
|
|
|
message.alert(text) |
|
|
|
|
|
|
|
// 发送操作成功的事件 |
|
|
|
emits('success') |
|
|
|
dialogVisible.value = false |
|
|
|
} |
|
|
|
|
|
|
|
/** 上传错误提示 */ |
|
|
@ -195,8 +202,8 @@ const handleExceed = (): void => { |
|
|
|
|
|
|
|
/** 下载模板操作 */ |
|
|
|
const importTemplate = () => { |
|
|
|
const res = importTemplateData.templateUrl |
|
|
|
download.excel(res, importTemplateData.templateTitle) |
|
|
|
const res = importTemplateData.value.templateUrl |
|
|
|
download.excel(res, importTemplateData.value.templateTitle) |
|
|
|
} |
|
|
|
</script> |
|
|
|
|
|
|
|