yangg 1 周之前
父節點
當前提交
9dc7ab7b05

+ 48 - 3
src/views/position/Jobcompetency/crud.tsx

@@ -114,6 +114,7 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
 			},
 			search: {
 				show: true,
+				autoSearch:false,
 				buttons: {
 					search: {
 						size: 'small', // 设置查询按钮大小为small
@@ -223,9 +224,53 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
 					}),
 					form: {
 						component: {
-							multiple: true,
-							filterable: true,
-							placeholder: '请选择关联职位',
+							/* multiple: true,
+							filterable: true, */
+							props: {
+								multiple: true, // 在编辑表单中保持多选
+								filterable: true,
+								placeholder: '请选择关联职位'
+							},
+							value: compute(({ form }) => {
+								if (!form.positions) return [];
+								console.log('form.positions', form.positions);
+								// 如果是数组但元素是对象,提取id
+								if (Array.isArray(form.positions)) {
+									const ids = form.positions.map((tag: any) => {
+										if (typeof tag === 'object' && tag !== null) {
+											// 同时更新 competency_tags_config
+											if (!form.competency_tags_config) {
+												form.competency_tags_config = [];
+												form.positions = [];
+											}
+											
+											// 检查配置是否已存在
+											const existingConfig = form.competency_tags_config.find(
+												(config: any) => config.id === tag.id
+											);
+											
+											if (!existingConfig) {
+												form.competency_tags_config.push({
+													id: tag.id,
+													competency_name: tag.name,
+													weight: tag.weight || 100,
+													importance: tag.importance || 1,
+													remark: ''
+												});
+											
+												form.positions.push(tag.id);
+											}
+											
+											return tag.id;
+										}
+										return tag;
+									});
+									return ids;
+								}
+								
+								return form.positions;
+							}),
+							/* placeholder: '请选择关联职位', */
 						},
 						/* rules: [
 							{ required: true, message: '关联职位为必填项' },

+ 11 - 1
src/views/position/Jobcompetency/jobIndex.vue

@@ -19,7 +19,7 @@
           <div class="custom-tree-node">
             <div class="node-label">
               <el-icon><Folder /></el-icon>
-              <span class="ml-2">{{ data.title }}</span>
+              <span class="ml-2 text-ellipsis">{{ data.title }}</span>
             </div>
           <!--   <div class="node-actions" v-if="data.id">
               <el-button type="primary" link size="small" @click.stop="handleEdit(data)">
@@ -114,6 +114,16 @@
     display: flex;
     align-items: center;
     flex: 1;
+    min-width: 0; // 这个很重要,确保子元素可以正确收缩
+}
+
+.text-ellipsis {
+    overflow: hidden;
+    white-space: nowrap;
+    text-overflow: ellipsis;
+    max-width: 155px; // 你可以根据需要调整这个值
+    align-items: center;
+    flex: 1;
     min-width: 0;
     position: relative;
     

+ 1 - 2
src/views/position/detail/index.vue

@@ -209,8 +209,7 @@
               v-model="editingEndDate"
               type="date"
               placeholder="请选择截止日期"
-              format="YYYY-MM-DD"
-              value-format="YYYY-MM-DD"
+              value-format="YYYY-MM-DD HH:mm:ss"
               style="width: 100%"
             />
             <div class="title-edit-actions">

+ 60 - 29
src/views/questionBank/positionList/components/editor.vue

@@ -5,6 +5,7 @@
     width="500px"
     :close-on-click-modal="false"
     class="question-dialog"
+    @close="resetForm"
   >
     <div class="question-form">
       <div class="form-item">
@@ -284,37 +285,51 @@ interface QuestionForm {
 // 对话框显示状态
 const showQuestionDialog = ref(false)
 
-// 监听 questionId 变化
-watch(() => props.questionId, async (newVal) => {
-  if (newVal) {
-    // 获取问题详情
-    try {
-      const response = await api.GetObj({question_id:newVal});
+// 监听对话框显示状态
+watch(() => showQuestionDialog.value, (newVal) => {
+  if (newVal && props.questionId) {
+    fetchQuestionDetail(props.questionId);
+  }
+});
+
+// 获取问题详情的函数
+const fetchQuestionDetail = async (id: string | number) => {
+  if (!id) return;
+  
+  try {
+    const response = await api.GetObj({ question_id: id });
+    
+    if (response?.code === 2000 && response.data) {
+      const questionData = response.data;
+      // 更新表单数据
+      questionForm.content = questionData.question || '';
+      questionForm.type = questionData.question_form === 1 ? 'single' : 
+                        questionData.question_form === 2 ? 'multiple' : 'open';
+      questionForm.position = questionData.positions || [];
+      questionForm.category = questionData.category_id || '';
+      questionForm.tags = questionData.tags || [];
+      questionForm.competency_tags = questionData.competency_tags || [];
+      questionForm.options = questionData.options || [];
+      questionForm.question_form = questionData.question_form;
+      questionForm.suggestedDuration = questionData.duration || 0;
+      questionForm.scoring_reference = questionData.scoring_reference || '';
       
-      if (response && response.code === 2000 && response.data) {
-        const questionData = response.data;
-        // 更新表单数据
-        questionForm.content = questionData.question || '';
-        questionForm.type = questionData.question_form === 1 ? 'single' : 
-                          questionData.question_form === 2 ? 'multiple' : 'open';
-        questionForm.position = questionData.positions || [];
-        questionForm.category = questionData.category_id || '';
-        questionForm.tags = questionData.tags || [];
-        questionForm.competency_tags = questionData.competency_tags || [];
-        questionForm.options = questionData.options || [];
-        questionForm.question_form = questionData.question_form;
-        questionForm.suggestedDuration = questionData.duration || 0;
-        questionForm.scoring_reference = questionData.scoring_reference || '';
-        
-        // 更新胜任力标签选择
-        competencyTagsValue.value = questionData.competency_tags?.map((tag: any) => tag.id) || [];
-      }
-    } catch (error: any) {
-      console.error('获取问题详情失败:', error);
-      ElMessage.error(error.message || '获取问题详情失败');
+      // 更新胜任力标签选择
+      competencyTagsValue.value = questionData.competency_tags?.map((tag: any) => tag.id) || [];
+    } else {
+      ElMessage.warning('未找到问题详情数据');
     }
+  } catch (error: any) {
+    console.error('获取问题详情失败:', error);
+    ElMessage.error(error.message || '获取问题详情失败');
   }
-}, { immediate: false });
+};
+
+// 监听 questionId 变化
+watch(() => props.questionId, (newVal) => {
+  console.log(newVal)
+  fetchQuestionDetail(newVal);
+}, { immediate: true });
 
 // 加载初始数据
 onMounted(async () => {
@@ -449,7 +464,22 @@ const removeLastOption = () => {
   }
 }
 
+// 重置表单数据
+const resetForm = () => {
+  questionForm.content = ''
+  questionForm.type = 'open'
+  questionForm.position = []
+  questionForm.category = ''
+  questionForm.tags = []
+  questionForm.competency_tags = []
+  questionForm.options = []
+  questionForm.suggestedDuration = 0
+  questionForm.scoring_reference = ''
+  competencyTagsValue.value = []
+}
+
 const cancelAddQuestion = () => {
+  resetForm()
   showQuestionDialog.value = false
 }
 
@@ -539,6 +569,7 @@ defineExpose({
   .config-row {
     display: flex;
     align-items: center;
+    justify-content: space-between;
     margin-bottom: 10px;
 
     &:last-child {
@@ -547,7 +578,7 @@ defineExpose({
   }
 
   .config-label {
-    width: 80px;
+    width: 105px;
     margin-right: 10px;
   }
 

+ 6 - 4
src/views/questionBank/positionList/index.vue

@@ -627,9 +627,9 @@ const loadQuestionOptions = async () => {
       questionPagination.value.total = response.data.total;
       
       // 如果是第一次加载,获取所有分类选项
-      if (questionCategoryOptions.value.length === 0) {
-        loadQuestionCategories();
-      }
+      /* if (questionCategoryOptions.value.length === 0) { */
+       
+      /* } */
     } else {
       ElMessage.error('获取问题列表失败');
     }
@@ -645,7 +645,7 @@ const loadQuestionOptions = async () => {
 const loadQuestionCategories = async () => {
   try {
     // 调用API获取问题分类列表
-    const response = await fetch(getBaseURL() + 'api/system/question_category/list?tenant_id='+Session.get('tenant_id'), {
+    const response = await fetch(getBaseURL() + 'api/system/question_category/list?page=1&limit=50&tenant_id='+Session.get('tenant_id'), {
       method: 'GET',
       headers: {
         'Authorization': 'JWT ' + Session.get('token'),
@@ -709,6 +709,8 @@ const openPositionQuestionDialog = () => {
   loadPositionOptions();
   // 加载问题选项
   loadQuestionOptions();
+  //加载分类
+  loadQuestionCategories();
   positionQuestionDialogVisible.value = true;
 };