fix: 添加c语言出题基本信息
This commit is contained in:
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@@ -87,7 +87,7 @@
|
|||||||
"source.fixAll.stylelint": "explicit"
|
"source.fixAll.stylelint": "explicit"
|
||||||
},
|
},
|
||||||
"[vue]": {
|
"[vue]": {
|
||||||
"editor.defaultFormatter": "octref.vetur"
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
},
|
},
|
||||||
"i18n-ally.localesPaths": ["src/locales"],
|
"i18n-ally.localesPaths": ["src/locales"],
|
||||||
"i18n-ally.keystyle": "nested",
|
"i18n-ally.keystyle": "nested",
|
||||||
|
@@ -171,3 +171,9 @@ export const setPsPoint = (data) => {
|
|||||||
export const getPsPointByQuId = (id) => {
|
export const getPsPointByQuId = (id) => {
|
||||||
return request.get({ url: `/exam/getPoints/getPsPointById/${id}` })
|
return request.get({ url: `/exam/getPoints/getPsPointById/${id}` })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const previewQuestion = (data) => {
|
||||||
|
return request.upload(
|
||||||
|
{ url: `/exam/question/previewQuestion`, data }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
@@ -18,7 +18,7 @@
|
|||||||
>
|
>
|
||||||
<template #image>
|
<template #image>
|
||||||
<img
|
<img
|
||||||
src="../../img/chrome_icon.png"
|
src="../../img/edge-new-fill.png"
|
||||||
style="width: 32px; height: 35px; margin-right: 12px"
|
style="width: 32px; height: 35px; margin-right: 12px"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
>
|
>
|
||||||
<template #image>
|
<template #image>
|
||||||
<img
|
<img
|
||||||
src="../../img/ie_icon.png"
|
src="../../img/import_icon.png"
|
||||||
style="width: 32px; height: 35px; margin-right: 12px"
|
style="width: 32px; height: 35px; margin-right: 12px"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
@@ -3,49 +3,144 @@
|
|||||||
<Dialog v-model="dialogVisible" :title="dialogTitle" width="70%" top="10vh">
|
<Dialog v-model="dialogVisible" :title="dialogTitle" width="70%" top="10vh">
|
||||||
<el-scrollbar height="600px">
|
<el-scrollbar height="600px">
|
||||||
<div class="main">
|
<div class="main">
|
||||||
|
<div class="tabsTip">
|
||||||
|
<el-icon><InfoFilled /></el-icon>C语言基础环境采用gcc编译器
|
||||||
|
</div>
|
||||||
<el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">
|
<el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">
|
||||||
<el-tab-pane label="基本内容" name="common">
|
<el-tab-pane label="基本内容" name="common">
|
||||||
|
<div class="line">
|
||||||
|
<div class="title-text">试题描述</div>
|
||||||
|
<ElInput v-model="inputText" style="width: 100%" />
|
||||||
|
</div>
|
||||||
<div class="line">
|
<div class="line">
|
||||||
<div class="title-text">试题题目</div>
|
<div class="title-text">试题题目</div>
|
||||||
|
<div class="buttons">
|
||||||
|
<ElButton type="primary" plain>
|
||||||
|
<el-icon><Document /></el-icon>
|
||||||
|
更换题目模板
|
||||||
|
</ElButton>
|
||||||
|
<ElButton type="primary" plain>
|
||||||
|
<el-icon><Search /></el-icon>
|
||||||
|
预览
|
||||||
|
</ElButton>
|
||||||
|
</div>
|
||||||
<div class="block">
|
<div class="block">
|
||||||
<Editor v-model="content" height="150px" />
|
<Editor v-model="content" height="150px" />
|
||||||
</div>
|
</div>
|
||||||
|
<div class="buttons">
|
||||||
|
<ElButton type="primary" plain>
|
||||||
|
<el-icon><Paperclip /></el-icon>
|
||||||
|
添加附件
|
||||||
|
</ElButton>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="line">
|
<div class="line">
|
||||||
<div class="title-text">答题程序模板</div>
|
<div class="title-text">答题程序模板</div>
|
||||||
<ElTextarea v-model="textarea" :rows="4" />
|
<div class="tips">
|
||||||
|
学生端答题的初始程序内容,学生可在此基础上进行程序的编写,插入作答区标记后关键字评分只在作答区内评分,否则关键字评分在整段代码评分。
|
||||||
|
注意: 为确保系统能正确捕获程序运行的输出结果,要求 scanf() 函数不能加参数,
|
||||||
|
不能采用类似 scanf("请输入: %s") 的形式
|
||||||
|
插入作答区标记后请在试题题目中明确告知学生不要自行更改作答区标记,以免无法正常评分。
|
||||||
</div>
|
</div>
|
||||||
<!-- <div class="line">
|
<ElTextarea v-model="formData.answer" :rows="4" />
|
||||||
<div class="title-text">基本信息</div>
|
<div class="tips"> 更改答题程序模板无效,若需要更改请上传程序文件。 </div>
|
||||||
<el-form
|
<div class="buttons">
|
||||||
label-width="80"
|
<ElButton type="primary" plain @click="openForm('1')">
|
||||||
:inline="false"
|
<el-icon><Upload /></el-icon>
|
||||||
:model="formData"
|
上传程序文件
|
||||||
class="demo-form-inline"
|
</ElButton>
|
||||||
|
<ElButton type="success" plain @click="openForm('2')">
|
||||||
|
<el-icon><Upload /></el-icon>
|
||||||
|
上传结果文件
|
||||||
|
</ElButton>
|
||||||
|
<el-tooltip
|
||||||
|
v-for="tag in formData.fileUploads.map((i) => i.url).filter((i) => i !== '')"
|
||||||
|
:key="tag"
|
||||||
|
content="点击下载"
|
||||||
|
placement="bottom"
|
||||||
>
|
>
|
||||||
<el-form-item label="知识点">
|
<el-tag
|
||||||
<el-input disabled placeholder="请输入知识点" size="large" />
|
:type="tagsType(formData.fileUploads.find((i) => i.url === tag)!.fileType)"
|
||||||
|
closable
|
||||||
|
:disable-transitions="false"
|
||||||
|
@close="
|
||||||
|
handleCloseTag(
|
||||||
|
tag,
|
||||||
|
formData.fileUploads.find((i) => i.url === tag)!.fileType
|
||||||
|
)
|
||||||
|
"
|
||||||
|
@click="downloadFile(formData.fileUploads.find((i) => i.url === tag)!.url)"
|
||||||
|
style="margin-left: 10px; cursor: pointer"
|
||||||
|
>
|
||||||
|
{{ formData.fileUploads.find((i) => i.url === tag)!.fileName }}
|
||||||
|
</el-tag>
|
||||||
|
</el-tooltip>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="line">
|
||||||
|
<el-form
|
||||||
|
ref="formRef"
|
||||||
|
:model="formData"
|
||||||
|
label-width="80px"
|
||||||
|
:inline="true"
|
||||||
|
label-position="right"
|
||||||
|
class="formList"
|
||||||
|
>
|
||||||
|
<el-form-item label="专业" prop="specialtyName">
|
||||||
|
<el-input v-model="formData.specialtyName" placeholder="请输入专业" disabled />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="试题版本">
|
|
||||||
<p>测试测试</p>
|
<el-form-item label="章节名称" prop="chapteridDictText">
|
||||||
|
<el-input
|
||||||
|
v-model="formData.chapteridDictTextVo"
|
||||||
|
placeholder="请输入章节名称"
|
||||||
|
disabled
|
||||||
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="来源">
|
<el-form-item label="课程" prop="courseName">
|
||||||
<p>测试测试</p>
|
<el-input v-model="formData.courseName" placeholder="请输入课程" disabled />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="创建人">
|
<el-form-item label="题型难度" prop="quLevel">
|
||||||
<p>测试测试</p>
|
<el-select v-model="formData.quLevel" placeholder="请选择题型难度" clearable>
|
||||||
|
<el-option
|
||||||
|
v-for="dict in getIntDictOptions(DICT_TYPE.EXAM_QUE_DIFF)"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="创建时间">
|
<el-form-item label="题型" prop="subjectName">
|
||||||
<p>测试测试</p>
|
<el-input v-model="formData.subjectName" placeholder="请输入题型" disabled />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="修改人">
|
<el-form-item label="知识点" prop="pointNames">
|
||||||
<p>测试测试</p>
|
<el-input
|
||||||
|
v-model="formData.pointNamesVo"
|
||||||
|
placeholder="请选择知识点"
|
||||||
|
readonly
|
||||||
|
@click="openPoints()"
|
||||||
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="修改时间">
|
|
||||||
<p>测试测试</p>
|
<el-dialog v-model="dialogVisiblePoints" title="选择知识点" width="30%">
|
||||||
|
<el-tree
|
||||||
|
ref="treeRef"
|
||||||
|
:data="deptList"
|
||||||
|
node-key="id"
|
||||||
|
:props="{ label: 'name', children: 'children' }"
|
||||||
|
highlight-current
|
||||||
|
default-expand-all
|
||||||
|
@node-click="handleNodeClick"
|
||||||
|
/>
|
||||||
|
</el-dialog>
|
||||||
|
<el-form-item label="启用状态" prop="status">
|
||||||
|
<el-radio-group v-model="formData.status">
|
||||||
|
<el-radio :label="'0'">启用</el-radio>
|
||||||
|
<el-radio :label="'1'">禁用</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</div> -->
|
</div>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane label="判分设置" name="score">
|
<el-tab-pane label="判分设置" name="score">
|
||||||
<div class="line">
|
<div class="line">
|
||||||
@@ -293,7 +388,7 @@
|
|||||||
v-model="keyVisible"
|
v-model="keyVisible"
|
||||||
title="编辑关键字"
|
title="编辑关键字"
|
||||||
width="50%"
|
width="50%"
|
||||||
style="height: auto;"
|
style="height: auto"
|
||||||
:before-close="keyDialogClose"
|
:before-close="keyDialogClose"
|
||||||
:close-on-click-modal="false"
|
:close-on-click-modal="false"
|
||||||
:close-on-press-escape="false"
|
:close-on-press-escape="false"
|
||||||
@@ -362,70 +457,217 @@
|
|||||||
</template>
|
</template>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- 表单弹窗:添加/修改 -->
|
||||||
|
<FileForm ref="FileRef" @success="handleUploadSuccess" />
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import * as QuestionApi from '@/api/paper/question'
|
||||||
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
||||||
import { CommonStatusEnum } from '@/utils/constants'
|
import { CommonStatusEnum } from '@/utils/constants'
|
||||||
import ElTextarea from './components/el-textarea.vue'
|
import ElTextarea from './components/el-textarea.vue'
|
||||||
import { defaultProps, handleTree } from '@/utils/tree'
|
import { defaultProps, handleTree } from '@/utils/tree'
|
||||||
import * as PostApi from '@/api/system/post'
|
import * as SpecialtyApi from '@/api/points'
|
||||||
import * as DeptApi from '@/api/system/dept'
|
import * as DeptApi from '@/api/system/dept'
|
||||||
import * as UserApi from '@/api/system/user'
|
import * as UserApi from '@/api/system/user'
|
||||||
import { FormRules } from 'element-plus'
|
import { FormRules } from 'element-plus'
|
||||||
|
import { Document, Search, InfoFilled, Paperclip, Upload } from '@element-plus/icons-vue'
|
||||||
|
import FileForm from './components/FileForm.vue'
|
||||||
|
import { nextTick } from 'vue'
|
||||||
|
import type { InputInstance } from 'element-plus'
|
||||||
defineOptions({ name: 'SystemUserForm' })
|
defineOptions({ name: 'SystemUserForm' })
|
||||||
|
const inputValue = ref('')
|
||||||
|
const inputVisible = ref(false)
|
||||||
|
const InputRef = ref<InputInstance>()
|
||||||
|
const tagsType = (type: string) => {
|
||||||
|
if (type === '1') {
|
||||||
|
return 'primary'
|
||||||
|
} else if (type === '2') {
|
||||||
|
return 'success'
|
||||||
|
} else {
|
||||||
|
return 'info'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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 handleCloseTag = (url: string, type: string) => {
|
||||||
|
const index = formData.value.fileUploads.findIndex((item) => item.url === url)
|
||||||
|
if (index !== -1) {
|
||||||
|
formData.value.fileUploads[index].url = ''
|
||||||
|
if (type === '1') {
|
||||||
|
formData.value.answer = ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const showInput = () => {
|
||||||
|
inputVisible.value = true
|
||||||
|
nextTick(() => {
|
||||||
|
InputRef.value!.input!.focus()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const { t } = useI18n() // 国际化
|
const { t } = useI18n() // 国际化
|
||||||
const message = useMessage() // 消息弹窗
|
const message = useMessage() // 消息弹窗
|
||||||
|
|
||||||
const dialogVisible = ref(false) // 弹窗的是否展示
|
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||||
const dialogTitle = ref('') // 弹窗的标题
|
const dialogTitle = ref('') // 弹窗的标题
|
||||||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||||
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
||||||
const formData = ref({
|
const formData = ref({
|
||||||
|
id: undefined,
|
||||||
|
pointNamesVo: '',
|
||||||
|
chapteridDictTextVo: '',
|
||||||
content: '',
|
content: '',
|
||||||
specialtyName: '',
|
specialtyName: '',
|
||||||
courseName: '',
|
courseName: '',
|
||||||
quBankName: '',
|
quBankName: '',
|
||||||
required: '',
|
required: '',
|
||||||
chapteridDictText: '',
|
chapteridDictText: '',
|
||||||
analysis: ''
|
analysis: '',
|
||||||
})
|
quLevel: 0,
|
||||||
const formRules = reactive<FormRules>({
|
pointNames: '',
|
||||||
specialtyName: [{ required: true, message: '用户名称不能为空', trigger: 'blur' }]
|
subjectName: '',
|
||||||
|
status: '0',
|
||||||
|
resourceValue: '',
|
||||||
|
answer: '',
|
||||||
|
answerList: [
|
||||||
|
{
|
||||||
|
image: '',
|
||||||
|
content: '',
|
||||||
|
contentIn: '',
|
||||||
|
scoreRate: ''
|
||||||
|
}
|
||||||
|
],
|
||||||
|
fileUploads: [
|
||||||
|
{
|
||||||
|
quId: '',
|
||||||
|
url: '',
|
||||||
|
fileType: '0',
|
||||||
|
fileName: ''
|
||||||
|
},
|
||||||
|
{
|
||||||
|
quId: '',
|
||||||
|
url: '',
|
||||||
|
fileType: '1',
|
||||||
|
fileName: ''
|
||||||
|
},
|
||||||
|
{
|
||||||
|
quId: '',
|
||||||
|
url: '',
|
||||||
|
fileType: '2',
|
||||||
|
fileName: ''
|
||||||
|
}
|
||||||
|
]
|
||||||
})
|
})
|
||||||
const formRef = ref() // 表单 Ref
|
const formRef = ref() // 表单 Ref
|
||||||
const deptList = ref<Tree[]>([]) // 树形结构
|
|
||||||
const postList = ref([] as PostApi.PostVO[]) // 岗位列表
|
/** 添加/修改操作 */
|
||||||
|
const FileRef = ref()
|
||||||
|
const openForm = (type: string) => {
|
||||||
|
FileRef.value.open(type)
|
||||||
|
}
|
||||||
|
|
||||||
/** 页面内容开始 */
|
/** 页面内容开始 */
|
||||||
const activeName = ref('common')
|
const activeName = ref('common')
|
||||||
const content = ref('')
|
const content = ref('')
|
||||||
const textarea = ref('')
|
const textarea = ref('')
|
||||||
|
const inputText = ref('')
|
||||||
const handleClick = (tab, e) => {
|
const handleClick = (tab, e) => {
|
||||||
activeName.value = tab.paneName.value
|
activeName.value = tab.paneName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleUploadSuccess = async ({ url, fileType, file }) => {
|
||||||
|
const res = await QuestionApi.previewQuestion({ file })
|
||||||
|
if (res.code !== 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
console.log(fileType)
|
||||||
|
|
||||||
|
const index = formData.value.fileUploads.findIndex((item) => item.fileType === fileType)
|
||||||
|
if (index !== -1) {
|
||||||
|
console.log(url)
|
||||||
|
|
||||||
|
formData.value.fileUploads[index].url = url
|
||||||
|
switch (fileType) {
|
||||||
|
case '1':
|
||||||
|
formData.value.fileUploads[index].fileName = 'C语言编程题'
|
||||||
|
formData.value.answer = res.data
|
||||||
|
break
|
||||||
|
case '2':
|
||||||
|
formData.value.fileUploads[index].fileName = '结果'
|
||||||
|
break
|
||||||
|
case '3':
|
||||||
|
formData.value.fileUploads[index].fileName = '素材'
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** 页面内容结束 */
|
/** 页面内容结束 */
|
||||||
|
|
||||||
/** 打开弹窗 */
|
/** 打开弹窗 */
|
||||||
const open = async (type: string, id?: number) => {
|
const open = async (queryParams: any, type: string, id?: number) => {
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
dialogTitle.value = t('action.' + type)
|
dialogTitle.value = t('action.' + type)
|
||||||
formType.value = type
|
formType.value = type
|
||||||
resetForm()
|
resetForm()
|
||||||
|
|
||||||
// 修改时,设置数据
|
// 修改时,设置数据
|
||||||
if (id) {
|
if (id) {
|
||||||
formLoading.value = true
|
formLoading.value = true
|
||||||
try {
|
try {
|
||||||
formData.value = await UserApi.getUser(id)
|
const res = await QuestionApi.getQuestion(id)
|
||||||
|
formData.value = res
|
||||||
|
// 数据回显到各个部分
|
||||||
|
content.value = res.content
|
||||||
|
textarea.value = res.analysis // 假设 res.analysis 对应某个 textarea
|
||||||
|
// 其他列表数据回显
|
||||||
|
examList.value = res.examList || []
|
||||||
|
scoreKeyList.value = res.scoreKeyList || []
|
||||||
|
keywordList.value = res.keywordList || []
|
||||||
|
mediumList.value = res.mediumList || []
|
||||||
} finally {
|
} finally {
|
||||||
formLoading.value = false
|
formLoading.value = false
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// 新增时,设置初始值
|
||||||
|
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
|
||||||
}
|
}
|
||||||
// 加载部门树
|
|
||||||
deptList.value = handleTree(await DeptApi.getSimpleDeptList())
|
|
||||||
// 加载岗位列表
|
|
||||||
postList.value = await PostApi.getSimplePostList()
|
|
||||||
}
|
}
|
||||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||||
|
|
||||||
@@ -465,7 +707,7 @@ const handleKeywordSelectionChange = (val: any) => {
|
|||||||
const keyVisible = ref(false)
|
const keyVisible = ref(false)
|
||||||
const keyEditType = ref('')
|
const keyEditType = ref('')
|
||||||
|
|
||||||
const keyWord = ref([null])
|
const keyWord = ref<any>([null])
|
||||||
|
|
||||||
const editKeyword = (key) => {
|
const editKeyword = (key) => {
|
||||||
keyEditType.value = key
|
keyEditType.value = key
|
||||||
@@ -495,7 +737,6 @@ const fileList = []
|
|||||||
/** 提交表单 */
|
/** 提交表单 */
|
||||||
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
||||||
const submitForm = async () => {
|
const submitForm = async () => {
|
||||||
console.log(textarea.value)
|
|
||||||
// 校验表单
|
// 校验表单
|
||||||
if (!formRef) return
|
if (!formRef) return
|
||||||
const valid = await formRef.value.validate()
|
const valid = await formRef.value.validate()
|
||||||
@@ -503,12 +744,17 @@ const submitForm = async () => {
|
|||||||
// 提交请求
|
// 提交请求
|
||||||
formLoading.value = true
|
formLoading.value = true
|
||||||
try {
|
try {
|
||||||
const data = formData.value as unknown as UserApi.UserVO
|
// 合并UI上的数据到formData
|
||||||
|
formData.value.content = content.value
|
||||||
|
// formData.value.analysis = textarea.value // 如果有解析内容
|
||||||
|
// ... 其他需要合并的数据
|
||||||
|
|
||||||
|
const data = formData.value
|
||||||
if (formType.value === 'create') {
|
if (formType.value === 'create') {
|
||||||
await UserApi.createUser(data)
|
await QuestionApi.addQuestion(data)
|
||||||
message.success(t('common.createSuccess'))
|
message.success(t('common.createSuccess'))
|
||||||
} else {
|
} else {
|
||||||
await UserApi.updateUser(data)
|
await QuestionApi.editQuestion(data)
|
||||||
message.success(t('common.updateSuccess'))
|
message.success(t('common.updateSuccess'))
|
||||||
}
|
}
|
||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
@@ -522,16 +768,84 @@ const submitForm = async () => {
|
|||||||
/** 重置表单 */
|
/** 重置表单 */
|
||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
formData.value = {
|
formData.value = {
|
||||||
|
id: undefined,
|
||||||
content: '',
|
content: '',
|
||||||
specialtyName: '',
|
specialtyName: '',
|
||||||
courseName: '',
|
courseName: '',
|
||||||
quBankName: '',
|
quBankName: '',
|
||||||
required: '',
|
required: '',
|
||||||
chapteridDictText: '',
|
chapteridDictText: '',
|
||||||
analysis: ''
|
analysis: '',
|
||||||
|
quLevel: 0,
|
||||||
|
pointNames: '',
|
||||||
|
pointNamesVo: '',
|
||||||
|
chapteridDictTextVo: '',
|
||||||
|
subjectName: '',
|
||||||
|
status: '0',
|
||||||
|
resourceValue: '',
|
||||||
|
answer: '',
|
||||||
|
answerList: [],
|
||||||
|
fileUploads: [
|
||||||
|
{ quId: '', url: '', fileType: '0', fileName: '' },
|
||||||
|
{ quId: '', url: '', fileType: '1', fileName: '' },
|
||||||
|
{ quId: '', url: '', fileType: '2', fileName: '' }
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
content.value = ''
|
||||||
|
textarea.value = ''
|
||||||
|
inputText.value = ''
|
||||||
|
examList.value = []
|
||||||
|
scoreKeyList.value = []
|
||||||
|
keywordList.value = []
|
||||||
|
mediumList.value = []
|
||||||
formRef.value?.resetFields()
|
formRef.value?.resetFields()
|
||||||
}
|
}
|
||||||
|
const dialogVisiblePoints = ref(false)
|
||||||
|
// 添加层级信息
|
||||||
|
const handleTreeWithLevel = (list, level = 1) => {
|
||||||
|
return list.map((item) => {
|
||||||
|
const node = { ...item, level }
|
||||||
|
if (item.children && item.children.length > 0) {
|
||||||
|
node.children = handleTreeWithLevel(item.children, level + 1)
|
||||||
|
}
|
||||||
|
return node
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 只允许点击第三级节点
|
||||||
|
const treeRef = ref() // 引用 el-tree
|
||||||
|
const handleNodeClick = (data, node) => {
|
||||||
|
if (data.level === 3) {
|
||||||
|
formData.value.pointNames = data.id
|
||||||
|
formData.value.pointNamesVo = data.name
|
||||||
|
|
||||||
|
// 获取父节点(章节名称)
|
||||||
|
const currentNode = treeRef.value.getNode(data)
|
||||||
|
const parentNode = currentNode.parent
|
||||||
|
if (parentNode && parentNode.data) {
|
||||||
|
formData.value.chapteridDictTextVo = parentNode.data.name
|
||||||
|
formData.value.chapteridDictText = parentNode.data.id
|
||||||
|
} else {
|
||||||
|
formData.value.chapteridDictText = ''
|
||||||
|
}
|
||||||
|
|
||||||
|
dialogVisiblePoints.value = false
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const deptList = ref<Tree[]>([]) // 树形结构
|
||||||
|
/** 获得部门树 */
|
||||||
|
const getTree = async () => {
|
||||||
|
const res = await SpecialtyApi.listPoints()
|
||||||
|
const tree = handleTree(res)
|
||||||
|
deptList.value = []
|
||||||
|
deptList.value = handleTreeWithLevel(tree)
|
||||||
|
}
|
||||||
|
const openPoints = async () => {
|
||||||
|
await getTree()
|
||||||
|
dialogVisiblePoints.value = true
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@@ -551,6 +865,20 @@ const resetForm = () => {
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
.main {
|
.main {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
position: relative;
|
||||||
|
padding-bottom: 100px;
|
||||||
|
padding-left: 10px;
|
||||||
|
padding-right: 10px;
|
||||||
|
.tabsTip {
|
||||||
|
position: absolute;
|
||||||
|
top: 10px;
|
||||||
|
right: 20px;
|
||||||
|
color: #4f9dfd;
|
||||||
|
line-height: 100%;
|
||||||
|
text-align: center;
|
||||||
|
align-items: center;
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
.el-tabs {
|
.el-tabs {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
.el-tabs__content {
|
.el-tabs__content {
|
||||||
@@ -558,11 +886,22 @@ const resetForm = () => {
|
|||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
.line {
|
.line {
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
|
.tips {
|
||||||
|
background-color: #fbf8e4;
|
||||||
|
color: #886d3e;
|
||||||
|
padding: 10px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
.title-text {
|
.title-text {
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
margin-bottom: 8px;
|
margin-bottom: 8px;
|
||||||
}
|
}
|
||||||
|
.buttons {
|
||||||
|
margin-top: 10px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
.block {
|
.block {
|
||||||
.tip {
|
.tip {
|
||||||
color: #8a6d3b;
|
color: #8a6d3b;
|
||||||
@@ -585,6 +924,26 @@ const resetForm = () => {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.formList {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-top: 60px;
|
||||||
|
width: 100%;
|
||||||
|
.el-form-item {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
width: 100%;
|
||||||
|
label {
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
.el-select {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.el-input {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.el-input {
|
.el-input {
|
||||||
width: 45%;
|
width: 45%;
|
||||||
|
@@ -48,7 +48,7 @@ const currentType = ref(null)
|
|||||||
/** 打开弹窗 */
|
/** 打开弹窗 */
|
||||||
const open = async (type) => {
|
const open = async (type) => {
|
||||||
currentType.value = type // 记录类型
|
currentType.value = type // 记录类型
|
||||||
console.log(currentType.value+"123123")
|
console.log(currentType.value + '123123')
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
resetForm()
|
resetForm()
|
||||||
}
|
}
|
||||||
@@ -76,17 +76,16 @@ const submitFormSuccess = (response: any, file: any) => {
|
|||||||
|
|
||||||
// 假设后端返回格式:{ url: '文件地址', fileName: '文件名' }
|
// 假设后端返回格式:{ url: '文件地址', fileName: '文件名' }
|
||||||
const url = response.data
|
const url = response.data
|
||||||
console.log(currentType.value+"v")
|
console.log(currentType.value + 'v')
|
||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
formLoading.value = false
|
formLoading.value = false
|
||||||
uploadRef.value?.clearFiles()
|
uploadRef.value?.clearFiles()
|
||||||
message.success(t('common.createSuccess'))
|
message.success(t('common.createSuccess'))
|
||||||
|
|
||||||
// 触发成功事件,携带文件信息传递给父组件
|
// 触发成功事件,携带文件信息传递给父组件
|
||||||
emit('success', { url, fileType: currentType.value })
|
emit('success', { url, fileType: currentType.value, file: file.raw })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** 上传错误提示 */
|
/** 上传错误提示 */
|
||||||
const submitFormError = (): void => {
|
const submitFormError = (): void => {
|
||||||
message.error('上传失败,请您重新上传!')
|
message.error('上传失败,请您重新上传!')
|
||||||
|
@@ -484,7 +484,7 @@ const handleSelectionChange = (rows) => {
|
|||||||
selections.value = rows
|
selections.value = rows
|
||||||
}
|
}
|
||||||
|
|
||||||
const selectedSchool = ref([])
|
const selectedSchool = ref<any>([])
|
||||||
|
|
||||||
const handleSelectionChangeSchool = (rows) => {
|
const handleSelectionChangeSchool = (rows) => {
|
||||||
selectedSchool.value = rows
|
selectedSchool.value = rows
|
||||||
@@ -609,7 +609,7 @@ const connectTent = async () => {
|
|||||||
const res = await QuestionApi.rabbitmqConnect()
|
const res = await QuestionApi.rabbitmqConnect()
|
||||||
console.log(res)
|
console.log(res)
|
||||||
message.success(t(res))
|
message.success(t(res))
|
||||||
} catch (error) {
|
} catch (error: any) {
|
||||||
message.error(t(`连接失败: ${error?.message || '未知错误'}`))
|
message.error(t(`连接失败: ${error?.message || '未知错误'}`))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -618,7 +618,7 @@ const connectTong = async () => {
|
|||||||
try {
|
try {
|
||||||
const res = await QuestionApi.receiveAll()
|
const res = await QuestionApi.receiveAll()
|
||||||
message.success(t('同步成功'))
|
message.success(t('同步成功'))
|
||||||
} catch (error) {
|
} catch (error: any) {
|
||||||
message.error(t(`连接失败: ${error?.message || '未知错误'}`))
|
message.error(t(`连接失败: ${error?.message || '未知错误'}`))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -704,7 +704,7 @@ const openForm = (type: string, id?: number) => {
|
|||||||
if (chooseQuestionType.value.includes('选择题')) {
|
if (chooseQuestionType.value.includes('选择题')) {
|
||||||
formRef.value.open(queryParams, type, id)
|
formRef.value.open(queryParams, type, id)
|
||||||
} else if (chooseQuestionType.value.includes('编程题')) {
|
} else if (chooseQuestionType.value.includes('编程题')) {
|
||||||
cformRef.value.open(type, id)
|
cformRef.value.open(queryParams,type, id)
|
||||||
} else if (chooseQuestionType.value.includes('程序设计')) {
|
} else if (chooseQuestionType.value.includes('程序设计')) {
|
||||||
mformRef.value.open(queryParams, type, id)
|
mformRef.value.open(queryParams, type, id)
|
||||||
} else if (chooseQuestionType.value.includes('网络题')) {
|
} else if (chooseQuestionType.value.includes('网络题')) {
|
||||||
|
Reference in New Issue
Block a user