Commit fb7d0b62 authored by 仇晓婷's avatar 仇晓婷

收藏功能ok

parent 869ad06e
......@@ -24,13 +24,13 @@
</ul>
</td>
</tr>
<tr v-for="(item,i) in filterSider">
<tr v-for="(item,i) in filterSider" :key="i">
<td class="t_title">
<b class="title">{{item.title}}</b>
</td>
<td>
<ul class="table_row_ul">
<li v-for="(li) in item.children">
<li v-for="(li,i) in item.children" :key="i">
<a
@click="goPage(item,li)"
:class="{'active': li.id === isActive}"
......@@ -56,6 +56,9 @@
</BreadcrumbItem>
<BreadcrumbItem>{{homeMenu}}</BreadcrumbItem>
<BreadcrumbItem :to="parthto" class="white">{{homeMenuItem}}</BreadcrumbItem>
<Tooltip :content="content" placement="top-start" :class="showStar?'icon-show':'icom-hide'">
<Icon type="md-star" @click="shoucang" />
</Tooltip>
</Breadcrumb>
<i-header-search v-if="showSearch && !headerMenu && !isMobile && !showBreadcrumb" />
<div class="header_right">
......@@ -125,7 +128,7 @@ export default {
iHeaderSetting,
iHeaderNotice,
iTabs,
iHeaderBug
iHeaderBug,
},
data() {
return {
......@@ -136,10 +139,12 @@ export default {
oldScrollTop: 0,
isDelayHideSider: false, // hack,当从隐藏侧边栏的 header 切换到正常 header 时,防止 Logo 抖动
loadRouter: true,
showStar: true,
content: "收藏",
menuId: null,
homeMenu: "",
homeMenuItem: "",
parthto: ""
parthto: "",
};
},
computed: {
......@@ -166,7 +171,7 @@ export default {
"showLog",
"showI18n",
"showReload",
"enableSetting"
"enableSetting",
]),
...mapState("admin/page", ["keepAlive"]),
...mapGetters("admin/menu", ["hideSider", "filterSider"]),
......@@ -193,8 +198,8 @@ export default {
"i-layout-header-stick": this.isHeaderStick && !this.isMobile,
"i-layout-header-with-menu": this.headerMenu,
"i-layout-header-with-hide-sider":
this.hideSider || this.isDelayHideSider
}
this.hideSider || this.isDelayHideSider,
},
];
},
headerStyle() {
......@@ -206,20 +211,20 @@ export default {
return this.isMobile || !this.headerFix
? {}
: {
width: `calc(100% - ${menuWidth}px)`
width: `calc(100% - ${menuWidth}px)`,
};
},
siderClasses() {
return {
"i-layout-sider-fix": this.siderFix,
"i-layout-sider-dark": this.siderTheme === "dark"
"i-layout-sider-dark": this.siderTheme === "dark",
};
},
contentClasses() {
return {
"i-layout-content-fix-with-header": this.headerFix,
"i-layout-content-with-tabs": this.tabs,
"i-layout-content-with-tabs-fix": this.tabs && this.tabsFix
"i-layout-content-with-tabs-fix": this.tabs && this.tabsFix,
};
},
insideClasses() {
......@@ -228,7 +233,7 @@ export default {
"i-layout-inside-fix-with-sider-collapse":
this.siderFix && this.menuCollapse,
"i-layout-inside-with-hide-sider": this.hideSider,
"i-layout-inside-mobile": this.isMobile
"i-layout-inside-mobile": this.isMobile,
};
},
drawerClasses() {
......@@ -238,7 +243,7 @@ export default {
},
menuSideWidth() {
return this.menuCollapse ? 80 : Setting.menuSideWidth;
}
},
},
watch: {
hideSider() {
......@@ -254,7 +259,24 @@ export default {
this.handleReload();
}
}
}
console.warn("to-from", to, from, this.filterSider);
//获取收藏列表,判断的当前路由是否收藏
let star = false;
this.$store.state.collect.map((u) => {
if (u.path == from.path) {
star = true;
}
});
this.showStar = star;
//获取菜单path并与当前路由比对,获取当前菜单id
let dataTemp = this.$u.treeToList(this.filterSider);
dataTemp.forEach((data) => {
if (data.path == from.path) {
this.menuId = data.id;
}
});
},
},
methods: {
...mapMutations("admin/layout", ["updateMenuCollapse"]),
......@@ -333,7 +355,28 @@ export default {
this.homeMenu = "";
this.homeMenuItem = "";
this.isActive = 0;
}
},
shoucang() {
if (this.showStar) {
let url = `${systemUrl}/favorite/delete`;
this.$api.delete(url, { id: this.menuId }).then((r) => {
if (r.result) {
this.showStar = false;
this.$Message.success("已取消收藏");
this.content = "收藏";
}
});
} else {
let url = `${systemUrl}/favorite/create`;
this.$api.post(url, { menuId: this.menuId }).then((r) => {
if (r.result) {
this.showStar = true;
this.$Message.success("收藏成功");
this.content = "取消收藏";
}
});
}
},
},
mounted() {
document.addEventListener("scroll", this.handleScroll, { passive: true });
......@@ -343,7 +386,7 @@ export default {
},
created() {
if (this.isTablet && this.showSiderCollapse) this.updateMenuCollapse(true);
}
},
};
</script>
......@@ -507,5 +550,14 @@ export default {
line-height: 50px;
}
}
.icon-show {
color: #2680eb;
font-size: 20px;
cursor: pointer;
}
.icom-hide {
cursor: pointer;
font-size: 20px;
}
}
</style>
\ No newline at end of file
......@@ -22,7 +22,5 @@ export default {
list(params) {
return Api.post(`${systemUrl}/newmessage/list`, params); //获取列表信息
},
favoriteList(params) {
return Api.post(`${systemUrl}/favorite/list`, params); //获取收藏列表信息
},
}
\ No newline at end of file
......@@ -8,7 +8,7 @@
<div class="user-text">
<p>你好:{{userData.userName}},欢迎登录MES系统!</p>
<p>
<span>{{userData.departmentTitle}}</span> &nbsp &nbsp
<span class="mr20">{{userData.departmentTitle}}</span>
<span>{{userData.roleTitles}}</span>
</p>
</div>
......@@ -16,37 +16,9 @@
<div class="bg-b">
<Icon type="ios-arrow-back" />
</div>
<!-- <div class="bg" v-for="(item,index) in listFavorite" :key="index">
<Icon :type="item.icon" />
<div class="bg" v-for="(item,i) in collect" :key="i" @click="toPage(item)">
<Icon :type="item.icon||'md-mail'" />
<p>{{item.title}}</p>
</div>-->
<div class="bg">
<Icon type="ios-cube" />
<p>电子对账单</p>
</div>
<div class="bg">
<Icon type="md-mail" />
<p>站内邮件</p>
</div>
<div class="bg">
<Icon type="md-map" />
<p>站内邮件</p>
</div>
<div class="bg">
<Icon type="ios-cube" />
<p>电子对账单</p>
</div>
<div class="bg">
<Icon type="ios-cube" />
<p>电子对账单</p>
</div>
<div class="bg">
<Icon type="md-mail" />
<p>站内邮件</p>
</div>
<div class="bg">
<Icon type="md-mail" />
<p>站内邮件</p>
</div>
<div class="bg-l">
<Icon type="ios-arrow-forward" />
......@@ -93,7 +65,7 @@ import Api from "./api";
import Approval from "./component/approval";
import UnreadMessage from "./component/unreadMessage";
import StaChart from "./component/staChart";
import { mapState } from "vuex";
export default {
components: {
Approval,
......@@ -110,10 +82,17 @@ export default {
imgPath: true,
};
},
async fetch({ store, params }) {
await store.dispatch("collectList"); // 加载数据字典
},
created() {
this.get();
this.getUserInfoFn();
this.getList();
console.log(this.$store.state.collect);
// this.getList();
},
computed: {
...mapState({ collect: "collect" }),
},
methods: {
getUserInfoFn() {
......@@ -139,27 +118,24 @@ export default {
this.$api.get(url).then((r) => {
list = r.result;
list.forEach((data) => {
// console.log(data.totalUrl)
console.log(data.totalUrl);
let ulrt = `http://${address}:` + data.totalUrl;
data.totalUrl = 0;
this.$api.get(ulrt).then((r) => {
return (data.totalUrl = r.result);
});
});
console.log(list);
this.listTask = list;
});
},
getList() {
let conditions = [];
Api.favoriteList({ conditions: conditions }).then((r) => {
this.listFavorite = r.result;
});
},
goPage(u) {
// alert(u.menuUrl)
this.$router.push(u.menuUrl);
},
toPage(u) {
this.$router.push(u.url);
},
},
};
</script>
......@@ -207,11 +183,12 @@ export default {
}
.bg {
text-align: center;
width: 100px;
width: 120px;
float: left;
.ivu-icon {
font-size: 35px;
color: #2680eb;
cursor: pointer;
}
p {
margin-top: 8px;
......
......@@ -11,6 +11,7 @@ export const state = () => ({
},
departments:{},//部门列表
cart: [],
collect:[],//用户收藏
count: 0,
countAps: 0, //aps排产
countAi: 0, //智能排产
......@@ -66,6 +67,9 @@ export const mutations = {
addUser(state, user) {
state.userMap.push(user);
},
setCollect(state, collectData) {
state.collect = collectData;
},
setDictionary(state, dictionary) {
state.dictionary = dictionary;
},
......@@ -94,6 +98,16 @@ export const mutations = {
}
export const actions = {
async collectList({
commit
}) {
let {
result
} = await Api.post(`${systemUrl}/favorite/listbyuser`);
console.warn("result", result)
commit("setCollect", result);
},
async loadUser({
commit
}, key) {
......
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 to comment