@@ -278,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() // 国际化
@@ -289,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: '',
@@ -296,7 +332,7 @@ const formData = ref({
required: '',
chapteridDictText: '',
analysis: '',
- quLevel: '',
+ quLevel: 0,
pointNames: '',
audit: '',
subjectName: '',
@@ -466,7 +502,7 @@ const resetForm = () => {
required: '',
chapteridDictText: '',
analysis: '',
- quLevel: '',
+ quLevel: 0,
pointNames: '',
audit: '',
subjectName: '',
@@ -475,6 +511,57 @@ const resetForm = () => {
}
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
+ })
+}
+