From b8a41a5e239f1d8711f6000f9bc7b9e105b57f8e Mon Sep 17 00:00:00 2001 From: yujialong <479214531@qq.com> Date: Fri, 9 Aug 2024 14:32:25 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E5=BD=95=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Header.vue | 9 +- src/utils/api.js | 2 + src/views/Login.vue | 127 +++++++++++++++++++++----- src/views/match/add/set.vue | 149 +++++++------------------------ src/views/match/manage/index.vue | 6 +- src/views/theoryExam/index.vue | 3 +- 6 files changed, 151 insertions(+), 145 deletions(-) diff --git a/src/components/Header.vue b/src/components/Header.vue index 74b70f2..7cc176b 100644 --- a/src/components/Header.vue +++ b/src/components/Header.vue @@ -10,7 +10,7 @@ {{ userName }} - 退出 + 退出 @@ -34,9 +34,10 @@ export default { this.$router.push('/person') } }, - loginout () { - localStorage.removeItem('ms_username'); - localStorage.removeItem('token'); + async logout () { + await this.$post(this.api.logout) + localStorage.removeItem('ms_username') + localStorage.removeItem('token') sessionStorage.clear() location.reload() }, diff --git a/src/utils/api.js b/src/utils/api.js index 5d5529c..366fd13 100644 --- a/src/utils/api.js +++ b/src/utils/api.js @@ -13,6 +13,8 @@ export default { refreshPageNotification: `nakadai/message/refreshPageNotification`, heartbeatDetection: `nakadai/message/heartbeatDetection`, getCurrentTime: `competition/competition/management/getCurrentTime`, + getToken: `users/users/user/getToken`, + logout: `users/users/user/logout`, // 阿里云文件/视频管理 getPlayAuth: `${uploadURL}oss/manage/getPlayAuth`, // 获取播放凭证 diff --git a/src/views/Login.vue b/src/views/Login.vue index eecc038..e892dd3 100644 --- a/src/views/Login.vue +++ b/src/views/Login.vue @@ -39,7 +39,7 @@ - + @@ -80,6 +80,21 @@ 确 定 + + + +

该手机号已绑定以下用户信息

+
    +
  • + {{ user.schoolName }},{{ user.userName }},{{ user.workNumber }}{{ + user.isEnable + ? '' + : '(已禁用)' }} + +
  • +
+
@@ -115,7 +130,6 @@ export default { platform: 3, random: '', distinguish: 1, - type: 2 }, rules: { account: [{ required: true, message: '请输入账号', trigger: 'blur' }], @@ -127,16 +141,15 @@ export default { showPhoneVerify: true,// 邮箱-验证码展示 PhoneVerificationIMG: '',// 电话或邮箱验证码拼接链接 phoneOrEmail: { - account: '', + workNumber: '', password: '', code: '', platform: 3, random: '', - distinguish: 2, - type: 2 + distinguish: 1, }, phoneOrEmailrules: { - account: [{ validator: regPhoneOrEmail, trigger: 'blur' }], + workNumber: [{ validator: regPhoneOrEmail, trigger: 'blur' }], password: [{ required: true, message: '请输入密码', trigger: 'blur' }], code: [{ required: true, message: '请输入验证码', trigger: 'blur' }], }, @@ -147,8 +160,11 @@ export default { phoneDisabled: false, phoneBtnText: '发送验证码', phoneTimer: '', - phoneOpener: '' + phoneOpener: '', + + userVisible: false, + users: [], }; }, components: { @@ -182,23 +198,21 @@ export default { let param = val === 'phone' ? this.phoneOrEmail : this.param this.$refs[ref].validate(valid => { if (valid) { - this.$post(this.api.logins, param).then(res => { - const { message } = res - sessionStorage.setItem('token', res.data.token) - this.$get(`${this.api.getUserRolesPermissionMenu}?platformId=${Setting.platformId}`).then(res => { - const list = res.permissionMenu - addRoutes(res.permissionMenu[0].children) - this.$store.commit('setDataPer', res.dataPermissionList) - this.$message.success(message); - this.$router.push({ - path: list[0].children[0].path - }); - localStorage.setItem('ms_username', this.param.username); - }).catch(err => { - if (err.status === 500) { - sessionStorage.clear() + this.$post(this.api.logins, param).then(({ status, data, message }) => { + if (status == 200) { + const accounts = data.userAccounts + // 如果返回的是数组,则弹框给用户选择登录哪个用户,否则,直接登录 + if (accounts instanceof Array) { + this.users = accounts + this.userVisible = true + } else { + sessionStorage.setItem('token', data.token) + this.setLogin() } - }) + } else { + param.code = '' + this.$message.error(message) + } }).catch(err => { if (err.status === 30001) { this.phoneVisible = true @@ -212,7 +226,32 @@ export default { return false; } }); - + }, + // 选择用户回调 + chooseUser (user) { + user.isEnable && this.$post(`${this.api.getToken}?id=${user.id}`).then(({ data }) => { + sessionStorage.setItem('token', data.token) + this.token = data.token + this.setLogin() + }).catch(res => { }) + }, + // 处理登录成功 + async setLogin () { + try { + const res = await this.$get(`${this.api.getUserRolesPermissionMenu}?platformId=${Setting.platformId}`) + const list = res.permissionMenu + addRoutes(res.permissionMenu[0].children) + this.$store.commit('setDataPer', res.dataPermissionList) + this.$message.success('登录成功!') + this.$router.push({ + path: list[0].children[0].path + }); + localStorage.setItem('ms_username', this.param.username); + } catch (e) { + if (e.status === 500) { + sessionStorage.clear() + } + } }, blur () { this.param.random = Math.floor(Math.random() * 999999999) @@ -437,6 +476,46 @@ img { color: #666; } +/deep/.user-dia { + .tips { + margin-bottom: 20px; + text-align: center; + color: #666; + } + + .users { + li { + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 15px; + margin-bottom: 10px; + line-height: 40px; + font-size: 14px; + background-color: #ebeef5; + cursor: pointer; + + &.isEnable { + color: #c0c4cc; + background-color: #f5f7fa; + cursor: not-allowed; + } + + &:last-child { + margin-bottom: 0; + } + + &:hover { + background-color: #d3e0ff; + } + + i { + font-size: 16px; + } + } + } +} + @media (max-width: 1600px) { /deep/.ms-login { width: 1000px; diff --git a/src/views/match/add/set.vue b/src/views/match/add/set.vue index e9074ba..03e3416 100644 --- a/src/views/match/add/set.vue +++ b/src/views/match/add/set.vue @@ -1,103 +1,69 @@ @@ -129,14 +91,13 @@ export default { data () { return { loadIns: null, - mallIds: [], - curs: [], + systems: [], keyword: '', projects: [], page: 1, pageSize: 5, total: 0, - sysId: '', + systemId: '', permissionsKeys: ['练习', '考核', '竞赛'], timeInvalid: false }; @@ -163,68 +124,27 @@ export default { // 获取课程 async getCourse () { const sid = this.$store.state.dataPer.find(e => e.permissionName === '服务配置') - const { serviceList } = await this.$post(this.api.queryServiceConfig, { + const res = await this.$post(this.api.queryServiceConfig, { pageNum: 1, pageSize: 1000, supplierId: sid ? sid.supplierId : '' }) - const { page } = await this.$post(this.api.listOfGoods, { - pageNum: 1, - pageSize: 10000, - hotTag: 1, - sort: 0, - isAssociatedProduct: 1, - isShelves: 0, - }) - const { records } = page - const { mallId, cid, systemId } = this.form + const { records } = res.serviceList if (records.length) { - serviceList.records.map(e => { - e.id = +e.systemId - e.label = e.systemName - }) - records.map(e => { - e.id = +e.mallId - e.label = e.productName - e.children = serviceList.records.filter(n => e.systemId.split(',').includes(n.systemId)) // 筛选出该课程下的系统 - }) - this.curs = records - - // 查询项目 - const first = records[0] - this.mallIds = [mallId || first.mallId, systemId || first.children[0].id] - this.form.mallId = mallId || first.mallId - this.form.cid = cid || +first.associatedProduct - this.form.systemId = systemId || first.systemId - this.sysId = systemId || first.systemId + this.systems = records + this.systemId = records[0].systemId this.loadIns = Loading.service() this.getProject() } }, - // 课程选择回调 - curChange (val) { - const id = val[0] - const item = this.curs.find(e => e.id == id) - if (val.length === 1) { - // 如果选择的是课程,则默认选中下面第一个系统 - this.mallIds = [id, item.children[0].id] - } - this.form.mallId = id - this.form.cid = +item.associatedProduct - this.form.systemId = this.mallIds[1] - this.sysId = this.mallIds[1] - this.loadIns = Loading.service() - this.getProject() - }, // 查询项目 getProject () { this.$post(this.api.getProjectAssessmentByCompetition, { pageNum: this.page, pageSize: this.pageSize, - cid: this.form.cid, projectName: this.keyword, - systemId: this.sysId, + systemId: this.systemId, permissions: 2 }).then(({ data }) => { this.projects = data.records @@ -302,5 +222,4 @@ export default { }; - \ No newline at end of file + \ No newline at end of file diff --git a/src/views/match/manage/index.vue b/src/views/match/manage/index.vue index b19fc1d..8050d95 100644 --- a/src/views/match/manage/index.vue +++ b/src/views/match/manage/index.vue @@ -55,7 +55,11 @@ export default { AbnormalTeam }, mounted () { - Setting.dynamicRoute && this.initTabs() + if (Setting.dynamicRoute) { + this.initTabs() + } else { + this.active = 'tab1' + } }, methods: { async initTabs () { diff --git a/src/views/theoryExam/index.vue b/src/views/theoryExam/index.vue index bd370c0..3e1cdfa 100644 --- a/src/views/theoryExam/index.vue +++ b/src/views/theoryExam/index.vue @@ -6,10 +6,11 @@