yangg 4 днів тому
батько
коміт
ca32b0e724

+ 44 - 1
src/views/questionBank/positionList/api.ts

@@ -4,7 +4,7 @@ import { Session } from '/@/utils/storage';
 import { time } from 'console';
 
 
-export function GetDocumentList(query: UserPageQuery) {
+export function GetDocumentList(query: any) {
   return request({
     url: 'api/system/job/questions',
     method: 'get',
@@ -116,3 +116,46 @@ export const UpdateInterviewQuestion = (params: any) => {
     data: params
   });
 };
+
+/* 分类列表 */
+export function GetCategoryList(query: UserPageQuery) {
+	return request({
+		url: '/api/system/question_category/list',
+		method: 'get',
+		params: {...query,tenant_id:1},
+	});
+}
+/* 标签列表 */
+export function GetTagList(query: UserPageQuery) {
+	return request({
+		url: '/api/system/question_tag/list',
+		method: 'get',
+		params: {...query,tenant_id:1},
+	});
+}
+/* 公共列表 */
+export function GetPublicList(query: any) {
+	return request({
+		url: '/api/system/interview_question/list',
+		method: 'get',
+    timeout: 60000,
+		params: {...query,tenant_id:1},/* :Session.get('tenant_id').tenant_id || ,tenant_id:'1' */
+	});
+}
+
+/* 添加分类 */
+export function AddCategory(obj: AddReq) {
+	return request({
+		url: '/api/system/question_category/create',
+		method: 'post',
+		data: {...obj,tenant_id:1},
+	});
+}
+/* 添加标签 */
+export function AddTag(obj: AddReq) {
+	return request({
+		url: '/api/system/question_tag/create',
+		method: 'post',
+		data: {...obj,tenant_id:1},
+	});
+}

+ 4 - 4
src/views/questionBank/positionList/components/DocumentFormCom/index.vue

@@ -5,7 +5,7 @@
         <el-input v-model="formData.name" placeholder="请输入分类名称" />
       </el-form-item>
       
-      <el-form-item label="上级分类" prop="parent">
+     <!--  <el-form-item label="上级分类" prop="parent">
         <el-tree-select
           v-model="formData.parent"
           :data="treeData"
@@ -14,7 +14,7 @@
           check-strictly
           clearable
         />
-      </el-form-item>
+      </el-form-item> -->
       
       <el-form-item label="排序" prop="sort">
         <el-input-number v-model="formData.sort" :min="0" :max="999" />
@@ -34,7 +34,7 @@
 
 <script lang="ts" setup>
 import { ref, reactive, defineProps, defineEmits, onMounted } from 'vue';
-import { AddDocumentCategory, UpdateDocumentCategory } from '../../api';
+import { AddDocumentCategory, UpdateDocumentCategory ,AddCategory,AddTag} from '../../api';
 import { successNotification } from '/@/utils/message';
 import type { FormInstance } from 'element-plus'
 
@@ -88,7 +88,7 @@ const handleSubmit = async () => {
           res = await UpdateDocumentCategory(formData);
         } else {
           // 新增
-          res = await AddDocumentCategory(formData);
+          res = await AddCategory(formData);
         }
         
         if (res && res.code === 2000) {

+ 20 - 10
src/views/questionBank/positionList/crud.tsx

@@ -12,21 +12,31 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
 	const pageRequest = async (query: any) => {
 		// 确保查询参数正确传递
 		console.log(query);
-		const params = {
+		
+		// 基础参数
+		const baseParams = {
 			...query,
 			limit: 100,
 			tenant_id: '1',
-			// 添加question_form参数的处理
-			question_form: query.form?.question_form,
-			// 获取job_id,优先从form中获取,如果没有则从query中获取
-			job_id: query.form?.job_id || query.job_id || 1,
-			// 如果 query.form 中有 category,使用它,否则使用 query.category
-			category: (query.form && query.form.category) || query.category || '',
+			
+			question_category: (query.form && query.form.category) || query.category || '',
+			question_tags: (query.form && query.form.tag) || query.tag || '',
 		};
 
-		console.log('Request params:', params); // 添加日志以便调试
-
-		return api.GetDocumentList(params);
+		// 根据是否有tag或category来选择不同的接口和参数
+		if (baseParams.question_category || baseParams.question_tags) {
+			if(baseParams.question_category==5){
+				baseParams.question_form = '4';
+			}
+			return api.GetPublicList(baseParams);
+		} else {
+			// 只有在不是tag和category查询时才添加job_id
+			return api.GetDocumentList({
+				...baseParams,
+				question_form: query.question_form,
+				job_id: query.form?.job_id || query.job_id || 1,
+			});
+		}
 	};
 
 	const editRequest = async ({ form, row }: any) => {

+ 50 - 15
src/views/questionBank/positionList/index.vue

@@ -416,7 +416,9 @@ import { Document, Delete, View, Printer, Search, Link } from '@element-plus/ico
 import { successNotification } from '/@/utils/message';
 import DocumentTreeCom from './components/DocumentTreeCom/index.vue';
 import DocumentFormCom from './components/DocumentFormCom/index.vue';
-import { GetDocumentTree, DeleteDocumentCategory, UpdateDocument ,UpdateSequence, GetInterviewQuestions,AddDocument } from './api';
+import { GetDocumentTree, DeleteDocumentCategory, UpdateDocument ,UpdateSequence, GetInterviewQuestions,AddDocument,
+  GetCategoryList, GetTagList
+ } from './api';
 import { useRouter } from 'vue-router';
 /* import { print } from '/@/utils/print'; */
 
@@ -809,6 +811,13 @@ const getTreeData = () => {
   GetDocumentTree({}).then((ret: any) => {
     console.log('ret', ret);
     const responseData = ret.data;
+    GetCategoryList({}).then((res: any) => {
+      console.log('res', res);
+      const categoryList = res.data.items;
+      GetTagList({}).then((res: any) => {
+        console.log('res', res);
+        const tagList = res.data.items;
+     
     // 创建根节点
     const rootNode =  [ 
       {
@@ -816,7 +825,9 @@ const getTreeData = () => {
         title: '职位开放题',
         children: responseData.map((item: any) => ({
           ...item,
-          title: item.name || item.title // 确保显示正确的标题
+          id: `open_${item.id}`, // 为职位开放题添加特定前缀
+          title: item.name || item.title,
+          question_type: 'open' // 添加类型标识
         }))
       },
       {
@@ -824,12 +835,22 @@ const getTreeData = () => {
         title: '专业考察题库',
         children: responseData.map((item: any) => ({
           ...item,
-          title: item.name || item.title // 确保显示正确的标题
+          id: `prof_${item.id}`, // 为专业考察题添加特定前缀
+          title: item.name || item.title,
+          question_type: 'professional' // 添加类型标识
         }))
       },
-      {
-        id: 'common_questions',
-        title: '常识题库',
+      ...categoryList.map((item: any) => ({
+        id: `category_${item.id}`,  
+        title: item.name,
+        children: tagList.filter((tag: any) => tag.category_id === item.id).map((tag: any) => ({
+          id: `tag_${tag.id}`,
+          title: tag.name
+        })) 
+      }))
+     /*  {
+        id: categoryList.find((item: any) => item.name === '基本常识')?.id || '7',
+        title: categoryList.find((item: any) => item.name === '基本常识')?.name || '基本常识',
       },
       {
         id: 'psychology_questions',
@@ -848,9 +869,11 @@ const getTreeData = () => {
             title: '明尼苏达多相人格测验',
           }
         ]
-      }
+      } */
     ]
     documentTreeData.value = rootNode
+      });
+    })
   });
 };
 
@@ -858,25 +881,34 @@ const getTreeData = () => {
 const handleTreeClick = (record: any) => {
   console.log('record', record);
   
+  // 获取当前节点ID并处理前缀
+  const currentNodeId = record?.currentNode?.id || '';
+  const originalId = currentNodeId.replace(/^(open_|prof_|category_|tag_)/, '');
+  
   // 保存当前选中的分类ID,如果ID不是数字则使用默认值1
-  const currentNodeId = record?.currentNode?.id;
-  selectedCategoryId.value = (!isNaN(Number(currentNodeId)) && currentNodeId !== null) ? currentNodeId : 1;
+  selectedCategoryId.value = (!isNaN(Number(originalId)) && originalId !== null) ? originalId : 1;
   
   // 根据不同的问题类型设置question_form
   let question_form;
   const firstLevelId = record?.firstLevel?.id;
+  const nodeType = currentNodeId.startsWith('open_') ? 'open' : 
+                   currentNodeId.startsWith('prof_') ? 'professional' :
+                   currentNodeId.startsWith('category_') ? 'category' :
+                   currentNodeId.startsWith('tag_') ? 'tag' : 
+                   firstLevelId;
+ 
   
-  if (firstLevelId === 'root') {
+  if (nodeType === 'open' || firstLevelId === 'root') {
     question_form = '0';  // 职位开放题
   } else if (firstLevelId === 'psychology_questions') {
     question_form = '4';  // 心理题库
   } else if (firstLevelId === 'common_questions') {
     question_form = '1';  // 常识题库
-  } else if (firstLevelId === 'professional_questions') {
-    question_form = '2';  // 专业考察题库
-  } else {
+  } else if (nodeType === 'professional' || firstLevelId === 'professional_questions') {
+    question_form = '1,2,3,4,6';  // 专业考察题库
+  } /*  else {
     question_form = '0';  // 默认为职位开放题
-  }
+  } */
 
   // 重置上传文件状态
   uploadedFile.value = null;
@@ -886,7 +918,9 @@ const handleTreeClick = (record: any) => {
     form: {
       limit: 100,
       job_id: selectedCategoryId.value,
-      question_form: question_form
+      question_form: question_form,
+      ...(nodeType === 'category' ? { category: originalId } : {}),
+      ...(nodeType === 'tag' ? { tag: originalId } : {})
     }
   };
   
@@ -1556,6 +1590,7 @@ const bindParentQuestion = (row: any) => {
   position: relative;
   border-radius: 0 8px 8px 0;
   margin-right: 10px;
+  overflow-y: auto;
 }
 
 .document-right-box {