zhangjie пре 2 година
родитељ
комит
df0a38e2c8

+ 97 - 66
src/modules/paper/components/QuestionGroupStruct.vue

@@ -21,12 +21,12 @@
           :expand-on-click-node="false"
           show-checkbox
           check-strictly
-          :props="defaultProps"
+          :props="treeProps"
           @check-change="checkChange"
         ></el-tree>
       </div>
       <div class="struct-prop">
-        <el-table :data="dataList">
+        <el-table :data="tableData" :tree-props="tableTreeProps" row-key="id">
           <el-table-column label="分类" prop="name"></el-table-column>
           <el-table-column
             v-if="!isDifficult"
@@ -36,37 +36,40 @@
           >
             <template slot-scope="scope">
               <el-input-number
-                v-model="scope.row.questionCount"
+                v-model="scope.row.selectCount"
                 class="search_width_80px"
                 :step="1"
                 :min="1"
-                :max="scope.row.totalCount"
+                :max="scope.row.questionCount"
                 :controls="false"
                 :precision="0"
                 step-strictly
               ></el-input-number>
-              <span class="inline-middle">/ {{ scope.row.totalCount }}</span>
+              <span class="inline-middle">/ {{ scope.row.questionCount }}</span>
             </template>
           </el-table-column>
           <el-table-column
-            v-for="(dinfo, dindex) in questionDistributeInfo"
+            v-for="(dinfo, dindex) in difficultDistributeInfo"
             v-else
             :key="dindex"
             :label="dinfo"
           >
             <template slot-scope="scope">
               <el-input-number
-                v-model="scope.row.questionDistributeInfo[dindex].questionCount"
+                v-model="scope.row.difficultDistributeInfo[dindex].selectCount"
                 class="search_width_80px"
                 :step="1"
                 :min="1"
-                :max="scope.row.questionDistributeInfo[dindex].count"
+                :max="scope.row.difficultDistributeInfo[dindex].questionCount"
                 :controls="false"
                 :precision="0"
                 step-strictly
               ></el-input-number>
               <span class="inline-middle"
-                >/ {{ scope.row.questionDistributeInfo[dindex].count }}</span
+                >/
+                {{
+                  scope.row.difficultDistributeInfo[dindex].questionCount
+                }}</span
               >
             </template>
           </el-table-column>
@@ -102,12 +105,17 @@ export default {
       selectedFolderIds: [],
       folderTree,
       // folderTree: [],
-      defaultProps: {
+      treeProps: {
         label: "name",
       },
       originList: [],
       dataList: [],
-      questionDistributeInfo: [],
+      tableData: [],
+      tableTreeProps: {
+        children: "propertyDistributeInfo",
+        hasChildren: "hasChildren",
+      },
+      difficultDistributeInfo: [],
       curCoursePropertyName: "",
     };
   },
@@ -167,71 +175,94 @@ export default {
       this.originList = res.data || [];
     },
     buildDataList() {
-      if (this.IS_ONLY_FOLDER) {
-        this.dataList = this.originList.map((item) => {
-          return {
-            name: item.name,
-            questionCount: undefined,
-            totalCount: item.totalCount,
-          };
-        });
-        return;
+      function buildClassifyData(data) {
+        let classifyData = {
+          id: data.classifyId,
+          name: data.classifyName,
+          classifyId: data.classifyId,
+          classifyName: data.classifyName,
+          isFolder: true,
+          questionCount: data.questionCount,
+          selectCount: undefined,
+          difficultDistributeInfo: null,
+        };
+        if (
+          data.difficultDistributeInfo &&
+          data.difficultDistributeInfo.length
+        ) {
+          classifyData.difficultDistributeInfo = parseQuestionDistributeInfo(
+            data.difficultDistributeInfo
+          );
+        }
+        if (!data.propertyDistributeInfo || !data.propertyDistributeInfo.length)
+          return classifyData;
+
+        const curCourseProp = data.propertyDistributeInfo.find(
+          (item) => item.coursePropertyName === this.curCoursePropertyName
+        );
+        if (!curCourseProp) {
+          return classifyData;
+        }
+
+        classifyData.propertyDistributeInfo = curCourseProp.distributeInfo.map(
+          (item) => parsePropertyData(item)
+        );
+
+        return classifyData;
       }
 
-      if (this.IS_ONLY_DIFFICULT) {
-        this.dataList = this.originList.map((item) => {
-          return {
-            name: `${item.name}(共${item.count}道)`,
-            questionCount: undefined,
-            totalCount: item.count,
-          };
+      function parseQuestionDistributeInfo(data) {
+        if (!this.difficultDistributeInfo.length) {
+          this.difficultDistributeInfo = data.map(
+            (item) => item.difficultLevel
+          );
+        }
+        return data.map((item) => {
+          return { ...item, selectCount: undefined };
         });
-        return;
       }
 
-      // 属性
-      const curCourseProp = this.originList.find(
-        (item) => item.coursePropertyName === this.curCoursePropertyName
-      );
-      if (!curCourseProp) {
-        this.dataList = [];
-        return;
-      }
-      let dataList = [];
-      const transformPropData = (item, level) => {
-        let nitem = {
-          name: item.classifyName,
-          level,
-          questionCount: undefined,
-          totalCount: item.totalCount,
+      function parsePropertyData(data) {
+        let propData = {
+          id: data.propertyId,
+          name: data.propertyName,
+          propertyId: data.propertyId,
+          propertyName: data.propertyName,
+          questionCount: data.questionCount,
+          selectCount: undefined,
+          difficultDistributeInfo: null,
         };
-        if (this.isDifficult) {
-          if (!this.questionDistributeInfo.length) {
-            this.questionDistributeInfo = item.questionDistributeInfo.map(
-              (info) => info.name
-            );
-          }
-          nitem.questionDistributeInfo = item.questionDistributeInfo.map(
-            (item) => {
-              return {
-                name: item.name,
-                count: item.count,
-                questionCount: undefined,
-              };
-            }
+        if (
+          data.difficultDistributeInfo &&
+          data.difficultDistributeInfo.length
+        ) {
+          propData.difficultDistributeInfo = parseQuestionDistributeInfo(
+            data.difficultDistributeInfo
           );
         }
-        return nitem;
-      };
-      curCourseProp.distributeInfo.forEach((item) => {
-        dataList.push(transformPropData(item, 0));
 
-        if (item.children && item.children.length) {
-          item.children.forEach((elem) => {
-            dataList.push(transformPropData(elem, 1));
-          });
+        if (data.propertyDistributeInfo && data.propertyDistributeInfo.length) {
+          propData.propertyDistributeInfo = data.propertyDistributeInfo.map(
+            (item) => parsePropertyData(item)
+          );
         }
-      });
+        return propData;
+      }
+
+      this.dataList = this.originList.map((item) => buildClassifyData(item));
+      this.tableData = this.dataList;
+
+      if (this.IS_ONLY_DIFFICULT) {
+        this.tableData = this.dataList[0].difficultDistributeInfo;
+        this.tableData.forEach((elem) => {
+          elem.id = elem.name;
+        });
+        return;
+      }
+      if (this.IS_ONLY_PROPERTY) {
+        this.tableData = this.dataList[0].children;
+        return;
+      }
     },
   },
 };

Разлика између датотеке није приказан због своје велике величине
+ 205 - 206
src/modules/paper/datas/folderPropStruct.json


+ 4 - 4
src/modules/question/views/QuestionManage.vue

@@ -293,10 +293,10 @@ export default {
       this.curCourse = val || {};
     },
     toStatistics() {
-      // if (!this.filter.courseId) {
-      //   this.$message.error("请先选择课程!");
-      //   return;
-      // }
+      if (!this.filter.courseId) {
+        this.$message.error("请先选择课程!");
+        return;
+      }
       this.$refs.QuestionStatisticsDialog.open();
     },
     toSafetySet() {

Неке датотеке нису приказане због велике количине промена