|
@@ -233,41 +233,45 @@ export default defineComponent({
|
|
|
console.log(data.file)
|
|
|
const msg = message.loading('正在上传文件', { duration: 0 })
|
|
|
customRequest_importData.loading = true
|
|
|
- const fileUrl = await api_uploadFile(data.file.file, () => {})
|
|
|
- const res = await api_openFileImportInfoSave({
|
|
|
- dataType: customRequest_importData.dataType,
|
|
|
- fileName: data.file.name,
|
|
|
- importUrl: fileUrl,
|
|
|
- lessonId: route.query.id
|
|
|
- })
|
|
|
- console.log('🚀 ~ res:', res)
|
|
|
- customRequest_importData.loading = false
|
|
|
- if (res.data) {
|
|
|
- msg.destroy()
|
|
|
- // 空表格
|
|
|
- if (res.data.insertRow === 0 && res.data.invalidRow === 0) {
|
|
|
- message.error('导入失败,表格为空')
|
|
|
- return
|
|
|
- }
|
|
|
- if (res.data.respUrl) {
|
|
|
- dialog.error({
|
|
|
- title: '信息',
|
|
|
- content: () => (
|
|
|
- <NSpace>
|
|
|
- <div>导入失败,点击下载错误信息</div>
|
|
|
- <a href={res.data.respUrl} download>
|
|
|
- 下载
|
|
|
- </a>
|
|
|
- </NSpace>
|
|
|
- )
|
|
|
- })
|
|
|
- return
|
|
|
+ try {
|
|
|
+ const fileUrl = await api_uploadFile(data.file.file, () => {})
|
|
|
+ const res = await api_openFileImportInfoSave({
|
|
|
+ dataType: customRequest_importData.dataType,
|
|
|
+ fileName: data.file.name,
|
|
|
+ importUrl: fileUrl,
|
|
|
+ lessonId: route.query.id
|
|
|
+ })
|
|
|
+ console.log('🚀 ~ res:', res)
|
|
|
+ customRequest_importData.loading = false
|
|
|
+ if (res.data) {
|
|
|
+ msg.destroy()
|
|
|
+ // 空表格
|
|
|
+ if (res.data.insertRow === 0 && res.data.invalidRow === 0) {
|
|
|
+ message.error('导入失败,表格为空')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (res.data.respUrl) {
|
|
|
+ dialog.error({
|
|
|
+ title: '信息',
|
|
|
+ content: () => (
|
|
|
+ <NSpace>
|
|
|
+ <div>导入失败,点击下载错误信息</div>
|
|
|
+ <a href={res.data.respUrl} download>
|
|
|
+ 下载
|
|
|
+ </a>
|
|
|
+ </NSpace>
|
|
|
+ )
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ getDetail()
|
|
|
+ message.success('导入成功')
|
|
|
+ } else {
|
|
|
+ message.error('请下载模板后,填写数据再导入')
|
|
|
}
|
|
|
- getDetail()
|
|
|
- message.success('导入成功')
|
|
|
- } else {
|
|
|
- message.error('请下载模板后,填写数据再导入')
|
|
|
- }
|
|
|
+ } catch {}
|
|
|
+ customRequest_importData.loading = false
|
|
|
+ msg.destroy()
|
|
|
}
|
|
|
return () => (
|
|
|
<div class={styles.courseConfiguration}>
|