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