diff --git a/src/views/dashboard/Analysis/index.vue b/src/views/dashboard/Analysis/index.vue
index 34a5558..25a2041 100644
--- a/src/views/dashboard/Analysis/index.vue
+++ b/src/views/dashboard/Analysis/index.vue
@@ -2,7 +2,8 @@
-
+
+
查询
@@ -57,13 +58,16 @@ export default {
Url: {
getEntrydate: '/cet/getEntrydate',
getCollege: '/cet/getCollege',
- getData: '/cet/getData'
+ getData: '/cet/getData',
+ getCollegeMajor: '/cet/getCollegeMajor'
},
total: 0,
collegeOptions: [],
+ collegeMajorOptions: [],
entrydateOptions: [],
college: null,
- entrydate: null
+ entrydate: null,
+ collegeMajor: null
};
},
methods: {
@@ -78,14 +82,40 @@ export default {
this.entrydateOptions = getEntrydate.entrydates;
this.entrydate = this.entrydateOptions[0].value;
},
+ //获取学院专业级联数据
+ async getCollegeMajorData() {
+ const res = await defHttp.get({ url: this.Url.getCollegeMajor });
+ //通过map方法将数据转换为级联选择器需要的数据格式
+ this.collegeMajorOptions = res.collegeMajor.map(item => {
+ return {
+ value: item.college,
+ label: item.college,
+ children: item.major.map(major => {
+ return {
+ value: major,
+ label: major
+ }
+ })
+ }
+ });
+ // 手动添加一个全校字段
+ this.collegeMajorOptions.unshift({ value: '全校', label: '全校' });
+ this.collegeMajor = ['全校'];
+ console.log(this.collegeMajorOptions);
+ },
// 查询数据
async query() {
try {
- this.loading = true;
+ //如果this.collegeMajor[1]不存在则设为null
+ let major = this.collegeMajor.length > 1 ? this.collegeMajor[1] : "";
+ if (this.college)
+ this.loading = true;
let params = {
- college: this.college,
+ college: this.collegeMajor[0],
+ major: major,
entrydate: this.entrydate
}
+ console.log("params", params);
const result = await defHttp.get({ url: this.Url.getData, params });
this.dataSourceCet4 = result.cet4;
this.total = result.total;
@@ -93,10 +123,11 @@ export default {
} finally {
this.loading = false;
}
- }
+ },
},
mounted() {
this.getEntrydateAndCollegeData();
+ this.getCollegeMajorData();
}
}