Commit cf90e32a by liangjianmin

js

parent ac9c65bb
Showing with 162 additions and 166 deletions
......@@ -15,7 +15,7 @@ export let NODE_ENVS = "/";
switch (envs) {
case 'development':
//开发环境
NODE_ENVS = 'http://192.168.2.164:8080';
NODE_ENVS = 'http://192.168.2.142:8080';
break;
case 'test':
//测试环境
......
......@@ -9,8 +9,8 @@
</a>
<a class="item fl"
:class="{'act':(JSON.stringify(item)==JSON.stringify({path: $route.path,title: $route.meta.title,query:$route.query}))}"
@click="tabUrl(item)" v-for="item in tabs">
:class="{'act':(JSON.stringify(item)==JSON.stringify({path: $route.path,title: $route.meta.title,query:$route.query}))}"
@click="tabUrl(item)" v-for="item in tabs">
<font class="fl">{{item.title}}</font>
<span class="icon iconfont fl" @click.stop="closetab(item.path)"></span>
</a>
......@@ -47,8 +47,8 @@
</div>
<el-menu class="el-menu-vertical-demo" @open="handleOpen" active-text-color="#1969F9" router
:default-active="$route.path" :router="true" :unique-opened="true" @close="handleClose"
@select="handleSelect">
:default-active="$route.path" :router="true" :unique-opened="true" @close="handleClose"
@select="handleSelect">
<el-menu-item :index="'/'" :class="{'indextab':isIndexTab}">
<template slot="title">
<span class="icon iconfont"></span>
......@@ -142,178 +142,174 @@
</template>
<script>
import Vue from 'vue';
import Util from "../tool";
import {
Form,
FormItem,
Menu,
MenuItem,
Submenu,
MenuItemGroup,
Message,
Dialog,
Button
} from 'element-ui'
Vue.use(Menu).use(MenuItem).use(MenuItemGroup).use(Submenu).use(Form).use(FormItem).use(Dialog).use(Button);
export default {
name: 'menus',
props: {},
created() {
this.getData();
import Vue from 'vue';
import Util from "../tool";
import {
Form,
FormItem,
Menu,
MenuItem,
Submenu,
MenuItemGroup,
Message,
Dialog,
Button
} from 'element-ui'
Vue.use(Menu).use(MenuItem).use(MenuItemGroup).use(Submenu).use(Form).use(FormItem).use(Dialog).use(Button);
export default {
name: 'menus',
props: {},
created() {
this.getData();
},
data() {
return {
userinfo: {},
collapse: false,
isIndexTab: true,
tabSure: "",
tabs: "",
dialogVisible: false,
ruleForm: {
name: ''
},
data() {
return {
userinfo: {},
collapse: false,
isIndexTab: true,
tabSure: "",
tabs: "",
dialogVisible: false,
ruleForm: {
name: ''
},
rules: {
name: [{
required: true,
message: '请输入活动名称',
trigger: 'blur'
}]
}
}
},
watch: {
$route(to, from) {
let tab_arr = sessionStorage.getItem('tabs')
if (tab_arr) {
this.tabs = JSON.parse(tab_arr);
}
rules: {
name: [{
required: true,
message: '请输入活动名称',
trigger: 'blur'
}]
}
}
},
watch: {
$route(to, from) {
let tab_arr = sessionStorage.getItem('tabs')
if (tab_arr) {
this.tabs = JSON.parse(tab_arr);
}
let app_ = document.getElementById('app');
this.collapse = false
if (this.collapse) {
app_.setAttribute('style', 'padding-left:62px');
} else {
app_.setAttribute('style', 'padding-left:226px');
}
let app_ = document.getElementById('app');
this.collapse = false
if (this.collapse) {
app_.setAttribute('style', 'padding-left:62px');
} else {
app_.setAttribute('style', 'padding-left:226px');
}
}
},
mounted() {
this.tabss(this.$route.path)
},
methods: {
getData() {
var userInfo_ = sessionStorage.getItem('userInfox');
if (userInfo_) {
this.userinfo = JSON.parse(userInfo_);
} else {
this.$http('get', "/api/user/getuserinfo").then(res => {
this.userinfo = res.data;
if (res.data) {
sessionStorage.setItem('userInfox', JSON.stringify(res.data));
}
},
mounted() {
this.tabss(this.$route.path)
},
methods: {
getData() {
var userInfo_ = sessionStorage.getItem('userInfox');
if (userInfo_) {
this.userinfo = JSON.parse(userInfo_);
} else {
this.$http('get', "/api/user/getuserinfo").then(res => {
this.userinfo = res.data;
if(res.data){
sessionStorage.setItem('userInfox', JSON.stringify(res.data));
}
})
}
},
tabUrl(item) {
})
}
},
tabUrl(item) {
this.$router.push({
path: item.path,
query: item.query
})
},
changePwd() {
this.dialogVisible = true;
},
tabss(lk) {
if (lk == "/") {
this.tabSure = 1
}
if (lk == "/inquire" || lk == "/quote") {
this.tabSure = 2
}
if (lk == "/list" || lk == "/enter") {
this.tabSure = 3
}
if (lk == "/goods" || lk == "/brand") {
this.tabSure = 4
}
if (lk == "/message") {
this.tabSure = 5
}
let tab_arr = sessionStorage.getItem('tabs')
if (tab_arr) {
this.tabs = JSON.parse(tab_arr);
}
},
closetab(path) {
let tab_arr = JSON.parse(sessionStorage.getItem('tabs'))
for (var i = 0; i < tab_arr.length; i++) {
if (tab_arr[i].path == path) {
tab_arr.splice(i, 1);
sessionStorage.setItem('tabs', JSON.stringify(tab_arr));
this.tabs = tab_arr;
if (path == this.$route.path) {
if (i == 0) {
this.$router.push({
path: item.path,
query: item.query
path: "/",
})
},
changePwd() {
this.dialogVisible = true;
},
tabss(lk) {
if (lk == "/") {
this.tabSure = 1
}
if (lk == "/inquire" || lk == "/quote") {
this.tabSure = 2
}
if (lk == "/list" || lk == "/enter") {
this.tabSure = 3
}
if (lk == "/goods" || lk == "/brand") {
this.tabSure = 4
}
if (lk == "/message") {
this.tabSure = 5
}
let tab_arr = sessionStorage.getItem('tabs')
if (tab_arr) {
this.tabs = JSON.parse(tab_arr);
}
},
closetab(path) {
let tab_arr = JSON.parse(sessionStorage.getItem('tabs'))
for (var i = 0; i < tab_arr.length; i++) {
if (tab_arr[i].path == path) {
tab_arr.splice(i, 1);
sessionStorage.setItem('tabs', JSON.stringify(tab_arr));
this.tabs = tab_arr;
if (path == this.$route.path) {
if (i == 0) {
this.$router.push({
path: "/",
})
} else {
this.$router.push({
path: tab_arr[i - 1].path,
})
}
}
break;
}
}
},
zk() {
this.collapse = !this.collapse;
let app_ = document.getElementById('app');
if (this.collapse) {
app_.setAttribute('style', 'padding-left:62px');
} else {
app_.setAttribute('style', 'padding-left:226px');
}
},
handleOpen(key, keyPath) {
if (this.$route.path == "/") {
this.isIndexTab = false
}
},
handleClose(key, keyPath) {
if (this.$route.path == "/") {
this.isIndexTab = true
}
},
handleSelect(key, keyPath) {
this.tabss(key)
},
logout() {
this.$http('post', "/auth/logout").then(res => {
Util.delCookie('token');
if (res.err_code === 0) {
window.location.href = '/#/login';
sessionStorage.removeItem('userInfox')
history.go(0);
} else {
Message(res.err_msg);
}
}).catch(err => {
console.log(err.message);
} else {
this.$router.push({
path: tab_arr[i - 1].path,
})
}
}
break;
}
}
},
zk() {
this.collapse = !this.collapse;
let app_ = document.getElementById('app');
if (this.collapse) {
app_.setAttribute('style', 'padding-left:62px');
} else {
app_.setAttribute('style', 'padding-left:226px');
}
},
handleOpen(key, keyPath) {
if (this.$route.path == "/") {
this.isIndexTab = false
}
},
handleClose(key, keyPath) {
if (this.$route.path == "/") {
this.isIndexTab = true
}
},
handleSelect(key, keyPath) {
this.tabss(key)
},
logout() {
this.$http('post', "/auth/logout").then(res => {
Util.delCookie('token');
window.location.href = '/#/login';
sessionStorage.removeItem('userInfox')
history.go(0);
}).catch(err => {
console.log(err.message);
})
}
}
}
</script>
<style lang="less">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment