diff --git a/src/views/paper/audit/ChoiceForm.vue b/src/views/paper/audit/ChoiceForm.vue index 5d48839..2674772 100644 --- a/src/views/paper/audit/ChoiceForm.vue +++ b/src/views/paper/audit/ChoiceForm.vue @@ -16,48 +16,103 @@ - + + + + + + + + + + + + + - - + - - - - - - + + + - - - - - + + + + + + + + + + + + - + - + 启用 禁用 - + - +
@@ -256,7 +311,8 @@ import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' import { FormRules } from 'element-plus' import * as QuestionApi from '@/api/paper/question' - +import * as SpecialtyApi from '@/api/points' +import { defaultProps, handleTree } from '@/utils/tree' defineOptions({ name: 'ChoiceForm' }) const { t } = useI18n() // 国际化 @@ -267,6 +323,8 @@ const dialogTitle = ref('') // 弹窗的标题 const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用 const formType = ref('') // 表单的类型:create - 新增;update - 修改 const formData = ref({ + pointNamesVo:'', + chapteridDictTextVo:'', content: '', specialtyName: '', courseName: '', @@ -274,7 +332,7 @@ const formData = ref({ required: '', chapteridDictText: '', analysis: '', - quLevel: '', + quLevel: 0, pointNames: '', audit: '', subjectName: '', @@ -349,12 +407,9 @@ const open = async (queryParams: any ,type: string, id?: number) => { dialogTitle.value = t('action.' + type) formType.value = type resetForm() - console.log(id+"idid") // 修改时,设置数据 if (id) { - - formLoading.value = true try { formData.value = await QuestionApi.getQuestionnotId(id) @@ -422,10 +477,8 @@ const submitForm = async () => { formLoading.value = true try { const data = formData.value as unknown - - await QuestionApi.editQuestionNoAudit(data) - message.success(t('common.updateSuccess')) - + await QuestionApi.editQuestionNoAudit(data) + message.success(t('common.updateSuccess')) dialogVisible.value = false // 发送操作成功的事件 emit('success') @@ -444,21 +497,66 @@ const resetForm = () => { required: '', chapteridDictText: '', analysis: '', - quLevel: '', + quLevel: 0, pointNames: '', audit: '', subjectName: '', status: '', - resourceValue: '', - + resourceValue: '' } - radio.value = 'A', - // 清空 optionsContent 的属性 - Object.keys(optionsContent).forEach(key => { - delete optionsContent[key] - }) formRef.value?.resetFields() } + + +const dialogVisiblePoints = ref(false) +const openPoints = async () => { + await getTree(); + dialogVisiblePoints.value = true; +} +// 只允许点击第三级节点 +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([]) // 树形结构 +/** 获得部门树 */ +const getTree = async () => { + const res = await SpecialtyApi.listPoints() + const tree = handleTree(res) + deptList.value = [] + deptList.value = handleTreeWithLevel(tree) + + +} + + +// 添加层级信息 +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 + }) +} +