From 100e8ce1659d503d802008951062488218255d6a Mon Sep 17 00:00:00 2001 From: yujialong <479214531@qq.com> Date: Fri, 2 Sep 2022 16:08:53 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E7=AD=89=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/index.js | 2 + src/assets/img/project.png | Bin 0 -> 343 bytes src/pages/course/add/index.vue | 166 ++++++++++++++-------------- src/pages/match/add/index.vue | 16 ++- src/pages/project/list/index.vue | 43 ++++--- src/pages/station/preview/index.vue | 158 +++++++++++++++++++++----- 6 files changed, 261 insertions(+), 124 deletions(-) create mode 100644 src/assets/img/project.png diff --git a/src/api/index.js b/src/api/index.js index c039c62..835cd00 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -18,6 +18,8 @@ export default { curriculumDetail: `nakadai/nakadai/curriculum/curriculumDetail`, // 课程详情 curriculumChapter: `nakadai/nakadai/curriculum/chapter/queryChaptersAndSubsections`, // 根据课程id查询章节小节,树状结构 curriculumGetSubsection: `nakadai/nakadai/curriculum/subsection/getSubsection`, // 根据小节id获取预览文件地址 + getProjectBySystemId: 'occupationlab/occupationlab/projectManage/getProjectBySystemId', + getTheMostRecentlyRunProject: 'python/python/getTheMostRecentlyRunProject', // 权限管理 getUserRolesPermissionMenu: `users/users/user-role/getUserRolesPermissionMenu`, diff --git a/src/assets/img/project.png b/src/assets/img/project.png new file mode 100644 index 0000000000000000000000000000000000000000..d3df1d1fb9826d97fd91404a592e62832acb52f5 GIT binary patch literal 343 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA3?vioaBc-sQ2{<7u0Wch?mrOm%jtng89jbk zeF&SO;XgzDe?duOhFXvU?5G~7MTb{fUqDuePg;*#L0d>j1!Rt_o*|or7SM2+k|4ie z2KTP=59e0Ro+hwHZvBj3&u%`x)Yn$!E1YB@!ME-6fg+%~37#&FAs)xyUfC^lNI{@A z(I8O#io?6OzW4uUom-Nuyk@Gk)z4MBKV}CfnB6aAb2wef_~5@)f%6)1-iEf=QW=^0 z`wQ13yYhR^XVX>5m2y}n_#?KjUOr-SvT5_n181Kus47x_n_yM6`P-W7w&mvg&0ep4 zBsXhwpILegJL9AYY%H8h8@n~SSD&BC^ohxG^Upin;a#5F^tgrkKq2Jm>gTe~DWM4f D=(&I> literal 0 HcmV?d00001 diff --git a/src/pages/course/add/index.vue b/src/pages/course/add/index.vue index 0a24bd7..c2b0818 100644 --- a/src/pages/course/add/index.vue +++ b/src/pages/course/add/index.vue @@ -2,7 +2,7 @@
- +
@@ -10,12 +10,12 @@
- +
- +
@@ -34,7 +34,7 @@ :headers="headers" name="file" > - +

上传封面

@@ -47,10 +47,10 @@ - + - {{ id ? "更新" : "创建" }} + {{ form.id ? "更新" : "创建" }} @@ -67,94 +67,59 @@ export default { data() { return { headers: { - token: util.local.get(Setting.tokenKey) + token: util.local.get(Setting.tokenKey) }, - id: this.$route.query.id, isDetail: Boolean(this.$route.query.show), - username: this.$store.state.name, - classificationId: "", - coverUrl: "", - name: "", + form: { + id: this.$route.query.id, + classificationId: '', + coverUrl: '', + name: '', + description: '', + distinguish: 1 + }, classificationList: [], uploadList: [], - description: "", - submiting: false + submiting: false, + updateTime: 0 }; }, + watch: { + // 监听信息是否有更改,有的话页面离开的时候要询问是否要保存 + form: { + handler(val){ + this.updateTime++ + }, + deep:true + } + }, mounted() { this.getClassification(); - this.id && this.getData(); + this.form.id && this.getData(); }, components: { quill }, methods: { - save() { - if (this.submiting) return false; - if (!this.name) return util.warningMsg("请填写课程名称"); - if (!this.classificationId) return util.warningMsg("请选择课程分类"); - if (!this.coverUrl) return util.warningMsg("请上传课程封面"); - this.submiting = true; - - let data = { - id: this.id, - classificationId: this.classificationId, - coverUrl: this.coverUrl, - description: this.description, - name: this.name, - founderId: this.userId, - founderName: this.username, - distinguish: 1 - }; - if (this.id) { - this.$put(this.api.editCourse, data).then(res => { - this.submiting = false; - util.successMsg("修改成功"); - this.$router.back(); - }).catch(err => { - this.submiting = false; - }); - } else { - this.$post(this.api.addCourse, data).then(res => { - this.submiting = false; - this.$confirm("课程创建成功,是否马上进行课程内容设置?", "提示", { - type: "success", - confirmButtonText: "马上设置", - cancelButtonText: "稍后操作" - }).then(() => { - this.$router.push(`/course/contentSettings?id=${res.courseId}`); - }).catch(() => { - this.$router.back(); - }); - }).catch(err => { - this.submiting = false; - }); - } - }, getClassification() { this.$get(this.api.queryGlClassification).then(res => { this.classificationList = res.classificationList; }).catch(res => {}); }, getData() { - this.$get(`${this.api.getCourse}/${this.id}`).then(res => { - let data = res.course; - this.name = data.name; - this.classificationId = data.classificationId; - this.description = data.description; - this.coverUrl = data.coverUrl; - this.uploadList.push({ - name: "cover.jpg", - url: this.coverUrl - }); - }).catch(err => {}); + this.$get(`${this.api.getCourse}/${this.form.id}`).then(({ course }) => { + this.form = course + this.uploadList.push({ + name: "cover.jpg", + url: course.coverUrl + }) + }).catch(err => {}) }, handleExceed(files, fileList) { // 上传文件 util.warningMsg("当前限制选择 1 个文件,如需更换,请删除上一个文件再重新选择!"); }, uploadSuccess(res, file, fileList) { - this.coverUrl = res.data.filesResult.fileUrl; - // this.uploadList.push({ name: file.name, url: response.message.fileUrl }); + this.form.coverUrl = res.data.filesResult.fileUrl }, uploadError(err, file, fileList) { this.$message({ @@ -167,21 +132,62 @@ export default { return this.$confirm(`确定移除 ${file.name}?`); }, handleRemove(file, fileList) { - let fileName = this.coverUrl.replace("https://liuwanr.oss-cn-shenzhen.aliyuncs.com/", ""); + let fileName = this.form.coverUrl.replace('https://huoran.oss-cn-shenzhen.aliyuncs.com/', ""); this.$del(`${this.api.fileDeletion}?keys=${fileName}`).then(res => { - this.coverUrl = ""; + this.form.coverUrl = '' }).catch(res => {}); }, - goback() { // 返回 - if (this.isDetail) { - this.$router.back(); - } else { - this.$confirm("确定返回?未更新的信息将不会保存。", "提示", { - type: "warning" - }).then(() => { + save() { + if (this.submiting) return false + const { form } = this + if (!form.name) return util.warningMsg("请填写课程名称") + if (!form.classificationId) return util.warningMsg("请选择课程分类") + if (!form.coverUrl) return util.warningMsg("请上传课程封面") + this.submiting = true + if (form.id) { + this.$put(this.api.editCourse, form).then(res => { + this.submiting = false; + util.successMsg("修改成功"); this.$router.back(); - }).catch(() => {}); + }).catch(err => { + this.submiting = false; + }); + } else { + this.$post(this.api.addCourse, form).then(res => { + this.submiting = false; + this.$confirm("课程创建成功,是否马上进行课程内容设置?", "提示", { + type: "success", + confirmButtonText: "马上设置", + cancelButtonText: "稍后操作" + }).then(() => { + this.$router.push(`/course/contentSettings?id=${res.courseId}`); + }).catch(() => { + this.$router.back(); + }); + }).catch(err => { + this.submiting = false; + }); } + }, + // 返回上一页 + backPage() { + this.$router.back() + }, + back() { + const { id } = this.form + const updateTime = this.updateTime + // 更改了信息才需要提示 + if ((id && updateTime > 2) || (!id && updateTime)) { + this.$confirm(`编辑的内容未保存,是否保存?`, '提示', { + type: 'warning' + }).then(() => { + this.save() + }).catch(() => { + this.backPage() + }) + } else { + this.backPage() + } } } }; diff --git a/src/pages/match/add/index.vue b/src/pages/match/add/index.vue index 8b5d0c7..f575247 100644 --- a/src/pages/match/add/index.vue +++ b/src/pages/match/add/index.vue @@ -156,6 +156,7 @@ :before-filter="beforeFilter" :options="rangeList" @change="rangeChange" + @visible-change="rangeViChange" @input.native="rangeSearch"> n.provinceId == e.provinceId) + e.disabled = !!checked.find(n => n.provinceId == e.provinceId && !n.cityId) data.push(e) }) resolve(data) @@ -264,7 +265,7 @@ export default { e.value = e.cityId e.label = e.cityName e.children = [] - e.disabled = !!checked.find(n => n.cityId == e.cityId) + e.disabled = !!checked.find(n => n.cityId == e.cityId && n.provinceId == e.provinceId && !n.schoolId) data.push(e) }) resolve(data) @@ -281,7 +282,7 @@ export default { e.value = e.schoolId e.label = e.schoolName e.leaf = true - e.disabled = !!checked.find(n => n.schoolId == e.schoolId) + e.disabled = !!checked.find(n => n.schoolId == e.schoolId && n.cityId == e.cityId && n.provinceId == e.provinceId) data.push(e) }) resolve(data) @@ -389,10 +390,17 @@ export default { const name = [] const { rangeChecked } = this checked.map(e => { - rangeChecked.find(n => n.value === e.value) || name.push(e.data) // 未勾选的,则push + rangeChecked.find(n => n.value === e.value && n.label == e.label) || name.push(e.data) // 未勾选的,则push }) this.rangeChecked.push(...name) }, + // 范围展开收缩回调 + rangeViChange(e) { + // 展开的时候清空搜索结果 + if (e) { + this.rangeList = [] + } + }, // 获取学校列表 getSchool() { this.$get(this.api.querySchoolData).then(({ list }) => { diff --git a/src/pages/project/list/index.vue b/src/pages/project/list/index.vue index e95d52a..d0de544 100644 --- a/src/pages/project/list/index.vue +++ b/src/pages/project/list/index.vue @@ -42,16 +42,22 @@
  • - + +
  • -
  • +
  • @@ -141,7 +147,8 @@ export default { data() { return { showBack: Boolean(this.$route.query.show), - roleIdEd: this.roleId ? 13 : this.roleId,// 管理员的roleId是13,老师的roleId是14,1个用户也可能是两个角色,就是13,14,当一个用户是两个角色的话,就取权重大的一个,就是管理员,即13;管理员>老师 + cid: [], + curs: [], systemId: "", systemList: [], systemListAll: [], @@ -278,9 +285,8 @@ export default { getSystemData() { this.$get(this.api.getSystemIdBySchool).then(({ data }) => { this.systemListAll = data - // 如果systemId有历史记录,就取历史记录里的systemId,否则就取默认的systemId this.getschoolCourse() - }); + }).catch(err => {}) }, // 获取课程 getschoolCourse() { @@ -288,16 +294,27 @@ export default { this.curriculumList = data const { cid } = this.queryData if (data.length) { - this.queryData.cid = cid || data[0].cid - this.courseChange() + this.cid = [cid || data[0].cid] + const all = this.systemListAll + data.map(e => { + e.id = e.cid + e.label = e.curriculumName + e.children = all.filter(n => e.systemId.split(',').includes(n.id + '')) // 筛选出该课程下的系统 + }) + this.curs = data + this.curChange(this.cid) } }).catch(err => {}) }, // 课程选择回调 - courseChange(val) { - const systemIds = this.curriculumList.find(e => e.cid == this.queryData.cid).systemId.split(',') // 获取选取的课程的systemId - this.systemList = this.systemListAll.filter(e => systemIds.includes(e.id + '')) // 筛选出该课程下的系统 - this.systemId = this.systemList.length ? this.systemList[0].id : '' + curChange(val) { + const cid = val[0] + if (val.length === 1) { + // 如果选择的是课程,则默认选中下面第一个系统 + this.cid = [cid, this.curs.find(e => e.id === cid).children[0].id] + } + this.queryData.cid = cid + this.systemId = this.cid[1] this.initData() }, // 创建人选择回调 diff --git a/src/pages/station/preview/index.vue b/src/pages/station/preview/index.vue index c0df017..a29749e 100644 --- a/src/pages/station/preview/index.vue +++ b/src/pages/station/preview/index.vue @@ -49,7 +49,7 @@
    - 进 入 实 验 + 进 入 实 验

    {{ courseName }}

    @@ -78,12 +78,19 @@

    课程目标

    {{ teachingObjectives }}

    - + +
      +
    • + + {{ item.projectName }} +
    • +
    + + + 取 消 + 确 定 + +
    @@ -130,7 +137,11 @@ export default { currentPage: 0, // pdf文件页码 pageCount: 0, // pdf文件总页数 fileType: "pdf", // 文件类型 - desShrink: false + desShrink: false, + projectVisible: false, + projects: [], + loading: false, + curProject: '' }; }, computed: { @@ -289,32 +300,84 @@ export default { loadPdfHandler(e) { this.currentPage = 1; }, - goSystem() { // 进入实验系统 - const id = this.systemIds - let href = '' + // 选择项目 + selectProject(item) { + this.curProject = item.projectId + }, + // 展示选择项目弹框 + queryProject() { + this.projectVisible = true + this.loading = true + this.$get(this.api.getProjectBySystemId, { + systemId: this.systemIds, + cId: this.courseId, // 课程id + permissions: 0 // 0: 练习,1: 考核 + }).then(({ projects }) => { + this.loading = false + this.projects = projects + }).catch(res => {}) + }, + // 进入实验 + entry() { + // 查询上次做的项目 + this.$get(this.api.getTheMostRecentlyRunProject, { + cid: this.courseId + }).then(({ data }) => { + // 返回了data则提示是否继续,否则,显示选择项目的弹框 + if (data && data.length) { + this.$confirm('是否要继续上次的实验?', '提示', { + confirmButtonText: '是', + cancelButtonText: '否', + type: 'success' + }).then(() => { + this.toPython(data[0].projectId) + }).catch(() => { + this.queryProject() + }) + } else { + this.queryProject() + } + }).catch(res => { + this.queryProject() + }) + }, + // 进入python系统 + toPython(projectId) { + const id = this.systemIds + let token = util.local.get(Setting.tokenKey); + util.cookies.set('assessmentId', '', -1) + util.cookies.set('startTime', '', -1) + util.cookies.set('stopTime', '', -1) + projectId ? util.cookies.set('projectId', projectId) : util.cookies.set('projectId', '', -1) + util.cookies.set('token', token) + util.cookies.set('courseId', this.courseId) + util.cookies.set('curriculumName', escape(this.curriculumName)) + util.cookies.set('systemId', id) + util.cookies.set('fromManager', 1) + // 8个python子系统都跳这个地址,子系统会通过cookie里的systemId识别展示哪套系统 + location.href = process.env.NODE_ENV === 'development' ? + `http://${location.hostname}:8085/#/` : + Setting.isPro ? + `https://${location.hostname}/pyTrials` : + `${location.origin}/pyTrials` + }, + // 进入子系统 + toSub() { + const { systemId } = this.projects.find(e => e.projectId == this.curProject) let token = util.local.get(Setting.tokenKey); let roleId = this.roleId == 4 ? 0 : 1; let userName = window.btoa(encodeURIComponent(this.userName)); - if (id == 11) { + + if (systemId == 11) { // 银行系统 - location.href = `${Setting.bankPath}/#/index/list?token=${token}&cid=${this.courseId}&systemId=${this.assessmentList[0].systemId}&projectId=&assessmentId=&classId=&stopTime=&test=true` - } else if (id == 21) { + location.href = `${Setting.bankPath}/#/index/list?curriculumName=${this.curriculumName}&token=${token}&cid=${this.courseId}&systemId=${this.systemIds}&projectId=${this.curProject}&assessmentId=&classId=&stopTime=&test=true` + } else if (systemId == 21) { window.open(`http://121.37.29.24:80/yyyflogin?userId=${this.userId}&userName=${userName}&userType=${roleId}&reqType=1&reqId=3989a0ad671849b99dcbdcc208782333&caseId=9681f86902314b10bc752909121f9ab9&authorization=87DIVy348Oxzj3ha&classId=1876&courserId=7ff5d4715b114b7398b6f26c20fac460`); - } else if (id == 22) { + } else if (systemId == 22) { window.open(`https://danbao.czcyedu.com/#/loginFromYyyf?userId=${this.userId}&userName=${userName}&userType=${roleId}&reqType=1&reqId=eb7d8355119d449184c548b07dc01ed9&caseId=1198241070647873538&authorization=87DIVy348Oxzj3ha&classId=1876&courserId=faaedd82adb9444285a5785e4a3dd4f9`); } else { - // python系统 - util.cookies.set("assessmentId", "", -1); - util.cookies.set("projectId", "", -1); - util.cookies.set("startTime", "", -1); - util.cookies.set("stopTime", "", -1); - util.cookies.set("token", token); - util.cookies.set("courseId", this.courseId); - util.cookies.set("curriculumName", escape(this.curriculumName)); - util.cookies.set("systemId", id); - location.href = process.env.NODE_ENV === 'development' ? - `http://${location.hostname}:8085/#/` : - `${location.origin}/pyTrials` // 8个python子系统都跳这个地址,子系统会通过cookie里的systemId识别展示哪套系统 + // python系统 + this.toPython(this.curProject) } } } @@ -536,4 +599,45 @@ $height: 700px; } } +/deep/.project-dia { + .el-dialog__body { + padding: 28px 32px; + } +} +.projects { + display: flex; + flex-wrap: wrap; + max-height: 400px; + overflow: auto; + li { + display: inline-flex; + align-items: center; + width: 238px; + padding: 16px; + margin: 0 20px 20px 0; + background-color: #F6F8FA; + border-radius: 16px; + cursor: pointer; + &:hover { + span { + color: #007EFF; + } + } + &:nth-child(3n) { + margin-right: 0; + } + &.active { + background-color: #f2f7ff; + span { + color: #3988ff; + } + } + } + span { + max-width: 140px; + margin-left: 14px; + font-size: 14px; + color: #333; + } +} \ No newline at end of file