diff --git a/src/views/paper/question/WpsPptxForm.vue b/src/views/paper/question/WpsPptxForm.vue index d1ad51b..ced3ec5 100644 --- a/src/views/paper/question/WpsPptxForm.vue +++ b/src/views/paper/question/WpsPptxForm.vue @@ -351,7 +351,7 @@ defineOptions({ name: 'WpsPptxFrom' }) const pptxPointsList = ref([]) // 树形结构 const pptxPointsInfoList = ref([]) // 树形结构 -const list = ref([]) // 列表的数 +const list = ref([]) // 列表的数 const { t } = useI18n() // 国际化 const message = useMessage() // 消息弹窗 const loading = ref(false) // 列表的加载中 @@ -404,17 +404,26 @@ const formData = ref({ ] }) -let pptxPointsInfosList: (typeof pptxPoints)[] = [] +// 定义 pptxPoints 类型 +interface PptxPoints { + firstName: string; + index: string; + function: string; + examName: string; + examCode: string; + method?: string; +} +let pptxPointsInfosList: PptxPoints[] = [] const removePoint = (index: number) => { list.value.splice(index, 1) } -function fileTypeFormatter(row, column, cellValue) { +function fileTypeFormatter(_row: any, _column: any, cellValue: any) { if (cellValue === '0') return '素材文件(上传ZIP)' if (cellValue === '1') return '考试文件' if (cellValue === '2') return '结果文件' return '未知类型' } -const documentList = ref([ +const documentList = ref([ { quId: '', url: '', @@ -437,16 +446,18 @@ const documentList = ref([ const dialogFormVisiblePptxInfo = ref(false) const dialogFormVisiblePptxInfos = ref(false) const titles = ref('') -const filePath = ref('') +// const filePath = ref('') // 未使用,注释 -const handleCheckChange = (data: Tree, checked: boolean, indeterminate: boolean) => { +// Tree 类型扩展,或用 any 替代 +const handleCheckChange = (data: any, _checked: boolean, _indeterminate: boolean) => { console.log(data) - const pptxPoints = { + const pptxPoints: PptxPoints = { firstName: '', index: '', function: '', examName: '', - examCode: '' + examCode: '', + method: '' } if (data.functions != null && data.functions != '') { pptxPoints.firstName = chineseName.value @@ -463,7 +474,11 @@ const file = ref() const getSlideDataInfo = async () => { const fileInput = document.getElementById('slideFile') as HTMLInputElement if (fileInput != null) { - file.value = fileInput.files[0] + if (fileInput.files && fileInput.files[0]) { + file.value = fileInput.files[0] + } else { + return + } const res = await PptxApi.getSlideDataInfo({ file: file.value }) pptxPointsList.value = [] pptxPointsList.value.push(...handleTree(res.data)) @@ -475,9 +490,7 @@ const addPptxForm = async () => { dialogFormVisiblePptxInfo.value = true } -const queryParams = reactive({ - nodeFunction: undefined -}) +// 已移除未使用的 queryParams const chineseName = ref('') const textIndex = ref() @@ -495,7 +508,7 @@ const handleNodelClick = async (row: any) => { const handleDelete = (row) => { console.log(row) for (let i = 0; i < list.value.length; i++) { - if (row.content == list.value[i].content) { + if ((row as any).content == (list.value[i] as any).content) { list.value.splice(i, 1) } } @@ -518,7 +531,7 @@ const submitPptxPoints = async () => { } } if (!indexFlag) { - res.data[i].sort = list.value.length + 1 + (res.data[i] as any).sort = list.value.length + 1 list.value.push(res.data[i]) } } @@ -559,7 +572,7 @@ const formRef = ref() // 表单 Ref const leftActiveName = ref('desc') // 右侧tab const rightActiveName = ref('annex') -const rightHandleClick = (tab, e) => { +const rightHandleClick = (tab) => { rightActiveName.value = tab.paneName.value } @@ -610,17 +623,7 @@ const deleteUrl = (index: number) => { formData.value.fileUploads[index].fileName = '' } // 媒体文件 -const mediumList = ref([] as any) -const multipleMediumSelection = ref([] as any) -const handleMediumSelectionChange = (val: any) => { - multipleMediumSelection.value = val -} -const fileList = [] - -const multipleDocumentSelection = ref([] as any) -const handleDocumentSelectionChange = (val: any) => { - multipleDocumentSelection.value = val -} +// 已移除未使用的 mediumList、handleMediumSelectionChange、handleDocumentSelectionChange 相关声明 const handleUploadSuccess = ({ url, fileType }) => { const index = documentList.value.findIndex((item) => item.fileType === fileType) if (index !== -1) { @@ -640,8 +643,8 @@ const open = async (queryParams: any, type: string, id?: number) => { const res = await QuestionApi.getQuestion(id) formData.value = res console.log(formData.value) - list.value = formData.value.answerList - documentList.value = res.fileUploads + list.value = formData.value.answerList as any[] + documentList.value = res.fileUploads as any[] } finally { formLoading.value = false } @@ -658,20 +661,13 @@ const open = async (queryParams: any, type: string, id?: number) => { } defineExpose({ open }) // 提供 open 方法,用于打开弹窗 // 转换函数:将大写字母 A-Z 映射为 0-25 -const mappedNumber = computed(() => { - const char = radio.value.toUpperCase() - const code = char.charCodeAt(0) - if (code >= 65 && code <= 90) { - return code - 65 - } else { - return '请输入 A-Z 的字母' - } -}) +// radio 未被模板或逻辑使用,已移除 +// mappedNumber 未被模板或逻辑使用,已移除 /** 提交表单 */ const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调 const submitForm = async () => { - formData.value.answerList = list.value - formData.value.fileUploads = documentList.value + formData.value.answerList = list.value as any[] + formData.value.fileUploads = documentList.value as any[] const values = Object.values(formData) console.log(values) // 校验表单 @@ -721,7 +717,7 @@ const resetForm = () => { contentIn: '', scoreRate: '' } - ], + ] as any[], fileUploads: [ { quId: '', @@ -782,7 +778,7 @@ const handleTreeWithLevel = (list, level = 1) => { // 只允许点击第三级节点 const treeRef = ref() // 引用 el-tree -const handleNodeClick = (data, node) => { +const handleNodeClick = (data) => { if (data.level === 3) { formData.value.pointNames = data.id formData.value.pointNamesVo = data.name