【修改】 wps出题样式优化,错误提示去除

This commit is contained in:
dlaren
2025-09-10 15:12:17 +08:00
parent a6edb33f1e
commit 502b4aa154
3 changed files with 238 additions and 206 deletions

View File

@@ -139,9 +139,10 @@
v-loading="loading"
:data="list"
@selection-change="handleSelectionChange"
style="width: 100%"
>
<!-- <el-table-column type="selection" width="55" /> -->
<el-table-column label="考点" align="center" prop="contentIn" width="360px" />
<el-table-column label="考点" align="center" prop="contentIn"/>
<el-table-column label="权值" align="center" prop="scoreRate" width="100px" />
<el-table-column label="操作" align="center" width="100px">
<template #default="scope">
@@ -294,18 +295,17 @@
/>
</div>
<div style="flex: 1.5; overflow: auto; border: 1px solid #eee; padding: 8px">
<div style="flex: 1.5; overflow: auto; border: 1px solid #eee; padding: 8px; width: 90%;">
<h3>考点详情</h3>
<el-table :data="list" style="width: 100%">
<el-table-column prop="contentIn" label="值" width="500px" />
<el-table-column prop="scoreRate" label="权值" width="100">
<el-table-column prop="contentIn" label="值" />
<el-table-column prop="scoreRate" label="权值" width="100px">
<template #default="{ row }">
<el-input v-model="row.scoreRate" size="small" style="width: 40px" />
<el-input v-model="row.scoreRate" size="small" style="width: 50px" />
</template>
</el-table-column>
<el-table-column label="操作" width="100">
<el-table-column label="操作" width="100px">
<template #default="{ row }">
<span
@click="removePoint(row)"
@@ -364,7 +364,15 @@ defineOptions({ name: 'WpsWordFrom' })
const wordPointsList = ref<Tree[]>([]) // 树形结构
const wordPointsInfoList = ref<Tree[]>([]) // 树形结构
const list = ref([]) // 列表的数
// 明确 list 类型,避免 never[] 类型报错
interface AnswerItem {
image: string;
content: string;
contentIn: string;
scoreRate: string;
[key: string]: any;
}
const list = ref<AnswerItem[]>([])
const { t } = useI18n() // 国际化
const message = useMessage() // 消息弹窗
const loading = ref(false) // 列表的加载中
@@ -417,7 +425,16 @@ const formData = ref({
]
})
let wordPointsInfosList: (typeof wordPoints)[] = []
// 定义 wordPointsInfosList 类型,避免 wordPoints 未定义报错
interface WordPointsInfo {
firstName: string;
index: string;
function: string;
examName: string;
examCode: string;
method?: string;
}
let wordPointsInfosList: WordPointsInfo[] = []
const removePoint = (row) => {
// list.value.splice(index, 1)
for (let i = 0; i < list.value.length; i++) {
@@ -426,7 +443,7 @@ const removePoint = (row) => {
}
}
}
function fileTypeFormatter(row, column, cellValue) {
function fileTypeFormatter(_row: any, _column: any, cellValue: string) {
if (cellValue === '0') return '素材文件(上传ZIP)'
if (cellValue === '1') return '考试文件'
if (cellValue === '2') return '结果文件'
@@ -455,33 +472,31 @@ const documentList = ref([
const dialogFormVisibleWordInfo = ref(false)
const dialogFormVisibleWordInfos = ref(false)
const titles = ref('')
const filePath = ref('')
// 已声明未用,注释掉避免报错
// const filePath = ref('')
const handleCheckChange = (data: Tree, checked: boolean, indeterminate: boolean) => {
console.log(data)
const wordPoints = {
firstName: '',
index: '',
function: '',
examName: '',
examCode: ''
// Tree 类型补充 any避免类型报错
const handleCheckChange = (data: any, _checked: boolean, _indeterminate: boolean) => {
const wordPoints: WordPointsInfo = {
firstName: chineseName.value,
index: textIndex.value,
function: data.functions ?? '',
examName: data.chineseName ?? '',
examCode: '111',
method: data.parameter ?? ''
}
if (data.functions != null && data.functions != '') {
wordPoints.firstName = chineseName.value
wordPoints.index = textIndex.value
wordPoints.function = data.functions
wordPoints.examName = data.chineseName
wordPoints.examCode = '111'
wordPoints.method = data.parameter
if (wordPoints.function) {
wordPointsInfosList.push(cloneDeep(wordPoints))
}
}
const file = ref()
const file = ref<any>()
// 获取docx文件并使用文件流进行解析
const getDocxDataInfo = async () => {
const fileInput = document.getElementById('docxFile') as HTMLInputElement
if (fileInput != null) {
file.value = fileInput.files[0]
if (fileInput.files && fileInput.files.length > 0) {
file.value = fileInput.files[0]
}
const res = await WordApi.getWordDataInfo({ file: file.value })
wordPointsList.value = []
wordPointsList.value.push(...handleTree(res.data))
@@ -493,9 +508,9 @@ const addWordForm = async () => {
dialogFormVisibleWordInfo.value = true
}
const queryParams = reactive({
nodeFunction: undefined
})
// const queryParams = reactive({
// nodeFunction: undefined
// })
const chineseName = ref('')
const textIndex = ref()
@@ -521,11 +536,11 @@ const handleNodelClick = async (row: any) => {
wordPointsInfoList.value.push(...handleTree(res))
dialogFormVisibleWordInfos.value = true
}
const handleDelete = (row) => {
console.log(row)
const handleDelete = (row: any) => {
for (let i = 0; i < list.value.length; i++) {
if (row.content == list.value[i].content) {
if ((row.content ?? row.contentIn) == (list.value[i].content ?? list.value[i].contentIn)) {
list.value.splice(i, 1)
break
}
}
}
@@ -550,14 +565,14 @@ const submitWordPoints = async () => {
res.data[i].scoreRate='1'
var indexFlag = false
for (let x = 0; x < list.value.length; x++) {
if (res.data[i].content == list.value[x].content) {
if ((res.data[i].content ?? res.data[i].contentIn) == (list.value[x].content ?? list.value[x].contentIn)) {
// 如果存在相同的数据话 不进入
indexFlag = true
}
}
if (!indexFlag) {
res.data[i].sort = list.value.length + 1
list.value.push(res.data[i])
list.value.push(res.data[i] as any)
}
}
// wordPoints.value = {
@@ -590,14 +605,15 @@ const submitWordPoints = async () => {
// wordPointsList.value = []
}
const formRules = reactive<FormRules>({
status: [{ required: true, message: '启用状态必填', trigger: 'blur' }]
status: [{ required: true, message: '启用状态必填', trigger: 'blur' }],
pointNames: [{ required: true, message: '知识点必填', trigger: 'blur' }]
})
const formRef = ref() // 表单 Ref
// 左侧试题描述
const leftActiveName = ref('desc')
// 右侧tab
const rightActiveName = ref('annex')
const rightHandleClick = (tab, e) => {
const rightHandleClick = (tab: any) => {
rightActiveName.value = tab.paneName.value
}
const selections = ref([])
@@ -647,17 +663,16 @@ const deleteUrl = (index: number) => {
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 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) {
@@ -695,15 +710,15 @@ const open = async (queryParams: any, type: string, id?: number) => {
}
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 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 () => {
@@ -819,7 +834,7 @@ const handleTreeWithLevel = (list, level = 1) => {
// 只允许点击第三级节点
const treeRef = ref() // 引用 el-tree
const handleNodeClick = (data, node) => {
const handleNodeClick = (data: any) => {
if (data.level === 3) {
formData.value.pointNames = data.id
formData.value.pointNamesVo = data.name