Ver código fonte

fix: 使用字典处理试题类型和专业类别下拉项

xieyong 1 semana atrás
pai
commit
d1d52100ff

+ 6 - 2
src/enum/dict.js

@@ -41,7 +41,10 @@ export default {
 
   记录表模板样式: 'record_template_style',
   放行类型: 'checklist_type',
-  记录规则报工类型: 'record_rules_report_work_type'
+  记录规则报工类型: 'record_rules_report_work_type',
+
+  试题专业类别: 'esh_professional_type',
+  试题类型: 'esh_question_type'
 };
 //主数据分类关联对应常量
 export const treeClassifyCodeEnum = {
@@ -54,7 +57,8 @@ export const numberList = [
   'root_cause_type',
   'emergency_plan_type',
   'drill_type',
-  'drill_level'
+  'drill_level',
+  'esh_professional_type'
 ];
 
 //审核枚举

+ 10 - 2
src/views/safetyExam/paperManagement/question-form.vue

@@ -210,12 +210,20 @@
       isView: {
         type: Boolean,
         default: false
+      },
+      /* 试题类型下拉项,由父级注入;不传则用模块内置的兜底数组 */
+      typeOptions: {
+        type: Array,
+        default: () => typeOptions
+      },
+      /* 专业类别下拉项,由父级注入;不传则用模块内置的兜底数组 */
+      categoryOptions: {
+        type: Array,
+        default: () => categoryOptions
       }
     },
     data() {
       return {
-        typeOptions,
-        categoryOptions,
         imageAccept: 'image/png,image/jpeg,image/jpg,image/gif,image/bmp',
         questionImageLoading: false,
         optionImageLoading: -1,

+ 38 - 1
src/views/safetyExam/questionBank/maintenance.vue

@@ -85,7 +85,13 @@
 
       <!-- 右侧试题表单 -->
       <div class="right-panel">
-        <question-form ref="questionFormRef" v-model="form" :is-view="isView" />
+        <question-form
+              ref="questionFormRef"
+              v-model="form"
+              :is-view="isView"
+              :type-options="questionTypeOptions"
+              :category-options="categoryOptions"
+            />
       </div>
     </div>
 
@@ -113,6 +119,7 @@
     getList,
     save as saveQuestionBank
   } from '@/api/questionBank/questionBank.js';
+  import dictMixins from '@/mixins/dictMixins';
 
   const questionTypeMap = {
     1: 'SINGLE',
@@ -161,6 +168,7 @@
       DeptSelect,
       QuestionForm
     },
+    mixins: [dictMixins],
     data() {
       return {
         visible: false,
@@ -192,6 +200,32 @@
       },
       isView() {
         return this.dialogType === 'view';
+      },
+      /* 试题类型下拉项,来自字典 esh_question_type */
+      questionTypeOptions() {
+        return (this.dict[this.dictEnum['试题类型']] || []).map((item) => {
+          let value = '1';
+          if (item.dictCode === "SINGLE") {
+            value = '1';
+          } else if (item.dictCode === "MULTIPLE") {
+            value = '2';
+          } else if (item.dictCode === "JUDGE") {
+            value = '3';
+          } else if (item.dictCode === "QUESTION_ANSWER") {
+            value = '4';
+          }
+          return {
+            value: String(value),
+            label: item.dictValue
+        };
+      });
+    },
+    /* 专业类别下拉项,来自字典 esh_professional_type */
+    categoryOptions() {
+      return (this.dict[this.dictEnum['试题专业类别']] || []).map((item) => ({
+          value: String(item.dictCode),
+          label: item.dictValue
+        }));
       }
     },
     methods: {
@@ -199,6 +233,9 @@
         this.visible = true;
         this.dialogType = type;
         this.questionSearch = '';
+        // 拉取试题类型与专业类别字典(已加载过会跳过)
+        this.requestDict('试题类型');
+        this.requestDict('试题专业类别');
         const questionBankId = row && (row.id || row.questionBankId);
         if (questionBankId) {
           this.bankForm = {