添加收藏夹功能

wp1.0
fanluyan 1 year ago
parent bd9b11294c
commit ce1b533423

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

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

@ -4,17 +4,12 @@
<span @dblclick="handleDblClick(areaData.cmdid)">{{ <span @dblclick="handleDblClick(areaData.cmdid)">{{
areaData.cmdid areaData.cmdid
}}</span> }}</span>
<!-- <el-tooltip <el-button
class="item" type="text"
effect="dark" :icon="areaData.isfavor == 1 ? 'el-icon-star-on' : 'el-icon-star-off'"
:content="!collect ? '取消收藏' : '添加收藏'" @click="addCollectClick"
placement="top" >{{ areaData.isfavor == 1 ? "取消收藏" : "添加收藏" }}</el-button
> >
<i
:class="collect ? 'el-icon-star-off' : 'el-icon-star-on'"
@click="collectCourses"
></i>
</el-tooltip> -->
</div> </div>
<div class="paramsDate"> <div class="paramsDate">
<h3>日历快速查询</h3> <h3>日历快速查询</h3>
@ -138,6 +133,7 @@
</div> </div>
</template> </template>
<script> <script>
import EventBus from "@/utils/event-bus";
import takePicButton from "./takePicButton.vue"; import takePicButton from "./takePicButton.vue";
import takeVideoButton from "./takeVideoButton.vue"; import takeVideoButton from "./takeVideoButton.vue";
import deviceInfoButton from "./deviceInfoButton.vue"; import deviceInfoButton from "./deviceInfoButton.vue";
@ -150,6 +146,7 @@ import {
getChannelByTermidJoggle, getChannelByTermidJoggle,
updateTermCamera, updateTermCamera,
getTermStatus, getTermStatus,
addFavorList,
} from "@/utils/api/index"; } from "@/utils/api/index";
export default { export default {
components: { components: {
@ -178,7 +175,7 @@ export default {
selectDyId: "", //线 selectDyId: "", //线
selectLineId: "", selectLineId: "",
selectTowerId: "", selectTowerId: "",
collect: false, // collectFlag: false, //
}; };
}, },
@ -222,8 +219,38 @@ export default {
console.log(this.dateValue); console.log(this.dateValue);
}, },
// //
collectCourses() { addCollectClick() {
this.collect = !this.collect; 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 //focus
handleDateFocus() { handleDateFocus() {
@ -365,17 +392,11 @@ export default {
font-size: 14px; font-size: 14px;
font-weight: normal; font-weight: normal;
display: flex; display: flex;
align-items: center; justify-content: space-between;
i { span {
margin-left: 16px; font-size: 12px;
cursor: pointer;
}
.el-icon-star-off {
font-size: 18px;
color: #f08200;
} }
.el-icon-star-on { .el-button--text {
font-size: 20px;
color: #f08200; color: #f08200;
} }
} }

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

Loading…
Cancel
Save