Explorar o código

修改单选页面

huangtao %!s(int64=4) %!d(string=hai) anos
pai
achega
e62318eab5

+ 20 - 13
src/App.vue

@@ -31,23 +31,30 @@ export default {
           ); // 赋值网页内容区域可视化高度值
         })();
       };
-      // 获取工种、试题类型数据,并存到vuex
+      this.getEngineeringWorkList();
+    },
+    // 获取工种,并存到vuex
+    getEngineeringWorkList() {
       this.$_http
         .get(this.$_API.INTERFACE_GET_ENGINEERINGWORK_LIST)
         .then((res) => {
           this.$store.commit('common/SET_ENGINEERING_WORK_LIST', res.data);
-          this.$_http
-            .get(this.$_API.INTERFACE_GET_EXAMS_QUESTION_TYPE_CONDITION_PARENT)
-            .then((res) => {
-              this.$store.commit(
-                'common/SET_EXAM_QUESTION_TYPE_CONDITION',
-                res.data
-              );
-              this.isInited = true;
-            })
-            .catch(() => {
-              this.isInited = true;
-            });
+          this.getExamQuestionTypeConditionParentList();
+        })
+        .catch(() => {
+          this.isInited = true;
+        });
+    },
+    // 获取试题类型-父类信息,并存到vuex
+    getExamQuestionTypeConditionParentList() {
+      this.$_http
+        .get(this.$_API.INTERFACE_GET_EXAMS_QUESTION_TYPE_CONDITION_PARENT)
+        .then((res) => {
+          this.$store.commit(
+            'common/SET_EXAM_QUESTION_TYPE_CONDITION_PARENT',
+            res.data
+          );
+          this.isInited = true;
         })
         .catch(() => {
           this.isInited = true;

+ 1 - 1
src/store/getters.js

@@ -3,6 +3,6 @@ const getters = {
   routes: state => state.user.menus,
   screenHeight: state => state.common.screenHeight,
   GET_ENGINEERING_WORK_LIST: state => state.common.engineeringWorkList,
-  GET_EXAM_QUESTION_TYPE_CONDITION: state => state.common.examQuestionTypeConditionList,
+  GET_EXAM_QUESTION_TYPE_CONDITION_PARENT: state => state.common.examQuestionTypeConditionParentList,
 };
 export default getters;

+ 3 - 3
src/store/modules/common.js

@@ -2,7 +2,7 @@
 const state = {
   screenHeight: 0, // 网页内容区域可视化高度值
   engineeringWorkList: [], // 工种类型列表
-  examQuestionTypeConditionList: [], // 试题类型列表
+  examQuestionTypeConditionParentList: [], // 试题类型列表-父类
 
 };
 
@@ -16,8 +16,8 @@ const mutations = {
     state.engineeringWorkList = list || []
   },
   // 存储试题类型列表数据
-  SET_EXAM_QUESTION_TYPE_CONDITION: (state, list) => {
-    state.examQuestionTypeConditionList = list || []
+  SET_EXAM_QUESTION_TYPE_CONDITION_PARENT: (state, list) => {
+    state.examQuestionTypeConditionParentList = list || []
   },
 };
 

+ 16 - 1
src/styles/components/index.less

@@ -77,11 +77,26 @@
       }
     }
   }
-
   .qusetionSubmitBtn {
     width: calc(60%);
     margin: 20px 0 20px calc(20% + 56px);
   }
+  .create-select-row {
+    padding-left: 56px;
+    >span {
+      flex-wrap: nowrap;
+      white-space: nowrap;
+    }
+    .create-select-item {
+      // display: flex;
+      // align-items: center;
+      span {
+        flex-wrap: nowrap;
+        white-space: nowrap;
+        margin: 0 10px 0 16px;
+      }
+    }
+  }
 }
 // 新建试题的统一样式--------end
 

+ 2 - 2
src/views/examQuestionManagement/examQuestionList.vue

@@ -162,7 +162,7 @@ export default {
     ...mapGetters([
       'screenHeight',
       'GET_ENGINEERING_WORK_LIST',
-      'GET_EXAM_QUESTION_TYPE_CONDITION',
+      'GET_EXAM_QUESTION_TYPE_CONDITION_PARENT',
     ]),
     // 判断是否有行被选择
     hasSelected() {
@@ -183,7 +183,7 @@ export default {
       // 试题类型
       this.examQuestionConditionType = [
         { name: '全部', id: '' },
-        ...this.GET_EXAM_QUESTION_TYPE_CONDITION,
+        ...this.GET_EXAM_QUESTION_TYPE_CONDITION_PARENT,
       ];
       // 工种类别
       this.engineeringWorkList = [

+ 14 - 3
src/views/examQuestionManagement/examQuestionTypeCondition.vue

@@ -162,13 +162,22 @@ export default {
         });
     },
     // 查询:试题类型列表-父类
-    getTableParentListFun() {
+    getTableParentListFun(isDeleteParent) {
       this.loading = true;
       this.$_http
         .get(this.$_API.INTERFACE_GET_EXAMS_QUESTION_TYPE_CONDITION_PARENT)
         .then((res) => {
           this.parentTypeTableList = res.data;
           this.parentTypeValue = this.parentTypeTableList[0].id;
+          // 存到vuex中
+          this.$store.commit(
+            'common/SET_EXAM_QUESTION_TYPE_CONDITION_PARENT',
+            res.data
+          );
+          // 删除的是父类,并且是下拉框中所选父类,需要重新赋值
+          if (isDeleteParent) {
+            this.getTableChildrenListFun();
+          }
           this.loading = false;
         })
         .catch(() => {
@@ -228,7 +237,7 @@ export default {
           this.questionTypeChildrenName = '';
           this.loading = false;
           this.$message.success('新建 试题类型-子类 成功');
-          this.getTableChildrenListFun(); // 查询:试题类型列表
+          this.getTableChildrenListFun(); // 查询:试题类型列表-子类
         })
         .catch(() => {
           this.loading = false;
@@ -257,7 +266,9 @@ export default {
             .then(() => {
               that.loading = false;
               that.$message.success('删除试题类型成功');
-              that.getTableParentListFun(); // 查询:试题类型列表
+              that.getTableParentListFun(
+                !record.parentId && record.id === that.parentTypeValue
+              ); // 查询:试题类型列表
             })
             .catch(() => {
               that.loading = false;

+ 2 - 2
src/views/examQuestionManagement/examQusetionCreateGapFilling.vue

@@ -160,7 +160,7 @@ export default {
   computed: {
     ...mapGetters([
       'GET_ENGINEERING_WORK_LIST',
-      'GET_EXAM_QUESTION_TYPE_CONDITION',
+      'GET_EXAM_QUESTION_TYPE_CONDITION_PARENT',
     ]),
   },
   methods: {
@@ -169,7 +169,7 @@ export default {
       // 试题类型
       this.typeConditionList = [
         { name: '不限', id: '' },
-        ...this.GET_EXAM_QUESTION_TYPE_CONDITION,
+        ...this.GET_EXAM_QUESTION_TYPE_CONDITION_PARENT,
       ];
       // 工种类别
       this.engineeringWorkList = [

+ 2 - 2
src/views/examQuestionManagement/examQusetionCreateMultiple.vue

@@ -184,7 +184,7 @@ export default {
   computed: {
     ...mapGetters([
       'GET_ENGINEERING_WORK_LIST',
-      'GET_EXAM_QUESTION_TYPE_CONDITION',
+      'GET_EXAM_QUESTION_TYPE_CONDITION_PARENT',
     ]),
   },
   methods: {
@@ -193,7 +193,7 @@ export default {
       // 试题类型
       this.typeConditionList = [
         { name: '不限', id: '' },
-        ...this.GET_EXAM_QUESTION_TYPE_CONDITION,
+        ...this.GET_EXAM_QUESTION_TYPE_CONDITION_PARENT,
       ];
       // 工种类别
       this.engineeringWorkList = [

+ 71 - 7
src/views/examQuestionManagement/examQusetionCreateSingle.vue

@@ -118,7 +118,7 @@
               ]"
             >
               <a-select-option
-                v-for="(item, index) in typeConditionList"
+                v-for="(item, index) in typeConditionParentList"
                 :key="index"
                 :value="item.id"
               >
@@ -126,6 +126,36 @@
               </a-select-option>
             </a-select>
           </a-form-item>
+          <div class="create-select-row">
+            <span>试题类型:</span>
+            <div class="create-select-item">
+              <span>父类</span>
+              <a-select
+                v-model="typeConditionParentValue"
+                @change="selectTypeConditionParent"
+              >
+                <a-select-option
+                  v-for="(item, index) in typeConditionParentList"
+                  :key="index"
+                  :value="item.id"
+                >
+                  {{ item.name }}
+                </a-select-option>
+              </a-select>
+            </div>
+            <div class="create-select-item">
+              <span>子类</span>
+              <a-select v-model="typeConditionChildrenValue">
+                <a-select-option
+                  v-for="(item, index) in typeConditionChildrenList"
+                  :key="index"
+                  :value="item.id"
+                >
+                  {{ item.name }}
+                </a-select-option>
+              </a-select>
+            </div>
+          </div>
           <a-form-item
             label="工种类别"
             :label-col="labelCol"
@@ -168,7 +198,11 @@
 </template>
 
 <script>
-import { formatQuestionIndex, formateUrlParams } from '@/filters';
+import {
+  formatQuestionIndex,
+  formateUrlParams,
+  formatePathParams,
+} from '@/filters';
 import { mapGetters } from 'vuex';
 export default {
   name: 'examQusetionCreateSingle',
@@ -184,7 +218,10 @@ export default {
       }),
       questionType: 'DanXuan', // 试题类别:单选题
       optionsList: [{ value: '' }, { value: '' }], // 选项列表
-      typeConditionList: [], // 试题类型列表
+      typeConditionParentList: [], // 试题类型-父类列表
+      typeConditionParentValue: '', // 父类所选值
+      typeConditionChildrenList: [], // 试题类型-子类列表
+      typeConditionChildrenValue: '', // 子类所选值
       typeCondition: '', // 所选试题类型
       engineeringWorkList: [], // 工种数据列表
       engineeringWorkChooseValue: '', // 所选工种
@@ -201,22 +238,45 @@ export default {
   computed: {
     ...mapGetters([
       'GET_ENGINEERING_WORK_LIST',
-      'GET_EXAM_QUESTION_TYPE_CONDITION',
+      'GET_EXAM_QUESTION_TYPE_CONDITION_PARENT',
     ]),
   },
   methods: {
     // 初始化数据
     initDataFun() {
       // 试题类型
-      this.typeConditionList = [
-        { name: '不限', id: '' },
-        ...this.GET_EXAM_QUESTION_TYPE_CONDITION,
+      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(); // 查询:试题类型列表-子类
+    },
+    // 查询:试题类型列表-子类
+    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() {
@@ -234,6 +294,10 @@ export default {
     //     this.answerDate = '';
     //   }
     // },
+    // 操作:选择了父类
+    selectTypeConditionParent() {
+      this.getTableChildrenListFun(); // 查询:试题类型列表-子类
+    },
     // 操作:表单提交
     handleSubmitForm(e) {
       e.preventDefault();

+ 2 - 2
src/views/examQuestionManagement/examQusetionCreateTrueOrFalse.vue

@@ -177,7 +177,7 @@ export default {
   computed: {
     ...mapGetters([
       'GET_ENGINEERING_WORK_LIST',
-      'GET_EXAM_QUESTION_TYPE_CONDITION',
+      'GET_EXAM_QUESTION_TYPE_CONDITION_PARENT',
     ]),
   },
   methods: {
@@ -186,7 +186,7 @@ export default {
       // 试题类型
       this.typeConditionList = [
         { name: '不限', id: '' },
-        ...this.GET_EXAM_QUESTION_TYPE_CONDITION,
+        ...this.GET_EXAM_QUESTION_TYPE_CONDITION_PARENT,
       ];
       // 工种类别
       this.engineeringWorkList = [