【修改】 pptx出题页面,还有关联页面更新

This commit is contained in:
dlaren
2025-08-06 14:52:17 +08:00
committed by 陆光LG
parent 0579d2ace7
commit 692a6b19e2
4 changed files with 205 additions and 211 deletions

View File

@@ -38,18 +38,17 @@ export const deletePptx = async (id: number) => {
return await request.delete({ url: '/exam/pptx/delete?id=' + id })
}
// // 获取Word考点大类
export const getPptxInfo = async (path: String) => {
return await request.get({ url: '/tool/wps/runWpsPptx?path=' + path })
}
// 查询Word节点列表(小类) 根据title查询出来下面所有的数据
export const getPptxInfos = async (title: string) => {
export const getPptxByNameList = async (title: string) => {
console.log(title)
return await request.get({ url: '/exam/pptx/getByNameList?title=' + title })
}
// // 获取Pptx考点
export const getPptxListInfos = async (data: any) => {
return await request.post({ url: '/tool/wps/runTestpptx' , data })
// 上传文件
export const getSlideDataInfo = (data: any) => {
return request.upload({ url: '/auto/wps/slideDataInfo', data })
}
// 获取考点
export const getslideMaster = (data: any) => {
return request.upload({ url: '/auto/wps/slideMaster', data })
}

View File

@@ -900,4 +900,4 @@ const handleTreeWithLevel = (list, level = 1) => {
}
}
}
</style>
</style>

View File

@@ -16,6 +16,7 @@
<el-input v-model="formData.specialtyName" placeholder="请输入专业" disabled />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="章节名称" prop="chapteridDictText">
<el-input
@@ -125,7 +126,7 @@
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item>
<el-button @click="addPptxInfo">添加</el-button>
<el-button @click="addPptxForm">添加</el-button>
</el-dropdown-item>
</el-dropdown-menu>
</template>
@@ -278,16 +279,9 @@
<!-- 表单弹窗添加/修改 -->
<FileForm ref="FileRef" @success="handleUploadSuccess" />
<!-- <el-dialog v-model="dialogFormVisiblePptxInfo" title="考点设置" width="400px">
<el-tree
style="max-width: 600px"
:data="pptxPointsList"
:props="defaultProps"
:expand-on-click-node="false"
@node-click="handleNodelClick"
/>
</el-dialog> -->
<el-dialog v-model="dialogFormVisiblePptxInfo" title="考点设置" width="70%">
<input type="file" id="slideFile" accept=".pptx" />
<button @click="getSlideDataInfo">文件解析</button>
<div style="height: 400px; overflow: hidden; display: flex; gap: 16px">
<div style="flex: 0.5; overflow: auto; border: 1px solid #eee; padding: 8px">
<h3>考点</h3>
@@ -301,11 +295,11 @@
</div>
<div style="flex: 1.5; overflow: auto; border: 1px solid #eee; padding: 8px">
<h3>设置考点</h3>
<h3>考点详情</h3>
<el-table :data="list" style="width: 100%">
<el-table-column prop="contentIn" label="值" width="500px" />
<el-table-column prop="scoreRate" label="权值" width="100">
<el-table-column prop="scoreRate" label="权值" width="100">
<template #default="{ row }">
<el-input v-model="row.scoreRate" size="small" style="width: 40px" />
</template>
@@ -325,7 +319,7 @@
</div>
</div>
<!-- <el-skeleton :rows="5" animated v-if="wordPointsList.length < 0 && isLoading" />
<!-- <el-skeleton :rows="5" animated v-if="pptxPointsList.length < 0 && isLoading" />
-->
</el-dialog>
<el-dialog v-model="dialogFormVisiblePptxInfos" :title="titles" width="300px">
@@ -344,16 +338,15 @@
</el-dialog>
</template>
<script lang="ts" setup>
import draggable from 'vuedraggable'
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'
import * as PptxApi from '@/api/wps/pptx'
import FileForm from './components/FileForm.vue'
import { defaultProps, handleTree } from '@/utils/tree'
import { cloneDeep } from 'lodash-es'
import * as SpecialtyApi from '@/api/points'
import * as PptxApi from '@/api/wps/pptx'
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import { defaultProps, handleTree } from '@/utils/tree'
import { FormRules } from 'element-plus'
import { cloneDeep } from 'lodash-es'
import FileForm from './components/FileForm.vue'
defineOptions({ name: 'WpsPptxFrom' })
const pptxPointsList = ref<Tree[]>([]) // 树形结构
const pptxPointsInfoList = ref<Tree[]>([]) // 树形结构
@@ -410,32 +403,8 @@ const formData = ref({
}
]
})
const pptxPointsFun = ref({
chineseName: '',
function: ''
})
const pptxPoints = ref({
fileNama: '',
chineseName: '',
paragraph: '',
title: '',
valueList: '',
type: '',
isText: '',
isTrue: '',
isParameter: ''
})
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)
}
}
}
const removePoint = (index: number) => {
list.value.splice(index, 1)
}
@@ -467,101 +436,118 @@ const documentList = ref([
])
const dialogFormVisiblePptxInfo = ref(false)
const dialogFormVisiblePptxInfos = ref(false)
const nodeFunction = ref('')
const titles = ref('')
const englishName = ref('')
const filePath = ref('')
const upFilePath = ref('')
const functionList = ref<string[]>([])
const pptxData = reactive({
chineseName: '',
englishName: '',
filePath: '',
function: [] as string[]
})
const handleCheckChange = (data: Tree, checked: boolean, indeterminate: boolean) => {
if (data.titleType == '2') {
pptxPoints.value.chineseName = chineseName.value + data.chineseName
pptxPoints.value.fileNama = englishNames.value
pptxPoints.value.paragraph = paragraph.value
pptxPoints.value.title = data.title
pptxPoints.value.valueList = data.valueList
pptxPoints.value.type = data.dataType
pptxPoints.value.isText = data.isText
pptxPoints.value.isTrue = data.isTrue
pptxPoints.value.isParameter = data.isParameter
pptxPoints.value.path = filePath.value
pptxPointsInfosList.push(cloneDeep(pptxPoints.value))
console.log(data)
const pptxPoints = {
firstName: '',
index: '',
function: '',
examName: '',
examCode: ''
}
if (data.functions != null && data.functions != "") {
pptxPoints.firstName = chineseName.value
pptxPoints.index = textIndex.value
pptxPoints.function = data.functions
pptxPoints.examName = data.chineseName
pptxPoints.examCode = '111'
pptxPoints.method = data.parameter
pptxPointsInfosList.push(cloneDeep(pptxPoints))
}
}
const file = ref()
// 获取slide文件并使用文件流进行解析
const getSlideDataInfo = async () => {
const fileInput = document.getElementById('slideFile') as HTMLInputElement
if (fileInput != null) {
file.value = fileInput.files[0]
const res = await PptxApi.getSlideDataInfo({ file: file.value })
pptxPointsList.value = []
pptxPointsList.value.push(...handleTree(res.data))
}
console.log(data, checked, indeterminate)
}
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 (filePath == '' || filePath == null) {
return
}
if (pptxPointsList.value.length <= 0) {
const res = await PptxApi.getPptxInfo(filePath)
pptxPointsList.value = []
pptxPointsList.value.push(...handleTree(res))
}
// 打开考点窗口
const addPptxForm = async () => {
dialogFormVisiblePptxInfo.value = true
}
const handleSpecialtyNodeClick = async (row: any) => {
titles.value = row.name
englishName.value = row.englishName
filePath.value = row.filePath
nodeFunction.value = row.selectName
dialogFormVisiblePptxInfos.value = true
}
const chineseName = ref('')
const paragraph = ref('')
const englishNames = ref('')
const queryParams = reactive({
nodeFunction: undefined
})
const chineseName = ref('')
const textIndex = ref()
// 打开
const handleNodelClick = async (row: any) => {
chineseName.value = '【' + row.name + '】'
filePath.value = row.filePath
paragraph.value = row.selectName
englishNames.value = row.englishName
console.log(row)
const res = await PptxApi.getPptxInfos(row.title)
// 获取名称
chineseName.value = '【' + row.name + '】'
textIndex.value = row.index
const res = await PptxApi.getSlideByNameList(row.type)
pptxPointsInfoList.value = []
pptxPointsInfoList.value.push(...handleTree(res))
dialogFormVisiblePptxInfos.value = true
}
const submitPptxPoints = async () => {
const res = await PptxApi.getPptxListInfos(pptxPointsInfosList)
pptxPointsInfosList = []
console.log(list.value)
var indexFlag = false
console.log(res)
if (res != null) {
for (let i = 0; i < res.length; i++) {
for (let x = 0; x < list.value.length; x++) {
if (res[i].contentIn == list.value[x].contentIn) {
// 如果存在相同的数据话 不进入
indexFlag = true
}
}
if (!indexFlag) {
// 排序,使用已经存在考点的数组的长度+1
res[i].sort = list.value.length + 1
list.value.push(res[i])
}
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)
}
}
}
// dialogFormVisiblePptxInfo.value = false
const submitPptxPoints = async () => {
console.log(pptxPointsInfosList)
const res = await PptxApi.getSlideMaster({
data: JSON.stringify(pptxPointsInfosList),
file: file.value
})
pptxPointsInfosList = []
console.log(res)
for (let i = 0; i < res.data.length; i++) {
var indexFlag = false
for (let x = 0; x < list.value.length; x++) {
if (res.data[i].content == list.value[x].content) {
// 如果存在相同的数据话 不进入
indexFlag = true
}
}
if (!indexFlag) {
res.data[i].sort = list.value.length + 1
list.value.push(res.data[i])
}
}
// pptxPoints.value = {
// name: '',
// englishName: '',
// filePath: '',
// type: '',
// belongTo: '',
// isboo: '',
// function: '',
// unit: '',
// isExam: ''
// }
// pptxPointsInfosList = []
// for (let i = 0; i < res.length; 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) {
// res[i].sort = list.value.length + 1
// list.value.push(res[i])
// }
// }
// // dialogFormVisiblePptxInfo.value = false
dialogFormVisiblePptxInfos.value = false
// pptxPointsList.value = []
}
@@ -576,7 +562,7 @@ const rightActiveName = ref('annex')
const rightHandleClick = (tab, e) => {
rightActiveName.value = tab.paneName.value
}
// 关键字
const selections = ref([])
const handleSelectionChange = (rows) => {
selections.value = rows
@@ -587,79 +573,6 @@ const FileRef = ref()
const openForm = (type: string) => {
FileRef.value.open(type)
}
// 媒体文件
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
}
const handleUploadSuccess = ({ url, fileType }) => {
const index = documentList.value.findIndex((item) => item.fileType === fileType)
if (index !== -1) {
documentList.value[index].url = url
}
}
/** 打开弹窗 */
const open = async (queryParams: any, type: string, id?: number) => {
dialogVisible.value = true
dialogTitle.value = t('action.' + type)
formType.value = type
// 修改时,设置数据
if (id) {
formLoading.value = true
try {
const res = await QuestionApi.getQuestion(id)
formData.value = res
list.value = formData.value.answerList
documentList.value = res.fileUploads
} finally {
formLoading.value = false
}
} else {
resetForm()
formData.value.specialtyName = queryParams.specialtyName
formData.value.courseName = queryParams.courseName
formData.value.subjectName = queryParams.subjectName
formData.value.pointNames = queryParams.pointNames
formData.value.chapteridDictText = queryParams.chapteridDictText
}
}
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
/** 提交表单 */
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
const submitForm = async () => {
formData.value.answerList = list.value
formData.value.fileUploads = documentList.value
// 校验表单
if (!formRef) return
const valid = await formRef.value.validate()
if (!valid) return
// 提交请求
formLoading.value = true
try {
const data = formData.value as unknown
if (formType.value === 'create') {
await QuestionApi.addQuestion(data)
message.success(t('common.createSuccess'))
} else {
await QuestionApi.editQuestion(data)
message.success(t('common.updateSuccess'))
}
dialogVisible.value = false
// 发送操作成功的事件
emit('success')
} finally {
formLoading.value = false
}
}
const downloadFile = async (url: string) => {
if (!url) {
ElMessage.warning('暂无可下载的文件地址')
@@ -696,6 +609,94 @@ const deleteUrl = (index: number) => {
formData.value.fileUploads[index].url = ''
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
}
const handleUploadSuccess = ({ url, fileType }) => {
const index = documentList.value.findIndex((item) => item.fileType === fileType)
if (index !== -1) {
documentList.value[index].url = url
}
}
/** 打开弹窗 */
const open = async (queryParams: any, type: string, id?: number) => {
dialogVisible.value = true
dialogTitle.value = t('action.' + type)
formType.value = type
// 修改时,设置数据
if (id) {
formLoading.value = true
try {
const res = await QuestionApi.getQuestion(id)
formData.value = res
console.log(formData.value)
list.value = formData.value.answerList
documentList.value = res.fileUploads
} finally {
formLoading.value = false
}
} else {
resetForm()
formData.value.specialtyName = queryParams.specialtyName
formData.value.courseName = queryParams.courseName
formData.value.subjectName = queryParams.subjectName
formData.value.pointNames = queryParams.pointNamesVo
formData.value.pointNamesVo = queryParams.pointNames
formData.value.chapteridDictText = queryParams.chapteridDictTextVo
formData.value.chapteridDictTextVo = queryParams.chapteridDictText
}
}
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 的字母'
}
})
/** 提交表单 */
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
const submitForm = async () => {
formData.value.answerList = list.value
formData.value.fileUploads = documentList.value
const values = Object.values(formData)
console.log(values)
// 校验表单
if (!formRef) return
const valid = await formRef.value.validate()
if (!valid) return
// 提交请求
formLoading.value = true
try {
const data = formData.value as unknown
if (formType.value === 'create') {
await QuestionApi.addQuestion(data)
message.success(t('common.createSuccess'))
} else {
await QuestionApi.editQuestion(data)
message.success(t('common.updateSuccess'))
}
dialogVisible.value = false
// 发送操作成功的事件
emit('success')
} finally {
formLoading.value = false
}
}
/** 重置表单 */
const resetForm = () => {
formData.value = {

View File

@@ -562,16 +562,10 @@ const rightActiveName = ref('annex')
const rightHandleClick = (tab, e) => {
rightActiveName.value = tab.paneName.value
}
// 关键字
const multipleKeywordSelection = ref([] as any)
const handleKeywordSelectionChange = (val: any) => {
multipleKeywordSelection.value = val
}
const selections = ref([])
const handleSelectionChange = (rows) => {
selections.value = rows
}
const keyWord = ref([null])
/** 添加/修改操作 */
const FileRef = ref()