Commit 674be7d5dda8f23be7a1cfb503517f363f42139e
Merge branch 'sqy_dev' into 'main'
'fix:更新地理位置页面以及修复设备位置bug' See merge request huang/yun-teng-iot-front!12
Showing
5 changed files
with
112 additions
and
94 deletions
... | ... | @@ -6,9 +6,11 @@ import type { |
6 | 6 | ContactInfo, |
7 | 7 | } from './model/alarmContactModal'; |
8 | 8 | import { getPageData } from '../../base'; |
9 | -enum Api { | |
9 | +import { DeviceModel, DeviceQueryParam } from '../../device/model/deviceModel'; | |
10 | +enum API { | |
10 | 11 | alarmContact = '/alarmContact', |
11 | 12 | updateAlarmContact = '/alarmContact/update', |
13 | + devicePage = '/device', | |
12 | 14 | } |
13 | 15 | |
14 | 16 | // 获取 |
... | ... | @@ -19,7 +21,7 @@ export const getAlarmContact = (params: ContactPageParams) => { |
19 | 21 | // 新增 |
20 | 22 | export const addAlarmContact = (params: ContactParams) => { |
21 | 23 | return defHttp.post({ |
22 | - url: Api.alarmContact, | |
24 | + url: API.alarmContact, | |
23 | 25 | data: params, |
24 | 26 | }); |
25 | 27 | }; |
... | ... | @@ -27,7 +29,7 @@ export const addAlarmContact = (params: ContactParams) => { |
27 | 29 | // 更新 |
28 | 30 | export const updateAlarmContact = (params: ContactParams) => { |
29 | 31 | return defHttp.post({ |
30 | - url: Api.updateAlarmContact, | |
32 | + url: API.updateAlarmContact, | |
31 | 33 | data: params, |
32 | 34 | }); |
33 | 35 | }; |
... | ... | @@ -35,7 +37,7 @@ export const updateAlarmContact = (params: ContactParams) => { |
35 | 37 | // 删除 |
36 | 38 | export const deleteAlarmContact = (ids: string[]) => { |
37 | 39 | return defHttp.delete({ |
38 | - url: Api.alarmContact, | |
40 | + url: API.alarmContact, | |
39 | 41 | data: ids, |
40 | 42 | }); |
41 | 43 | }; |
... | ... | @@ -45,3 +47,10 @@ export const saveOrEditAlarmContact = (params: ContactInfo, isUpdate: boolean) = |
45 | 47 | if (isUpdate) return updateAlarmContact(params); |
46 | 48 | addAlarmContact(params); |
47 | 49 | }; |
50 | + | |
51 | +export const devicePage = (params: DeviceQueryParam) => { | |
52 | + return defHttp.get<DeviceModel>({ | |
53 | + url: API.devicePage, | |
54 | + params, | |
55 | + }); | |
56 | +}; | ... | ... |
1 | +import { BasicColumn } from '/@/components/Table'; | |
2 | + | |
1 | 3 | import { FormSchema } from '/@/components/Table'; |
2 | 4 | export const formSchema: FormSchema[] = [ |
3 | 5 | { |
4 | 6 | field: 'organization', |
5 | 7 | label: '', |
6 | 8 | component: 'TreeSelect', |
7 | - componentProps: {}, | |
9 | + componentProps: { | |
10 | + placeholder: '请选择组织', | |
11 | + }, | |
8 | 12 | }, |
9 | 13 | { |
10 | 14 | field: 'organization', |
11 | 15 | label: '', |
12 | 16 | component: 'Select', |
13 | - componentProps: {}, | |
17 | + componentProps: { | |
18 | + placeholder: '请选择设备配置', | |
19 | + }, | |
14 | 20 | }, |
15 | 21 | { |
16 | 22 | field: 'device', |
17 | 23 | label: '', |
18 | - slot: 'device', | |
19 | 24 | component: 'Input', |
25 | + componentProps: { | |
26 | + placeholder: '请输入设备名称', | |
27 | + }, | |
28 | + }, | |
29 | + { | |
30 | + field: 'status', | |
31 | + label: '', | |
32 | + component: 'RadioGroup', | |
33 | + componentProps: { | |
34 | + size: 'small', | |
35 | + options: [ | |
36 | + { label: '全部', value: 'Apple' }, | |
37 | + { label: '离线', value: 'Pear' }, | |
38 | + { label: '在线', value: 'Orange' }, | |
39 | + { label: '报警', value: 'hhh' }, | |
40 | + ], | |
41 | + }, | |
42 | + }, | |
43 | +]; | |
44 | + | |
45 | +export const columns: BasicColumn[] = [ | |
46 | + { | |
47 | + title: '名称', | |
48 | + dataIndex: 'name', | |
49 | + width: 100, | |
50 | + }, | |
51 | + { | |
52 | + title: '位置', | |
53 | + dataIndex: 'deviceInfo.address', | |
54 | + width: 100, | |
55 | + }, | |
56 | + { | |
57 | + title: '状态', | |
58 | + dataIndex: 'deviceState', | |
59 | + width: 100, | |
20 | 60 | }, |
21 | 61 | ]; | ... | ... |
... | ... | @@ -2,68 +2,21 @@ |
2 | 2 | <div class="wrapper"> |
3 | 3 | <div ref="wrapRef" :style="{ height, width }"> </div> |
4 | 4 | <div class="right-wrap"> |
5 | - <BasicForm @register="registerForm"> | |
6 | - <template #device> | |
7 | - <div class="flex justify-between"> | |
8 | - <a-input v-model:value="deviceValue" placeholder="请输入设备名称" style="width: 70%" /> | |
9 | - <a-button color="success" @click="handleReset" class="w-1/4">复位查询</a-button> | |
10 | - </div> | |
11 | - </template> | |
12 | - </BasicForm> | |
13 | - <div> | |
14 | - <RadioGroup v-model:value="deviceStatus"> | |
15 | - <Radio :value="1">全部</Radio> | |
16 | - <Radio :value="2">在线</Radio> | |
17 | - <Radio :value="3">离线</Radio> | |
18 | - <Radio :value="4">报警</Radio> | |
19 | - </RadioGroup> | |
20 | - <div class="scroll-wrap"> | |
21 | - <ScrollContainer ref="scrollRef"> | |
22 | - <template | |
23 | - v-for="(item, index) in 10" | |
24 | - :key="index" | |
25 | - :class="{ active: currentIndex == index }" | |
26 | - @click="bander(index)" | |
27 | - > | |
28 | - <div class="flex" style="border-bottom: 1px solid #ccc"> | |
29 | - <div> | |
30 | - <div class="flex"> | |
31 | - <div class="font-bold ml-5">名称 </div> | |
32 | - <div class="ml-5">发动机{{ item }}</div> | |
33 | - </div> | |
34 | - <div class="flex"> | |
35 | - <div class="font-bold ml-5">位置 </div> | |
36 | - <div class="ml-5 font-bold">四川省成都市高新区{{ item }}</div> | |
37 | - </div> | |
38 | - </div> | |
39 | - <div class="self-center ml-10"><Tag color="default">离线</Tag></div> | |
40 | - </div> | |
41 | - </template> | |
42 | - </ScrollContainer> | |
43 | - </div> | |
44 | - <div class="flex justify-end"> | |
45 | - <Pagination v-model:current="current" :total="50" size="small" show-less-items /> | |
46 | - </div> | |
47 | - </div> | |
5 | + <BasicTable @register="registerTable" /> | |
48 | 6 | </div> |
49 | 7 | </div> |
50 | 8 | </template> |
51 | 9 | <script lang="ts"> |
52 | 10 | import { defineComponent, ref, nextTick, unref, onMounted } from 'vue'; |
53 | 11 | import { useScript } from '/@/hooks/web/useScript'; |
54 | - import { BasicForm, useForm } from '/@/components/Form/index'; | |
55 | - import { formSchema } from './config.data'; | |
56 | - import { RadioGroup, Radio, Tag, Pagination } from 'ant-design-vue'; | |
57 | - import { ScrollContainer, ScrollActionType } from '/@/components/Container/index'; | |
12 | + import { formSchema, columns } from './config.data'; | |
13 | + import { BasicTable, useTable } from '/@/components/Table'; | |
14 | + import { devicePage } from '/@/api/alarm/contact/alarmContact'; | |
15 | + | |
58 | 16 | export default defineComponent({ |
59 | 17 | name: 'BaiduMap', |
60 | 18 | components: { |
61 | - BasicForm, | |
62 | - RadioGroup, | |
63 | - Radio, | |
64 | - Tag, | |
65 | - ScrollContainer, | |
66 | - Pagination, | |
19 | + BasicTable, | |
67 | 20 | }, |
68 | 21 | props: { |
69 | 22 | width: { |
... | ... | @@ -75,12 +28,10 @@ |
75 | 28 | default: 'calc(100vh - 78px)', |
76 | 29 | }, |
77 | 30 | }, |
78 | - | |
79 | 31 | setup() { |
80 | 32 | const BAI_DU_MAP_URL = |
81 | 33 | 'https://api.map.baidu.com/getscript?v=3.0&ak=7uOPPyAHn2Y2ZryeQqHtcRqtIY374vKa'; |
82 | 34 | const wrapRef = ref<HTMLDivElement | null>(null); |
83 | - const scrollRef = ref<Nullable<ScrollActionType>>(null); | |
84 | 35 | const { toPromise } = useScript({ src: BAI_DU_MAP_URL }); |
85 | 36 | async function initMap() { |
86 | 37 | await toPromise(); |
... | ... | @@ -96,31 +47,26 @@ |
96 | 47 | onMounted(() => { |
97 | 48 | initMap(); |
98 | 49 | }); |
99 | - const deviceValue = ref(''); | |
100 | - const deviceStatus = ref(1); | |
101 | - const current = ref(2); | |
102 | - const currentIndex = ref(1); | |
103 | - const bander = (index: number) => { | |
104 | - currentIndex.value = index; | |
105 | - }; | |
106 | - const [registerForm] = useForm({ | |
107 | - labelWidth: 90, | |
108 | - schemas: formSchema, | |
109 | - showActionButtonGroup: false, | |
50 | + | |
51 | + const [registerTable, { reload }] = useTable({ | |
52 | + api: devicePage, | |
53 | + columns, | |
54 | + formConfig: { | |
55 | + labelWidth: 120, | |
56 | + schemas: formSchema, | |
57 | + showAdvancedButton: false, | |
58 | + showActionButtonGroup: false, | |
59 | + }, | |
60 | + showIndexColumn: false, | |
61 | + useSearchForm: true, | |
110 | 62 | }); |
111 | - const handleReset = () => { | |
112 | - deviceValue.value = ''; | |
63 | + const handleSuccess = () => { | |
64 | + reload(); | |
113 | 65 | }; |
114 | 66 | return { |
115 | 67 | wrapRef, |
116 | - registerForm, | |
117 | - deviceValue, | |
118 | - deviceStatus, | |
119 | - handleReset, | |
120 | - scrollRef, | |
121 | - current, | |
122 | - currentIndex, | |
123 | - bander, | |
68 | + registerTable, | |
69 | + handleSuccess, | |
124 | 70 | }; |
125 | 71 | }, |
126 | 72 | }); |
... | ... | @@ -135,15 +81,13 @@ |
135 | 81 | } |
136 | 82 | .right-wrap { |
137 | 83 | padding-top: 10px; |
138 | - width: 20%; | |
84 | + width: 22%; | |
139 | 85 | height: 80%; |
140 | 86 | position: absolute; |
141 | 87 | right: 5%; |
142 | 88 | top: 10%; |
143 | - background-color: #f3f8fe; | |
144 | 89 | } |
145 | 90 | .scroll-wrap { |
146 | 91 | height: 450px; |
147 | - background-color: #f3f8fe; | |
148 | 92 | } |
149 | 93 | </style> | ... | ... |
... | ... | @@ -24,7 +24,7 @@ |
24 | 24 | </div> |
25 | 25 | |
26 | 26 | <a-form :wrapper-col="wrapperCol" labelAlign="left" v-if="item.isPass"> |
27 | - <a-form-item label="要传递的关联类型" :labelCol="{ style: { width: '120px' } }"> | |
27 | + <a-form-item label="传递的关联类型" :labelCol="{ style: { width: '120px' } }"> | |
28 | 28 | <a-input /> |
29 | 29 | </a-form-item> |
30 | 30 | </a-form> |
... | ... | @@ -47,7 +47,11 @@ |
47 | 47 | <EditOutlined class="cursor-pointer ml-4" style="font-size: 20px" |
48 | 48 | /></p> |
49 | 49 | <p class="mt-4 ml-4" |
50 | - >详情:1 <EditOutlined class="cursor-pointer ml-4" style="font-size: 20px" | |
50 | + >详情:1 | |
51 | + <EditOutlined | |
52 | + @click="editCreateDetail(index, index1)" | |
53 | + class="cursor-pointer ml-4" | |
54 | + style="font-size: 20px" | |
51 | 55 | /></p> |
52 | 56 | <p class="mt-4 ml-4">dashboard: <a-select style="width: 180px" /></p> |
53 | 57 | </div> |
... | ... | @@ -66,6 +70,10 @@ |
66 | 70 | <a-button class="mt-5" @click="addCreateRole(index)" |
67 | 71 | ><PlusCircleOutlined />添加创建条件</a-button |
68 | 72 | > |
73 | + <!-- 创建报警规则的弹框 --> | |
74 | + <a-modal v-model:visible="visible" title="详情" centered> | |
75 | + <a-textarea placeholder="报警详细信息" :rows="4" /> | |
76 | + </a-modal> | |
69 | 77 | |
70 | 78 | <p style="color: #3c3c3c">清除报警规则</p> |
71 | 79 | <template v-for="(item2, index2) in item.removeRule" :key="item2"> |
... | ... | @@ -81,8 +89,9 @@ |
81 | 89 | <EditOutlined class="cursor-pointer ml-4" style="font-size: 20px" |
82 | 90 | /></p> |
83 | 91 | <p class="mt-4 ml-4" |
84 | - >详情:1 <EditOutlined class="cursor-pointer ml-4" style="font-size: 20px" | |
85 | - /></p> | |
92 | + >详情:1 <EditOutlined class="cursor-pointer ml-4" style="font-size: 20px" /> | |
93 | + </p> | |
94 | + | |
86 | 95 | <p class="mt-4 ml-4">Mobile dashboard: <a-select style="width: 150px" /></p> |
87 | 96 | </div> |
88 | 97 | </div> |
... | ... | @@ -98,7 +107,7 @@ |
98 | 107 | </div> |
99 | 108 | </template> |
100 | 109 | <a-button class="mt-5" @click="addRemoveRule(index)" |
101 | - ><PlusCircleOutlined />添加创建条件</a-button | |
110 | + ><PlusCircleOutlined />添加清除条件</a-button | |
102 | 111 | > |
103 | 112 | </CollapseContainer> |
104 | 113 | </template> |
... | ... | @@ -119,6 +128,8 @@ |
119 | 128 | Button, |
120 | 129 | Select, |
121 | 130 | Tooltip, |
131 | + Modal, | |
132 | + Textarea, | |
122 | 133 | } from 'ant-design-vue'; |
123 | 134 | import { |
124 | 135 | DeleteOutlined, |
... | ... | @@ -143,6 +154,8 @@ |
143 | 154 | CollapseContainer, |
144 | 155 | EditOutlined, |
145 | 156 | PlusOutlined, |
157 | + [Modal.name]: Modal, | |
158 | + [Textarea.name]: Textarea, | |
146 | 159 | [Tooltip.name]: Tooltip, |
147 | 160 | [Button.name]: Button, |
148 | 161 | [Input.name]: Input, |
... | ... | @@ -157,6 +170,7 @@ |
157 | 170 | emits: ['prev'], |
158 | 171 | setup(_, { emit }) { |
159 | 172 | const alarmList = ref<alarmListItem[]>([]); |
173 | + const visible = ref(false); | |
160 | 174 | const options = ref([ |
161 | 175 | { |
162 | 176 | value: '1', |
... | ... | @@ -207,7 +221,9 @@ |
207 | 221 | }; |
208 | 222 | // 添加创建条件 |
209 | 223 | const addCreateRole = (index) => { |
210 | - alarmList.value[index].alarmRule.push('1'); | |
224 | + alarmList.value[index].alarmRule.push({ | |
225 | + detail: '', | |
226 | + }); | |
211 | 227 | }; |
212 | 228 | const handleDeleteCondition = (index, index1) => { |
213 | 229 | alarmList.value[index].alarmRule.splice(index1, 1); |
... | ... | @@ -221,10 +237,17 @@ |
221 | 237 | alarmList.value[index].removeRule.splice(index1, 1); |
222 | 238 | }; |
223 | 239 | |
240 | + // 编辑创建规则的详情 | |
241 | + const editCreateDetail = (index, index1) => { | |
242 | + visible.value = true; | |
243 | + console.log(alarmList.value[index].alarmRule[index1].detail); | |
244 | + }; | |
245 | + | |
224 | 246 | return { |
225 | 247 | rules, |
226 | 248 | alarmList, |
227 | 249 | options, |
250 | + visible, | |
228 | 251 | prevStep, |
229 | 252 | addAlarmRule, |
230 | 253 | addCreateRole, |
... | ... | @@ -232,6 +255,7 @@ |
232 | 255 | handleDeleteCondition, |
233 | 256 | addRemoveRule, |
234 | 257 | handleDeleteRemoveCondition, |
258 | + editCreateDetail, | |
235 | 259 | labelCol: { style: { width: '150px' } }, |
236 | 260 | wrapperCol: { span: 18 }, |
237 | 261 | }; | ... | ... |
... | ... | @@ -152,7 +152,9 @@ |
152 | 152 | const selectPosition = () => { |
153 | 153 | visible.value = true; |
154 | 154 | if (!positionState.longitude) { |
155 | - initMap('104.04666605565338', '30.543516387560476'); | |
155 | + positionState.longitude = '104.04666605565338'; | |
156 | + positionState.latitude = '30.543516387560476'; | |
157 | + initMap(positionState.longitude, positionState.latitude); | |
156 | 158 | } else { |
157 | 159 | initMap(positionState.longitude, positionState.latitude); |
158 | 160 | } |
... | ... | @@ -191,7 +193,6 @@ |
191 | 193 | map.enableScrollWheelZoom(true); |
192 | 194 | map.addEventListener('click', (e) => { |
193 | 195 | const { lat, lng } = e.point; |
194 | - console.log(lat, lng); | |
195 | 196 | positionState.latitude = lat + ''; |
196 | 197 | positionState.longitude = lng + ''; |
197 | 198 | let gc = new BMap.Geocoder(); | ... | ... |