diff --git a/course/courseDetail/courseDetail.vue b/course/courseDetail/courseDetail.vue index 5ca7062..7e010d7 100644 --- a/course/courseDetail/courseDetail.vue +++ b/course/courseDetail/courseDetail.vue @@ -1,19 +1,22 @@ @@ -202,7 +213,6 @@ } ], subjectList: [], //专业学科 - schoolList: [], showArch: false, archivesList: [], archivesForm: { @@ -218,6 +228,21 @@ professionalId: '', professionalName: '', }, + + schoolVisible: false, + keyword: '', + searchTimer: null, + schoolList: [], + schoolListAll: [], + curArch: {}, + } + }, + watch: { + keyword () { + clearTimeout(this.searchTimer) + this.searchTimer = setTimeout(() => { + this.filterSchool() + }, 500) } }, onShow() { @@ -303,12 +328,35 @@ // 获取学校 async getSchool(){ const { list } = await querySchool() - list.forEach(e => { - e.value = e.schoolId - e.text = e.schoolName - }) this.schoolList = list + this.schoolListAll = list + }, + // 显示学校弹框 + showSchool(item) { + this.curArch = item + this.schoolVisible = true }, + // 学校模糊匹配 + filterSchool() { + const { keyword } = this + this.schoolList = keyword ? + this.schoolListAll.filter(e => e.schoolName.includes(keyword)) : + this.schoolListAll + }, + // 关闭学校弹框 + closeSchool() { + this.schoolVisible = false + this.keyword = '' + this.schoolList = this.schoolListAll + }, + // 客户名称选择回调 + schoolChange(school) { + const { schoolId } = school + this.curArch.schoolId = schoolId + this.curArch.schoolName = school.schoolName + this.closeSchool() + }, + // 上传头像回调 onChooseAvatar(e) { OSS(e.detail.avatarUrl, ({ url }) => {