【修改】 pptx出题页面,还有关联页面更新
This commit is contained in:
@@ -38,18 +38,17 @@ export const deletePptx = async (id: number) => {
|
|||||||
return await request.delete({ url: '/exam/pptx/delete?id=' + id })
|
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查询出来下面所有的数据
|
// 查询Word节点列表(小类) 根据title查询出来下面所有的数据
|
||||||
export const getPptxInfos = async (title: string) => {
|
export const getPptxByNameList = async (title: string) => {
|
||||||
console.log(title)
|
console.log(title)
|
||||||
return await request.get({ url: '/exam/pptx/getByNameList?title=' + title })
|
return await request.get({ url: '/exam/pptx/getByNameList?title=' + title })
|
||||||
}
|
}
|
||||||
|
|
||||||
// // 获取Pptx考点()
|
// 上传文件
|
||||||
export const getPptxListInfos = async (data: any) => {
|
export const getSlideDataInfo = (data: any) => {
|
||||||
return await request.post({ url: '/tool/wps/runTestpptx' , data })
|
return request.upload({ url: '/auto/wps/slideDataInfo', data })
|
||||||
|
}
|
||||||
|
// 获取考点
|
||||||
|
export const getslideMaster = (data: any) => {
|
||||||
|
return request.upload({ url: '/auto/wps/slideMaster', data })
|
||||||
}
|
}
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
<el-input v-model="formData.specialtyName" placeholder="请输入专业" disabled />
|
<el-input v-model="formData.specialtyName" placeholder="请输入专业" disabled />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="章节名称" prop="chapteridDictText">
|
<el-form-item label="章节名称" prop="chapteridDictText">
|
||||||
<el-input
|
<el-input
|
||||||
@@ -125,7 +126,7 @@
|
|||||||
<template #dropdown>
|
<template #dropdown>
|
||||||
<el-dropdown-menu>
|
<el-dropdown-menu>
|
||||||
<el-dropdown-item>
|
<el-dropdown-item>
|
||||||
<el-button @click="addPptxInfo">添加</el-button>
|
<el-button @click="addPptxForm">添加</el-button>
|
||||||
</el-dropdown-item>
|
</el-dropdown-item>
|
||||||
</el-dropdown-menu>
|
</el-dropdown-menu>
|
||||||
</template>
|
</template>
|
||||||
@@ -278,16 +279,9 @@
|
|||||||
<!-- 表单弹窗:添加/修改 -->
|
<!-- 表单弹窗:添加/修改 -->
|
||||||
<FileForm ref="FileRef" @success="handleUploadSuccess" />
|
<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%">
|
<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="height: 400px; overflow: hidden; display: flex; gap: 16px">
|
||||||
<div style="flex: 0.5; overflow: auto; border: 1px solid #eee; padding: 8px">
|
<div style="flex: 0.5; overflow: auto; border: 1px solid #eee; padding: 8px">
|
||||||
<h3>考点</h3>
|
<h3>考点</h3>
|
||||||
@@ -301,7 +295,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style="flex: 1.5; overflow: auto; border: 1px solid #eee; padding: 8px">
|
<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 :data="list" style="width: 100%">
|
||||||
<el-table-column prop="contentIn" label="值" width="500px" />
|
<el-table-column prop="contentIn" label="值" width="500px" />
|
||||||
|
|
||||||
@@ -325,7 +319,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</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>
|
||||||
<el-dialog v-model="dialogFormVisiblePptxInfos" :title="titles" width="300px">
|
<el-dialog v-model="dialogFormVisiblePptxInfos" :title="titles" width="300px">
|
||||||
@@ -344,16 +338,15 @@
|
|||||||
</el-dialog>
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<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 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 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' })
|
defineOptions({ name: 'WpsPptxFrom' })
|
||||||
const pptxPointsList = ref<Tree[]>([]) // 树形结构
|
const pptxPointsList = ref<Tree[]>([]) // 树形结构
|
||||||
const pptxPointsInfoList = 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)[] = []
|
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) => {
|
const removePoint = (index: number) => {
|
||||||
list.value.splice(index, 1)
|
list.value.splice(index, 1)
|
||||||
}
|
}
|
||||||
@@ -467,101 +436,118 @@ const documentList = ref([
|
|||||||
])
|
])
|
||||||
const dialogFormVisiblePptxInfo = ref(false)
|
const dialogFormVisiblePptxInfo = ref(false)
|
||||||
const dialogFormVisiblePptxInfos = ref(false)
|
const dialogFormVisiblePptxInfos = ref(false)
|
||||||
const nodeFunction = ref('')
|
|
||||||
const titles = ref('')
|
const titles = ref('')
|
||||||
const englishName = ref('')
|
|
||||||
const filePath = 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) => {
|
const handleCheckChange = (data: Tree, checked: boolean, indeterminate: boolean) => {
|
||||||
if (data.titleType == '2') {
|
console.log(data)
|
||||||
pptxPoints.value.chineseName = chineseName.value + data.chineseName
|
const pptxPoints = {
|
||||||
pptxPoints.value.fileNama = englishNames.value
|
firstName: '',
|
||||||
pptxPoints.value.paragraph = paragraph.value
|
index: '',
|
||||||
pptxPoints.value.title = data.title
|
function: '',
|
||||||
pptxPoints.value.valueList = data.valueList
|
examName: '',
|
||||||
pptxPoints.value.type = data.dataType
|
examCode: ''
|
||||||
pptxPoints.value.isText = data.isText
|
}
|
||||||
pptxPoints.value.isTrue = data.isTrue
|
if (data.functions != null && data.functions != "") {
|
||||||
pptxPoints.value.isParameter = data.isParameter
|
pptxPoints.firstName = chineseName.value
|
||||||
pptxPoints.value.path = filePath.value
|
pptxPoints.index = textIndex.value
|
||||||
pptxPointsInfosList.push(cloneDeep(pptxPoints.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 = ''
|
const addPptxForm = async () => {
|
||||||
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))
|
|
||||||
}
|
|
||||||
dialogFormVisiblePptxInfo.value = true
|
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) => {
|
const handleNodelClick = async (row: any) => {
|
||||||
chineseName.value = '【' + row.name + '】'
|
|
||||||
filePath.value = row.filePath
|
|
||||||
paragraph.value = row.selectName
|
|
||||||
englishNames.value = row.englishName
|
|
||||||
console.log(row)
|
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 = []
|
||||||
pptxPointsInfoList.value.push(...handleTree(res))
|
pptxPointsInfoList.value.push(...handleTree(res))
|
||||||
dialogFormVisiblePptxInfos.value = true
|
dialogFormVisiblePptxInfos.value = true
|
||||||
}
|
}
|
||||||
const submitPptxPoints = async () => {
|
const handleDelete = (row) => {
|
||||||
const res = await PptxApi.getPptxListInfos(pptxPointsInfosList)
|
console.log(row)
|
||||||
pptxPointsInfosList = []
|
for (let i = 0; i < list.value.length; i++) {
|
||||||
console.log(list.value)
|
if (row.content == list.value[i].content) {
|
||||||
var indexFlag = false
|
list.value.splice(i, 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const submitPptxPoints = async () => {
|
||||||
|
console.log(pptxPointsInfosList)
|
||||||
|
const res = await PptxApi.getSlideMaster({
|
||||||
|
data: JSON.stringify(pptxPointsInfosList),
|
||||||
|
file: file.value
|
||||||
|
})
|
||||||
|
pptxPointsInfosList = []
|
||||||
console.log(res)
|
console.log(res)
|
||||||
if (res != null) {
|
for (let i = 0; i < res.data.length; i++) {
|
||||||
for (let i = 0; i < res.length; i++) {
|
var indexFlag = false
|
||||||
for (let x = 0; x < list.value.length; x++) {
|
for (let x = 0; x < list.value.length; x++) {
|
||||||
if (res[i].contentIn == list.value[x].contentIn) {
|
if (res.data[i].content == list.value[x].content) {
|
||||||
// 如果存在相同的数据话 不进入
|
// 如果存在相同的数据话 不进入
|
||||||
indexFlag = true
|
indexFlag = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!indexFlag) {
|
if (!indexFlag) {
|
||||||
// 排序,使用已经存在考点的数组的长度+1
|
res.data[i].sort = list.value.length + 1
|
||||||
res[i].sort = list.value.length + 1
|
list.value.push(res.data[i])
|
||||||
list.value.push(res[i])
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
// pptxPoints.value = {
|
||||||
|
// name: '',
|
||||||
// dialogFormVisiblePptxInfo.value = false
|
// 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
|
dialogFormVisiblePptxInfos.value = false
|
||||||
// pptxPointsList.value = []
|
// pptxPointsList.value = []
|
||||||
}
|
}
|
||||||
@@ -576,7 +562,7 @@ const rightActiveName = ref('annex')
|
|||||||
const rightHandleClick = (tab, e) => {
|
const rightHandleClick = (tab, e) => {
|
||||||
rightActiveName.value = tab.paneName.value
|
rightActiveName.value = tab.paneName.value
|
||||||
}
|
}
|
||||||
// 关键字
|
|
||||||
const selections = ref([])
|
const selections = ref([])
|
||||||
const handleSelectionChange = (rows) => {
|
const handleSelectionChange = (rows) => {
|
||||||
selections.value = rows
|
selections.value = rows
|
||||||
@@ -587,79 +573,6 @@ const FileRef = ref()
|
|||||||
const openForm = (type: string) => {
|
const openForm = (type: string) => {
|
||||||
FileRef.value.open(type)
|
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) => {
|
const downloadFile = async (url: string) => {
|
||||||
if (!url) {
|
if (!url) {
|
||||||
ElMessage.warning('暂无可下载的文件地址')
|
ElMessage.warning('暂无可下载的文件地址')
|
||||||
@@ -696,6 +609,94 @@ const deleteUrl = (index: number) => {
|
|||||||
formData.value.fileUploads[index].url = ''
|
formData.value.fileUploads[index].url = ''
|
||||||
formData.value.fileUploads[index].fileName = ''
|
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 = () => {
|
const resetForm = () => {
|
||||||
formData.value = {
|
formData.value = {
|
||||||
|
@@ -562,16 +562,10 @@ const rightActiveName = ref('annex')
|
|||||||
const rightHandleClick = (tab, e) => {
|
const rightHandleClick = (tab, e) => {
|
||||||
rightActiveName.value = tab.paneName.value
|
rightActiveName.value = tab.paneName.value
|
||||||
}
|
}
|
||||||
// 关键字
|
|
||||||
const multipleKeywordSelection = ref([] as any)
|
|
||||||
const handleKeywordSelectionChange = (val: any) => {
|
|
||||||
multipleKeywordSelection.value = val
|
|
||||||
}
|
|
||||||
const selections = ref([])
|
const selections = ref([])
|
||||||
const handleSelectionChange = (rows) => {
|
const handleSelectionChange = (rows) => {
|
||||||
selections.value = rows
|
selections.value = rows
|
||||||
}
|
}
|
||||||
const keyWord = ref([null])
|
|
||||||
|
|
||||||
/** 添加/修改操作 */
|
/** 添加/修改操作 */
|
||||||
const FileRef = ref()
|
const FileRef = ref()
|
||||||
|
Reference in New Issue
Block a user