Skip to content

Commit

Permalink
Merge pull request #31 from a54552239/dev
Browse files Browse the repository at this point in the history
v2.8.9
  • Loading branch information
a54552239 authored Feb 23, 2020
2 parents e3f07f1 + bf1e212 commit 2e22b97
Show file tree
Hide file tree
Showing 14 changed files with 109 additions and 43 deletions.
9 changes: 9 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,14 @@
<!--<script src="https://webapi.amap.com/js/marker.js"></script>
<script type="text/javascript"
src="https://webapi.amap.com/maps?v=1.4.7&key=936c5eca7d2e763f953a0483e75637c8&plugin=AMap.Transfer,AMap.Driving,AMap.Walking,AMap.LineSearch,AMap.Geocoder"></script>-->
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?eb6ecfed64ffefae6d5d74ea2945e7aa";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
</body>
</html>
12 changes: 11 additions & 1 deletion src/api/organization.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
import $http from '@/assets/js/http'
import store from '@/store';

export function list(data) {
return $http.post('project/organization',data);
return $http.post('project/organization', data);
}

export function _getOrgList(data) {
return $http.post('project/organization/_getOrgList', data).then(res => {
if (res.data) {
store.dispatch('setOrganizationList', res.data);
}
return Promise.resolve(res);
});
}

export function doData(data) {
Expand Down
39 changes: 37 additions & 2 deletions src/api/user.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import $http from '@/assets/js/http'
import router from '@/router';
import store from '@/store';
import {checkResponse, createRoute} from "../assets/js/utils";

export async function Login(data) {
return $http.post('project/login', data);
Expand All @@ -20,8 +23,40 @@ export function _resetPasswordByMail(data) {
return $http.post('project/login/_resetPasswordByMail', data);
}

export function changeCurrentOrganization(organizationCode) {
return $http.post('project/index/changeCurrentOrganization', {organizationCode: organizationCode});
export function changeCurrentOrganization(organization) {
const organizationCode = organization.code;
store.dispatch('setCurrentOrganization', organization);
return $http.post('project/index/changeCurrentOrganization', {organizationCode: organizationCode}).then(res=>{
if (checkResponse(res)) {
store.dispatch('SET_MENU', res.data.menuList);
store.dispatch('SET_USER', res.data.member);
store.dispatch('windowLoading', true);
setTimeout(function () {
const menu = res.data.menuList;
if (menu) {
let routes = router.options.routes;
menu.forEach(function (v) {
routes[0].children.push(createRoute(v));
if (v.children) {
v.children.forEach(function (v2) {
routes[0].children.push(createRoute(v2));
if (v2.children) {
v2.children.forEach(function (v3) {
routes[0].children.push(createRoute(v3));
});
}

});
}
});
router.addRoutes(routes);
store.dispatch('windowLoading', false);
// router.replace('/');
}
}, 500);
return Promise.resolve(res);
}
});
}

export function list(data) {
Expand Down
6 changes: 5 additions & 1 deletion src/assets/js/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import $router from '../../router/index';
import {notice} from './notice';
import config from "../../config/config";

const HOME_PAGE = config.HOME_PAGE;
let HOME_PAGE = config.HOME_PAGE;
const currentOrganization = getStore('currentOrganization', true);
if (currentOrganization) {
HOME_PAGE = HOME_PAGE + '/' + currentOrganization.code;
}
const crossDomain = config.crossDomain;
let axiosConfig = {};
if (crossDomain) {
Expand Down
4 changes: 3 additions & 1 deletion src/components/error/errorPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
</template>
<script>
import {Button} from 'ant-design-vue';
import {getStore} from "../../assets/js/storage";
const currentOrganization = getStore('currentOrganization', true);
export default {
components: {
Expand All @@ -33,7 +35,7 @@
default: '抱歉,服务器出错了',
},
url: {
default: '/home'
default: currentOrganization ? '/home/' + currentOrganization.code : '/home'
},
urlText: {
default: '返回首页'
Expand Down
38 changes: 8 additions & 30 deletions src/components/layout/header/HeaderSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
<a-dropdown class="action-item" placement="bottomCenter">
<div class="organization-select">
<span>{{currentOrganization.name}}</span>
<a-icon :style="{fontSize: '14px'}" type="down" />
<a-icon :style="{fontSize: '14px', marginLeft: '2px'}" type="down" />
</div>
<a-menu slot="overlay" class="middle-menu organization-menu" :selectable="false" @click="organizationAction">
<a-menu-item v-for="(organization,index) in organizationList" :key="index">
<a href="javascript:;">{{organization.name}}</a>
<div class="muted flex ant-row-flex-middle">
<span href="javascript:;" class="text-default">{{organization.name}} </span>
<a-icon v-show="currentOrganization.code == organization.code" class="muted m-l-lg" type="check" />
</div>
</a-menu-item>
</a-menu>
</a-dropdown>
Expand Down Expand Up @@ -35,36 +38,11 @@
methods: {
organizationAction(action) {
let app = this;
app.$store.dispatch('setCurrentOrganization', app.organizationList[action.key]);
changeCurrentOrganization(app.organizationList[action.key].code).then(res=>{
changeCurrentOrganization(app.organizationList[action.key]).then(res=>{
if (checkResponse(res)) {
app.$store.dispatch('SET_MENU', res.data.menuList);
app.$store.dispatch('SET_USER', res.data.member);
app.$store.dispatch('windowLoading', true);
setTimeout(function () {
const menu = res.data.menuList;
if (menu) {
let routes = app.$router.options.routes;
menu.forEach(function (v) {
routes[0].children.push(createRoute(v));
if (v.children) {
v.children.forEach(function (v2) {
routes[0].children.push(createRoute(v2));
if (v2.children) {
v2.children.forEach(function (v3) {
routes[0].children.push(createRoute(v3));
});
}
});
}
});
app.$router.addRoutes(routes);
app.$store.dispatch('windowLoading', false);
app.$router.replace('/');
}
}, 500);
app.$router.replace('/home/' + app.organizationList[action.key].code);
}
console.log(res);
})
},
}
Expand Down
1 change: 1 addition & 0 deletions src/components/project/projectSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
getProjectList(loading = true) {
this.loading = loading;
this.requestData.pageSize = 50;
this.requestData.archive = -1;
getProjectList(this.requestData).then(res => {
console.log(res);
this.projectList = res.data.list;
Expand Down
2 changes: 1 addition & 1 deletion src/config/version.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export default {
VERSION: '2.8.8',
VERSION: '2.8.9',
};
11 changes: 11 additions & 0 deletions src/mixins/common.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// common-mixin.vue
import {getStore} from "../assets/js/storage";
import config from "../config/config";

export default {
data() {
return {}
Expand All @@ -11,5 +14,13 @@ export default {
this.$router.push(page);
}
},
toHome() {
const currentOrganization = getStore('currentOrganization', true);
let home = config.HOME_PAGE;
if (currentOrganization) {
home = home + '/' + currentOrganization.code;
}
this.$router.push(home);
},
}
}
5 changes: 5 additions & 0 deletions src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ router.beforeEach((to, from, next) => {
});
return false;
}
// 统计代码
if (to.path) {
_hmt.push(['_trackPageview', '/#' + to.fullPath]);
console.log(_hmt);
}
next();
});
router.afterEach(route => {
Expand Down
3 changes: 3 additions & 0 deletions src/views/home/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@
this.init();
},
watch:{
$route: function (to, from) {
this.init();
},
socketAction(val) {
console.log(val);
if (val.action === 'organization:task') {
Expand Down
12 changes: 10 additions & 2 deletions src/views/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<a-spin :spinning="windowLoading">
<a-layout id="layout" :class="layoutClass">
<a-layout-header :class="{'collapsed':collapsed}">
<div class="logo" @click="()=>{this.$router.push(config.HOME_PAGE)}">
<div class="logo" @click="toHome">
<img class="logo-img" src="../assets/image/common/logo.png" alt="">
<span class="title" v-if="system">
{{system.app_name}}
Expand Down Expand Up @@ -127,7 +127,8 @@
import Socket from '../components/websocket/socket';
import config from "../config/config";
import {notice} from "../assets/js/notice";

import {getStore} from "../assets/js/storage";
import {_getOrgList} from "../api/organization";

const ASider = ALayout.Sider;
const AFooter = ALayout.Footer;
Expand Down Expand Up @@ -187,6 +188,9 @@
notice({title: this.$route.query.message}, 'notice');
// notice(this.$route.query.message);
}
if (this.logged) {
_getOrgList();
}
},
watch: {
$route: function (to, from) {
Expand Down Expand Up @@ -328,6 +332,10 @@
} else {
turnPath += v.children[0].children[0].fullUrl;
}
if (turnPath == '/home') {
that.toHome();
return false;
}
if (turnPath != '/#') {
that.$router.push(turnPath);
}
Expand Down
6 changes: 3 additions & 3 deletions src/views/member/login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@
}
})
},
loginSuccess(res) {
loginSuccess(res, org) {
setTimeout(() => {
const menu = getStore('menu', true);
if (menu) {
Expand All @@ -314,7 +314,7 @@
});
this.loginBtn = false;
this.$router.addRoutes(routes);
let redirect = this.$route.query.redirect || config.HOME_PAGE;
let redirect = this.$route.query.redirect || config.HOME_PAGE + '/' + org.code;
this.$router.push({
path: redirect
});
Expand Down Expand Up @@ -377,7 +377,7 @@
}
app.$store.dispatch('setCurrentOrganization', currentOrganization);
app.$store.dispatch('GET_MENU').then(() => {
app.loginSuccess(res);
app.loginSuccess(res, currentOrganization);
});
} else {
app.oauthLoading = false;
Expand Down
4 changes: 2 additions & 2 deletions src/views/project/space/task.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
<div class="project-nav-header">
<a-breadcrumb>
<a-breadcrumb-item>
<router-link to="/home">
<a @click="toHome">
<a-icon type="home"/>
首页
</router-link>
</a>
</a-breadcrumb-item>
<a-breadcrumb-item>
<project-select class="nav-title" style="display: inline-block" :code="code"></project-select>
Expand Down

0 comments on commit 2e22b97

Please sign in to comment.