From ca87016f7df5fe09b9ce2c0d36a659261dc8b419 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Wed, 12 Apr 2023 08:36:12 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20app=E6=9B=B4=E6=96=B0=E7=A7=BB=E5=88=B0?= =?UTF-8?q?login=5F.vue,=E5=BC=95=E5=85=A5=E4=B8=8B=E8=BD=BD=E8=BF=9B?= =?UTF-8?q?=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 162 ++++++++++++++++++++--------------------- pages/login/login_.vue | 56 -------------- 2 files changed, 81 insertions(+), 137 deletions(-) diff --git a/App.vue b/App.vue index 38300d6..f743144 100644 --- a/App.vue +++ b/App.vue @@ -1,67 +1,67 @@ + diff --git a/pages/login/login_.vue b/pages/login/login_.vue index 79ed929..f848ebc 100644 --- a/pages/login/login_.vue +++ b/pages/login/login_.vue @@ -434,64 +434,10 @@ // }) }).catch(e => {}) // #endif - that.getUserRange(); }).catch(e => { console.log(e) }) }, - getUserRange() { - let that = this; - that.$u.api.deptList({ - page: 0, - type__in: 'rparty,dept', - query: '{id, name, parent, type}' - }).then(res => { - let list1 = res; - let list2 = []; - let reqList = []; - list1.forEach(function(item) { - reqList.push(that.$u.api.userList({ - page: 0, - belong_dept: item.id, - is_active: true, - query: '{id, name, belong_dept}' - })) - }) - Promise.all(reqList).then(res => { - for (let i = 0; i < res.length; i++) { - list1[i].children = res[i] - } - list1.forEach(item => { - if (item.type == 'dept') { - list2.push({ - ...item - }) - } - }) - that.$u.vuex('vuex_userRange', that.parseData(list1)) - that.$u.vuex('vuex_userRange2', that.parseData(list2)) - }) - }) - }, - parseData(data) { - // * 先生成parent建立父子关系 - const obj = {}; - data.forEach((item) => { - obj[item.id] = item; - }); - const parentList = []; - data.forEach((item) => { - const parent = obj[item.parent]; - if (parent) { - // * 当前项有父节点 - parent.children = parent.children || []; - parent.children.unshift(item); - } else { - parentList.push(item); - } - }); - return parentList; - }, formSubmit2(e) { var that = this; const obj = e.target.value; @@ -499,7 +445,6 @@ that.$u.api.codeLogin(obj).then(res => { that.$u.vuex('vuex_token', res.access) that.$u.vuex('vuex_refresh', res.refresh) - that.getUserRange(); that.$u.api.getUserInfo().then(res => { if (res.avatar) { res.avatar = this.vuex_host + res.avatar @@ -619,7 +564,6 @@ } } }) - that.getUserRange() }) } }