ADD:导入子计划元数据二次确认提示
This commit is contained in:
@@ -3,12 +3,15 @@
|
|||||||
<el-form class="drawer-multiColumn-form" style="margin-top: 10px" label-width="100px">
|
<el-form class="drawer-multiColumn-form" style="margin-top: 10px" label-width="100px">
|
||||||
<el-form-item label="文件上传:">
|
<el-form-item label="文件上传:">
|
||||||
<el-upload
|
<el-upload
|
||||||
|
ref="uploadRef"
|
||||||
action="#"
|
action="#"
|
||||||
class="upload"
|
class="upload"
|
||||||
drag
|
drag
|
||||||
:http-request="uploadZip"
|
:http-request="uploadZip"
|
||||||
accept=".zip"
|
accept=".zip"
|
||||||
:show-file-list="false"
|
:auto-upload="!parameter.confirmMessage"
|
||||||
|
:on-change="handleChange"
|
||||||
|
:on-remove="handleRemove"
|
||||||
>
|
>
|
||||||
<slot name="empty">
|
<slot name="empty">
|
||||||
<el-icon class="el-icon--upload">
|
<el-icon class="el-icon--upload">
|
||||||
@@ -27,20 +30,27 @@
|
|||||||
</el-upload>
|
</el-upload>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
<template #footer v-if="parameter.confirmMessage">
|
||||||
|
<el-button :disabled="disable" type="primary" @click="uploadSubmit">开始导入</el-button>
|
||||||
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts" name="ImportZip">
|
<script setup lang="ts" name="ImportZip">
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { ElMessage, UploadRequestOptions } from 'element-plus'
|
import type { UploadInstance, UploadProps, UploadRequestOptions } from 'element-plus'
|
||||||
|
|
||||||
export interface ZipParameterProps {
|
export interface ZipParameterProps {
|
||||||
title: string // 标题
|
title: string // 标题
|
||||||
patternId?: string // 模式ID
|
patternId?: string // 模式ID
|
||||||
importApi?: (params: any) => Promise<any> // 批量导入的Api
|
importApi?: (params: any) => Promise<any> // 批量导入的Api
|
||||||
|
confirmMessage?: string // 提示信息
|
||||||
}
|
}
|
||||||
// dialog状态
|
// dialog状态
|
||||||
const dialogVisible = ref(false)
|
const dialogVisible = ref(false)
|
||||||
|
const disable = ref(true)
|
||||||
|
const uploadRef = ref<UploadInstance>()
|
||||||
|
|
||||||
// 父组件传过来的参数
|
// 父组件传过来的参数
|
||||||
const parameter = ref<ZipParameterProps>({
|
const parameter = ref<ZipParameterProps>({
|
||||||
title: ''
|
title: ''
|
||||||
@@ -73,7 +83,26 @@ const handleImportResponse = (res: any) => {
|
|||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
emit('result', res.data)
|
emit('result', res.data)
|
||||||
}
|
}
|
||||||
|
const uploadSubmit = () => {
|
||||||
|
if (!uploadRef.value) {
|
||||||
|
return ElMessage.warning('请选择文件!')
|
||||||
|
}
|
||||||
|
ElMessageBox.confirm(parameter.value.confirmMessage, '温馨提示', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning'
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
uploadRef.value?.submit()
|
||||||
|
})
|
||||||
|
.catch(() => {})
|
||||||
|
}
|
||||||
|
const handleChange: UploadProps['onChange'] = (uploadFile, uploadFiles) => {
|
||||||
|
disable.value = uploadFiles.length === 0
|
||||||
|
}
|
||||||
|
const handleRemove: UploadProps['onRemove'] = (uploadFile, uploadFiles) => {
|
||||||
|
disable.value = uploadFiles.length === 0
|
||||||
|
}
|
||||||
defineExpose({
|
defineExpose({
|
||||||
acceptParams
|
acceptParams
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -643,7 +643,8 @@ const importSubClick = () => {
|
|||||||
const params = {
|
const params = {
|
||||||
title: '导入检测计划',
|
title: '导入检测计划',
|
||||||
patternId: dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id ?? '',
|
patternId: dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id ?? '',
|
||||||
importApi: importSubPlan
|
importApi: importSubPlan,
|
||||||
|
confirmMessage: '本次导入会覆盖已有数据信息,是否确认继续?'
|
||||||
}
|
}
|
||||||
planImportZip.value?.acceptParams(params)
|
planImportZip.value?.acceptParams(params)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user