|
@@ -41,18 +41,35 @@
|
|
|
<el-button type="primary" :loading="loading" @click="onSubmit">确定导入</el-button>
|
|
|
</el-form-item>
|
|
|
</base-form>
|
|
|
+ <base-dialog v-model="importMethodVisible" title="选择导入方式" destroy-on-close :width="350">
|
|
|
+ <!-- <base-form ref="formRef" :model="model" :items="items" :rules="rules" :label-width="useVW(72)"> -->
|
|
|
+ <div style="color: red; font-size: 14px">已有数据,是否继续导入?</div>
|
|
|
+ <el-radio-group v-model="clearMethod" size="large" style="text-align: center">
|
|
|
+ <el-radio label="追加导入" />
|
|
|
+ <el-radio v-if="curCheckStatus === 'CHOOSE'" label="清空导入" />
|
|
|
+ </el-radio-group>
|
|
|
+ <template #footer>
|
|
|
+ <div class="flex justify-end">
|
|
|
+ <confirm-button @confirm="sureImport" @cancel="cancelImport"></confirm-button>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <!-- </base-form> -->
|
|
|
+ </base-dialog>
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts" name="ImportSample">
|
|
|
/** 导入培训卷 */
|
|
|
import { reactive, watch, computed, ref } from 'vue'
|
|
|
-import { ElFormItem, ElButton, ElUpload, ElInput, ElMessage, ElProgress } from 'element-plus'
|
|
|
+import { ElFormItem, ElButton, ElUpload, ElInput, ElMessage, ElProgress, ElRadioGroup, ElRadio } from 'element-plus'
|
|
|
import BaseForm from '@/components/element/BaseForm.vue'
|
|
|
import useFetch from '@/hooks/useFetch'
|
|
|
import useForm from '@/hooks/useForm'
|
|
|
import useOptions from '@/hooks/useOptions'
|
|
|
import useUploadFile from '@/hooks/useUploadFile'
|
|
|
import useVW from '@/hooks/useVW'
|
|
|
+import BaseDialog from '@/components/element/BaseDialog.vue'
|
|
|
+import ConfirmButton from '@/components/common/ConfirmButton.vue'
|
|
|
|
|
|
import type { FormGroup, EpFormItem, EpFormRules } from 'global-type'
|
|
|
import type { ExtractApiParams } from '@/api/api'
|
|
@@ -64,6 +81,7 @@ const { fileList, upload, percentage, setPercentage, onExceed, onUploadProgress,
|
|
|
const { fetch: getImportFilePath, result: filePath } = useFetch('getImportFilePath')
|
|
|
|
|
|
const { fetch, loading } = useFetch('importSamplePaper', { onUploadProgress })
|
|
|
+const { fetch: checkFetch, loading: checkLoading } = useFetch('importCheck')
|
|
|
|
|
|
const model = reactive<ExtractApiParams<'importSamplePaper'>>({
|
|
|
file: void 0,
|
|
@@ -185,17 +203,53 @@ const items = computed<EpFormItem[]>(() => {
|
|
|
]
|
|
|
})
|
|
|
|
|
|
+const clearMethod = ref('追加导入')
|
|
|
+const importMethodVisible = ref(false)
|
|
|
+const curCheckStatus = ref('')
|
|
|
+const clear = ref(false)
|
|
|
+const sureImport = () => {
|
|
|
+ clear.value = clearMethod.value === '清空导入'
|
|
|
+ submitHandler()
|
|
|
+}
|
|
|
+const cancelImport = () => {
|
|
|
+ importMethodVisible.value = false
|
|
|
+}
|
|
|
+const submitHandler = async () => {
|
|
|
+ showProgress.value = true
|
|
|
+ setPercentage(0)
|
|
|
+ await fetch({ ...model, clear: clear.value })
|
|
|
+ setPercentage(100)
|
|
|
+ ElMessage.success(`导入成功`)
|
|
|
+ elFormRef?.value?.resetFields()
|
|
|
+ reset()
|
|
|
+ importMethodVisible.value = false
|
|
|
+}
|
|
|
async function onSubmit() {
|
|
|
try {
|
|
|
const valid = await elFormRef?.value?.validate()
|
|
|
if (valid) {
|
|
|
- showProgress.value = true
|
|
|
- setPercentage(0)
|
|
|
- await fetch(model)
|
|
|
- setPercentage(100)
|
|
|
- ElMessage.success(`导入成功`)
|
|
|
- elFormRef?.value?.resetFields()
|
|
|
- reset()
|
|
|
+ let checkRes: any = await checkFetch({
|
|
|
+ mainNumber: model.mainNumber,
|
|
|
+ subjectCode: model.subjectCode,
|
|
|
+ paperType: model.paperType,
|
|
|
+ })
|
|
|
+ console.log('checkRes:', checkRes)
|
|
|
+ curCheckStatus.value = checkRes
|
|
|
+ clearMethod.value = '追加导入'
|
|
|
+ clear.value = false
|
|
|
+ if (checkRes === 'CHOOSE' || checkRes === 'APPEND') {
|
|
|
+ importMethodVisible.value = true
|
|
|
+ } else {
|
|
|
+ submitHandler()
|
|
|
+ }
|
|
|
+
|
|
|
+ // showProgress.value = true
|
|
|
+ // setPercentage(0)
|
|
|
+ // await fetch(model)
|
|
|
+ // setPercentage(100)
|
|
|
+ // ElMessage.success(`导入成功`)
|
|
|
+ // elFormRef?.value?.resetFields()
|
|
|
+ // reset()
|
|
|
}
|
|
|
} catch (error) {
|
|
|
showProgress.value = false
|