|
@@ -43,16 +43,13 @@ import useVW from '@/hooks/useVW'
|
|
|
import type { FormGroup, EpFormItem } from 'global-type'
|
|
|
import type { ExtractApiParams } from 'api-type'
|
|
|
|
|
|
-const { fetch: getImportFilePath, result: filePath } = useFetch('getImportFilePath')
|
|
|
+const showProgress = ref(false)
|
|
|
|
|
|
-const { fetch, loading } = useFetch('importMarkStandard', { onUploadProgress })
|
|
|
+const { fileList, upload, percentage, setPercentage, onExceed, onUploadProgress } = useUploadFile()
|
|
|
|
|
|
-const showProgress = ref(false)
|
|
|
-const percentage = ref<number>(0)
|
|
|
+const { fetch: getImportFilePath, result: filePath } = useFetch('getImportFilePath')
|
|
|
|
|
|
-function onUploadProgress(event: ProgressEvent) {
|
|
|
- percentage.value = Math.min(parseFloat(((((event.loaded / event.total) * 10000) | 0) / 100).toFixed(2)), 99)
|
|
|
-}
|
|
|
+const { fetch, loading } = useFetch('importMarkStandard', { onUploadProgress })
|
|
|
|
|
|
const model = reactive<ExtractApiParams<'importMarkStandard'>>({
|
|
|
file: void 0,
|
|
@@ -75,8 +72,6 @@ const { subjectList, mainQuestionList } = useOptions(['subject', 'question'])
|
|
|
|
|
|
const { formRef, elFormRef, defineColumn, _ } = useForm()
|
|
|
|
|
|
-const { fileList, upload, onExceed } = useUploadFile()
|
|
|
-
|
|
|
const fileName = computed(() => fileList.value?.[0]?.name)
|
|
|
|
|
|
watch(
|
|
@@ -137,12 +132,12 @@ async function onSubmit() {
|
|
|
if (valid) {
|
|
|
showProgress.value = true
|
|
|
await fetch(model)
|
|
|
- percentage.value = 100
|
|
|
+ setPercentage(100)
|
|
|
ElMessage.success(`导入成功`)
|
|
|
}
|
|
|
} catch (error) {
|
|
|
showProgress.value = false
|
|
|
- percentage.value = 0
|
|
|
+ setPercentage(0)
|
|
|
console.error(error)
|
|
|
}
|
|
|
}
|