添加收藏夹功能

wp1.0
fanluyan 1 year ago
parent bd9b11294c
commit ce1b533423

@ -126,8 +126,8 @@ export default {
: this.defaultExpandedKeys; //defaultKey ;
console.log(this.defaultExpandedKeys);
if (this.lineTreeData[0].list[0].list.length > 0) {
}
// if (this.lineTreeData[0].list[0].list.length > 0) {
// }
if (
this.currentData !== null &&
Object.keys(this.currentData).length !== 0

@ -687,3 +687,11 @@ export function deletePicList(data) {
data,
});
}
export function addFavorList(data) {
return request({
url: "/api/addFavorList",
method: "post",
data,
});
}

@ -4,17 +4,12 @@
<span @dblclick="handleDblClick(areaData.cmdid)">{{
areaData.cmdid
}}</span>
<!-- <el-tooltip
class="item"
effect="dark"
:content="!collect ? '取消收藏' : '添加收藏'"
placement="top"
<el-button
type="text"
:icon="areaData.isfavor == 1 ? 'el-icon-star-on' : 'el-icon-star-off'"
@click="addCollectClick"
>{{ areaData.isfavor == 1 ? "取消收藏" : "添加收藏" }}</el-button
>
<i
:class="collect ? 'el-icon-star-off' : 'el-icon-star-on'"
@click="collectCourses"
></i>
</el-tooltip> -->
</div>
<div class="paramsDate">
<h3>日历快速查询</h3>
@ -138,6 +133,7 @@
</div>
</template>
<script>
import EventBus from "@/utils/event-bus";
import takePicButton from "./takePicButton.vue";
import takeVideoButton from "./takeVideoButton.vue";
import deviceInfoButton from "./deviceInfoButton.vue";
@ -150,6 +146,7 @@ import {
getChannelByTermidJoggle,
updateTermCamera,
getTermStatus,
addFavorList,
} from "@/utils/api/index";
export default {
components: {
@ -178,7 +175,7 @@ export default {
selectDyId: "", //线
selectLineId: "",
selectTowerId: "",
collect: false, //
collectFlag: false, //
};
},
@ -222,8 +219,38 @@ export default {
console.log(this.dateValue);
},
//
collectCourses() {
this.collect = !this.collect;
addCollectClick() {
if (this.areaData.isfavor !== 1) {
this.$confirm("此操作将添加至收藏夹, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
}).then(() => {
this.areaData.isfavor = 1;
addFavorList({ list: [this.areaData.id], type: 1 }).then((res) => {
EventBus.$emit("treelist");
});
this.$message({
type: "success",
message: "添加成功!",
});
});
} else {
this.$confirm("此操作将取消收藏, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
}).then(() => {
this.areaData.isfavor = 0;
addFavorList({ list: [this.areaData.id], type: 0 }).then((res) => {
EventBus.$emit("treelist");
});
this.$message({
type: "success",
message: "取消收藏!",
});
});
}
},
//focus
handleDateFocus() {
@ -365,17 +392,11 @@ export default {
font-size: 14px;
font-weight: normal;
display: flex;
align-items: center;
i {
margin-left: 16px;
cursor: pointer;
}
.el-icon-star-off {
font-size: 18px;
color: #f08200;
justify-content: space-between;
span {
font-size: 12px;
}
.el-icon-star-on {
font-size: 20px;
.el-button--text {
color: #f08200;
}
}

@ -46,6 +46,47 @@
@node-click="handleNodeClick"
>
<span class="custom-tree-node" slot-scope="{ node, data }">
<!-- v-if="node.name === '收藏夹'" -->
<span>
<span>
<span
v-if="node.label === '收藏夹'"
class="el-icon-collection"
style="margin-right: 6px"
></span>
<span
v-if="node.level === 1 && node.label !== '收藏夹'"
class="iconfont icon-dianli"
style="margin-right: 6px"
></span>
<span
v-if="node.level === 2 && data.bsManufacturer"
class="iconfont icon-dianlihangye"
style="margin-right: 6px"
>
</span>
<span
v-if="
node.label !== '收藏夹' && !data.bsManufacturer && !data.dyValue
"
>
<span
class="iconfont icon-shexiangtoulixian"
v-if="data.onlinestatus == 0"
:class="data.onlinestatus == 0 ? 'disconnect' : ''"
style="margin-right: 6px"
></span>
<span
class="iconfont icon-shexiangtou-lixian"
v-else
:class="data.onlinestatus == 0 ? 'disconnect' : ''"
style="margin-right: 6px"
></span>
</span>
<span>{{ node.label }} </span>
</span>
</span>
<!-- <span v-else>
<span v-if="node.level === 1">
<span class="iconfont icon-dianli" style="margin-right: 6px"></span>
<span>{{ node.label }} </span>
@ -77,11 +118,13 @@
>{{ node.label }}</span
>
</span>
</span> -->
</span>
</el-tree>
</div>
</template>
<script>
import EventBus from "@/utils/event-bus";
import { getdyTreeListJoggle, getzzdyTreeList } from "@/utils/api/index";
export default {
data() {
@ -102,6 +145,7 @@ export default {
currentNodekey: "", //,
role: "",
treeStatustimer: null,
isfavorList: [],
};
},
components: {},
@ -127,6 +171,7 @@ export default {
this.getRadio(); //线线
this.getLineTreeList(); //
this.treeStatustimer = setInterval(this.getLineTreeStatus, 60000); // 10
EventBus.$on("treelist", this.getLineTreeStatus);
},
methods: {
//radio
@ -147,6 +192,13 @@ export default {
.then((res) => {
console.log(res);
this.lineTreeData = res.data.list;
this.isfavorList = res.data.favorlist;
this.lineTreeData.unshift({
id: 0,
name: "收藏夹",
bsManufacturer: "收藏夹",
list: this.isfavorList,
});
this.onlineNum = res.data.onlineNum;
this.totalNum = res.data.totalNum;
this.currentData = JSON.parse(localStorage.getItem("currentData"));
@ -179,53 +231,16 @@ export default {
//
getLineTreeList() {
console.log(this.zzradio);
if (this.role == 4) {
getzzdyTreeList({ type: this.zzradio })
.then((res) => {
this.lineTreeData = res.data.list;
this.onlineNum = res.data.onlineNum;
this.totalNum = res.data.totalNum;
this.currentData = JSON.parse(localStorage.getItem("currentData"));
this.lineTreeData.forEach((node) => {
if (node.list) {
node.list.forEach((child) => {
this.defaultExpandedKeys.push(child.id);
});
} else {
this.defaultExpandedKeys.push(node.id);
}
});
this.defaultExpandedKeys =
JSON.parse(localStorage.getItem("defaultKey")) !== null
? JSON.parse(localStorage.getItem("defaultKey"))
: this.defaultExpandedKeys; //defaultKey ;
console.log(this.defaultExpandedKeys);
if (this.lineTreeData[0].list[0].list.length > 0) {
}
if (
this.currentData !== null &&
Object.keys(this.currentData).length !== 0
) {
this.currentNodekey = this.currentData.id;
this.handleNodeClick(this.currentData);
} else {
this.currentData = this.lineTreeData[0]; //
this.currentNodekey = this.lineTreeData[0].id; //
this.handleNodeClick(this.currentData);
}
this.$nextTick(() => {
this.$refs.tree.setCurrentKey(this.currentNodekey); //
this.scrollView();
});
})
.catch((err) => {
console.log(err); //
});
} else {
getdyTreeListJoggle({ type: this.zzradio })
.then((res) => {
this.lineTreeData = res.data.list;
this.isfavorList = res.data.favorlist;
this.lineTreeData.unshift({
id: 0,
name: "收藏夹",
bsManufacturer: "收藏夹",
list: this.isfavorList,
});
this.onlineNum = res.data.onlineNum;
this.totalNum = res.data.totalNum;
this.currentData = JSON.parse(localStorage.getItem("currentData"));
@ -244,8 +259,8 @@ export default {
: this.defaultExpandedKeys; //defaultKey ;
console.log(this.defaultExpandedKeys);
if (this.lineTreeData[0].list[0].list.length > 0) {
}
// if (this.lineTreeData[0].list[0].list.length > 0) {
// }
if (
this.currentData !== null &&
Object.keys(this.currentData).length !== 0
@ -265,11 +280,18 @@ export default {
.catch((err) => {
console.log(err); //
});
}
},
//treenode
handleNodeClick(data) {
if (data.name == "收藏夹") {
return;
}
if (data.isfavor == 0 || data.isfavor == null) {
this.collectFlag = false;
} else {
this.collectFlag = true;
}
this.currentData = data;
// this.scrollView();
this.$store.commit("currentData", this.currentData); //currentDatavuex

Loading…
Cancel
Save