index.vue
4.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<template>
<div class="wrapper">
<div ref="wrapRef" :style="{ height, width }"> </div>
<div class="right-wrap">
<BasicForm @register="registerForm">
<template #device>
<div class="flex justify-between">
<a-input v-model:value="deviceValue" placeholder="请输入设备名称" style="width: 70%" />
<a-button color="success" @click="handleReset" class="w-1/4">复位查询</a-button>
</div>
</template>
</BasicForm>
<div>
<RadioGroup v-model:value="deviceStatus">
<Radio :value="1">全部</Radio>
<Radio :value="2">在线</Radio>
<Radio :value="3">离线</Radio>
<Radio :value="4">报警</Radio>
</RadioGroup>
<div class="scroll-wrap">
<ScrollContainer ref="scrollRef">
<template
v-for="(item, index) in 10"
:key="index"
:class="{ active: currentIndex == index }"
@click="bander(index)"
>
<div class="flex" style="border-bottom: 1px solid #ccc">
<div>
<div class="flex">
<div class="font-bold ml-5">名称 </div>
<div class="ml-5">发动机{{ item }}</div>
</div>
<div class="flex">
<div class="font-bold ml-5">位置 </div>
<div class="ml-5 font-bold">四川省成都市高新区{{ item }}</div>
</div>
</div>
<div class="self-center ml-10"><Tag color="default">离线</Tag></div>
</div>
</template>
</ScrollContainer>
</div>
<div class="flex justify-end">
<Pagination v-model:current="current" :total="50" size="small" show-less-items />
</div>
</div>
</div>
</div>
</template>
<script lang="ts">
import { defineComponent, ref, nextTick, unref, onMounted } from 'vue';
import { useScript } from '/@/hooks/web/useScript';
import { BasicForm, useForm } from '/@/components/Form/index';
import { formSchema } from './config.data';
import { RadioGroup, Radio, Tag, Pagination } from 'ant-design-vue';
import { ScrollContainer, ScrollActionType } from '/@/components/Container/index';
export default defineComponent({
name: 'BaiduMap',
components: {
BasicForm,
RadioGroup,
Radio,
Tag,
ScrollContainer,
Pagination,
},
props: {
width: {
type: String,
default: '100%',
},
height: {
type: String,
default: 'calc(100vh - 78px)',
},
},
setup() {
const BAI_DU_MAP_URL =
'https://api.map.baidu.com/getscript?v=3.0&ak=7uOPPyAHn2Y2ZryeQqHtcRqtIY374vKa';
const wrapRef = ref<HTMLDivElement | null>(null);
const scrollRef = ref<Nullable<ScrollActionType>>(null);
const { toPromise } = useScript({ src: BAI_DU_MAP_URL });
async function initMap() {
await toPromise();
await nextTick();
const wrapEl = unref(wrapRef);
const BMap = (window as any).BMap;
if (!wrapEl) return;
const map = new BMap.Map(wrapEl);
const point = new BMap.Point(116.14282, 35.19515);
map.centerAndZoom(point, 15);
map.enableScrollWheelZoom(true);
}
onMounted(() => {
initMap();
});
const deviceValue = ref('');
const deviceStatus = ref(1);
const current = ref(2);
const currentIndex = ref(1);
const bander = (index: number) => {
currentIndex.value = index;
};
const [registerForm] = useForm({
labelWidth: 90,
schemas: formSchema,
showActionButtonGroup: false,
});
const handleReset = () => {
deviceValue.value = '';
};
return {
wrapRef,
registerForm,
deviceValue,
deviceStatus,
handleReset,
scrollRef,
current,
currentIndex,
bander,
};
},
});
</script>
<style scoped>
.wrapper {
position: relative;
}
.active {
background-color: #fff;
}
.right-wrap {
padding-top: 10px;
width: 20%;
height: 80%;
position: absolute;
right: 5%;
top: 10%;
background-color: #f3f8fe;
}
.scroll-wrap {
height: 450px;
background-color: #f3f8fe;
}
</style>