|
@@ -70,11 +70,11 @@
|
|
|
>
|
|
>
|
|
|
<a-table-column title="Id" data-index="id" key="id" width="90px" />
|
|
<a-table-column title="Id" data-index="id" key="id" width="90px" />
|
|
|
<a-table-column
|
|
<a-table-column
|
|
|
- title="学科"
|
|
|
|
|
- data-index="subjectId"
|
|
|
|
|
- key="subjectId"
|
|
|
|
|
|
|
+ title="题库类型"
|
|
|
|
|
+ data-index="bankType"
|
|
|
|
|
+ key="bankType"
|
|
|
width="150px"
|
|
width="150px"
|
|
|
- :customRender="subjectFormatter"
|
|
|
|
|
|
|
+ :customRender="bankTypeFormatter"
|
|
|
/>
|
|
/>
|
|
|
<a-table-column
|
|
<a-table-column
|
|
|
title="题型"
|
|
title="题型"
|
|
@@ -218,6 +218,10 @@
|
|
|
queryParam.pageIndex = 1
|
|
queryParam.pageIndex = 1
|
|
|
search()
|
|
search()
|
|
|
}
|
|
}
|
|
|
|
|
+ const bankTypeFormatter = ({ text }) => {
|
|
|
|
|
+ const key = Number(text)
|
|
|
|
|
+ return enumFormat(bankTypeEnum.value, key)
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
const search = () => {
|
|
const search = () => {
|
|
|
listLoading.value = true
|
|
listLoading.value = true
|
|
@@ -294,19 +298,34 @@
|
|
|
// 处理Excel导入
|
|
// 处理Excel导入
|
|
|
const handleImportExcel = (options) => {
|
|
const handleImportExcel = (options) => {
|
|
|
const { file } = options
|
|
const { file } = options
|
|
|
- const loading = message.loading('正在导入中...', 0)
|
|
|
|
|
|
|
+ const loading = message.loading('正在检查文件...', 0)
|
|
|
|
|
|
|
|
|
|
+ // 先调用检查接口
|
|
|
tQuestionApi
|
|
tQuestionApi
|
|
|
- .importExcel(file)
|
|
|
|
|
- .then((res) => {
|
|
|
|
|
|
|
+ .checkExcel(file)
|
|
|
|
|
+ .then((checkRes) => {
|
|
|
loading()
|
|
loading()
|
|
|
- message.success('导入成功')
|
|
|
|
|
- search() // 刷新列表
|
|
|
|
|
|
|
+ // 检查通过后,再调用导入接口
|
|
|
|
|
+ const importLoading = message.loading('正在导入中...', 0)
|
|
|
|
|
+
|
|
|
|
|
+ return tQuestionApi
|
|
|
|
|
+ .importExcel(file)
|
|
|
|
|
+ .then((res) => {
|
|
|
|
|
+ importLoading()
|
|
|
|
|
+ message.success('导入成功')
|
|
|
|
|
+ search() // 刷新列表
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch((error) => {
|
|
|
|
|
+ importLoading()
|
|
|
|
|
+ message.error('导入失败,请检查Excel文件格式是否正确')
|
|
|
|
|
+ console.error('导入失败:', error)
|
|
|
|
|
+ throw error // 继续抛出错误以便外层catch捕获
|
|
|
|
|
+ })
|
|
|
})
|
|
})
|
|
|
.catch((error) => {
|
|
.catch((error) => {
|
|
|
loading()
|
|
loading()
|
|
|
- message.error('导入失败,请检查Excel文件格式是否正确')
|
|
|
|
|
- console.error('导入失败:', error)
|
|
|
|
|
|
|
+ message.error('文件检查失败,请确保Excel格式正确')
|
|
|
|
|
+ console.error('检查失败:', error)
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
</script>
|
|
</script>
|