|
@@ -15,6 +15,7 @@
|
|
|
v-model="curCoursePropertyId"
|
|
|
class="margin-left-10"
|
|
|
size="small"
|
|
|
+ @change="buildDataList"
|
|
|
>
|
|
|
<el-option
|
|
|
v-for="item in propertyInfo"
|
|
@@ -54,7 +55,13 @@
|
|
|
v-if="scope.row.isClassify"
|
|
|
class="icon icon-files-act margin-right-5"
|
|
|
></i>
|
|
|
- <span class="inline-middle">{{ scope.row.name }}</span>
|
|
|
+
|
|
|
+ <span
|
|
|
+ v-if="scope.row.isClassify && scope.row.id === 0"
|
|
|
+ class="inline-middle"
|
|
|
+ >根目录</span
|
|
|
+ >
|
|
|
+ <span v-else class="inline-middle">{{ scope.row.name }}</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column
|
|
@@ -72,6 +79,7 @@
|
|
|
:controls="false"
|
|
|
:precision="0"
|
|
|
step-strictly
|
|
|
+ @change="selectCountChange"
|
|
|
></el-input-number>
|
|
|
<span class="inline-middle">/ {{ scope.row.questionCount }}</span>
|
|
|
</template>
|
|
@@ -99,6 +107,7 @@
|
|
|
:controls="false"
|
|
|
:precision="0"
|
|
|
step-strictly
|
|
|
+ @change="selectCountChange"
|
|
|
></el-input-number>
|
|
|
<span class="inline-middle"
|
|
|
>/
|
|
@@ -115,9 +124,9 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import folderTree from "../datas/folderTree.json";
|
|
|
import { questionGroupStructListApi } from "../api";
|
|
|
-import { deepCopy } from "@/plugins/utils";
|
|
|
+import { classifyTreeApi } from "../../question/api";
|
|
|
+import { calcSum, deepCopy } from "@/plugins/utils";
|
|
|
|
|
|
export default {
|
|
|
name: "QuestionGroupStruct",
|
|
@@ -139,8 +148,14 @@ export default {
|
|
|
useProperty: false,
|
|
|
checkedSet: [],
|
|
|
selectedFolderIds: [],
|
|
|
- classifyTree: folderTree,
|
|
|
- // classifyTree: [],
|
|
|
+ classifyTree: [
|
|
|
+ {
|
|
|
+ id: 0,
|
|
|
+ parent: null,
|
|
|
+ name: "根目录",
|
|
|
+ children: [],
|
|
|
+ },
|
|
|
+ ],
|
|
|
treeProps: {
|
|
|
label: "name",
|
|
|
},
|
|
@@ -168,9 +183,10 @@ export default {
|
|
|
},
|
|
|
},
|
|
|
watch: {
|
|
|
- "filterData.questionType": {
|
|
|
+ filterData: {
|
|
|
+ deep: true,
|
|
|
handler(val, oldval) {
|
|
|
- if (val !== oldval) {
|
|
|
+ if (JSON.stringify(val) !== JSON.stringify(oldval)) {
|
|
|
this.resetDataList();
|
|
|
}
|
|
|
},
|
|
@@ -178,6 +194,7 @@ export default {
|
|
|
},
|
|
|
mounted() {
|
|
|
this.resetDataList();
|
|
|
+ this.getClassifyTree();
|
|
|
},
|
|
|
methods: {
|
|
|
setChange() {
|
|
@@ -188,6 +205,10 @@ export default {
|
|
|
this.selectedFolderIds = this.$refs.folderTree.getCheckedKeys();
|
|
|
this.resetDataList();
|
|
|
},
|
|
|
+ async getClassifyTree() {
|
|
|
+ const res = await classifyTreeApi();
|
|
|
+ this.classifyTree[0].children = res.data || [];
|
|
|
+ },
|
|
|
async resetDataList() {
|
|
|
await this.getOriginList();
|
|
|
|
|
@@ -220,10 +241,13 @@ export default {
|
|
|
let coursePropertyIds = [],
|
|
|
propertyInfo = [];
|
|
|
this.originList.forEach((item) => {
|
|
|
- if (!item.propertyDistributeInfo || !item.propertyDistributeInfo.length)
|
|
|
+ if (
|
|
|
+ !item.coursePropertyDistributeInfo ||
|
|
|
+ !item.coursePropertyDistributeInfo.length
|
|
|
+ )
|
|
|
return;
|
|
|
|
|
|
- item.propertyDistributeInfo.forEach((prop) => {
|
|
|
+ item.coursePropertyDistributeInfo.forEach((prop) => {
|
|
|
if (coursePropertyIds.includes(prop.coursePropertyId)) return;
|
|
|
coursePropertyIds.push(prop.coursePropertyId);
|
|
|
propertyInfo.push({
|
|
@@ -331,12 +355,13 @@ export default {
|
|
|
|
|
|
if (this.USE_ONLY_DIFFICULT) {
|
|
|
this.tableData = this.dataList[0].difficultDistributeInfo;
|
|
|
- this.tableData.map((item) => {
|
|
|
+ this.tableData = this.tableData.map((item) => {
|
|
|
let nitem = { ...item };
|
|
|
nitem.id = item.difficultLevel;
|
|
|
nitem.name = item.difficultLevel;
|
|
|
return nitem;
|
|
|
});
|
|
|
+ this.selectCountChange();
|
|
|
return;
|
|
|
}
|
|
|
if (this.useClassify && !this.useProperty) {
|
|
@@ -345,11 +370,62 @@ export default {
|
|
|
nitem.propertyDistributeInfo = null;
|
|
|
return nitem;
|
|
|
});
|
|
|
+ this.selectCountChange();
|
|
|
+ return;
|
|
|
}
|
|
|
if (!this.useClassify && this.useProperty) {
|
|
|
this.tableData = this.dataList[0].propertyDistributeInfo;
|
|
|
+ this.selectCountChange();
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
+ this.selectCountChange();
|
|
|
+ },
|
|
|
+ getTotalQuestionCount() {
|
|
|
+ let questionCount = 0;
|
|
|
+
|
|
|
+ if (this.USE_ONLY_DIFFICULT) {
|
|
|
+ questionCount = calcSum(
|
|
|
+ this.tableData.map((item) => item.selectCount || 0)
|
|
|
+ );
|
|
|
+ return questionCount;
|
|
|
+ }
|
|
|
+
|
|
|
+ let _this = this;
|
|
|
+ function getCount(data) {
|
|
|
+ let count = 0;
|
|
|
+ if (_this.useDifficult) {
|
|
|
+ if (data.difficultDistributeInfo) {
|
|
|
+ count = calcSum(
|
|
|
+ data.difficultDistributeInfo.map((item) => item.selectCount || 0)
|
|
|
+ );
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ count = data.selectCount || 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ return count;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.tableData.forEach((item) => {
|
|
|
+ questionCount += getCount(item);
|
|
|
+
|
|
|
+ if (this.useProperty && item.propertyDistributeInfo) {
|
|
|
+ item.propertyDistributeInfo.forEach((pItem) => {
|
|
|
+ questionCount += getCount(pItem);
|
|
|
+ if (pItem.propertyDistributeInfo) {
|
|
|
+ pItem.propertyDistributeInfo.forEach((spItem) => {
|
|
|
+ questionCount += getCount(spItem);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ return questionCount;
|
|
|
+ },
|
|
|
+ selectCountChange() {
|
|
|
+ this.$emit("count-change", this.getTotalQuestionCount());
|
|
|
},
|
|
|
getDataList() {
|
|
|
let dataList = deepCopy(this.dataList);
|
|
@@ -384,7 +460,14 @@ export default {
|
|
|
return item;
|
|
|
});
|
|
|
|
|
|
- return dataList;
|
|
|
+ return {
|
|
|
+ questionDistributeInfo: dataList,
|
|
|
+ questionCount: this.getTotalQuestionCount(),
|
|
|
+ useClassify: this.useClassify,
|
|
|
+ useDifficult: this.useDifficult,
|
|
|
+ useProperty: this.useProperty,
|
|
|
+ curCoursePropertyId: this.curCoursePropertyId,
|
|
|
+ };
|
|
|
},
|
|
|
},
|
|
|
};
|