Forráskód Böngészése

修改试题类型数据查询

yellowtaotao 4 éve
szülő
commit
a575c09ef5

+ 6 - 6
src/filters/index.js

@@ -137,14 +137,14 @@ export function dateChange() {
 
 /**
  * 请求地址拼接指定参数:/url/{id}
- * @pathParams {Object} 路径参数
+ * @formatePathParams {Object} 路径参数
  * @return 新path
  */
-export function formatePathParams(path, pathParams) {
-  if (path.includes('{') && pathParams) {
-    let keys = Object.keys(pathParams);
+export function formatePathParams(path, formatePathParams) {
+  if (path.includes('{') && formatePathParams) {
+    let keys = Object.keys(formatePathParams);
     keys.forEach((it) => {
-      path = path.replace('{' + `${it}` + '}', pathParams[it]);
+      path = path.replace('{' + `${it}` + '}', formatePathParams[it]);
     });
   }
   return path;
@@ -152,7 +152,7 @@ export function formatePathParams(path, pathParams) {
 
 /**
  * 请求地址拼接路径的参数: /url?id=xx&name=yy
- * @pathParams {Object} 路径参数
+ * @formatePathParams {Object} 路径参数
  * @return 新path
  */
 export function formateUrlParams(path, urlParams) {

+ 19 - 19
src/views/articleManagement/articleCreate.vue

@@ -95,9 +95,9 @@
 </template>
 
 <script>
-import { pathParams } from "@/filters";
+import { formatePathParams } from '@/filters';
 export default {
-  name: "articleCreate",
+  name: 'articleCreate',
   props: {},
   components: {
     // components: (reslove) => {
@@ -106,17 +106,17 @@ export default {
   },
   data() {
     return {
-      content: "输入内容",
+      content: '输入内容',
       //   展示预览
       previewVisible: false,
-      form: this.$form.createForm(this, { name: "articleCreate" }),
+      form: this.$form.createForm(this, { name: 'articleCreate' }),
       articalParentClassArr: [],
       articalChildClassArr: [],
       engineerTypeArray: [],
       articalParentClass: {},
       articalChildClass: {},
-      engineerType: "",
-      learnDate: ""
+      engineerType: '',
+      learnDate: '',
     };
   },
   created() {
@@ -136,7 +136,7 @@ export default {
     getArticalParentClass() {
       this.$_http
         .get(this.$_API.INTERFACE_GET_CATEGORIES)
-        .then(res => {
+        .then((res) => {
           this.articalParentClassArr = res.data;
           this.loading = false;
         })
@@ -146,15 +146,15 @@ export default {
     },
     // 查询文章分类子集
     getArticalChildClass() {
-      let pathParamsData = { categoryId: "" };
+      let pathParamsData = { categoryId: '' };
       this.$_http
         .get(
-          pathParams(
+          formatePathParams(
             this.$_API.INTERFACE_GET_CATEGORIES_CATEGROYID,
             pathParamsData
           )
         )
-        .then(res => {
+        .then((res) => {
           this.articalChildClassArr = res.data;
           this.loading = false;
         })
@@ -166,7 +166,7 @@ export default {
     getEngineersWork() {
       this.$_http
         .get(this.$_API.INTERFACE_GET_ENGINEERINGWORK_LIST)
-        .then(res => {
+        .then((res) => {
           this.engineerTypeArray = res.data;
         });
     },
@@ -180,7 +180,7 @@ export default {
       // 子类选项清空
       this.articalChildClassArr = [];
       this.form.setFieldsValue({
-        articalChildClass: ""
+        articalChildClass: '',
       });
     },
     // 文章分类子类变化
@@ -200,18 +200,18 @@ export default {
       e.preventDefault();
 
       this.form.setFieldsValue({
-        articalParentClass: this.articalParentClass.name
+        articalParentClass: this.articalParentClass.name,
       });
       this.form.setFieldsValue({
-        articalChildClass: this.articalChildClass.name
+        articalChildClass: this.articalChildClass.name,
       });
       this.form.setFieldsValue({
-        engineerType: this.engineerType.name
+        engineerType: this.engineerType.name,
       });
-      
+
       this.form.validateFields((err, values) => {
         if (!err) {
-          console.log("Received values of form: ", values);
+          console.log('Received values of form: ', values);
         }
       });
     },
@@ -222,8 +222,8 @@ export default {
     // 关闭预览
     closepreview() {
       this.previewVisible = false;
-    }
-  }
+    },
+  },
 };
 </script>
 

+ 68 - 24
src/views/examQuestionManagement/examQuestionTypeCondition.vue

@@ -2,10 +2,10 @@
   <div class="app-container">
     <div class="common-card">
       <!-- 新建类型 -->
-      <div class="engineeringWork-create">
-        <div class="engineeringWork-create-title">新建类型</div>
-        <div class="engineeringWork-create-edit">
-          <div class="engineeringWork-create-input">
+      <div class="questionTypeCondition-create">
+        <div class="questionTypeCondition-create-title">新建类型</div>
+        <div class="questionTypeCondition-create-edit">
+          <div class="questionTypeCondition-create-input">
             <span>父类名称:</span>
             <a-input
               v-model.trim="questionTypeParentName"
@@ -19,10 +19,10 @@
             >新建父类</a-button
           >
         </div>
-        <div class="engineeringWork-create-edit">
-          <div class="engineeringWork-create-input">
+        <div class="questionTypeCondition-create-edit">
+          <div class="questionTypeCondition-create-input">
             <span>所属父类:</span>
-            <a-select v-model="parentTypeValue">
+            <a-select v-model="parentTypeValue" style="width: 174px">
               <a-select-option
                 v-for="(item, index) in parentTypeTableList"
                 :key="index"
@@ -32,7 +32,7 @@
               </a-select-option>
             </a-select>
           </div>
-          <div class="engineeringWork-create-input">
+          <div class="questionTypeCondition-create-input">
             <span>子类名称:</span>
             <a-input
               v-model.trim="questionTypeChildrenName"
@@ -50,8 +50,8 @@
     </div>
     <div class="common-card a-card-margin-top">
       <!-- 已有类型-父类 -->
-      <div class="engineeringWork-list">
-        <div class="engineeringWork-list-title">已有父类</div>
+      <div class="questionTypeCondition-list">
+        <div class="questionTypeCondition-list-title">已有父类</div>
         <a-table
           :columns="columns"
           :row-key="(record) => record.id"
@@ -61,7 +61,7 @@
           <a
             slot="action"
             slot-scope="text, record"
-            @click="engineeringWorkDelete(record)"
+            @click="questionTypeConditionDelete(record)"
             >删除</a
           >
         </a-table>
@@ -69,8 +69,20 @@
     </div>
     <div class="common-card a-card-margin-top">
       <!-- 已有类型-子类 -->
-      <div class="engineeringWork-list">
-        <div class="engineeringWork-list-title">已有子类</div>
+      <div class="questionTypeCondition-list">
+        <div class="questionTypeCondition-list-title">已有子类</div>
+        <div class="questionTypeCondition-list-filter">
+          <span>所属父类:</span>
+          <a-select v-model="parentTypeValue" style="width: 174px">
+            <a-select-option
+              v-for="(item, index) in parentTypeTableList"
+              :key="index"
+              :value="item.id"
+            >
+              {{ item.name }}
+            </a-select-option>
+          </a-select>
+        </div>
         <a-table
           :columns="columns"
           :row-key="(record) => record.id"
@@ -80,7 +92,7 @@
           <a
             slot="action"
             slot-scope="text, record"
-            @click="engineeringWorkDelete(record)"
+            @click="questionTypeConditionDelete(record)"
             >删除</a
           >
         </a-table>
@@ -129,8 +141,21 @@ export default {
           width: 150,
         },
       ];
-      this.getTableParentListFun(); // 查询:列表-父类
-      this.getTableChildrenListFun(); // 查询:列表-子类
+      this.initTableParentListFun(); // 查询:列表-父类
+    },
+    // 查询:试题类型列表-父类
+    initTableParentListFun() {
+      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;
+          this.getTableChildrenListFun(); // 查询:列表-子类
+        })
+        .catch(() => {
+          this.loading = false;
+        });
     },
     // 查询:试题类型列表-父类
     getTableParentListFun() {
@@ -149,8 +174,16 @@ export default {
     // 查询:试题类型列表-子类
     getTableChildrenListFun() {
       this.loading = true;
+      let params = {
+        categoryId: this.parentTypeValue,
+      };
       this.$_http
-        .get(this.$_API.INTERFACE_GET_EXAMS_QUESTION_TYPE_CONDITION_CHILDRENS)
+        .get(
+          formatePathParams(
+            this.$_API.INTERFACE_GET_EXAMS_QUESTION_TYPE_CONDITION_CHILDRENS,
+            params
+          )
+        )
         .then((res) => {
           this.childrenTypeTableList = res.data;
           this.loading = false;
@@ -198,7 +231,7 @@ export default {
         });
     },
     // 操作:删除试题类型
-    engineeringWorkDelete(record) {
+    questionTypeConditionDelete(record) {
       let that = this;
       this.$confirm({
         title: '删除',
@@ -239,19 +272,19 @@ export default {
 @import '~@/styles/common/variable.less';
 .app-container {
   overflow-y: auto;
-  .engineeringWork-create {
+  .questionTypeCondition-create {
     width: 100%;
-    .engineeringWork-create-title {
+    .questionTypeCondition-create-title {
       font-size: 18px;
       font-weight: bold;
       color: @mainColorBlack85;
     }
-    .engineeringWork-create-edit {
+    .questionTypeCondition-create-edit {
       margin-top: @paddingMarginVal;
       padding: 0 100px 0 100px;
       display: flex;
       justify-content: space-between;
-      .engineeringWork-create-input {
+      .questionTypeCondition-create-input {
         display: flex;
         align-items: center;
         > span {
@@ -262,13 +295,24 @@ export default {
       }
     }
   }
-  .engineeringWork-list {
-    .engineeringWork-list-title {
+  .questionTypeCondition-list {
+    .questionTypeCondition-list-title {
       margin-bottom: @paddingMarginVal;
       font-size: 18px;
       font-weight: bold;
       color: @mainColorBlack85;
     }
+    .questionTypeCondition-list-filter {
+      display: flex;
+      align-items: center;
+      margin-bottom: @paddingMarginVal;
+      > span {
+        font-size: 16px;
+        font-weight: bold;
+        flex-wrap: nowrap;
+        white-space: nowrap;
+      }
+    }
   }
 }
 </style>