yellowtaotao 4 年之前
父节点
当前提交
7f108d8187

+ 185 - 0
src/components/common/QuestionDetailDialog.vue

@@ -0,0 +1,185 @@
+<template>
+  <a-modal
+    class="question-detail-modal"
+    :title="basicTitle"
+    v-model="visible"
+    centered
+    @cancel="onClose"
+  >
+    <!-- 试题类别 -->
+    <div class="dialog-detail-row">
+      <div class="dialog-detail-title">试题类别:</div>
+      <div class="dialog-detail-content">
+        <span>{{ questionDetail.questionTypeTxt }}</span>
+      </div>
+    </div>
+    <!-- 内容 -->
+    <div class="dialog-detail-row">
+      <div class="dialog-detail-title">试题内容:</div>
+      <div class="dialog-detail-content">
+        <span>{{ questionDetail.content }}</span>
+      </div>
+    </div>
+    <!-- 选项 -->
+    <div v-if="questionDetail.type !== 'TianKong'" class="dialog-detail-row">
+      <div class="dialog-detail-title">试题选项:</div>
+      <div class="dialog-detail-content">
+        <div
+          class="dialog-detail-options"
+          v-for="(item, index) in optionsList"
+          :key="index"
+        >
+          <div class="dialog-detail-options-index">
+            {{ index | formatQuestionIndex }}.
+          </div>
+          <div class="dialog-detail-options-content">{{ item.value }}</div>
+        </div>
+      </div>
+    </div>
+    <!-- 答案 -->
+    <div class="dialog-detail-row">
+      <div class="dialog-detail-title">正确答案:</div>
+      <div class="dialog-detail-content">
+        <span
+          class=""
+          v-for="(item, index) in questionDetail.finalAnswer"
+          :key="index"
+          >{{ item }}
+        </span>
+      </div>
+    </div>
+    <!-- 试题类型 -->
+    <div class="dialog-detail-row">
+      <div class="dialog-detail-title">试题类型:</div>
+      <div class="dialog-detail-content">
+        <div></div>
+        <div>
+          <span class="dialog-detail-contidon-txt">试题父类:</span>
+          <span>{{
+            questionDetail.rootQuestionCategory
+              ? questionDetail.rootQuestionCategory.name
+              : ''
+          }}</span>
+        </div>
+        <div>
+          <span class="dialog-detail-contidon-txt">试题子类:</span>
+          <span>{{
+            questionDetail.questionCategory
+              ? questionDetail.questionCategory.name
+              : ''
+          }}</span>
+        </div>
+      </div>
+    </div>
+    <!-- 工种 -->
+    <div class="dialog-detail-row">
+      <div class="dialog-detail-title">工种类别:</div>
+      <div class="dialog-detail-content">
+        <span>{{ questionDetail.engineerTypeTxt }}</span>
+      </div>
+    </div>
+  </a-modal>
+</template>
+
+<script>
+export default {
+  props: {
+    // 试题信息
+    questionDetail: {
+      type: Object,
+      default() {
+        return {};
+      },
+    },
+    // 是否显示
+    isVisible: {
+      type: Boolean,
+      default: false,
+    },
+  },
+  components: {},
+  data() {
+    return {
+      visible: false, // 显隐状态
+      basicTitle: '试题详情', // 页面标题
+      optionsList: [], // 选项列表
+      finalAnswerIndexs: undefined, // 正确答案下标
+    };
+  },
+  created() {},
+  mounted() {},
+  beforeDestroy() {},
+  watch: {
+    isVisible(val) {
+      this.visible = val;
+      if (val) {
+        this.initDataFun();
+      }
+    },
+  },
+  computed: {},
+  methods: {
+    //初始化数据
+    initDataFun() {
+      if (this.questionDetail.answers) {
+        // 选项
+        this.optionsList = this.questionDetail.answers.map((item) => {
+          return { value: item };
+        });
+      }
+    },
+    // 现隐状态变化后
+    afterVisibleChange(val) {
+      console.log('isVisible', val);
+    },
+    // 关闭
+    onClose() {
+      this.optionsList = [];
+      this.$emit('update:questionDetail', {});
+      this.$emit('update:isVisible', false);
+    },
+  },
+};
+</script>
+
+<style lang="less">
+.question-detail-modal {
+  .ant-modal-footer {
+    display: none;
+  }
+}
+</style>
+
+<style lang="less" scoped>
+@import '~@/styles/common/variable.less';
+.dialog-detail-row {
+  margin-bottom: @paddingMarginVal;
+  display: flex;
+  // flex-wrap: wrap;
+  .dialog-detail-title {
+    font-size: 14px;
+    font-weight: bold;
+    color: @mainColorBlack85;
+    flex-wrap: nowrap;
+    white-space: nowrap;
+  }
+  .dialog-detail-content {
+    // padding-left: 32px;
+    font-size: 14px;
+    color: @mainColorBlack85;
+    > span {
+      word-break: break-all;
+      word-wrap: break-word;
+    }
+  }
+  .dialog-detail-options {
+    display: flex;
+    .dialog-detail-options-index {
+      margin-right: 5px;
+    }
+  }
+  .dialog-detail-contidon-txt {
+    // color: @mainColorBlack65;
+  }
+}
+</style>

+ 7 - 2
src/components/layout/components/Sider.vue

@@ -2,7 +2,7 @@
   <div class="sider-box">
     <div class="logoArea">
       <img class="logoAreaImg" :src="logoImg" />
-      <div class="logoAreaTittle">
+      <div class="logoAreaTittle" v-show="!collapsed">
         <div class="programTitle">{{ title }}</div>
         <div class="programTitleTwo">{{ titleTwo }}</div>
       </div>
@@ -73,7 +73,12 @@ const SubMenu = {
   },
 };
 export default {
-  props: {},
+  props: {
+    collapsed: {
+      type: Boolean,
+      default: false,
+    },
+  },
   components: {
     SubMenu,
   },

+ 1 - 1
src/components/layout/index.vue

@@ -1,7 +1,7 @@
 <template>
   <a-layout id="components-layout-demo-custom-trigger">
     <a-layout-sider v-model="collapsed" :trigger="null" collapsible>
-      <Sider @reload="reload" />
+      <Sider @reload="reload" :collapsed.sync="collapsed" />
     </a-layout-sider>
     <a-layout>
       <a-layout-header style="background: #fff; padding: 0">

+ 3 - 3
src/main.js

@@ -26,10 +26,10 @@ import './common'
 // 共通filters
 import * as filters from './filters'
 
-// 富文本编辑组件
-// import TinymceEditor from "@/components/tinymce/TinymceEditor";
+// 试题详情组件
+import QuestionDetailDialog from "@/components/common/QuestionDetailDialog";
 
-// Vue.component('TinymceEditor',TinymceEditor)
+Vue.component('QuestionDetailDialog',QuestionDetailDialog)
 Object.entries(filters).forEach(([key, value]) => {
   Vue.filter(key, value)
 })

+ 4 - 4
src/router/menu.js

@@ -65,10 +65,10 @@ export default [
           },
         ],
       },
-      {
-        path: '/examQuestionManagement/batchImport',
-        meta: { title: '批量导入' },
-      },
+      // {
+      //   path: '/examQuestionManagement/batchImport',
+      //   meta: { title: '批量导入' },
+      // },
     ],
   },
   {

+ 8 - 0
src/views/answerManagement/answerManagementSpecial.vue

@@ -203,6 +203,10 @@
         copyright © 浮游科技有限公司出品
       </span>
     </div>
+    <QuestionDetailDialog
+      :questionDetail.sync="questionDetail"
+      :isVisible.sync="isVisible"
+    />
   </div>
 </template>
 
@@ -255,6 +259,8 @@ export default {
         current: 1,
         total: 0,
       }, // 分页参数
+      isVisible: false, // 是否显示详情浮窗
+      questionDetail: {}, // 需要展示的试题详情
     };
   },
   created() {
@@ -438,6 +444,8 @@ export default {
     // 操作:详情
     toQuestionDetailFun(record) {
       console.log('查看某个试题的详情', record);
+      this.questionDetail = record;
+      this.isVisible = true;
       // if (!record || !record.id) {
       //   this.$message.error('数据异常,请重新进入当前页面');
       //   return;

+ 20 - 10
src/views/articleManagement/articleCreate.vue

@@ -31,11 +31,12 @@
                 'description',
                 {
                   rules: [{ required: true, message: '请输入文章描述' }],
+                  initialValue: description,
                 },
               ]"
             />
           </a-form-item>
-          <a-form-item label="文章分类" v-if="optionType == 'create'">
+          <a-form-item label="文章分类">
             <!-- 文章分类父类 -->
             <a-select
               v-decorator="[
@@ -47,6 +48,7 @@
                       message: '请选择文章分类父类',
                     },
                   ],
+                  initialValue: articleChildClass.name,
                 },
               ]"
               @change="articleClassParentChange"
@@ -58,7 +60,7 @@
               >
             </a-select>
           </a-form-item>
-          <a-form-item label="文章子类" v-if="optionType == 'create'">
+          <a-form-item label="文章子类">
             <!-- 文章分类子类 -->
             <a-select
               v-decorator="[
@@ -70,6 +72,7 @@
                       message: '请选择文章分类子类',
                     },
                   ],
+                  initialValue: articleParentClass.name,
                 },
               ]"
               :disabled="!articleParentClass || !articleParentClass.id"
@@ -101,7 +104,11 @@
             </a-select>
           </a-form-item>
           <a-form-item label="必学日期:">
-            <a-date-picker @change="learnDateChoose" style="width:100%;" />
+            <a-date-picker
+              :defaultValue="learnDate"
+              @change="learnDateChoose"
+              style="width:100%;"
+            />
           </a-form-item>
           <a-form-item v-show="false" :wrapper-col="{ span: 20, offset: 10 }">
             <a-button id="articleCreateSubmit" type="primary" html-type="submit"
@@ -163,6 +170,7 @@ export default {
       engineerType: '',
       learnDate: '',
       optionType: '',
+      description: '',
     };
   },
   created() {
@@ -254,6 +262,7 @@ export default {
     },
     // 必学日期选择
     learnDateChoose(date, dateString) {
+      console.log(dateString);
       this.learnDate = dateString;
     },
     handleSubmitBtnFun() {
@@ -282,10 +291,11 @@ export default {
         name: item.name,
       });
       //   文章描述
-      let description = item.description == null ? '' : item.description;
-      this.form.setFieldsValue({
-        description: description,
-      });
+      this.description = item.description ? item.description : '';
+      // 文章分类-父类
+      this.articleChildClass = item.rootMaterialCategory;
+      // 文章分类-子类
+      this.articleParentClass = item.materialCategory;
       //   选中工种
       if (item.engineerTypes.length !== 0) {
         let engineerId = item.engineerTypes[0];
@@ -296,7 +306,7 @@ export default {
           }
         }
       }
-      let learnDate = item.tags.length === 0 ? '' : item.tags[0];
+      let learnDate = item.tags.length > 0 ? item.tags[0] : '';
       // 必学日期
       this.learnDateChoose(null, learnDate);
       // 文章内容
@@ -340,7 +350,7 @@ export default {
                 description: values.description,
                 type: 'ARTICLE',
                 contents: that.content,
-                tages: [that.learnDate],
+                tags: [that.learnDate],
                 engineerTypes: [that.engineerType.id],
                 links: [],
               };
@@ -377,7 +387,7 @@ export default {
                 description: values.description,
                 type: 'ARTICLE',
                 contents: that.content,
-                tages: [that.learnDate],
+                tags: [that.learnDate],
                 engineerTypes: [that.engineerType.id],
                 links: [],
               };

+ 11 - 0
src/views/examManagement/examAutomaticVolumeFormation.vue

@@ -325,6 +325,11 @@
         copyright © 浮游科技有限公司出品
       </span>
     </div>
+
+    <QuestionDetailDialog
+      :questionDetail.sync="questionDetail"
+      :isVisible.sync="isVisible"
+    />
   </div>
 </template>
 
@@ -448,6 +453,10 @@ export default {
         gapFillingGrade: '',
       },
       examId: null, // 当前提交预组卷生成的考试ID
+      disabledIdArr: [], // 当前试题中已有的试题ID(即题库列表中不可选取的行数据Id)
+      searchInputVal: '', // 搜索框内容
+      isVisible: false, // 是否显示详情浮窗
+      questionDetail: {}, // 需要展示的试题详情
     };
   },
   created() {
@@ -757,6 +766,8 @@ export default {
     // 操作:详情
     toQuestionDetailFun(record) {
       console.log('查看某个试题的详情', record);
+      this.questionDetail = record;
+      this.isVisible = true;
       // if (!record || !record.id) {
       //   this.$message.error('数据异常,请重新进入当前页面');
       //   return;

+ 20 - 13
src/views/examManagement/examManagementDetail.vue

@@ -68,12 +68,11 @@
           </div>
           <div class="border-line"></div>
         </div>
-        <!-- 表单 -->
+        <!-- 表单 :scroll="{ y: tableHeight }"-->
         <a-table
           :columns="columns"
           :data-source="tableData"
           :row-key="(record) => record.id"
-          :scroll="{ y: tableHeight }"
           :pagination="false"
         >
           <template slot="questionCategory" slot-scope="text, record">
@@ -124,6 +123,10 @@
         copyright © 浮游科技有限公司出品
       </span>
     </div>
+    <QuestionDetailDialog
+      :questionDetail.sync="questionDetail"
+      :isVisible.sync="isVisible"
+    />
   </div>
 </template>
 
@@ -146,7 +149,7 @@ export default {
   components: {},
   data() {
     return {
-      tableHeight: 400, // 表格高度
+      // tableHeight: 400, // 表格高度
       columns: [], // form表单的列参数
       pagination: {
         pageSize: 7,
@@ -158,30 +161,32 @@ export default {
       tableData: [], // 单场考试的试题列表
       engineeringWorkList: [], // 工种数据列表
       examStatusTypeTxt: EXAM_STATUS_TYPE_TXT, // 考试状态属性文字
+      isVisible: false, // 是否显示详情浮窗
+      questionDetail: {}, // 需要展示的试题详情
     };
   },
   created() {
     this.initDataFun(); //初始化数据
   },
   mounted() {
-    this.initTableHeightFun(); // 初始化表单的高度
+    // this.initTableHeightFun(); // 初始化表单的高度
   },
   beforeDestroy() {},
   watch: {
-    screenHeight() {
-      this.initTableHeightFun(); // 初始化表单的高度
-    },
+    // screenHeight() {
+    //   this.initTableHeightFun(); // 初始化表单的高度
+    // },
   },
   computed: {
     ...mapGetters(['screenHeight', 'GET_ENGINEERING_WORK_LIST']),
   },
   methods: {
-    // 初始化表单的高度
-    initTableHeightFun() {
-      this.tableHeight =
-        this.$refs.tableBody.offsetHeight -
-        (this.$refs.filterCard.offsetHeight + 48 * 3 + 16);
-    },
+    // // 初始化表单的高度
+    // initTableHeightFun() {
+    //   this.tableHeight =
+    //     this.$refs.tableBody.offsetHeight -
+    //     (this.$refs.filterCard.offsetHeight + 48 * 3 + 16);
+    // },
     //初始化数据
     initDataFun() {
       if (!this.$route.query.id) {
@@ -359,6 +364,8 @@ export default {
     // 操作:详情
     toQuestionDetailFun(record) {
       console.log('查看某个试题的详情', record);
+      this.questionDetail = record;
+      this.isVisible = true;
       // if (!record || !record.id) {
       //   this.$message.error('数据异常,请重新进入当前页面');
       //   return;

+ 8 - 0
src/views/examManagement/examManualVolumeFormation.vue

@@ -400,6 +400,10 @@
         copyright © 浮游科技有限公司出品
       </span>
     </div>
+    <QuestionDetailDialog
+      :questionDetail.sync="questionDetail"
+      :isVisible.sync="isVisible"
+    />
   </div>
 </template>
 
@@ -560,6 +564,8 @@ export default {
       bank_selectedRowKeys: [], // 多选的结果
       disabledIdArr: [], // 当前试题中已有的试题ID(即题库列表中不可选取的行数据Id)
       searchInputVal: '', // 搜索框内容
+      isVisible: false, // 是否显示详情浮窗
+      questionDetail: {}, // 需要展示的试题详情
     };
   },
   created() {
@@ -1105,6 +1111,8 @@ export default {
     // 操作:详情
     toQuestionDetailFun(record) {
       console.log('查看某个试题的详情', record);
+      this.questionDetail = record;
+      this.isVisible = true;
       // if (!record || !record.id) {
       //   this.$message.error('数据异常,请重新进入当前页面');
       //   return;

+ 0 - 1
src/views/examQuestionManagement/examQuestionList.vue

@@ -397,7 +397,6 @@ export default {
     },
     // 操作:详情
     toQuestionDetailFun(record) {
-      console.log('查看某个试题的详情', record);
       if (!record || !record.id) {
         this.$message.error('数据异常,请重新进入当前页面');
         return;

+ 107 - 8
src/views/examQuestionManagement/examQusetionCreateGapFilling.vue

@@ -21,6 +21,7 @@
                 'content',
                 {
                   rules: [{ required: true, message: '请输入试题内容!' }],
+                  initialValue: examQuestionDetail.content,
                 },
               ]"
             />
@@ -54,6 +55,7 @@
                   `answers-${index}`,
                   {
                     rules: [{ required: true, message: '请输入填空答案!' }],
+                    initialValue: item.value,
                   },
                 ]"
               />
@@ -79,7 +81,10 @@
               </div>
               <div class="create-select-item">
                 <span>子类:</span>
-                <a-select v-model="typeConditionChildrenValue">
+                <a-select
+                  v-model="typeConditionChildrenValue"
+                  :disabled="!typeConditionParentValue"
+                >
                   <a-select-option
                     v-for="(item, index) in typeConditionChildrenList"
                     :key="index"
@@ -138,7 +143,11 @@
 </template>
 
 <script>
-import { formateUrlParams, formatePathParams } from '@/filters';
+import {
+  // formatQuestionLetter,
+  formateUrlParams,
+  formatePathParams,
+} from '@/filters';
 import { mapGetters } from 'vuex';
 export default {
   name: 'examQusetionCreateGapFilling',
@@ -161,6 +170,16 @@ export default {
       engineeringWorkList: [], // 工种数据列表
       engineeringWorkChooseValue: '', // 所选工种
       finalAnswerIndexs: undefined, // 正确答案下标
+      examQuestionDetail: {
+        id: '', // key
+        content: '', // 内容
+        finalAnswer: [], // 正确答案
+        engineerTypes: [], // 信息集合:工种
+        type: '', // 试题类型ID
+        answers: [], // 选项
+        rootQuestionCategory: '', // 试题类型-父类
+        questionCategory: '', // 试题类型-子类
+      }, // 题目的信息
     };
   },
   created() {
@@ -182,13 +201,58 @@ export default {
       this.typeConditionParentList = [
         ...this.GET_EXAM_QUESTION_TYPE_CONDITION_PARENT,
       ];
-      this.typeConditionParentValue = this.typeConditionParentList[0].id;
       // 工种类别
       this.engineeringWorkList = [
         { name: '不限', id: '' },
         ...this.GET_ENGINEERING_WORK_LIST,
       ];
-      this.getTableChildrenListFun(); // 查询:试题类型列表-子类
+      if (this.$route.query.id) {
+        this.getExamQuestionDetailFun(this.$route.query.id); // 查询:试题的详情
+      } else {
+        this.typeConditionParentValue = this.typeConditionParentList[0].id; // 所选试题类型-父类
+        this.getTableChildrenListFun(); // 查询:试题类型列表-子类
+      }
+    },
+    // 查询:试题的详情
+    getExamQuestionDetailFun(id) {
+      if (!id) {
+        return;
+      }
+      this.loading = true;
+      let params = {
+        questionId: id,
+      };
+      this.$_http
+        .get(
+          formatePathParams(
+            this.$_API.INTERFACE_GET_EXAMS_QUESTION_DETAIL,
+            params
+          )
+        )
+        .then((res) => {
+          this.examQuestionDetail = { ...res.data };
+          // 选项
+          this.optionsList = this.examQuestionDetail.finalAnswer.map((item) => {
+            return { value: item };
+          });
+          // 正确答案
+          // this.finalAnswerIndexs = formatQuestionLetter(
+          //   this.examQuestionDetail.finalAnswer[0]
+          // )[0];
+          // 试题类型-父类
+          this.typeConditionParentValue =
+            this.examQuestionDetail.rootQuestionCategory || '';
+          this.selectTypeConditionParent(); // 查询:试题类型列表-子类
+          // 试题类型-子类
+          this.typeConditionChildrenValue =
+            this.examQuestionDetail.questionCategory || '';
+          // 工种
+          this.engineeringWorkChooseValue = this.examQuestionDetail.engineerTypes[0];
+          this.loading = false;
+        })
+        .catch(() => {
+          this.loading = false;
+        });
     },
     // 查询:试题类型列表-子类
     getTableChildrenListFun() {
@@ -222,7 +286,12 @@ export default {
     },
     // 操作:选择了父类
     selectTypeConditionParent() {
-      this.getTableChildrenListFun(); // 查询:试题类型列表-子类
+      if (this.typeConditionParentValue) {
+        this.getTableChildrenListFun(); // 查询:试题类型列表-子类
+      } else {
+        this.typeConditionChildrenList = [];
+        this.typeConditionChildrenValue = '';
+      }
     },
     // 操作:表单提交
     handleSubmitForm(e) {
@@ -242,7 +311,15 @@ export default {
             type: this.questionType, // 试题类型ID
             answers: [], // 选项
           };
-          this.httpQuestFun(urlParams, params);
+          if (this.examQuestionDetail.id) {
+            params.id = this.examQuestionDetail.id;
+            let pathParams = {
+              questionId: this.examQuestionDetail.id,
+            };
+            this.httpQuestEditFun(urlParams, params, pathParams); // 编辑
+          } else {
+            this.httpQuestAddFun(urlParams, params); // 新建
+          }
         }
       });
     },
@@ -256,8 +333,8 @@ export default {
       }
       return arr;
     },
-    // 表单提交请求
-    httpQuestFun(urlParams, params) {
+    // 新建
+    httpQuestAddFun(urlParams, params) {
       this.loading = true;
       this.$_http
         .post(
@@ -275,6 +352,28 @@ export default {
           this.loading = false;
         });
     },
+    // 编辑
+    httpQuestEditFun(urlParams, params, pathParams) {
+      this.loading = true;
+      this.$_http
+        .put(
+          formatePathParams(
+            formateUrlParams(
+              this.$_API.INTERFACE_POST_EXAMS_QUESTION_EDIT,
+              urlParams
+            ),
+            pathParams
+          ),
+          params
+        )
+        .then(() => {
+          this.loading = false;
+          this.$message.success('编辑填空题成功');
+        })
+        .catch(() => {
+          this.loading = false;
+        });
+    },
   },
 };
 </script>

+ 103 - 7
src/views/examQuestionManagement/examQusetionCreateMultiple.vue

@@ -21,6 +21,7 @@
                 'content',
                 {
                   rules: [{ required: true, message: '请输入试题内容!' }],
+                  initialValue: examQuestionDetail.content,
                 },
               ]"
             />
@@ -54,6 +55,7 @@
                   `answers-${index}`,
                   {
                     rules: [{ required: true, message: '请输入选项内容!' }],
+                    initialValue: item.value,
                   },
                 ]"
               />
@@ -104,7 +106,10 @@
               </div>
               <div class="create-select-item">
                 <span>子类:</span>
-                <a-select v-model="typeConditionChildrenValue">
+                <a-select
+                  v-model="typeConditionChildrenValue"
+                  :disabled="!typeConditionParentValue"
+                >
                   <a-select-option
                     v-for="(item, index) in typeConditionChildrenList"
                     :key="index"
@@ -165,6 +170,7 @@
 <script>
 import {
   formatQuestionIndex,
+  formatQuestionLetter,
   formateUrlParams,
   formatePathParams,
 } from '@/filters';
@@ -190,6 +196,16 @@ export default {
       engineeringWorkList: [], // 工种数据列表
       engineeringWorkChooseValue: '', // 所选工种
       finalAnswerIndexs: undefined, // 正确答案下标
+      examQuestionDetail: {
+        id: '', // key
+        content: '', // 内容
+        finalAnswer: [], // 正确答案
+        engineerTypes: [], // 信息集合:工种
+        type: '', // 试题类型ID
+        answers: [], // 选项
+        rootQuestionCategory: '', // 试题类型-父类
+        questionCategory: '', // 试题类型-子类
+      }, // 题目的信息
     };
   },
   created() {
@@ -211,13 +227,58 @@ export default {
       this.typeConditionParentList = [
         ...this.GET_EXAM_QUESTION_TYPE_CONDITION_PARENT,
       ];
-      this.typeConditionParentValue = this.typeConditionParentList[0].id;
       // 工种类别
       this.engineeringWorkList = [
         { name: '不限', id: '' },
         ...this.GET_ENGINEERING_WORK_LIST,
       ];
-      this.getTableChildrenListFun(); // 查询:试题类型列表-子类
+      if (this.$route.query.id) {
+        this.getExamQuestionDetailFun(this.$route.query.id); // 查询:试题的详情
+      } else {
+        this.typeConditionParentValue = this.typeConditionParentList[0].id; // 所选试题类型-父类
+        this.getTableChildrenListFun(); // 查询:试题类型列表-子类
+      }
+    },
+    // 查询:试题的详情
+    getExamQuestionDetailFun(id) {
+      if (!id) {
+        return;
+      }
+      this.loading = true;
+      let params = {
+        questionId: id,
+      };
+      this.$_http
+        .get(
+          formatePathParams(
+            this.$_API.INTERFACE_GET_EXAMS_QUESTION_DETAIL,
+            params
+          )
+        )
+        .then((res) => {
+          this.examQuestionDetail = { ...res.data };
+          // 选项
+          this.optionsList = this.examQuestionDetail.answers.map((item) => {
+            return { value: item };
+          });
+          // 正确答案
+          this.finalAnswerIndexs = formatQuestionLetter(
+            this.examQuestionDetail.finalAnswer[0]
+          );
+          // 试题类型-父类
+          this.typeConditionParentValue =
+            this.examQuestionDetail.rootQuestionCategory || '';
+          this.selectTypeConditionParent(); // 查询:试题类型列表-子类
+          // 试题类型-子类
+          this.typeConditionChildrenValue =
+            this.examQuestionDetail.questionCategory || '';
+          // 工种
+          this.engineeringWorkChooseValue = this.examQuestionDetail.engineerTypes[0];
+          this.loading = false;
+        })
+        .catch(() => {
+          this.loading = false;
+        });
     },
     // 查询:试题类型列表-子类
     getTableChildrenListFun() {
@@ -251,7 +312,12 @@ export default {
     },
     // 操作:选择了父类
     selectTypeConditionParent() {
-      this.getTableChildrenListFun(); // 查询:试题类型列表-子类
+      if (this.typeConditionParentValue) {
+        this.getTableChildrenListFun(); // 查询:试题类型列表-子类
+      } else {
+        this.typeConditionChildrenList = [];
+        this.typeConditionChildrenValue = '';
+      }
     },
     // 操作:表单提交
     handleSubmitForm(e) {
@@ -273,7 +339,15 @@ export default {
             type: this.questionType, // 试题类型ID
             answers: this.formatQuestionAnswersArr(values), // 选项
           };
-          this.httpQuestFun(urlParams, params);
+          if (this.examQuestionDetail.id) {
+            params.id = this.examQuestionDetail.id;
+            let pathParams = {
+              questionId: this.examQuestionDetail.id,
+            };
+            this.httpQuestEditFun(urlParams, params, pathParams); // 编辑
+          } else {
+            this.httpQuestAddFun(urlParams, params); // 新建
+          }
         }
       });
     },
@@ -300,8 +374,8 @@ export default {
       }
       return arr;
     },
-    // 表单提交请求
-    httpQuestFun(urlParams, params) {
+    // 新建
+    httpQuestAddFun(urlParams, params) {
       this.loading = true;
       this.$_http
         .post(
@@ -319,6 +393,28 @@ export default {
           this.loading = false;
         });
     },
+    // 编辑
+    httpQuestEditFun(urlParams, params, pathParams) {
+      this.loading = true;
+      this.$_http
+        .put(
+          formatePathParams(
+            formateUrlParams(
+              this.$_API.INTERFACE_POST_EXAMS_QUESTION_EDIT,
+              urlParams
+            ),
+            pathParams
+          ),
+          params
+        )
+        .then(() => {
+          this.loading = false;
+          this.$message.success('编辑多选题成功');
+        })
+        .catch(() => {
+          this.loading = false;
+        });
+    },
   },
 };
 </script>

+ 55 - 26
src/views/examQuestionManagement/examQusetionCreateSingle.vue

@@ -255,28 +255,6 @@ export default {
         this.getTableChildrenListFun(); // 查询:试题类型列表-子类
       }
     },
-    // 查询:试题类型列表-子类
-    getTableChildrenListFun() {
-      this.loading = true;
-      let params = {
-        categoryId: this.typeConditionParentValue,
-      };
-      this.$_http
-        .get(
-          formatePathParams(
-            this.$_API.INTERFACE_GET_EXAMS_QUESTION_TYPE_CONDITION_CHILDRENS,
-            params
-          )
-        )
-        .then((res) => {
-          this.typeConditionChildrenList = res.data;
-          this.typeConditionChildrenValue = this.typeConditionChildrenList[0].id;
-          this.loading = false;
-        })
-        .catch(() => {
-          this.loading = false;
-        });
-    },
     // 查询:试题的详情
     getExamQuestionDetailFun(id) {
       if (!id) {
@@ -319,7 +297,28 @@ export default {
           this.loading = false;
         });
     },
-    // 转换字母为数字
+    // 查询:试题类型列表-子类
+    getTableChildrenListFun() {
+      this.loading = true;
+      let params = {
+        categoryId: this.typeConditionParentValue,
+      };
+      this.$_http
+        .get(
+          formatePathParams(
+            this.$_API.INTERFACE_GET_EXAMS_QUESTION_TYPE_CONDITION_CHILDRENS,
+            params
+          )
+        )
+        .then((res) => {
+          this.typeConditionChildrenList = res.data;
+          this.typeConditionChildrenValue = this.typeConditionChildrenList[0].id;
+          this.loading = false;
+        })
+        .catch(() => {
+          this.loading = false;
+        });
+    },
     // 操作:新增选项
     questionOptionAddFun() {
       this.optionsList.push({ value: '' });
@@ -366,7 +365,15 @@ export default {
             // tages: [this.answerDate], // 日期
             answers: this.formatQuestionAnswersArr(values), // 选项
           };
-          this.httpQuestFun(urlParams, params);
+          if (this.examQuestionDetail.id) {
+            params.id = this.examQuestionDetail.id;
+            let pathParams = {
+              questionId: this.examQuestionDetail.id,
+            };
+            this.httpQuestEditFun(urlParams, params, pathParams); // 编辑
+          } else {
+            this.httpQuestAddFun(urlParams, params); // 新建
+          }
         }
       });
     },
@@ -385,8 +392,8 @@ export default {
       }
       return arr;
     },
-    // 表单提交请求
-    httpQuestFun(urlParams, params) {
+    // 新建
+    httpQuestAddFun(urlParams, params) {
       this.loading = true;
       this.$_http
         .post(
@@ -404,6 +411,28 @@ export default {
           this.loading = false;
         });
     },
+    // 编辑
+    httpQuestEditFun(urlParams, params, pathParams) {
+      this.loading = true;
+      this.$_http
+        .put(
+          formatePathParams(
+            formateUrlParams(
+              this.$_API.INTERFACE_POST_EXAMS_QUESTION_EDIT,
+              urlParams
+            ),
+            pathParams
+          ),
+          params
+        )
+        .then(() => {
+          this.loading = false;
+          this.$message.success('编辑单选题成功');
+        })
+        .catch(() => {
+          this.loading = false;
+        });
+    },
   },
 };
 </script>

+ 103 - 8
src/views/examQuestionManagement/examQusetionCreateTrueOrFalse.vue

@@ -21,6 +21,7 @@
                 'content',
                 {
                   rules: [{ required: true, message: '请输入试题内容!' }],
+                  initialValue: examQuestionDetail.content,
                 },
               ]"
             />
@@ -96,7 +97,10 @@
               </div>
               <div class="create-select-item">
                 <span>子类:</span>
-                <a-select v-model="typeConditionChildrenValue">
+                <a-select
+                  v-model="typeConditionChildrenValue"
+                  :disabled="!typeConditionParentValue"
+                >
                   <a-select-option
                     v-for="(item, index) in typeConditionChildrenList"
                     :key="index"
@@ -157,6 +161,7 @@
 <script>
 import {
   formatQuestionIndex,
+  formatQuestionLetter,
   formateUrlParams,
   formatePathParams,
 } from '@/filters';
@@ -174,7 +179,7 @@ export default {
         name: 'examQusetionAddPanDuan',
       }),
       questionType: 'PanDuan', // 试题类型:判断题
-      optionsList: [{ value: '正确' }, { value: '错误' }], // 选项列表
+      optionsList: [{ value: '对' }, { value: '错' }], // 选项列表
       typeConditionParentList: [], // 试题类型-父类列表
       typeConditionParentValue: '', // 父类所选值
       typeConditionChildrenList: [], // 试题类型-子类列表
@@ -182,6 +187,16 @@ export default {
       engineeringWorkList: [], // 工种数据列表
       engineeringWorkChooseValue: '', // 所选工种
       finalAnswerIndexs: undefined, // 正确答案下标
+      examQuestionDetail: {
+        id: '', // key
+        content: '', // 内容
+        finalAnswer: [], // 正确答案
+        engineerTypes: [], // 信息集合:工种
+        type: '', // 试题类型ID
+        answers: [], // 选项
+        rootQuestionCategory: '', // 试题类型-父类
+        questionCategory: '', // 试题类型-子类
+      }, // 题目的信息
     };
   },
   created() {
@@ -203,13 +218,58 @@ export default {
       this.typeConditionParentList = [
         ...this.GET_EXAM_QUESTION_TYPE_CONDITION_PARENT,
       ];
-      this.typeConditionParentValue = this.typeConditionParentList[0].id;
       // 工种类别
       this.engineeringWorkList = [
         { name: '不限', id: '' },
         ...this.GET_ENGINEERING_WORK_LIST,
       ];
-      this.getTableChildrenListFun(); // 查询:试题类型列表-子类
+      if (this.$route.query.id) {
+        this.getExamQuestionDetailFun(this.$route.query.id); // 查询:试题的详情
+      } else {
+        this.typeConditionParentValue = this.typeConditionParentList[0].id; // 所选试题类型-父类
+        this.getTableChildrenListFun(); // 查询:试题类型列表-子类
+      }
+    },
+    // 查询:试题的详情
+    getExamQuestionDetailFun(id) {
+      if (!id) {
+        return;
+      }
+      this.loading = true;
+      let params = {
+        questionId: id,
+      };
+      this.$_http
+        .get(
+          formatePathParams(
+            this.$_API.INTERFACE_GET_EXAMS_QUESTION_DETAIL,
+            params
+          )
+        )
+        .then((res) => {
+          this.examQuestionDetail = { ...res.data };
+          // 选项
+          // this.optionsList = this.examQuestionDetail.answers.map((item) => {
+          //   return { value: item };
+          // });
+          // 正确答案
+          this.finalAnswerIndexs = formatQuestionLetter(
+            this.examQuestionDetail.finalAnswer[0]
+          )[0];
+          // 试题类型-父类
+          this.typeConditionParentValue =
+            this.examQuestionDetail.rootQuestionCategory || '';
+          this.selectTypeConditionParent(); // 查询:试题类型列表-子类
+          // 试题类型-子类
+          this.typeConditionChildrenValue =
+            this.examQuestionDetail.questionCategory || '';
+          // 工种
+          this.engineeringWorkChooseValue = this.examQuestionDetail.engineerTypes[0];
+          this.loading = false;
+        })
+        .catch(() => {
+          this.loading = false;
+        });
     },
     // 查询:试题类型列表-子类
     getTableChildrenListFun() {
@@ -235,7 +295,12 @@ export default {
     },
     // 操作:选择了父类
     selectTypeConditionParent() {
-      this.getTableChildrenListFun(); // 查询:试题类型列表-子类
+      if (this.typeConditionParentValue) {
+        this.getTableChildrenListFun(); // 查询:试题类型列表-子类
+      } else {
+        this.typeConditionChildrenList = [];
+        this.typeConditionChildrenValue = '';
+      }
     },
     // 操作:表单提交
     handleSubmitForm(e) {
@@ -257,7 +322,15 @@ export default {
             type: this.questionType, // 试题类型ID
             answers: this.formatQuestionAnswersArr(values), // 选项
           };
-          this.httpQuestFun(urlParams, params);
+          if (this.examQuestionDetail.id) {
+            params.id = this.examQuestionDetail.id;
+            let pathParams = {
+              questionId: this.examQuestionDetail.id,
+            };
+            this.httpQuestEditFun(urlParams, params, pathParams); // 编辑
+          } else {
+            this.httpQuestAddFun(urlParams, params); // 新建
+          }
         }
       });
     },
@@ -276,8 +349,8 @@ export default {
       }
       return arr;
     },
-    // 表单提交请求
-    httpQuestFun(urlParams, params) {
+    // 新建
+    httpQuestAddFun(urlParams, params) {
       this.loading = true;
       this.$_http
         .post(
@@ -295,6 +368,28 @@ export default {
           this.loading = false;
         });
     },
+    // 编辑
+    httpQuestEditFun(urlParams, params, pathParams) {
+      this.loading = true;
+      this.$_http
+        .put(
+          formatePathParams(
+            formateUrlParams(
+              this.$_API.INTERFACE_POST_EXAMS_QUESTION_EDIT,
+              urlParams
+            ),
+            pathParams
+          ),
+          params
+        )
+        .then(() => {
+          this.loading = false;
+          this.$message.success('编辑判断题成功');
+        })
+        .catch(() => {
+          this.loading = false;
+        });
+    },
   },
 };
 </script>