【新增】 出题页面新增

This commit is contained in:
DESKTOP-932OMT8\REN
2025-06-23 17:09:50 +08:00
committed by 陆光LG
parent ab5035bab3
commit 8bbe607f68
4 changed files with 3131 additions and 386 deletions

View File

@@ -0,0 +1,912 @@
<template>
<div class="edit-dialog">
<Dialog v-model="dialogVisible" :title="dialogTitle" width="85%" top="10vh">
<el-scrollbar>
<div class="main">
<el-form
ref="formRef"
v-loading="formLoading"
:model="formData"
:rules="formRules"
label-width="80px"
>
<el-row>
<el-col :span="12">
<el-form-item label="专业" prop="specialtyName">
<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
v-model="formData.chapteridDictTextVo"
placeholder="请输入章节名称"
disabled
/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="课程" prop="courseName">
<el-input v-model="formData.courseName" placeholder="请输入课程" disabled />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="题型难度" prop="quLevel">
<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-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="题型" prop="subjectName">
<el-input v-model="formData.subjectName" placeholder="请输入题型" disabled />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="知识点" prop="pointNames">
<el-input
v-model="formData.pointNamesVo"
placeholder="请选择知识点"
readonly
@click="openPoints()"
/>
</el-form-item>
</el-col>
<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-row>
<el-row>
<el-col :span="12">
<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-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">
<div class="edit-left bottom-common">
<el-tabs v-model="leftActiveName" class="demo-tabs">
<el-tab-pane label="试题描述" name="desc">
<div class="block">
<Editor v-model="formData.content" height="150px" />
</div>
</el-tab-pane>
</el-tabs>
</div>
<div class="edit-right bottom-common">
<el-tabs v-model="rightActiveName" class="demo-tabs" @tab-click="rightHandleClick">
<el-tab-pane label="试题解析" name="analysis">
<div class="block">
<Editor v-model="formData.analysis" height="150px" />
</div>
</el-tab-pane>
<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
v-loading="loading"
:data="list"
@selection-change="handleSelectionChange"
>
<!-- <el-table-column type="selection" width="55" /> -->
<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>
<!-- <el-tab-pane name="medium">
<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-upload
v-model:file-list="fileList"
class="upload-demo"
action="https://run.mocky.io/v3/9d059bf9-4660-45f2-925d-ce80ad6c4d15"
>
<el-button>导入</el-button>
</el-upload>
</el-dropdown-item>
<el-dropdown-item>导出</el-dropdown-item>
<el-dropdown-item>播放</el-dropdown-item>
<el-dropdown-item>编辑</el-dropdown-item>
<el-dropdown-item>删除选中</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</div>
</template>
<div class="block">
<el-table
:data="mediumList"
style="width: 100%"
@selection-change="handleMediumSelectionChange"
>
<el-table-column type="index" width="50" />
<el-table-column type="selection" width="55" />
<el-table-column prop="type" label="媒体类型" width="80" />
<el-table-column prop="title" label="标题" />
<el-table-column prop="displayIndex" label="显示序号" />
<el-table-column prop="size" label="大小" />
</el-table>
</div>
</el-tab-pane> -->
<el-tab-pane name="annex">
<template #label>
<div class="custom-tabs-label">
<p>试题附件</p>
</div>
</template>
<!-- 提示 -->
<el-alert type="warning" show-icon :closable="false">
<template #default>
<span>提示文件名称可默认不设置</span>
</template>
</el-alert>
<div class="block">
<el-table :data="documentList" style="width: 100%">
<el-table-column type="index" label="#" width="50" />
<el-table-column label="文件名称" width="250">
<template #default="scope">
<el-input
v-model="scope.row.fileName"
size="small"
placeholder="请输入文件名称(未输入自动命名)"
/>
</template>
</el-table-column>
<el-table-column
prop="fileType"
label="类型"
:formatter="fileTypeFormatter"
/>
<el-table-column prop="url" label="地址" width="200">
<template #default="{ row }">
<div
style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis"
:title="row.url"
>
{{ row.url }}
</div>
</template>
</el-table-column>
<el-table-column label="操作" width="150">
<template #default="scope">
<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>
</div>
</el-tab-pane>
</el-tabs>
</div>
</div>
</div>
</el-scrollbar>
<template #footer>
<el-button :disabled="formLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
</Dialog>
</div>
<!-- 表单弹窗添加/修改 -->
<FileForm ref="FileRef" @success="handleUploadSuccess" />
<el-dialog v-model="dialogFormVisibleWordInfo" title="考点设置" width="1100px">
<Email />
</el-dialog>
</template>
<script lang="ts" setup>
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 FileForm from './components/FileForm.vue'
import Email from '@/components/Email/index.vue'
import * as SpecialtyApi from '@/api/points'
import { defaultProps, handleTree } from '@/utils/tree'
import { cloneDeep } from 'lodash-es'
defineOptions({ name: 'WpsWordFrom' })
const wordPointsList = ref<Tree[]>([]) // 树形结构
const wordPointsInfoList = ref<Tree[]>([]) // 树形结构
const list = ref([]) // 列表的数
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 - 修改
const formData = ref({
pointNamesVo: '',
chapteridDictTextVo: '',
content: '',
specialtyName: '',
courseName: '',
quBankName: '',
required: '',
chapteridDictText: '',
analysis: '',
quLevel: 0,
pointNames: '',
subjectName: '',
status: ' ',
resourceValue: '',
answerList: [
{
image: '',
content: '',
contentIn: '',
scoreRate: ''
}
],
fileUploads: [
{
quId: '',
url: '',
fileType: '0',
fileName: ''
},
{
quId: '',
url: '',
fileType: '1',
fileName: ''
},
{
quId: '',
url: '',
fileType: '2',
fileName: ''
}
]
})
const wordPointsFun = ref({
chineseName: '',
function: ''
})
const wordPoints = ref({
name: '',
englishName: '',
filePath: '',
type: '',
belongTo: '',
isboo: '',
function: '',
unit: '',
isExam: ''
})
let wordPointsInfosList: (typeof wordPoints)[] = []
function fileTypeFormatter(row, column, cellValue) {
if (cellValue === '0') return '素材文件(上传ZIP)'
if (cellValue === '1') return '考试文件'
if (cellValue === '2') return '结果文件'
return '未知类型'
}
const documentList = ref([
{
quId: '',
url: '',
fileType: '0',
fileName: ''
},
{
quId: '',
url: '',
fileType: '1',
fileName: ''
},
{
quId: '',
url: '',
fileType: '2',
fileName: ''
}
])
const dialogFormVisibleWordInfo = ref(false)
const dialogFormVisibleWordInfos = ref(false)
const nodeFunction = ref('')
const titles = ref('')
const englishName = ref('')
const filePath = ref('')
const upFilePath = ref('')
const functionList = ref<string[]>([])
const wordData = reactive({
chineseName: '',
englishName: '',
filePath: '',
function: [] as string[]
})
const handleCheckChange = (data: Tree, checked: boolean, indeterminate: boolean) => {
// if (checked || indeterminate) {
// wordPoints.value.belongTo = data.belongTo
// wordPoints.value.parameter = data.isboo
// wordPoints.value.type = data.type
// wordPointsFun.value = {
// chineseName: '',
// function: ''
// }
// wordPointsFun.value.chineseName = data.toChinese
// wordPointsFun.value.function = data.nodeFunction
// wordPoints.value.function.push(cloneDeep(wordPointsFun.value))
// console.log(wordPoints)
// }
if (data.titleType == '2') {
wordPoints.value.name = chineseName.value + data.toChinese
wordPoints.value.filePath = filePath.value
wordPoints.value.function = englishNames.value + data.nodeFunction
wordPoints.value.englishName = englishNames.value
wordPoints.value.belongTo = data.belongTo
wordPoints.value.isboo = data.isboo
wordPoints.value.type = data.type
wordPoints.value.unit = data.unit
wordPoints.value.isExam = '0'
wordPointsInfosList.push(cloneDeep(wordPoints.value))
}
console.log(data, checked, indeterminate)
}
const addWordInfo = async () => {
dialogFormVisibleWordInfo.value = true
}
const queryParams = reactive({
nodeFunction: undefined
})
const chineseName = ref('')
const nodeFunctions = ref('')
const englishNames = ref('')
const handleNodelClick = async (row: any) => {
queryParams.nodeFunction = row.selectName
chineseName.value = '【' + row.name + '】'
filePath.value = row.filePath
nodeFunctions.value = row.selectName
englishNames.value = row.englishName
const res = await WordApi.getWordInfos(queryParams)
wordPointsInfoList.value = []
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 () => {
const res = await WordApi.getWordListInfos(wordPointsInfosList)
wordPoints.value = {
name: '',
englishName: '',
filePath: '',
type: '',
belongTo: '',
isboo: '',
function: '',
unit: '',
isExam: ''
}
let index = 0
wordPointsInfosList = []
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) {
index += 1
res[i].sort = index
list.value.push(res[i])
}
}
dialogFormVisibleWordInfo.value = false
dialogFormVisibleWordInfos.value = false
wordPointsList.value = []
}
const formRules = reactive<FormRules>({
status: [{ required: true, message: '启用状态必填', trigger: 'blur' }]
})
const formRef = ref() // 表单 Ref
// 左侧试题描述
const leftActiveName = ref('desc')
// 右侧tab
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()
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)
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 = {
content: '',
specialtyName: '',
courseName: '',
quBankName: '',
required: '',
chapteridDictText: '',
analysis: '',
quLevel: 0,
pointNames: '',
subjectName: '',
status: '0',
resourceValue: '',
answerList: [
{
image: '',
content: '',
contentIn: '',
scoreRate: ''
}
],
fileUploads: [
{
quId: '',
url: '',
fileType: '0',
fileName: ''
},
{
quId: '',
url: '',
fileType: '1',
fileName: ''
},
{
quId: '',
url: '',
fileType: '2',
fileName: ''
}
]
}
documentList.value = [
{
quId: '',
url: '',
fileType: '0',
fileName: ''
},
{
quId: '',
url: '',
fileType: '1',
fileName: ''
},
{
quId: '',
url: '',
fileType: '2',
fileName: ''
}
]
list.value = []
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>
<style lang="scss" scoped>
.edit-dialog {
:deep(.el-dialog) {
display: flex;
flex-direction: column;
.el-dialog__header {
border-bottom: 1px solid #ededed;
}
.el-dialog__footer {
border-top: 1px solid #ededed;
}
.el-dialog__body {
flex: 1;
overflow: hidden;
.main {
.el-form {
padding: 10px;
.el-row {
justify-content: space-between;
margin-bottom: 10px;
}
.el-form-item {
width: 100%;
margin-bottom: 0;
align-items: center;
}
}
.edit-bottom {
display: flex;
justify-content: space-between;
padding-bottom: 10px;
.bottom-common {
width: calc(50% - 10px);
.el-tabs {
height: 100%;
.el-tabs__content {
flex: 1;
overflow-y: auto;
.block {
width: 100%;
height: 200px;
overflow: auto;
}
.answer {
.tip {
color: #8a6d3b;
background-color: #fcf8e3;
border-color: #faebcc;
padding: 10px 20px;
display: flex;
align-items: center;
> p {
flex-shrink: 0;
}
}
.el-radio-group {
width: 100%;
display: inline-flex;
align-items: flex-start;
font-size: 0;
flex-direction: column;
.options {
width: 100%;
margin-top: 15px;
.content {
display: flex;
.text {
width: 100%;
height: 70px;
border: 1px solid #ededed;
.el-textarea__inner {
resize: none;
}
}
}
.more-btn {
margin-top: 8px;
background-color: #ffffff;
border-color: #007bff;
color: #007bff;
width: auto;
height: auto;
padding: 10px 10px;
}
}
}
}
}
.custom-tabs-label {
display: flex;
align-items: center;
.setting_icon {
width: 16px;
height: 16px;
background: url('@/assets/icon/setting_blue.png') no-repeat center;
background-size: 100%;
margin-left: 3px;
display: none;
}
}
.is-active {
.custom-tabs-label {
.setting_icon {
display: block;
}
}
}
:deep(.ele-pro-table) {
flex: 1;
margin-top: 10px;
.el-table--fit {
height: 100%;
}
}
}
}
}
}
}
}
}
:deep(.tox-tinymce) {
.tox-statusbar {
display: none;
}
}
:deep(.el-table) {
.el-table__header-wrapper {
.el-table__header {
thead {
tr {
th {
background: #ebebeb;
}
}
}
}
}
}
</style>

View File

@@ -0,0 +1,921 @@
<template>
<div class="edit-dialog">
<Dialog v-model="dialogVisible" :title="dialogTitle" width="85%" top="10vh">
<el-scrollbar>
<div class="main">
<el-form
ref="formRef"
v-loading="formLoading"
:model="formData"
:rules="formRules"
label-width="80px"
>
<el-row>
<el-col :span="12">
<el-form-item label="专业" prop="specialtyName">
<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
v-model="formData.chapteridDictTextVo"
placeholder="请输入章节名称"
disabled
/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="课程" prop="courseName">
<el-input v-model="formData.courseName" placeholder="请输入课程" disabled />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="题型难度" prop="quLevel">
<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-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="题型" prop="subjectName">
<el-input v-model="formData.subjectName" placeholder="请输入题型" disabled />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="知识点" prop="pointNames">
<el-input
v-model="formData.pointNamesVo"
placeholder="请选择知识点"
readonly
@click="openPoints()"
/>
</el-form-item>
</el-col>
<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-row>
<el-row>
<el-col :span="12">
<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-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">
<div class="edit-left bottom-common">
<el-tabs v-model="leftActiveName" class="demo-tabs">
<el-tab-pane label="试题描述" name="desc">
<div class="block">
<Editor v-model="formData.content" height="150px" />
</div>
</el-tab-pane>
</el-tabs>
</div>
<div class="edit-right bottom-common">
<el-tabs v-model="rightActiveName" class="demo-tabs" @tab-click="rightHandleClick">
<el-tab-pane label="试题解析" name="analysis">
<div class="block">
<Editor v-model="formData.analysis" height="150px" />
</div>
</el-tab-pane>
<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
v-loading="loading"
:data="list"
@selection-change="handleSelectionChange"
>
<!-- <el-table-column type="selection" width="55" /> -->
<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>
<!-- <el-tab-pane name="medium">
<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-upload
v-model:file-list="fileList"
class="upload-demo"
action="https://run.mocky.io/v3/9d059bf9-4660-45f2-925d-ce80ad6c4d15"
>
<el-button>导入</el-button>
</el-upload>
</el-dropdown-item>
<el-dropdown-item>导出</el-dropdown-item>
<el-dropdown-item>播放</el-dropdown-item>
<el-dropdown-item>编辑</el-dropdown-item>
<el-dropdown-item>删除选中</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</div>
</template>
<div class="block">
<el-table
:data="mediumList"
style="width: 100%"
@selection-change="handleMediumSelectionChange"
>
<el-table-column type="index" width="50" />
<el-table-column type="selection" width="55" />
<el-table-column prop="type" label="媒体类型" width="80" />
<el-table-column prop="title" label="标题" />
<el-table-column prop="displayIndex" label="显示序号" />
<el-table-column prop="size" label="大小" />
</el-table>
</div>
</el-tab-pane> -->
<el-tab-pane name="annex">
<template #label>
<div class="custom-tabs-label">
<p>试题附件</p>
</div>
</template>
<!-- 提示 -->
<el-alert type="warning" show-icon :closable="false">
<template #default>
<span>提示文件名称可默认不设置</span>
</template>
</el-alert>
<div class="block">
<el-table :data="documentList" style="width: 100%">
<el-table-column type="index" label="#" width="50" />
<el-table-column label="文件名称" width="250">
<template #default="scope">
<el-input
v-model="scope.row.fileName"
size="small"
placeholder="请输入文件名称(未输入自动命名)"
/>
</template>
</el-table-column>
<el-table-column
prop="fileType"
label="类型"
:formatter="fileTypeFormatter"
/>
<el-table-column prop="url" label="地址" width="200">
<template #default="{ row }">
<div
style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis"
:title="row.url"
>
{{ row.url }}
</div>
</template>
</el-table-column>
<el-table-column label="操作" width="150">
<template #default="scope">
<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>
</div>
</el-tab-pane>
</el-tabs>
</div>
</div>
</div>
</el-scrollbar>
<template #footer>
<el-button :disabled="formLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
</Dialog>
</div>
<!-- 表单弹窗添加/修改 -->
<FileForm ref="FileRef" @success="handleUploadSuccess" />
<el-dialog v-model="dialogFormVisibleWordInfo" title="考点设置" width="1100px">
<Setting />
</el-dialog>
</template>
<script lang="ts" setup>
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 FileForm from './components/FileForm.vue'
import Setting from '@/components/Setting/index.vue'
import * as SpecialtyApi from '@/api/points'
import { defaultProps, handleTree } from '@/utils/tree'
import { cloneDeep } from 'lodash-es'
import { emitter } from '@/utils/eventBus'
defineOptions({ name: 'WpsWordFrom' })
const wordPointsList = ref<Tree[]>([]) // 树形结构
const wordPointsInfoList = ref<Tree[]>([]) // 树形结构
onMounted(() => {
emitter.on('maskDisplay', handleFromC)
})
function handleFromC(data: any) {
console.log(data.value)
let index = 0
for (let i = 0; i < data.value.length; i++) {
var indexFlag = false
for (let x = 0; x < list.value.length; x++) {
if (data.value[i].content == list.value[x].content) {
// 如果存在相同的数据话 不进入
indexFlag = true
}
}
if (!indexFlag) {
index += 1
data.value[i].sort = index
data.value[i].scoreRate = "1"
list.value.push(data.value[i])
}
}
}
const list = ref([]) // 列表的数
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 - 修改
const formData = ref({
pointNamesVo: '',
chapteridDictTextVo: '',
content: '',
specialtyName: '',
courseName: '',
quBankName: '',
required: '',
chapteridDictText: '',
analysis: '',
quLevel: 0,
pointNames: '',
subjectName: '',
status: ' ',
resourceValue: '',
answerList: [
{
image: '',
content: '',
contentIn: '',
scoreRate: ''
}
],
fileUploads: [
{
quId: '',
url: '',
fileType: '0',
fileName: ''
},
{
quId: '',
url: '',
fileType: '1',
fileName: ''
},
{
quId: '',
url: '',
fileType: '2',
fileName: ''
}
]
})
const wordPointsFun = ref({
chineseName: '',
function: ''
})
const wordPoints = ref({
name: '',
englishName: '',
filePath: '',
type: '',
belongTo: '',
isboo: '',
function: '',
unit: '',
isExam: ''
})
let wordPointsInfosList: (typeof wordPoints)[] = []
function fileTypeFormatter(row, column, cellValue) {
if (cellValue === '0') return '素材文件(上传ZIP)'
if (cellValue === '1') return '考试文件'
if (cellValue === '2') return '结果文件'
return '未知类型'
}
const documentList = ref([
{
quId: '',
url: '',
fileType: '0',
fileName: ''
},
{
quId: '',
url: '',
fileType: '1',
fileName: ''
},
{
quId: '',
url: '',
fileType: '2',
fileName: ''
}
])
const dialogFormVisibleWordInfo = ref(false)
const dialogFormVisibleWordInfos = ref(false)
const nodeFunction = ref('')
const titles = ref('')
const englishName = ref('')
const filePath = ref('')
const upFilePath = ref('')
const functionList = ref<string[]>([])
const wordData = reactive({
chineseName: '',
englishName: '',
filePath: '',
function: [] as string[]
})
const handleCheckChange = (data: Tree, checked: boolean, indeterminate: boolean) => {
// if (checked || indeterminate) {
// wordPoints.value.belongTo = data.belongTo
// wordPoints.value.parameter = data.isboo
// wordPoints.value.type = data.type
// wordPointsFun.value = {
// chineseName: '',
// function: ''
// }
// wordPointsFun.value.chineseName = data.toChinese
// wordPointsFun.value.function = data.nodeFunction
// wordPoints.value.function.push(cloneDeep(wordPointsFun.value))
// console.log(wordPoints)
// }
if (data.titleType == '2') {
wordPoints.value.name = chineseName.value + data.toChinese
wordPoints.value.filePath = filePath.value
wordPoints.value.function = englishNames.value + data.nodeFunction
wordPoints.value.englishName = englishNames.value
wordPoints.value.belongTo = data.belongTo
wordPoints.value.isboo = data.isboo
wordPoints.value.type = data.type
wordPoints.value.unit = data.unit
wordPoints.value.isExam = '0'
wordPointsInfosList.push(cloneDeep(wordPoints.value))
}
console.log(data, checked, indeterminate)
}
const addWordInfo = async () => {
dialogFormVisibleWordInfo.value = true
}
const queryParams = reactive({
nodeFunction: undefined
})
const chineseName = ref('')
const nodeFunctions = ref('')
const englishNames = ref('')
const handleNodelClick = async (row: any) => {
queryParams.nodeFunction = row.selectName
chineseName.value = '【' + row.name + '】'
filePath.value = row.filePath
nodeFunctions.value = row.selectName
englishNames.value = row.englishName
const res = await WordApi.getWordInfos(queryParams)
wordPointsInfoList.value = []
wordPointsInfoList.value.push(...handleTree(res))
dialogFormVisibleWordInfos.value = true
}
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 submitWordPoints = async () => {
const res = await WordApi.getWordListInfos(wordPointsInfosList)
wordPoints.value = {
name: '',
englishName: '',
filePath: '',
type: '',
belongTo: '',
isboo: '',
function: '',
unit: '',
isExam: ''
}
wordPointsInfosList = []
dialogFormVisibleWordInfo.value = false
dialogFormVisibleWordInfos.value = false
wordPointsList.value = []
}
const formRules = reactive<FormRules>({
status: [{ required: true, message: '启用状态必填', trigger: 'blur' }]
})
const formRef = ref() // 表单 Ref
// 左侧试题描述
const leftActiveName = ref('desc')
// 右侧tab
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()
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)
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 = {
content: '',
specialtyName: '',
courseName: '',
quBankName: '',
required: '',
chapteridDictText: '',
analysis: '',
quLevel: 0,
pointNames: '',
subjectName: '',
status: '0',
resourceValue: '',
answerList: [
{
image: '',
content: '',
contentIn: '',
scoreRate: ''
}
],
fileUploads: [
{
quId: '',
url: '',
fileType: '0',
fileName: ''
},
{
quId: '',
url: '',
fileType: '1',
fileName: ''
},
{
quId: '',
url: '',
fileType: '2',
fileName: ''
}
]
}
documentList.value = [
{
quId: '',
url: '',
fileType: '0',
fileName: ''
},
{
quId: '',
url: '',
fileType: '1',
fileName: ''
},
{
quId: '',
url: '',
fileType: '2',
fileName: ''
}
]
list.value = []
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>
<style lang="scss" scoped>
.edit-dialog {
:deep(.el-dialog) {
display: flex;
flex-direction: column;
.el-dialog__header {
border-bottom: 1px solid #ededed;
}
.el-dialog__footer {
border-top: 1px solid #ededed;
}
.el-dialog__body {
flex: 1;
overflow: hidden;
.main {
.el-form {
padding: 10px;
.el-row {
justify-content: space-between;
margin-bottom: 10px;
}
.el-form-item {
width: 100%;
margin-bottom: 0;
align-items: center;
}
}
.edit-bottom {
display: flex;
justify-content: space-between;
padding-bottom: 10px;
.bottom-common {
width: calc(50% - 10px);
.el-tabs {
height: 100%;
.el-tabs__content {
flex: 1;
overflow-y: auto;
.block {
width: 100%;
height: 200px;
overflow: auto;
}
.answer {
.tip {
color: #8a6d3b;
background-color: #fcf8e3;
border-color: #faebcc;
padding: 10px 20px;
display: flex;
align-items: center;
> p {
flex-shrink: 0;
}
}
.el-radio-group {
width: 100%;
display: inline-flex;
align-items: flex-start;
font-size: 0;
flex-direction: column;
.options {
width: 100%;
margin-top: 15px;
.content {
display: flex;
.text {
width: 100%;
height: 70px;
border: 1px solid #ededed;
.el-textarea__inner {
resize: none;
}
}
}
.more-btn {
margin-top: 8px;
background-color: #ffffff;
border-color: #007bff;
color: #007bff;
width: auto;
height: auto;
padding: 10px 10px;
}
}
}
}
}
.custom-tabs-label {
display: flex;
align-items: center;
.setting_icon {
width: 16px;
height: 16px;
background: url('@/assets/icon/setting_blue.png') no-repeat center;
background-size: 100%;
margin-left: 3px;
display: none;
}
}
.is-active {
.custom-tabs-label {
.setting_icon {
display: block;
}
}
}
:deep(.ele-pro-table) {
flex: 1;
margin-top: 10px;
.el-table--fit {
height: 100%;
}
}
}
}
}
}
}
}
}
:deep(.tox-tinymce) {
.tox-statusbar {
display: none;
}
}
:deep(.el-table) {
.el-table__header-wrapper {
.el-table__header {
thead {
tr {
th {
background: #ebebeb;
}
}
}
}
}
}
</style>

View File

@@ -0,0 +1,959 @@
<template>
<div class="edit-dialog">
<Dialog v-model="dialogVisible" :title="dialogTitle" width="85%" top="10vh">
<el-scrollbar>
<div class="main">
<el-form
ref="formRef"
v-loading="formLoading"
:model="formData"
:rules="formRules"
label-width="80px"
>
<el-row>
<el-col :span="12">
<el-form-item label="专业" prop="specialtyName">
<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 v-model="formData.chapteridDictTextVo" placeholder="请输入章节名称" disabled />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="课程" prop="courseName">
<el-input v-model="formData.courseName" placeholder="请输入课程" disabled />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="题型难度" prop="quLevel">
<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-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="题型" prop="subjectName">
<el-input v-model="formData.subjectName" placeholder="请输入题型" disabled />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="知识点" prop="pointNames">
<el-input
v-model="formData.pointNamesVo"
placeholder="请选择知识点"
readonly
@click="openPoints()"
/>
</el-form-item>
</el-col>
<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-row>
<el-row>
<el-col :span="12">
<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-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">
<div class="edit-left bottom-common">
<el-tabs v-model="leftActiveName" class="demo-tabs">
<el-tab-pane label="试题描述" name="desc">
<div class="block">
<Editor v-model="formData.content" height="150px" />
</div>
</el-tab-pane>
</el-tabs>
</div>
<div class="edit-right bottom-common">
<el-tabs v-model="rightActiveName" class="demo-tabs" @tab-click="rightHandleClick">
<el-tab-pane label="试题解析" name="analysis">
<div class="block">
<Editor v-model="formData.analysis" height="150px" />
</div>
</el-tab-pane>
<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
v-loading="loading"
:data="list"
@selection-change="handleSelectionChange"
>
<!-- <el-table-column type="selection" width="55" /> -->
<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>
<!-- <el-tab-pane name="medium">
<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-upload
v-model:file-list="fileList"
class="upload-demo"
action="https://run.mocky.io/v3/9d059bf9-4660-45f2-925d-ce80ad6c4d15"
>
<el-button>导入</el-button>
</el-upload>
</el-dropdown-item>
<el-dropdown-item>导出</el-dropdown-item>
<el-dropdown-item>播放</el-dropdown-item>
<el-dropdown-item>编辑</el-dropdown-item>
<el-dropdown-item>删除选中</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</div>
</template>
<div class="block">
<el-table
:data="mediumList"
style="width: 100%"
@selection-change="handleMediumSelectionChange"
>
<el-table-column type="index" width="50" />
<el-table-column type="selection" width="55" />
<el-table-column prop="type" label="媒体类型" width="80" />
<el-table-column prop="title" label="标题" />
<el-table-column prop="displayIndex" label="显示序号" />
<el-table-column prop="size" label="大小" />
</el-table>
</div>
</el-tab-pane> -->
<el-tab-pane name="annex">
<template #label>
<div class="custom-tabs-label">
<p>试题附件</p>
</div>
</template>
<!-- 提示 -->
<el-alert type="warning" show-icon :closable="false">
<template #default>
<span>提示文件名称可默认不设置</span>
</template>
</el-alert>
<div class="block">
<el-table :data="documentList" style="width: 100%">
<el-table-column type="index" label="#" width="50" />
<el-table-column label="文件名称" width="250">
<template #default="scope">
<el-input
v-model="scope.row.fileName"
size="small"
placeholder="请输入文件名称(未输入自动命名)"
/>
</template>
</el-table-column>
<el-table-column
prop="fileType"
label="类型"
:formatter="fileTypeFormatter"
/>
<el-table-column prop="url" label="地址" width="200">
<template #default="{ row }">
<div
style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis"
:title="row.url"
>
{{ row.url }}
</div>
</template>
</el-table-column>
<el-table-column label="操作" width="150">
<template #default="scope">
<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>
</div>
</el-tab-pane>
</el-tabs>
</div>
</div>
</div>
</el-scrollbar>
<template #footer>
<el-button :disabled="formLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
</Dialog>
</div>
<!-- 表单弹窗添加/修改 -->
<FileForm ref="FileRef" @success="handleUploadSuccess" />
<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"
:props="defaultProps"
:expand-on-click-node="false"
@node-click="handleNodelClick"
/>
</el-dialog>
<el-dialog v-model="dialogFormVisibleWordInfos" :title="titles" width="300px">
<el-tree
style="max-width: 600px"
:data="wordPointsInfoList"
:props="defaultProps"
:expand-on-click-node="false"
show-checkbox
@check-change="handleCheckChange"
/>
<template #footer>
<el-button type="primary" @click="submitWordPoints"> </el-button>
<el-button @click="dialogFormVisibleWordInfos = false"> </el-button>
</template>
</el-dialog>
</template>
<script lang="ts" setup>
import { DICT_TYPE, getIntDictOptions, getStrDictOptions } from '@/utils/dict'
import { FormRules } from 'element-plus'
import * as QuestionApi from '@/api/paper/question'
import * as XlsxApi from '@/api/wps/xlsx'
import FileForm from './components/FileForm.vue'
import WordInfo from './components/WordInfo.vue'
import WordInfos from './components/WordInfos.vue'
import * as SpecialtyApi from '@/api/points'
import { defaultProps, handleTree } from '@/utils/tree'
import { cloneDeep } from 'lodash-es'
defineOptions({ name: 'WpsWordFrom' })
const wordPointsList = ref<Tree[]>([]) // 树形结构
const wordPointsInfoList = ref<Tree[]>([]) // 树形结构
const list = ref([]) // 列表的数
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 - 修改
const formData = ref({
pointNamesVo:'',
chapteridDictTextVo:'',
content: '',
specialtyName: '',
courseName: '',
quBankName: '',
required: '',
chapteridDictText: '',
analysis: '',
quLevel: 0,
pointNames: '',
subjectName: '',
status: ' ',
resourceValue: '',
answerList: [
{
image: '',
content: '',
contentIn: '',
scoreRate: ''
}
],
fileUploads: [
{
quId: '',
url: '',
fileType: '0',
fileName: ''
},
{
quId: '',
url: '',
fileType: '1',
fileName: ''
},
{
quId: '',
url: '',
fileType: '2',
fileName: ''
}
]
})
const wordPointsFun = ref({
chineseName: '',
function: ''
})
const wordPoints = ref({
name: '',
englishName: '',
filePath: '',
type: '',
belongTo: '',
isboo: '',
function: '',
unit: '',
isExam: ''
})
let wordPointsInfosList: (typeof wordPoints)[] = []
function fileTypeFormatter(row, column, cellValue) {
if (cellValue === '0') return '素材文件(上传ZIP)'
if (cellValue === '1') return '考试文件'
if (cellValue === '2') return '结果文件'
return '未知类型'
}
const documentList = ref([
{
quId: '',
url: '',
fileType: '0',
fileName: ''
},
{
quId: '',
url: '',
fileType: '1',
fileName: ''
},
{
quId: '',
url: '',
fileType: '2',
fileName: ''
}
])
const dialogFormVisibleWordInfo = ref(false)
const dialogFormVisibleWordInfos = ref(false)
const nodeFunction = ref('')
const titles = ref('')
const englishName = ref('')
const filePath = ref('')
const upFilePath = ref('')
const functionList = ref<string[]>([])
const wordData = reactive({
chineseName: '',
englishName: '',
filePath: '',
function: [] as string[]
})
const handleCheckChange = (data: Tree, checked: boolean, indeterminate: boolean) => {
// if (checked || indeterminate) {
// wordPoints.value.belongTo = data.belongTo
// wordPoints.value.parameter = data.isboo
// wordPoints.value.type = data.type
// wordPointsFun.value = {
// chineseName: '',
// function: ''
// }
// wordPointsFun.value.chineseName = data.toChinese
// wordPointsFun.value.function = data.nodeFunction
// wordPoints.value.function.push(cloneDeep(wordPointsFun.value))
// console.log(wordPoints)
// }
if (data.titleType == '2') {
wordPoints.value.name = chineseName.value + data.toChinese
wordPoints.value.filePath = filePath.value
wordPoints.value.function = englishNames.value + data.nodeFunction
wordPoints.value.englishName = englishNames.value
wordPoints.value.belongTo = data.belongTo
wordPoints.value.isboo = data.isboo
wordPoints.value.type = data.type
wordPoints.value.unit = data.unit
wordPoints.value.isExam = "0"
wordPointsInfosList.push(cloneDeep(wordPoints.value))
}
console.log(data, checked, indeterminate)
}
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 (filePath == '' || filePath == null) {
return
}
// dialogFormVisibleWordInfo.value = true
isLoading.value = true
// if (wordPointsList.value.length <= 0) {
const res = await XlsxApi.getXlsxInfo(filePath)
list.value = res
// isLoading.value = false
// wordPointsList.value = []
// wordPointsList.value.push(...handleTree(res))
// }
}
const queryParams = reactive({
nodeFunction: undefined
})
const chineseName = ref('')
const nodeFunctions = ref('')
const englishNames = ref('')
// const handleNodelClick = async (row: any) => {
// queryParams.nodeFunction = row.selectName
// chineseName.value = '【' + row.name + '】'
// filePath.value = row.filePath
// nodeFunctions.value = row.selectName
// englishNames.value = row.englishName
// const res = await Xlsx.getWordInfos(queryParams)
// wordPointsInfoList.value = []
// 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 () => {
// const res = await WordApi.getWordListInfos(wordPointsInfosList)
// wordPoints.value = {
// name: '',
// englishName: '',
// filePath: '',
// type: '',
// belongTo: '',
// isboo: '',
// function: '',
// unit: '',
// isExam: ''
// }
// let index = 0
// wordPointsInfosList = []
// 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) {
// index += 1;
// res[i].sort = index;
// list.value.push(res[i])
// }
// }
// dialogFormVisibleWordInfo.value = false
// dialogFormVisibleWordInfos.value = false
// wordPointsList.value = []
// }
const formRules = reactive<FormRules>({
status: [{ required: true, message: '启用状态必填', trigger: 'blur' }]
})
const formRef = ref() // 表单 Ref
// 左侧试题描述
const leftActiveName = ref('desc')
// 右侧tab
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()
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)
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 = {
content: '',
specialtyName: '',
courseName: '',
quBankName: '',
required: '',
chapteridDictText: '',
analysis: '',
quLevel: 0,
pointNames: '',
subjectName: '',
status: '0',
resourceValue: '',
answerList: [
{
image: '',
content: '',
contentIn: '',
scoreRate: ''
}
],
fileUploads: [
{
quId: '',
url: '',
fileType: '0',
fileName: ''
},
{
quId: '',
url: '',
fileType: '1',
fileName: ''
},
{
quId: '',
url: '',
fileType: '2',
fileName: ''
}
]
}
documentList.value = [
{
quId: '',
url: '',
fileType: '0',
fileName: ''
},
{
quId: '',
url: '',
fileType: '1',
fileName: ''
},
{
quId: '',
url: '',
fileType: '2',
fileName: ''
}
]
list.value = []
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>
<style lang="scss" scoped>
.edit-dialog {
:deep(.el-dialog) {
display: flex;
flex-direction: column;
.el-dialog__header {
border-bottom: 1px solid #ededed;
}
.el-dialog__footer {
border-top: 1px solid #ededed;
}
.el-dialog__body {
flex: 1;
overflow: hidden;
.main {
.el-form {
padding: 10px;
.el-row {
justify-content: space-between;
margin-bottom: 10px;
}
.el-form-item {
width: 100%;
margin-bottom: 0;
align-items: center;
}
}
.edit-bottom {
display: flex;
justify-content: space-between;
padding-bottom: 10px;
.bottom-common {
width: calc(50% - 10px);
.el-tabs {
height: 100%;
.el-tabs__content {
flex: 1;
overflow-y: auto;
.block {
width: 100%;
height: 200px;
overflow: auto;
}
.answer {
.tip {
color: #8a6d3b;
background-color: #fcf8e3;
border-color: #faebcc;
padding: 10px 20px;
display: flex;
align-items: center;
> p {
flex-shrink: 0;
}
}
.el-radio-group {
width: 100%;
display: inline-flex;
align-items: flex-start;
font-size: 0;
flex-direction: column;
.options {
width: 100%;
margin-top: 15px;
.content {
display: flex;
.text {
width: 100%;
height: 70px;
border: 1px solid #ededed;
.el-textarea__inner {
resize: none;
}
}
}
.more-btn {
margin-top: 8px;
background-color: #ffffff;
border-color: #007bff;
color: #007bff;
width: auto;
height: auto;
padding: 10px 10px;
}
}
}
}
}
.custom-tabs-label {
display: flex;
align-items: center;
.setting_icon {
width: 16px;
height: 16px;
background: url('@/assets/icon/setting_blue.png') no-repeat center;
background-size: 100%;
margin-left: 3px;
display: none;
}
}
.is-active {
.custom-tabs-label {
.setting_icon {
display: block;
}
}
}
:deep(.ele-pro-table) {
flex: 1;
margin-top: 10px;
.el-table--fit {
height: 100%;
}
}
}
}
}
}
}
}
}
:deep(.tox-tinymce) {
.tox-statusbar {
display: none;
}
}
:deep(.el-table) {
.el-table__header-wrapper {
.el-table__header {
thead {
tr {
th {
background: #ebebeb;
}
}
}
}
}
}
</style>

View File

@@ -1,14 +1,14 @@
<template>
<el-row :gutter="20">
<!-- 左侧部门树 -->
<el-col :span="4" :xs="24">
<ContentWrap style="height: 50%; overflow-y: auto;">
<SpecialtyTree @node-click="handleSpecialtyNodeClick" />
</ContentWrap>
<ContentWrap style="height: 50%; overflow-y: auto;">
<DeptTree @node-click="handleDeptNodeClick" />
</ContentWrap>
</el-col>
<el-col :span="4" :xs="24">
<ContentWrap style="height: 50%; overflow-y: auto">
<SpecialtyTree @node-click="handleSpecialtyNodeClick" />
</ContentWrap>
<ContentWrap style="height: 50%; overflow-y: auto">
<DeptTree @node-click="handleDeptNodeClick" />
</ContentWrap>
</el-col>
<el-col :span="20" :xs="24">
<!-- 搜索 -->
@@ -20,25 +20,25 @@
:inline="true"
label-width="68px"
>
<!-- <el-form-item label="用户名称" prop="username">-->
<!-- <el-input-->
<!-- v-model="queryParams.username"-->
<!-- placeholder="请输入用户名称"-->
<!-- clearable-->
<!-- @keyup.enter="handleQuery"-->
<!-- class="!w-240px"-->
<!-- />-->
<!-- </el-form-item>-->
<!-- <el-form-item label="手机号码" prop="mobile">-->
<!-- <el-input-->
<!-- v-model="queryParams.mobile"-->
<!-- placeholder="请输入手机号码"-->
<!-- clearable-->
<!-- @keyup.enter="handleQuery"-->
<!-- class="!w-240px"-->
<!-- />-->
<!-- </el-form-item>-->
<!-- <el-form-item label="审核状态" prop="audit">
<!-- <el-form-item label="用户名称" prop="username">-->
<!-- <el-input-->
<!-- v-model="queryParams.username"-->
<!-- placeholder="请输入用户名称"-->
<!-- clearable-->
<!-- @keyup.enter="handleQuery"-->
<!-- class="!w-240px"-->
<!-- />-->
<!-- </el-form-item>-->
<!-- <el-form-item label="手机号码" prop="mobile">-->
<!-- <el-input-->
<!-- v-model="queryParams.mobile"-->
<!-- placeholder="请输入手机号码"-->
<!-- clearable-->
<!-- @keyup.enter="handleQuery"-->
<!-- class="!w-240px"-->
<!-- />-->
<!-- </el-form-item>-->
<!-- <el-form-item label="审核状态" prop="audit">
<el-select
v-model="queryParams.audit"
placeholder="请选择审核状态"
@@ -53,107 +53,96 @@
/>
</el-select>
</el-form-item> -->
<el-form-item>
<!-- 状态切换单独一行 -->
<el-radio-group v-model="queryParams.audit" @change="handleQuery">
<el-radio-button :label="''">全部</el-radio-button>
<el-radio-button :label="'0'">审核通过</el-radio-button>
<el-radio-button :label="'1'">未审核</el-radio-button>
<el-radio-button :label="'2'">待审核</el-radio-button>
<el-radio-button :label="'3'">审核未通过</el-radio-button>
</el-radio-group>
</el-form-item>
<!-- <el-form-item label="创建时间" prop="createTime">-->
<!-- <el-date-picker-->
<!-- v-model="queryParams.createTime"-->
<!-- value-format="YYYY-MM-DD HH:mm:ss"-->
<!-- type="datetimerange"-->
<!-- start-placeholder="开始日期"-->
<!-- end-placeholder="结束日期"-->
<!-- class="!w-240px"-->
<!-- />-->
<!-- </el-form-item>-->
<el-form-item>
<!-- 状态切换单独一行 -->
<el-radio-group v-model="queryParams.audit" @change="handleQuery">
<el-radio-button :label="''">全部</el-radio-button>
<el-radio-button :label="'0'">审核通过</el-radio-button>
<el-radio-button :label="'1'">未审核</el-radio-button>
<el-radio-button :label="'2'">待审核</el-radio-button>
<el-radio-button :label="'3'">审核未通过</el-radio-button>
</el-radio-group>
</el-form-item>
<!-- <el-form-item label="创建时间" prop="createTime">-->
<!-- <el-date-picker-->
<!-- v-model="queryParams.createTime"-->
<!-- value-format="YYYY-MM-DD HH:mm:ss"-->
<!-- type="datetimerange"-->
<!-- start-placeholder="开始日期"-->
<!-- end-placeholder="结束日期"-->
<!-- class="!w-240px"-->
<!-- />-->
<!-- </el-form-item>-->
<el-form-item>
<el-button @click="handleQuery"><Icon icon="ep:search" />搜索</el-button>
<!-- <el-button @click="resetQuery"><Icon icon="ep:refresh" />重置</el-button> -->
<el-button
type="danger"
class="ele-btn-del"
:disabled="!selections.length"
@click="handleDeletes()"
>
批量删除
</el-button>
<el-button
type="warning"
plain
@click="handleImport"
>
<Icon icon="ep:upload" /> 导入
</el-button>
<el-button
type="primary"
plain
@click="openForm('create')"
type="danger"
class="ele-btn-del"
:disabled="!selections.length"
@click="handleDeletes()"
>
批量删除
</el-button>
<el-button type="warning" plain @click="handleImport">
<Icon icon="ep:upload" /> 导入
</el-button>
<el-button type="primary" plain @click="openForm('create')">
<Icon icon="ep:plus" /> 新增
</el-button>
<el-button @click="connectTent()">连接服务器</el-button>
<el-button @click="connectTong()">同步试题</el-button>
<!-- <el-button-->
<!-- type="warning"-->
<!-- plain-->
<!-- @click="handleImport"-->
<!-- v-hasPermi="['system:user:import']"-->
<!-- >-->
<!-- <Icon icon="ep:upload" /> 导入-->
<!-- </el-button>-->
<!-- <el-button-->
<!-- type="success"-->
<!-- plain-->
<!-- @click="handleExport"-->
<!-- :loading="exportLoading"-->
<!-- v-hasPermi="['system:user:export']"-->
<!-- >-->
<!-- <Icon icon="ep:download" />导出-->
<!-- </el-button>-->
<el-button @click="connectTent()">连接服务器</el-button>
<el-button @click="connectTong()">同步试题</el-button>
<!-- <el-button-->
<!-- type="warning"-->
<!-- plain-->
<!-- @click="handleImport"-->
<!-- v-hasPermi="['system:user:import']"-->
<!-- >-->
<!-- <Icon icon="ep:upload" /> 导入-->
<!-- </el-button>-->
<!-- <el-button-->
<!-- type="success"-->
<!-- plain-->
<!-- @click="handleExport"-->
<!-- :loading="exportLoading"-->
<!-- v-hasPermi="['system:user:export']"-->
<!-- >-->
<!-- <Icon icon="ep:download" />导出-->
<!-- </el-button>-->
</el-form-item>
<!-- 审核按钮单独显示在下一行 -->
<el-form-item>
<el-button v-if="queryParams.audit === '1'" type="primary" plain @click="handleAudit()">
<Icon icon="ep:plus" /> 推送审核试题
</el-button>
<el-button
v-if="queryParams.audit === '' || queryParams.audit === '0'"
type="primary"
plain
@click="handleTUI()"
v-hasPermi="['question:create']"
>
<Icon icon="ep:top" />推送试题
</el-button>
</el-form-item>
<!-- 审核按钮单独显示在下一行 -->
<el-form-item >
<el-button
v-if="queryParams.audit === '1'"
type="primary"
plain
@click="handleAudit()"
>
<Icon icon="ep:plus" /> 推送审核试题
</el-button>
<el-button
v-if="queryParams.audit === '' || queryParams.audit === '0'"
type="primary"
plain
@click="handleTUI()"
v-hasPermi="['question:create']"
>
<Icon icon="ep:top" />推送试题
</el-button>
</el-form-item>
</el-form>
</ContentWrap>
<ContentWrap>
<el-table v-loading="loading" :data="list" @selection-change="handleSelectionChange">
<el-table v-loading="loading" :data="list" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" />
<el-table-column label="试题编号" align="center" prop="quNum" :show-overflow-tooltip="true"/>
<el-table-column
label="试题编号"
align="center"
prop="quNum"
:show-overflow-tooltip="true"
/>
<el-table-column label="专业" align="center" prop="specialtyName" width="120" />
<el-table-column
label="课程"
align="center"
prop="courseName"
:show-overflow-tooltip="true"
label="课程"
align="center"
prop="courseName"
:show-overflow-tooltip="true"
/>
<el-table-column
label="章节名称"
@@ -167,35 +156,29 @@
prop="nickname"
:show-overflow-tooltip="true"
/> -->
<el-table-column
label="难度"
align="center"
prop="quLevel"
:show-overflow-tooltip="true"
>
<template #default="scope">
<dict-tag :type="DICT_TYPE.EXAM_QUE_DIFF" :value="scope.row.quLevel" />
</template>
</el-table-column>
<el-table-column label="难度" align="center" prop="quLevel" :show-overflow-tooltip="true">
<template #default="scope">
<dict-tag :type="DICT_TYPE.EXAM_QUE_DIFF" :value="scope.row.quLevel" />
</template>
</el-table-column>
<el-table-column
label="知识点"
align="center"
prop="pointNamesVo"
:show-overflow-tooltip="true"
label="知识点"
align="center"
prop="pointNamesVo"
:show-overflow-tooltip="true"
/>
<el-table-column
label="审核状态"
align="center"
prop="audit"
:show-overflow-tooltip="true"
>
<template #default="scope">
<dict-tag :type="DICT_TYPE.QUESTION_AUDIT" :value="scope.row.audit" />
</template>
</el-table-column>
label="审核状态"
align="center"
prop="audit"
:show-overflow-tooltip="true"
>
<template #default="scope">
<dict-tag :type="DICT_TYPE.QUESTION_AUDIT" :value="scope.row.audit" />
</template>
</el-table-column>
<!-- <el-table-column
label="来源"
align="center"
@@ -217,12 +200,11 @@
<el-table-column label="状态" key="status">
<template #default="scope">
<el-switch
v-model="scope.row.status"
active-value="0"
inactive-value="1"
@change="handleStatusChange(scope.row)"
v-model="scope.row.status"
active-value="0"
inactive-value="1"
@change="handleStatusChange(scope.row)"
/>
</template>
</el-table-column>
<el-table-column
@@ -235,18 +217,10 @@
<el-table-column label="操作" align="center" width="160">
<template #default="scope">
<div class="flex items-center justify-center">
<el-button
type="primary"
link
@click="openForm('update', scope.row.quId)"
>
<el-button type="primary" link @click="openForm('update', scope.row.quId)">
<Icon icon="ep:edit" />修改
</el-button>
<el-button
type="primary"
link
@click="handleDelete( scope.row.quId)"
>
<el-button type="primary" link @click="handleDelete(scope.row.quId)">
<Icon icon="ep:delete" />删除
</el-button>
</div>
@@ -263,73 +237,68 @@
</el-col>
</el-row>
<!-- 同步弹框 -->
<el-dialog
v-model="syncDialogVisible"
<!-- 同步弹框 -->
<el-dialog
v-model="syncDialogVisible"
:title="'同步试题'"
width="800px"
:before-close="handleCloseSyncDialog"
>
<ContentWrap>
<!-- 搜索表单 -->
<el-form
class="-mb-15px"
:model="queryParamsSchool"
ref="queryFormRefSchool"
:inline="true"
label-width="68px"
>
width="800px"
:before-close="handleCloseSyncDialog"
>
<ContentWrap>
<!-- 搜索表单 -->
<el-form
class="-mb-15px"
:model="queryParamsSchool"
ref="queryFormRefSchool"
:inline="true"
label-width="68px"
>
<el-form-item label="学校" prop="name">
<el-input
v-model="queryParamsSchool.name"
placeholder="请输入学校名称"
clearable
class="!w-240px"
@keyup.enter="handleQuerySchool"
/>
</el-form-item>
<el-input
v-model="queryParamsSchool.name"
placeholder="请输入学校名称"
clearable
class="!w-240px"
@keyup.enter="handleQuerySchool"
/>
</el-form-item>
<el-form-item>
<el-button @click="handleQuerySchool">
<Icon icon="ep:search" class="mr-5px" /> 搜索
</el-button>
<el-form-item>
<el-button @click="handleQuerySchool">
<Icon icon="ep:search" class="mr-5px" /> 搜索
</el-button>
<el-button @click="resetQuerySchool"><Icon icon="ep:refresh" />重置</el-button>
</el-form-item>
</el-form>
</ContentWrap>
<ContentWrap>
<el-table v-loading="loadingSchool" :data="listSchool" @selection-change="handleSelectionChangeSchool">
<el-table-column type="selection" width="55" />
<el-table-column v-if="false" label="编号" align="center" prop="id" />
<el-table-column label="学校" align="center" prop="name" />
</el-table>
<Pagination
:total="totalSchool"
v-model:page="queryParamsSchool.pageNo"
v-model:limit="queryParamsSchool.pageSize"
@pagination="getSchoolList"
/>
</ContentWrap>
<template #footer>
<span class="dialog-footer">
<el-button @click="handleCloseSyncDialog">取消</el-button>
<el-button @click="connectSchoolAll">测试连接</el-button>
<el-button type="primary" @click="confirmSync">确定</el-button>
</span>
</template>
</el-dialog>
</el-form-item>
</el-form>
</ContentWrap>
<ContentWrap>
<el-table
v-loading="loadingSchool"
:data="listSchool"
@selection-change="handleSelectionChangeSchool"
>
<el-table-column type="selection" width="55" />
<el-table-column v-if="false" label="编号" align="center" prop="id" />
<el-table-column label="学校" align="center" prop="name" />
</el-table>
<Pagination
:total="totalSchool"
v-model:page="queryParamsSchool.pageNo"
v-model:limit="queryParamsSchool.pageSize"
@pagination="getSchoolList"
/>
</ContentWrap>
<template #footer>
<span class="dialog-footer">
<el-button @click="handleCloseSyncDialog">取消</el-button>
<el-button @click="connectSchoolAll">测试连接</el-button>
<el-button type="primary" @click="confirmSync">确定</el-button>
</span>
</template>
</el-dialog>
<!-- 添加或修改选择题 -->
<ChoiceForm ref="formRef" @success="getList" />
@@ -347,8 +316,10 @@
<FdesignForm ref="fformRef" @success="getList" />
<WpsWordForm ref="wformRef" @success="getList" />
<WpsPptxForm ref="pformRef" @success="getList" />
<SettingForm ref="setformRef" @success="getList" />
<EmailForm ref="emailformRef" @success="getList" />
<WpsExcelForm ref="xlsxformRef" @success="getList" />
</template>
<script lang="ts" setup>
import { checkPermi } from '@/utils/permission'
@@ -366,10 +337,14 @@ import FdesignForm from './FileForm.vue'
import UserImportForm from './UserImportForm.vue'
import WpsWordForm from './WpsWordForm.vue'
import WpsPptxForm from './WpsPptxForm.vue'
import SettingForm from './SettingForm.vue'
import WpsExcelForm from './WpsExcelForm.vue'
import EmailForm from './EmailForm.vue'
import UserAssignRoleForm from './UserAssignRoleForm.vue'
import DeptTree from './DeptTree.vue'
import SpecialtyTree from './SpecialtyTree.vue'
import {handleTree} from "@/utils/tree";
import { handleTree } from '@/utils/tree'
import * as SpecialtyApi from '@/api/points'
defineOptions({ name: 'SystemUser' })
@@ -381,16 +356,16 @@ const total = ref(0) // 列表的总页数
const list = ref([]) // 列表的数
const queryParams = reactive({
chapteridDictTextVo:'',
pointNamesVo:'',
specialtyName: "",
courseName: "",
subjectName: "",
pointNames:"",
chapteridDictText:"",
chapteridDictTextVo: '',
pointNamesVo: '',
specialtyName: '',
courseName: '',
subjectName: '',
pointNames: '',
chapteridDictText: '',
pageNo: 1,
pageSize: 10,
audit:""
audit: ''
})
const queryFormRef = ref() // 搜索的表单
const specialtyList = ref<Tree[]>([]) // 树形结构
@@ -412,16 +387,16 @@ const syncDialogVisible = ref(false)
/** 查询列表 */
const getList = async () => {
await getTree();
await getTreePoint();
await getTree()
await getTreePoint()
loading.value = true
try {
const params = {
...queryParams,
pointNames: queryParams.pointNamesVo,
chapteridDictText: queryParams.chapteridDictTextVo,
};
const data = await QuestionApi.getQuestionList(params);
chapteridDictText: queryParams.chapteridDictTextVo
}
const data = await QuestionApi.getQuestionList(params)
list.value = data.list
total.value = data.total
} finally {
@@ -444,40 +419,40 @@ const resetQuery = () => {
queryFormRef.value?.resetFields()
handleQuery()
}
const choosePointsType = ref('');
const choosePointsType = ref('')
/** 处理部门被点击 */
const handleDeptNodeClick = async (row) => {
choosePointsType.value = row.name;
choosePointsType.value = row.name
// 判断点击的层级结构,进行入参
if (!row.children != null){
if (!row.children != null) {
}
const specArr: any = findIdPathFromTreeList(respoint.value, row.id)
console.log(specArr+"specArr")
console.log(specArr + 'specArr')
console.log(specArr[1].name + 'specArr[1].name')
console.log(specArr[1].id + 'specArr[1].name')
console.log(specArr[1].name+"specArr[1].name")
console.log(specArr[1].id+"specArr[1].name")
// 判断长度赋值
if (specArr.length == 1) {
}
if (specArr.length == 2) {
}
if (specArr.length == 3) {
queryParams.chapteridDictText=specArr[1].name;
queryParams.pointNames = specArr[2].name;
queryParams.chapteridDictText = specArr[1].name
queryParams.pointNames = specArr[2].name
queryParams.chapteridDictTextVo = specArr[1].id;
queryParams.pointNamesVo = specArr[2].id;
queryParams.chapteridDictTextVo = specArr[1].id
queryParams.pointNamesVo = specArr[2].id
}
await getList()
}
/** 处理专业被点击 */
const chooseQuestionType = ref('');
const chooseQuestionType = ref('')
const handleSpecialtyNodeClick = async (row: any) => {
chooseQuestionType.value = row.name;
chooseQuestionType.value = row.name
// 判断点击的层级结构,进行入参
if (!row.children != null){
if (!row.children != null) {
// 说明是题型
queryParams.courseName = row.name
}
@@ -499,71 +474,66 @@ const handleSpecialtyNodeClick = async (row: any) => {
await getList()
}
/** 表格选中数据 */
const selections = ref([]);
/** 表格选中数据 */
const selections = ref([])
const handleSelectionChange = (rows) => {
selections.value = rows;
selections.value = rows
}
const selectedSchool = ref([]);
const selectedSchool = ref([])
const handleSelectionChangeSchool = (rows) => {
selectedSchool.value = rows;
selectedSchool.value = rows
}
const selectedRows = ref<string[]>([])
const selectedRows = ref<string[]>([])
const handleAudit = async () => {
try {
const rows = selections.value;
if (!rows.length) {
message.error('请至少选择一条数据');
return;
}
const rows = selections.value
if (!rows.length) {
message.error('请至少选择一条数据')
return
}
selectedRows.value = rows.map((d: any) => d.quId);
console.log(selectedRows.value)
selectedRows.value = rows.map((d: any) => d.quId)
console.log(selectedRows.value)
const requestBody = {
type: '0',
quIds: selectedRows.value
}
await QuestionApi.auditQuestion(requestBody)
const requestBody = {
type: '0',
quIds: selectedRows.value
}
await QuestionApi.auditQuestion(requestBody)
message.success(t('推送成功'))
// 刷新列表
await getList()
} catch {}
}
const queryParamsSchool = reactive({
name:'',
name: '',
pageNo: 1,
pageSize: 10,
pageSize: 10
})
const totalSchool = ref(0) // 列表的总页数
const listSchool = ref([]) // 列表的数
const schoolNameList = ref();
const schoolNameList = ref()
const loadingSchool = ref(true)
const handleTUI = async () => {
try {
const rows = selections.value;
if (!rows.length) {
message.error('请至少选择一条数据');
return;
}
const rows = selections.value
if (!rows.length) {
message.error('请至少选择一条数据')
return
}
selectedRows.value = rows.map((d: any) => d.quId);
getSchoolList();
syncDialogVisible.value = true
selectedRows.value = rows.map((d: any) => d.quId)
getSchoolList()
syncDialogVisible.value = true
} catch {}
}
const getSchoolList = async () => {
loadingSchool.value = true
try {
const data = await QuestionApi.getSchoolName(queryParamsSchool);
const data = await QuestionApi.getSchoolName(queryParamsSchool)
listSchool.value = data.list
totalSchool.value = data.total
@@ -576,11 +546,9 @@ const handleQuerySchool = () => {
getSchoolList()
}
const resetQuerySchool = () => {
queryParamsSchool.name = ''
queryParamsSchool.name = ''
}
const handleCloseSyncDialog = () => {
syncDialogVisible.value = false
queryParamsSchool.name = ''
@@ -589,75 +557,68 @@ const handleCloseSyncDialog = () => {
}
const confirmSync = () => {
if (selectedSchool.value.length === 0) {
ElMessage.warning('请先选择要同步的学校');
return;
ElMessage.warning('请先选择要同步的学校')
return
}
const selectedIds = selectedSchool.value.map(item => item.ququeName);
console.log('选中的ID:', selectedIds);
const selectedIds = selectedSchool.value.map((item) => item.ququeName)
console.log('选中的ID:', selectedIds)
const rows = selections.value;
selectedRows.value = rows.map((d: any) => d.quId);
console.log(selectedRows.value+"选中的试题")
const rows = selections.value
selectedRows.value = rows.map((d: any) => d.quId)
console.log(selectedRows.value + '选中的试题')
const payload = {
queueNames: selectedIds,
questionIds: selectedRows.value
};
console.log(payload+"payload")
QuestionApi.doPush(payload).then(
() => {
ElMessage.success('推送成功');
syncDialogVisible.value = false;
getList();
const payload = {
queueNames: selectedIds,
questionIds: selectedRows.value
}
).catch(() => {
ElMessage.error('推送失败');
}
);
};
console.log(payload + 'payload')
QuestionApi.doPush(payload)
.then(() => {
ElMessage.success('推送成功')
syncDialogVisible.value = false
getList()
})
.catch(() => {
ElMessage.error('推送失败')
})
}
const connectSchoolAll = () => {
if (selectedSchool.value.length === 0) {
ElMessage.warning('请先选择要连接的学校');
return;
ElMessage.warning('请先选择要连接的学校')
return
}
const selectedIds = selectedSchool.value.map(item => item.ququeName);
console.log('选中的ID:', selectedIds);
QuestionApi.connectSchoolAll(selectedIds).then(() => {
ElMessage.success('连接成功');
}).catch(() => {
ElMessage.error('同步失败');
});
};
const selectedIds = selectedSchool.value.map((item) => item.ququeName)
console.log('选中的ID:', selectedIds)
QuestionApi.connectSchoolAll(selectedIds)
.then(() => {
ElMessage.success('连接成功')
})
.catch(() => {
ElMessage.error('同步失败')
})
}
const connectTent = async () => {
try {
const res = await QuestionApi.rabbitmqConnect();
const res = await QuestionApi.rabbitmqConnect()
console.log(res)
message.success(t(res));
message.success(t(res))
} catch (error) {
message.error(t(`连接失败: ${error?.message || '未知错误'}`));
message.error(t(`连接失败: ${error?.message || '未知错误'}`))
}
}
const connectTong = async () => {
try {
const res = await QuestionApi.receiveAll();
message.success(t('同步成功'));
const res = await QuestionApi.receiveAll()
message.success(t('同步成功'))
} catch (error) {
message.error(t(`连接失败: ${error?.message || '未知错误'}`));
message.error(t(`连接失败: ${error?.message || '未知错误'}`))
}
}
interface Tree {
id: number
name: string
@@ -667,11 +628,7 @@ interface Tree {
* 递归查找路径
*/
/** 递归查找路径(根据 ID 返回 name 路径) */
const findNamePath = (
node: Tree,
targetId: number,
path: string[] = []
): string[] | null => {
const findNamePath = (node: Tree, targetId: number, path: string[] = []): string[] | null => {
const currentPath = [...path, node.name]
if (node.id === targetId) {
return currentPath
@@ -688,8 +645,8 @@ const findNamePath = (
const findIdNamePath = (
node: Tree,
targetId: number,
path: Array<{ id: number, name: string }> = []
): Array<{ id: number, name: string }> | null => {
path: Array<{ id: number; name: string }> = []
): Array<{ id: number; name: string }> | null => {
const currentPath = [...path, { id: node.id, name: node.name }]
if (node.id === targetId) {
return currentPath
@@ -703,7 +660,6 @@ const findIdNamePath = (
return null
}
/** 入口函数:支持根节点是数组的情况 */
const findNamePathFromTreeList = (treeList: Tree[], targetId: number): string[] | null => {
for (const tree of treeList) {
@@ -713,12 +669,11 @@ const findNamePathFromTreeList = (treeList: Tree[], targetId: number): string[]
return null
}
// 遍历树列表查找路径
const findIdPathFromTreeList = (
treeList: Tree[],
targetId: number
): Array<{ id: number, name: string }> | null => {
): Array<{ id: number; name: string }> | null => {
for (const tree of treeList) {
const result = findIdNamePath(tree, targetId)
if (result) return result
@@ -733,26 +688,35 @@ const bformRef = ref()
const fformRef = ref()
const wformRef = ref()
const pformRef = ref()
const setformRef = ref()
const emailformRef = ref()
const xlsxformRef = ref()
const openForm = (type: string, id?: number) => {
console.log(queryParams)
if (queryParams.subjectName == "") {
return message.confirm('请选择题型!');
if (queryParams.subjectName == '') {
return message.confirm('请选择题型!')
}
if (chooseQuestionType.value.includes("选择题")){
if (chooseQuestionType.value.includes('选择题')) {
formRef.value.open(queryParams, type, id)
} else if(chooseQuestionType.value.includes("编程题")) {
cformRef.value.open(type, id)
}else if(chooseQuestionType.value.includes("程序设计")) {
mformRef.value.open(queryParams,type, id)
}else if(chooseQuestionType.value.includes("网络题")) {
bformRef.value.open(queryParams,type, id)
}else if(chooseQuestionType.value.includes("文件处理")) {
fformRef.value.open(queryParams,type, id)
} else if (chooseQuestionType.value.includes("文字")){
wformRef.value.open(queryParams,type, id)
} else if (chooseQuestionType.value.includes("演示")){
pformRef.value.open(queryParams,type, id)
} else if (chooseQuestionType.value.includes('编程题')) {
cformRef.value.open(type, id)
} else if (chooseQuestionType.value.includes('程序设计')) {
mformRef.value.open(queryParams, type, id)
} else if (chooseQuestionType.value.includes('网络题')) {
bformRef.value.open(queryParams, type, id)
} else if (chooseQuestionType.value.includes('文件处理')) {
fformRef.value.open(queryParams, type, id)
} else if (chooseQuestionType.value.includes('文字')) {
wformRef.value.open(queryParams, type, id)
} else if (chooseQuestionType.value.includes('演示')) {
pformRef.value.open(queryParams, type, id)
} else if (chooseQuestionType.value.includes('windows网络设置')) {
setformRef.value.open(queryParams, type, id)
} else if (chooseQuestionType.value.includes('邮箱')) {
emailformRef.value.open(queryParams, type, id)
} else if (chooseQuestionType.value.includes('表格')) {
xlsxformRef.value.open(queryParams, type, id)
}
}
@@ -765,7 +729,7 @@ const handleStatusChange = async (row: any) => {
// 修改状态的二次确认
await message.confirm('确认要修改' + row.quNum + '"试题状态吗?')
// 发起修改状态
QuestionApi.updateQuStatus(row.quId,row.status);
QuestionApi.updateQuStatus(row.quId, row.status)
// 刷新列表
await getList()
} catch {
@@ -799,22 +763,18 @@ const handleCommand = (command: string, row: UserApi.UserVO) => {
const handleDelete = async (id: number) => {
try {
// 删除的二次确认
await ElMessageBox.confirm(
'只能删除未被使用的试题,是否确认删除?',
'警告',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}
);
await ElMessageBox.confirm('只能删除未被使用的试题,是否确认删除?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
// 发起删除
const res = await QuestionApi.removeQuestions(id);
if(res=='删除成功'){
message.success(res)
}else{
message.error(res)
}
const res = await QuestionApi.removeQuestions(id)
if (res == '删除成功') {
message.success(res)
} else {
message.error(res)
}
// 刷新列表
await getList()
} catch {}
@@ -822,32 +782,25 @@ const handleDelete = async (id: number) => {
const handleDeletes = async () => {
try {
const rows = selections.value;
if (!rows.length) {
message.error('请至少选择一条数据');
return;
}
const rows = selections.value
if (!rows.length) {
message.error('请至少选择一条数据')
return
}
// 删除的二次确认
await ElMessageBox.confirm(
'只能删除未被使用的试题,是否确认删除?',
'警告',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}
);
selectedRows.value = rows.map((d: any) => d.quId); // 保存选中的行数据
await QuestionApi.removeQuestions(selectedRows.value)
await ElMessageBox.confirm('只能删除未被使用的试题,是否确认删除?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
selectedRows.value = rows.map((d: any) => d.quId) // 保存选中的行数据
await QuestionApi.removeQuestions(selectedRows.value)
message.success(t('common.delSuccess'))
// 刷新列表
await getList()
} catch {}
}
/** 重置密码 */
const handleResetPwd = async (row: UserApi.UserVO) => {
try {