【修改】 wps-word,pptx出题页面BUG修改

This commit is contained in:
DESKTOP-932OMT8\REN
2025-06-04 14:47:07 +08:00
parent 0762b9549f
commit cffa67bf95
2 changed files with 253 additions and 31 deletions

View File

@@ -30,10 +30,13 @@
</el-col>
<el-col :span="12">
<el-form-item label="题型难度" prop="quLevel">
<el-select v-model="formData.quLevel" placeholder="请选择题型难度" clearable>
<el-option label="简单" :value="'0'" />
<el-option label="一般" :value="'1'" />
<el-option label="困难" :value="'2'" />
<el-select v-model="formData.quLevel" placeholder="请选择题型难度">
<el-option
v-for="dict in getStrDictOptions(DICT_TYPE.EXAM_QUE_DIFF)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
</el-col>
@@ -63,6 +66,18 @@
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="审核状态" prop="audit">
<el-select v-model="formData.audit" placeholder="请选择审核状态">
<el-option
v-for="dict in getStrDictOptions(DICT_TYPE.QUESTION_AUDIT)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div class="edit-bottom">
@@ -92,8 +107,15 @@
@selection-change="handleSelectionChange"
>
<!-- <el-table-column type="selection" width="55" /> -->
<el-table-column label="考点" align="center" prop="contentIn" />
<el-table-column label="权值" align="center" prop="scoreRate" />
<el-table-column label="考点" align="center" prop="contentIn" width="360px"/>
<el-table-column label="权值" align="center" prop="scoreRate" width="100px"/>
<el-table-column label="操作" align="center" width="100px">
<template #default="scope">
<el-button type="primary" link @click="handleDelete(scope.row)">
<Icon icon="ep:delete" />删除
</el-button>
</template>
</el-table-column>
</el-table>
</div>
</el-tab-pane>
@@ -181,9 +203,29 @@
</el-table-column>
<el-table-column label="操作" width="150">
<template #default="scope">
<el-button type="primary" plain @click="openForm(scope.row.fileType)">
<el-button
type="primary"
plain
@click="openForm(scope.row.fileType)"
size="small"
>
<Icon icon="ep:upload" class="mr-5px" /> 上传
</el-button>
<el-button
type="success"
plain
@click="downloadFile(scope.row.url)"
size="small"
>
<Icon icon="ep:download" class="mr-5px" /> 下载
</el-button>
<el-button
type="danger"
plain
@click="deleteUrl(scope.$index)"
size="small"
><Icon icon="ep:download" class="mr-5px" />删除
</el-button>
</template>
</el-table-column>
</el-table>
@@ -227,7 +269,7 @@
</el-dialog>
</template>
<script lang="ts" setup>
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import { DICT_TYPE, getIntDictOptions, getStrDictOptions } from '@/utils/dict'
import { FormRules } from 'element-plus'
import * as QuestionApi from '@/api/paper/question'
import * as WordApi from '@/api/wps/word'
@@ -306,6 +348,14 @@ const pptxPoints = ref({
})
let pptxPointsInfosList: (typeof pptxPoints)[] = []
const handleDelete = (row) => {
for (let i = 0; i < list.value.length; i++) {
if (row.content == list.value[i].content) {
list.value.splice(i, 1)
}
}
}
function fileTypeFormatter(row, column, cellValue) {
if (cellValue === '0') return '素材文件(上传ZIP)'
if (cellValue === '1') return '考试文件'
@@ -363,11 +413,17 @@ const handleCheckChange = (data: Tree, checked: boolean, indeterminate: boolean)
}
const addPptxInfo = async () => {
var filePath = ''
for (var i = 0; i < documentList.value.length; i++) {
if (documentList.value[i].fileType == '2') {
filePath = documentList.value[i].url
}
}
// http://115.120.213.238:9000/exam/9f7d8f5d7c68cc2bfd03a23c19045efe7ba13a4bebeb833abece146908bcd0c6.docx documentList.value[1].url
if (documentList.value[2].url == '' || documentList.value[2].url == null) {
if (filePath == '' || filePath == null) {
return
}
const res = await PptxApi.getPptxInfo(documentList.value[2].url)
const res = await PptxApi.getPptxInfo(filePath)
pptxPointsList.value = []
pptxPointsList.value.push(...handleTree(res))
dialogFormVisiblePptxInfo.value = true
@@ -400,11 +456,21 @@ const submitPptxPoints = async () => {
const res = await PptxApi.getPptxListInfos(pptxPointsInfosList)
pptxPointsInfosList = []
console.log(list.value)
var indexFlag = false
for (let i = 0; i < res.length; i++) {
list.value.push(res[i])
for (let x = 0; x < list.value.length; x++) {
if (res[i].content == list.value[x].content) {
// 如果存在相同的数据话 不进入
indexFlag = true
}
}
if (!indexFlag) {
list.value.push(res[i])
}
}
dialogFormVisiblePptxInfo.value = false
dialogFormVisiblePptxInfos.value = false
pptxPointsList.value = []
}
const formRules = reactive<FormRules>({
status: [{ required: true, message: '启用状态必填', trigger: 'blur' }]
@@ -501,7 +567,42 @@ const submitForm = async () => {
formLoading.value = false
}
}
const downloadFile = async (url: string) => {
if (!url) {
ElMessage.warning('暂无可下载的文件地址')
return
}
try {
const response = await fetch(url)
if (!response.ok) {
throw new Error('下载失败')
}
const blob = await response.blob()
const blobUrl = window.URL.createObjectURL(blob)
// 提取文件名
const filename = url.substring(url.lastIndexOf('/') + 1).split('?')[0]
// 创建 a 标签并下载
const a = document.createElement('a')
a.href = blobUrl
a.download = filename
a.style.display = 'none'
document.body.appendChild(a)
a.click()
a.remove()
window.URL.revokeObjectURL(blobUrl)
} catch (err: any) {
ElMessage.error(`下载失败:${err.message}`)
}
}
const deleteUrl = (index: number) => {
formData.value.fileUploads[index].url = ''
formData.value.fileUploads[index].fileName = ''
}
/** 重置表单 */
const resetForm = () => {
formData.value = {
@@ -567,6 +668,7 @@ const resetForm = () => {
fileName: ''
}
]
list.value = []
formRef.value?.resetFields()
}
</script>

View File

@@ -30,10 +30,18 @@
</el-col>
<el-col :span="12">
<el-form-item label="题型难度" prop="quLevel">
<el-select v-model="formData.quLevel" placeholder="请选择题型难度" clearable>
<!-- <el-select v-model="formData.quLevel" placeholder="请选择题型难度" clearable>
<el-option label="简单" :value="'0'" />
<el-option label="一般" :value="'1'" />
<el-option label="困难" :value="'2'" />
</el-select> -->
<el-select v-model="formData.quLevel" placeholder="请选择题型难度">
<el-option
v-for="dict in getStrDictOptions(DICT_TYPE.EXAM_QUE_DIFF)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
</el-col>
@@ -63,6 +71,18 @@
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="审核状态" prop="audit">
<el-select v-model="formData.audit" placeholder="请选择审核状态">
<el-option
v-for="dict in getStrDictOptions(DICT_TYPE.QUESTION_AUDIT)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div class="edit-bottom">
@@ -82,8 +102,24 @@
<Editor v-model="formData.analysis" height="150px" />
</div>
</el-tab-pane>
<el-tab-pane label="试题考点" name="answer">
<el-button @click="addWordInfo">新增</el-button>
<el-tab-pane name="answer">
<template #label>
<div class="custom-tabs-label">
<p>试题考点</p>
<el-dropdown>
<span class="el-dropdown-link" @click.stop="false">
<div class="setting_icon"></div>
</span>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item>
<el-button @click="addWordInfo">添加</el-button>
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</div>
</template>
<!-- <el-button type="danger">删除</el-button> -->
<div class="block">
<el-table
@@ -92,8 +128,15 @@
@selection-change="handleSelectionChange"
>
<!-- <el-table-column type="selection" width="55" /> -->
<el-table-column label="考点" align="center" prop="contentIn" />
<el-table-column label="权值" align="center" prop="scoreRate" />
<el-table-column label="考点" align="center" prop="contentIn" width="360px" />
<el-table-column label="权值" align="center" prop="scoreRate" width="100px" />
<el-table-column label="操作" align="center" width="100px">
<template #default="scope">
<el-button type="primary" link @click="handleDelete(scope.row)">
<Icon icon="ep:delete" />删除
</el-button>
</template>
</el-table-column>
</el-table>
</div>
</el-tab-pane>
@@ -181,9 +224,29 @@
</el-table-column>
<el-table-column label="操作" width="150">
<template #default="scope">
<el-button type="primary" plain @click="openForm(scope.row.fileType)">
<el-button
type="primary"
plain
@click="openForm(scope.row.fileType)"
size="small"
>
<Icon icon="ep:upload" class="mr-5px" /> 上传
</el-button>
<el-button
type="success"
plain
@click="downloadFile(scope.row.url)"
size="small"
>
<Icon icon="ep:download" class="mr-5px" /> 下载
</el-button>
<el-button
type="danger"
plain
@click="deleteUrl(scope.$index)"
size="small"
><Icon icon="ep:download" class="mr-5px" />删除
</el-button>
</template>
</el-table-column>
</el-table>
@@ -202,7 +265,8 @@
</div>
<!-- 表单弹窗添加/修改 -->
<FileForm ref="FileRef" @success="handleUploadSuccess" />
<el-dialog v-model="dialogFormVisibleWordInfo" title="考点设置" width="400px">
<el-dialog v-model="dialogFormVisibleWordInfo" title="考点设置*暂不支持多选)" width="400px">
<el-skeleton :rows="5" animated v-if="wordPointsList.length < 0 && isLoading" />
<el-tree
style="max-width: 600px"
:data="wordPointsList"
@@ -227,7 +291,7 @@
</el-dialog>
</template>
<script lang="ts" setup>
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import { DICT_TYPE, getIntDictOptions, getStrDictOptions } from '@/utils/dict'
import { FormRules } from 'element-plus'
import * as QuestionApi from '@/api/paper/question'
import * as WordApi from '@/api/wps/word'
@@ -246,6 +310,7 @@ const { t } = useI18n() // 国际化
const message = useMessage() // 消息弹窗
const loading = ref(false) // 列表的加载中
const dialogVisible = ref(false) // 弹窗的是否展示
const isLoading = ref(false)
const dialogTitle = ref('') // 弹窗的标题
const formLoading = ref(false) // 表单的加载中1修改时的数据加载2提交的按钮禁用
const formType = ref('') // 表单的类型create - 新增update - 修改
@@ -371,25 +436,26 @@ const handleCheckChange = (data: Tree, checked: boolean, indeterminate: boolean)
}
const addWordInfo = async () => {
var filePath = ''
for (var i = 0; i < documentList.value.length; i++) {
if (documentList.value[i].fileType == '2') {
filePath = documentList.value[i].url
}
}
// http://115.120.213.238:9000/exam/9f7d8f5d7c68cc2bfd03a23c19045efe7ba13a4bebeb833abece146908bcd0c6.docx documentList.value[1].url
if (documentList.value[2].url == '' || documentList.value[2].url == null) {
if (filePath == '' || filePath == null) {
return
}
const res = await WordApi.getWordInfo(documentList.value[2].url)
dialogFormVisibleWordInfo.value = true
isLoading.value = true
const res = await WordApi.getWordInfo(filePath)
isLoading.value = false
wordPointsList.value = []
wordPointsList.value.push(...handleTree(res))
dialogFormVisibleWordInfo.value = true
}
const queryParams = reactive({
nodeFunction: undefined
})
const handleSpecialtyNodeClick = async (row: any) => {
titles.value = row.name
englishName.value = row.englishName
filePath.value = row.filePath
nodeFunction.value = row.selectName
dialogFormVisibleWordInfos.value = true
}
const handleNodelClick = async (row: any) => {
queryParams.nodeFunction = row.selectName
@@ -402,6 +468,15 @@ const handleNodelClick = async (row: any) => {
wordPointsInfoList.value.push(...handleTree(res))
dialogFormVisibleWordInfos.value = true
}
const handleDelete = (row) => {
console.log(row)
for (let i = 0; i < list.value.length; i++) {
if (row.content == list.value[i].content) {
list.value.splice(i, 1)
}
}
}
const submitWordPoints = async () => {
wordPointsInfosList.push(wordPoints.value)
const res = await WordApi.getWordListInfos(wordPointsInfosList)
@@ -416,12 +491,21 @@ const submitWordPoints = async () => {
function: []
}
wordPointsInfosList = []
console.log(list.value)
for (let i = 0; i < res.length; i++) {
list.value.push(res[i])
var indexFlag = false
for (let x = 0; x < list.value.length; x++) {
if (res[i].content == list.value[x].content) {
// 如果存在相同的数据话 不进入
indexFlag = true
}
}
if (!indexFlag) {
list.value.push(res[i])
}
}
dialogFormVisibleWordInfo.value = false
dialogFormVisibleWordInfos.value = false
wordPointsList.value = []
}
const formRules = reactive<FormRules>({
status: [{ required: true, message: '启用状态必填', trigger: 'blur' }]
@@ -450,7 +534,42 @@ const FileRef = ref()
const openForm = (type: string) => {
FileRef.value.open(type)
}
const downloadFile = async (url: string) => {
if (!url) {
ElMessage.warning('暂无可下载的文件地址')
return
}
try {
const response = await fetch(url)
if (!response.ok) {
throw new Error('下载失败')
}
const blob = await response.blob()
const blobUrl = window.URL.createObjectURL(blob)
// 提取文件名
const filename = url.substring(url.lastIndexOf('/') + 1).split('?')[0]
// 创建 a 标签并下载
const a = document.createElement('a')
a.href = blobUrl
a.download = filename
a.style.display = 'none'
document.body.appendChild(a)
a.click()
a.remove()
window.URL.revokeObjectURL(blobUrl)
} catch (err: any) {
ElMessage.error(`下载失败:${err.message}`)
}
}
const deleteUrl = (index: number) => {
formData.value.fileUploads[index].url = ''
formData.value.fileUploads[index].fileName = ''
}
// 媒体文件
const mediumList = ref([] as any)
const multipleMediumSelection = ref([] as any)
@@ -602,6 +721,7 @@ const resetForm = () => {
fileName: ''
}
]
list.value = []
formRef.value?.resetFields()
}
</script>