123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- <template>
- <view class="container">
- <cu-custom id="custom"
- bgImage="https://yostest175549.obs.cn-east-2.myhuaweicloud.com:443/202306151686796745663B52544232.png"
- :isBack="isBack">
- <block slot="backText">返回</block>
- <block slot="content">
- 设备中心
- </block>
- </cu-custom>
- <My_search :heightReduction="heightReduction" ref="Search" @onFilter="onFilter" @startSearch="startSearch"
- :filter="filter">
- <template slot="left">
- <view class="change" hover-class="navigator-hover" @click="changePage(PageCur == '设备列表' ? '设备地图' : '设备列表')">
- {{ PageCur == '设备列表' ? '列表' : '地图' }}
- </view>
- </template>
- </My_search>
- <list ref="设备列表" :empty="empty" :list="list" v-show="PageCur == '设备列表'" />
- <my-map ref="设备地图" :tabHeight="tabHeight" :markers="markers" v-show="PageCur == '设备地图'" />
- </view>
- </template>
- <script>
- import list from "./list.vue"
- import myMap from "./my-map.vue";
- export default {
- components: { list, myMap },
- props: {
- tabHeight: {
- type: Number,
- default: 98
- }
- },
- name: "facility",
- data() {
- return {
- condition: "",
- empty: false,
- isBack: true,
- uninitialized: true,
- PageCur: "设备列表",
- list: [],
- markers: [],
- "where": {
- "condition": "",
- "status": ""
- },
- filter: [{
- label: "状态",
- list: [{
- status: '全部',
- value: ""
- }, {
- status: '在线',
- value: "在线"
- }, {
- status: '离线',
- value: "离线"
- }, {
- status: '禁用',
- value: "禁用"
- }],
- key: "status",
- selectKey: "value",
- showKey: 'status',
- default: "0",
- selectIndex: 0,
- }],
- heightReduction: 0
- }
- },
- onLoad(options) {
- this.getlist();
- setTimeout(() => this.loadElement(), 100)
- },
- methods: {
- init() {
- this.getlist();
- this.PageCur = '设备地图';
- this.isBack = false;
- this.heightReduction = 45
- setTimeout(() => this.loadElement(true, {
- mode: 'minus',
- num: 50
- }), 100)
- },
- changePage(page) {
- this.PageCur = page;
- this.loadElement()
- },
- loadElement(forcedUpdating, data) {
- let page = this.$refs[this.PageCur];
- if (page.uninitialized || forcedUpdating) page.init();
- },
- getlist() {
- this.$Http.basic({
- "id": 20230615153202,
- "content": {
- "pageNumber": 1,
- "pageSize": 99999,
- where: this.where
- }
- }).then(res => {
- console.log("设备列表", res)
- if (this.cutoff(res.msg)) return;
- this.empty = res.data.length == 0;
- this.$refs.Search.onFinish();
- this.markers = res.data.filter(v => v.latitude).map(v => {
- v.id = v.w_deviceid - 0;
- v.title = v.devicename;
- if (this.usePort == 'h5') v.iconPath = require("../../static/img/icon.png");
- v.customCallout = { display: 'BYCLICK', anchorY: -10 }
- return v
- });
- this.list = res.data.map(v => {
- switch (v.status) {
- case '在线':
- v.bgColor = "#3C9CFF";
- break;
- case '禁用':
- v.bgColor = "#F56C6C";
- break;
- default:
- v.bgColor = "#F9AE3D";
- break;
- }
- return v
- })
- })
- },
- startSearch(condition) {
- if (condition == this.where.condition) return;
- this.where.condition = condition;
- this.getlist()
- },
- onFilter(where) {
- console.log("开始筛选", where)
- where.condition = this.where.condition;
- this.where = where;
- this.getlist()
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- /deep/.My_search {
- padding-left: 0 !important;
- }
- .change {
- height: 30px;
- line-height: 30px;
- text-align: center;
- margin-left: 5px;
- font-size: 14px;
- color: #FFFFFF;
- border-radius: 4px;
- padding: 0 10px;
- margin-right: 5px;
- border-radius: 4px;
- }
- </style>
|