联调 模版下载 批量导入功能 修改云效bug

This commit is contained in:
GGJ
2024-06-24 16:38:59 +08:00
parent d61db37512
commit 1487f5ceea
9 changed files with 187 additions and 100 deletions

View File

@@ -95,83 +95,98 @@ const submit = async () => {
if (valid) {
let data = new FormData()
data.append('file', form.file)
if (title.value == '导入干扰源用户') {
if (title.value === '导入干扰源用户') {
await importSensitiveReportData(data)
.then((res: any) => {
if (res.type === 'application/json') {
// 说明是普通对象数据,读取信息
const fileReader = new FileReader()
fileReader.onloadend = () => {
try {
const jsonData = JSON.parse(fileReader.result)
// 后台信息
if (jsonData.code === 'A0000') {
ElMessage.success('导入成功')
} else {
ElMessage.error('导入失败,请查看下载附件!')
}
} catch (err) {
console.log(err)
}
}
fileReader.readAsText(res)
} else {
ElMessage.error('导入失败,请查看下载附件!')
let blob = new Blob([res], {
type: 'application/vnd.ms-excel'
})
const url = window.URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = '敏感及重要用户失败列表'
document.body.appendChild(link)
link.click()
link.remove()
}
})
.then(res => handleImportResponse(title.value, res))
.finally(() => {
tableStore.index()
eventDataUploadVisible.value = false
})
} else {
await importSensitiveUserData(data)
.then((res: any) => {
if (res.type === 'application/json') {
// 说明是普通对象数据,读取信息
const fileReader = new FileReader()
fileReader.onloadend = () => {
try {
const jsonData = JSON.parse(fileReader.result)
// 后台信息
if (jsonData.code === 'A0000') {
ElMessage.success('导入成功')
} else {
ElMessage.error('导入失败,请查看下载附件!')
}
} catch (err) {
console.log(err)
}
}
fileReader.readAsText(res)
} else {
ElMessage.error('导入失败,请查看下载附件!')
let blob = new Blob([res], {
type: 'application/vnd.ms-excel'
})
const url = window.URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = '敏感及重要用户失败列表'
document.body.appendChild(link)
link.click()
link.remove()
}
})
.then(res => handleImportResponse(title.value, res))
.finally(() => {
tableStore.index()
eventDataUploadVisible.value = false
})
}
// if (title.value == '导入干扰源用户') {
// await importSensitiveReportData(data)
// .then((res: any) => {
// if (res.type === 'application/json') {
// // 说明是普通对象数据,读取信息
// const fileReader = new FileReader()
// fileReader.onloadend = () => {
// try {
// const jsonData = JSON.parse(fileReader.result)
// // 后台信息
// if (jsonData.code === 'A0000') {
// ElMessage.success('导入成功')
// } else {
// ElMessage.error('导入失败,请查看下载附件!')
// }
// } catch (err) {
// console.log(err)
// }
// }
// fileReader.readAsText(res)
// } else {
// ElMessage.error('导入失败,请查看下载附件!')
// let blob = new Blob([res], {
// type: 'application/vnd.ms-excel'
// })
// const url = window.URL.createObjectURL(blob)
// const link = document.createElement('a')
// link.href = url
// link.download = '干扰源用户失败列表'
// document.body.appendChild(link)
// link.click()
// link.remove()
// }
// })
// .finally(() => {
// tableStore.index()
// eventDataUploadVisible.value = false
// })
// } else {
// await importSensitiveUserData(data)
// .then((res: any) => {
// if (res.type === 'application/json') {
// // 说明是普通对象数据,读取信息
// const fileReader = new FileReader()
// fileReader.onloadend = () => {
// try {
// const jsonData = JSON.parse(fileReader.result)
// // 后台信息
// if (jsonData.code === 'A0000') {
// ElMessage.success('导入成功')
// } else {
// ElMessage.error('导入失败,请查看下载附件!')
// }
// } catch (err) {
// console.log(err)
// }
// }
// fileReader.readAsText(res)
// } else {
// ElMessage.error('导入失败,请查看下载附件!')
// let blob = new Blob([res], {
// type: 'application/vnd.ms-excel'
// })
// const url = window.URL.createObjectURL(blob)
// const link = document.createElement('a')
// link.href = url
// link.download = '敏感及重要用户失败列表'
// document.body.appendChild(link)
// link.click()
// link.remove()
// }
// })
// .finally(() => {
// tableStore.index()
// eventDataUploadVisible.value = false
// })
// }
}
})
} else {
@@ -179,6 +194,35 @@ const submit = async () => {
}
}
async function handleImportResponse(title: any, res: any) {
if (res.type === 'application/json') {
const fileReader = new FileReader()
fileReader.onloadend = () => {
try {
const jsonData = JSON.parse(fileReader.result)
if (jsonData.code === 'A0000') {
ElMessage.success('导入成功')
} else {
ElMessage.error('导入失败,请查看下载附件!')
}
} catch (err) {
console.log(err)
}
}
fileReader.readAsText(res)
} else {
ElMessage.error('导入失败,请查看下载附件!')
let blob = new Blob([res], { type: 'application/vnd.ms-excel' })
const url = window.URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = title.includes('干扰源用户') ? '干扰源用户失败列表' : '敏感及重要用户失败列表'
document.body.appendChild(link)
link.click()
link.remove()
}
}
defineExpose({ open })
</script>