|
@@ -141,13 +141,16 @@ export default {
|
|
|
};
|
|
|
},
|
|
|
},
|
|
|
+ dataSource: {
|
|
|
+ type: Object,
|
|
|
+ default: null,
|
|
|
+ },
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
useClassify: false,
|
|
|
useDifficult: false,
|
|
|
useProperty: false,
|
|
|
- checkedSet: [],
|
|
|
selectedFolderIds: [],
|
|
|
classifyTree: [
|
|
|
{
|
|
@@ -170,6 +173,7 @@ export default {
|
|
|
difficultDistributeInfo: [],
|
|
|
curCoursePropertyId: "",
|
|
|
propertyInfo: [],
|
|
|
+ sourceDataMap: {},
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
@@ -182,6 +186,9 @@ export default {
|
|
|
USE_NONE_SET() {
|
|
|
return !this.useClassify && !this.useDifficult && !this.useProperty;
|
|
|
},
|
|
|
+ SOURCE_REVIEW() {
|
|
|
+ return !!this.dataSource;
|
|
|
+ },
|
|
|
},
|
|
|
watch: {
|
|
|
filterData: {
|
|
@@ -193,9 +200,23 @@ export default {
|
|
|
},
|
|
|
},
|
|
|
},
|
|
|
- mounted() {
|
|
|
- this.resetDataList();
|
|
|
- this.getClassifyTree();
|
|
|
+ async mounted() {
|
|
|
+ if (this.dataSource) {
|
|
|
+ this.parseSourceDataMap();
|
|
|
+ this.useProperty = this.dataSource.useProperty;
|
|
|
+ this.useClassify = this.dataSource.useClassify;
|
|
|
+ this.useDifficult = this.dataSource.useDifficult;
|
|
|
+ if (this.dataSource.useClassify)
|
|
|
+ this.selectedFolderIds = this.dataSource.classifyIdList;
|
|
|
+ }
|
|
|
+ await this.resetDataList();
|
|
|
+ await this.getClassifyTree();
|
|
|
+
|
|
|
+ if (this.selectedFolderIds.length) {
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs.folderTree.setCheckedKeys(this.selectedFolderIds);
|
|
|
+ });
|
|
|
+ }
|
|
|
},
|
|
|
methods: {
|
|
|
setChange() {
|
|
@@ -289,7 +310,7 @@ export default {
|
|
|
classifyName: data.classifyName,
|
|
|
isClassify: true,
|
|
|
questionCount: data.questionCount,
|
|
|
- selectCount: undefined,
|
|
|
+ selectCount: this.gerSourceData(data.classifyId),
|
|
|
difficultDistributeInfo: [],
|
|
|
};
|
|
|
if (
|
|
@@ -297,7 +318,8 @@ export default {
|
|
|
data.difficultDistributeInfo.length
|
|
|
) {
|
|
|
classifyData.difficultDistributeInfo = parseQuestionDistributeInfo(
|
|
|
- data.difficultDistributeInfo
|
|
|
+ data.difficultDistributeInfo,
|
|
|
+ data.classifyId
|
|
|
);
|
|
|
}
|
|
|
if (
|
|
@@ -318,28 +340,33 @@ export default {
|
|
|
parsePropertyData(item, classifyData.id)
|
|
|
);
|
|
|
|
|
|
+ classifyData.propertyDistributeInfo = filterPropertyData(
|
|
|
+ classifyData.propertyDistributeInfo
|
|
|
+ );
|
|
|
+
|
|
|
return classifyData;
|
|
|
}
|
|
|
|
|
|
- function parseQuestionDistributeInfo(data) {
|
|
|
+ function parseQuestionDistributeInfo(data, preInfo) {
|
|
|
if (!_this.difficultDistributeInfo.length) {
|
|
|
_this.difficultDistributeInfo = data.map(
|
|
|
(item) => item.difficultLevel
|
|
|
);
|
|
|
}
|
|
|
return data.map((item) => {
|
|
|
- return { ...item, selectCount: undefined };
|
|
|
+ return { ...item, selectCount: this.gerSourceData(preInfo) };
|
|
|
});
|
|
|
}
|
|
|
|
|
|
function parsePropertyData(data, parentId) {
|
|
|
+ const propId = `${parentId}_${data.propertyId}`;
|
|
|
let propData = {
|
|
|
- id: `${parentId}_${data.propertyId}`,
|
|
|
+ id: propId,
|
|
|
name: data.propertyName,
|
|
|
propertyId: data.propertyId,
|
|
|
propertyName: data.propertyName,
|
|
|
questionCount: data.questionCount,
|
|
|
- selectCount: undefined,
|
|
|
+ selectCount: this.gerSourceData(propId),
|
|
|
difficultDistributeInfo: null,
|
|
|
};
|
|
|
if (
|
|
@@ -347,7 +374,8 @@ export default {
|
|
|
data.difficultDistributeInfo.length
|
|
|
) {
|
|
|
propData.difficultDistributeInfo = parseQuestionDistributeInfo(
|
|
|
- data.difficultDistributeInfo
|
|
|
+ data.difficultDistributeInfo,
|
|
|
+ propId
|
|
|
);
|
|
|
}
|
|
|
|
|
@@ -359,6 +387,26 @@ export default {
|
|
|
return propData;
|
|
|
}
|
|
|
|
|
|
+ function filterPropertyData(propertyDistributeInfo) {
|
|
|
+ // 只处理两级属性
|
|
|
+ let pDistributeInfo = propertyDistributeInfo.map((data) => {
|
|
|
+ if (
|
|
|
+ data.propertyDistributeInfo &&
|
|
|
+ data.propertyDistributeInfo.length
|
|
|
+ ) {
|
|
|
+ data.propertyDistributeInfo = data.propertyDistributeInfo.filter(
|
|
|
+ (item) => item.questionCount
|
|
|
+ );
|
|
|
+ }
|
|
|
+ return data;
|
|
|
+ });
|
|
|
+ pDistributeInfo = pDistributeInfo.filter(
|
|
|
+ (data) =>
|
|
|
+ data.propertyDistributeInfo && data.propertyDistributeInfo.length
|
|
|
+ );
|
|
|
+ return pDistributeInfo;
|
|
|
+ }
|
|
|
+
|
|
|
this.dataList = this.originList.map((item) => buildClassifyData(item));
|
|
|
this.tableData = this.dataList;
|
|
|
|
|
@@ -470,6 +518,7 @@ export default {
|
|
|
});
|
|
|
|
|
|
return {
|
|
|
+ classifyIdList: this.useClassify ? this.selectedFolderIds : [],
|
|
|
questionDistributeInfo: dataList,
|
|
|
questionCount: this.getTotalQuestionCount(),
|
|
|
useClassify: this.useClassify,
|
|
@@ -478,6 +527,43 @@ export default {
|
|
|
curCoursePropertyId: this.curCoursePropertyId,
|
|
|
};
|
|
|
},
|
|
|
+ // source relate
|
|
|
+ gerSourceData(k) {
|
|
|
+ return this.sourceDataMap[k] || undefined;
|
|
|
+ },
|
|
|
+ parseSourceDataMap() {
|
|
|
+ let sourceDataMap = {};
|
|
|
+
|
|
|
+ function parseDifficultMap(difficultDistributeInfo, preInfo) {
|
|
|
+ if (!difficultDistributeInfo || !difficultDistributeInfo.length) return;
|
|
|
+
|
|
|
+ difficultDistributeInfo.forEach((d) => {
|
|
|
+ if (d.selectCount)
|
|
|
+ sourceDataMap[`${preInfo}_${d.difficultLevel}`] = d.selectCount;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ function parsePropertyMap(propertyDistributeInfo) {
|
|
|
+ if (!propertyDistributeInfo || !propertyDistributeInfo.length) return;
|
|
|
+
|
|
|
+ propertyDistributeInfo.forEach((pInfo) => {
|
|
|
+ if (pInfo.selectCount) sourceDataMap[pInfo.id] = pInfo.selectCount;
|
|
|
+ parseDifficultMap(pInfo.difficultDistributeInfo, pInfo.id);
|
|
|
+
|
|
|
+ parsePropertyMap(pInfo.propertyDistributeInfo);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ this.dataSource.questionDistributeInfo.forEach((classifyData) => {
|
|
|
+ if (classifyData.selectCount) {
|
|
|
+ sourceDataMap[classifyData.id] = classifyData.selectCount;
|
|
|
+ }
|
|
|
+
|
|
|
+ parseDifficultMap(classifyData.difficultDistributeInfo);
|
|
|
+ parsePropertyMap(classifyData.propertyDistributeInfo);
|
|
|
+ });
|
|
|
+ this.sourceDataMap = sourceDataMap;
|
|
|
+ },
|
|
|
},
|
|
|
};
|
|
|
</script>
|