Showing
5 changed files
with
112 additions
and
94 deletions
@@ -6,9 +6,11 @@ import type { | @@ -6,9 +6,11 @@ import type { | ||
6 | ContactInfo, | 6 | ContactInfo, |
7 | } from './model/alarmContactModal'; | 7 | } from './model/alarmContactModal'; |
8 | import { getPageData } from '../../base'; | 8 | import { getPageData } from '../../base'; |
9 | -enum Api { | 9 | +import { DeviceModel, DeviceQueryParam } from '../../device/model/deviceModel'; |
10 | +enum API { | ||
10 | alarmContact = '/alarmContact', | 11 | alarmContact = '/alarmContact', |
11 | updateAlarmContact = '/alarmContact/update', | 12 | updateAlarmContact = '/alarmContact/update', |
13 | + devicePage = '/device', | ||
12 | } | 14 | } |
13 | 15 | ||
14 | // 获取 | 16 | // 获取 |
@@ -19,7 +21,7 @@ export const getAlarmContact = (params: ContactPageParams) => { | @@ -19,7 +21,7 @@ export const getAlarmContact = (params: ContactPageParams) => { | ||
19 | // 新增 | 21 | // 新增 |
20 | export const addAlarmContact = (params: ContactParams) => { | 22 | export const addAlarmContact = (params: ContactParams) => { |
21 | return defHttp.post({ | 23 | return defHttp.post({ |
22 | - url: Api.alarmContact, | 24 | + url: API.alarmContact, |
23 | data: params, | 25 | data: params, |
24 | }); | 26 | }); |
25 | }; | 27 | }; |
@@ -27,7 +29,7 @@ export const addAlarmContact = (params: ContactParams) => { | @@ -27,7 +29,7 @@ export const addAlarmContact = (params: ContactParams) => { | ||
27 | // 更新 | 29 | // 更新 |
28 | export const updateAlarmContact = (params: ContactParams) => { | 30 | export const updateAlarmContact = (params: ContactParams) => { |
29 | return defHttp.post({ | 31 | return defHttp.post({ |
30 | - url: Api.updateAlarmContact, | 32 | + url: API.updateAlarmContact, |
31 | data: params, | 33 | data: params, |
32 | }); | 34 | }); |
33 | }; | 35 | }; |
@@ -35,7 +37,7 @@ export const updateAlarmContact = (params: ContactParams) => { | @@ -35,7 +37,7 @@ export const updateAlarmContact = (params: ContactParams) => { | ||
35 | // 删除 | 37 | // 删除 |
36 | export const deleteAlarmContact = (ids: string[]) => { | 38 | export const deleteAlarmContact = (ids: string[]) => { |
37 | return defHttp.delete({ | 39 | return defHttp.delete({ |
38 | - url: Api.alarmContact, | 40 | + url: API.alarmContact, |
39 | data: ids, | 41 | data: ids, |
40 | }); | 42 | }); |
41 | }; | 43 | }; |
@@ -45,3 +47,10 @@ export const saveOrEditAlarmContact = (params: ContactInfo, isUpdate: boolean) = | @@ -45,3 +47,10 @@ export const saveOrEditAlarmContact = (params: ContactInfo, isUpdate: boolean) = | ||
45 | if (isUpdate) return updateAlarmContact(params); | 47 | if (isUpdate) return updateAlarmContact(params); |
46 | addAlarmContact(params); | 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 | import { FormSchema } from '/@/components/Table'; | 3 | import { FormSchema } from '/@/components/Table'; |
2 | export const formSchema: FormSchema[] = [ | 4 | export const formSchema: FormSchema[] = [ |
3 | { | 5 | { |
4 | field: 'organization', | 6 | field: 'organization', |
5 | label: '', | 7 | label: '', |
6 | component: 'TreeSelect', | 8 | component: 'TreeSelect', |
7 | - componentProps: {}, | 9 | + componentProps: { |
10 | + placeholder: '请选择组织', | ||
11 | + }, | ||
8 | }, | 12 | }, |
9 | { | 13 | { |
10 | field: 'organization', | 14 | field: 'organization', |
11 | label: '', | 15 | label: '', |
12 | component: 'Select', | 16 | component: 'Select', |
13 | - componentProps: {}, | 17 | + componentProps: { |
18 | + placeholder: '请选择设备配置', | ||
19 | + }, | ||
14 | }, | 20 | }, |
15 | { | 21 | { |
16 | field: 'device', | 22 | field: 'device', |
17 | label: '', | 23 | label: '', |
18 | - slot: 'device', | ||
19 | component: 'Input', | 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,68 +2,21 @@ | ||
2 | <div class="wrapper"> | 2 | <div class="wrapper"> |
3 | <div ref="wrapRef" :style="{ height, width }"> </div> | 3 | <div ref="wrapRef" :style="{ height, width }"> </div> |
4 | <div class="right-wrap"> | 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 | </div> | 6 | </div> |
49 | </div> | 7 | </div> |
50 | </template> | 8 | </template> |
51 | <script lang="ts"> | 9 | <script lang="ts"> |
52 | import { defineComponent, ref, nextTick, unref, onMounted } from 'vue'; | 10 | import { defineComponent, ref, nextTick, unref, onMounted } from 'vue'; |
53 | import { useScript } from '/@/hooks/web/useScript'; | 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 | export default defineComponent({ | 16 | export default defineComponent({ |
59 | name: 'BaiduMap', | 17 | name: 'BaiduMap', |
60 | components: { | 18 | components: { |
61 | - BasicForm, | ||
62 | - RadioGroup, | ||
63 | - Radio, | ||
64 | - Tag, | ||
65 | - ScrollContainer, | ||
66 | - Pagination, | 19 | + BasicTable, |
67 | }, | 20 | }, |
68 | props: { | 21 | props: { |
69 | width: { | 22 | width: { |
@@ -75,12 +28,10 @@ | @@ -75,12 +28,10 @@ | ||
75 | default: 'calc(100vh - 78px)', | 28 | default: 'calc(100vh - 78px)', |
76 | }, | 29 | }, |
77 | }, | 30 | }, |
78 | - | ||
79 | setup() { | 31 | setup() { |
80 | const BAI_DU_MAP_URL = | 32 | const BAI_DU_MAP_URL = |
81 | 'https://api.map.baidu.com/getscript?v=3.0&ak=7uOPPyAHn2Y2ZryeQqHtcRqtIY374vKa'; | 33 | 'https://api.map.baidu.com/getscript?v=3.0&ak=7uOPPyAHn2Y2ZryeQqHtcRqtIY374vKa'; |
82 | const wrapRef = ref<HTMLDivElement | null>(null); | 34 | const wrapRef = ref<HTMLDivElement | null>(null); |
83 | - const scrollRef = ref<Nullable<ScrollActionType>>(null); | ||
84 | const { toPromise } = useScript({ src: BAI_DU_MAP_URL }); | 35 | const { toPromise } = useScript({ src: BAI_DU_MAP_URL }); |
85 | async function initMap() { | 36 | async function initMap() { |
86 | await toPromise(); | 37 | await toPromise(); |
@@ -96,31 +47,26 @@ | @@ -96,31 +47,26 @@ | ||
96 | onMounted(() => { | 47 | onMounted(() => { |
97 | initMap(); | 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 | return { | 66 | return { |
115 | wrapRef, | 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,15 +81,13 @@ | ||
135 | } | 81 | } |
136 | .right-wrap { | 82 | .right-wrap { |
137 | padding-top: 10px; | 83 | padding-top: 10px; |
138 | - width: 20%; | 84 | + width: 22%; |
139 | height: 80%; | 85 | height: 80%; |
140 | position: absolute; | 86 | position: absolute; |
141 | right: 5%; | 87 | right: 5%; |
142 | top: 10%; | 88 | top: 10%; |
143 | - background-color: #f3f8fe; | ||
144 | } | 89 | } |
145 | .scroll-wrap { | 90 | .scroll-wrap { |
146 | height: 450px; | 91 | height: 450px; |
147 | - background-color: #f3f8fe; | ||
148 | } | 92 | } |
149 | </style> | 93 | </style> |
@@ -24,7 +24,7 @@ | @@ -24,7 +24,7 @@ | ||
24 | </div> | 24 | </div> |
25 | 25 | ||
26 | <a-form :wrapper-col="wrapperCol" labelAlign="left" v-if="item.isPass"> | 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 | <a-input /> | 28 | <a-input /> |
29 | </a-form-item> | 29 | </a-form-item> |
30 | </a-form> | 30 | </a-form> |
@@ -47,7 +47,11 @@ | @@ -47,7 +47,11 @@ | ||
47 | <EditOutlined class="cursor-pointer ml-4" style="font-size: 20px" | 47 | <EditOutlined class="cursor-pointer ml-4" style="font-size: 20px" |
48 | /></p> | 48 | /></p> |
49 | <p class="mt-4 ml-4" | 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 | /></p> | 55 | /></p> |
52 | <p class="mt-4 ml-4">dashboard: <a-select style="width: 180px" /></p> | 56 | <p class="mt-4 ml-4">dashboard: <a-select style="width: 180px" /></p> |
53 | </div> | 57 | </div> |
@@ -66,6 +70,10 @@ | @@ -66,6 +70,10 @@ | ||
66 | <a-button class="mt-5" @click="addCreateRole(index)" | 70 | <a-button class="mt-5" @click="addCreateRole(index)" |
67 | ><PlusCircleOutlined />添加创建条件</a-button | 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 | <p style="color: #3c3c3c">清除报警规则</p> | 78 | <p style="color: #3c3c3c">清除报警规则</p> |
71 | <template v-for="(item2, index2) in item.removeRule" :key="item2"> | 79 | <template v-for="(item2, index2) in item.removeRule" :key="item2"> |
@@ -81,8 +89,9 @@ | @@ -81,8 +89,9 @@ | ||
81 | <EditOutlined class="cursor-pointer ml-4" style="font-size: 20px" | 89 | <EditOutlined class="cursor-pointer ml-4" style="font-size: 20px" |
82 | /></p> | 90 | /></p> |
83 | <p class="mt-4 ml-4" | 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 | <p class="mt-4 ml-4">Mobile dashboard: <a-select style="width: 150px" /></p> | 95 | <p class="mt-4 ml-4">Mobile dashboard: <a-select style="width: 150px" /></p> |
87 | </div> | 96 | </div> |
88 | </div> | 97 | </div> |
@@ -98,7 +107,7 @@ | @@ -98,7 +107,7 @@ | ||
98 | </div> | 107 | </div> |
99 | </template> | 108 | </template> |
100 | <a-button class="mt-5" @click="addRemoveRule(index)" | 109 | <a-button class="mt-5" @click="addRemoveRule(index)" |
101 | - ><PlusCircleOutlined />添加创建条件</a-button | 110 | + ><PlusCircleOutlined />添加清除条件</a-button |
102 | > | 111 | > |
103 | </CollapseContainer> | 112 | </CollapseContainer> |
104 | </template> | 113 | </template> |
@@ -119,6 +128,8 @@ | @@ -119,6 +128,8 @@ | ||
119 | Button, | 128 | Button, |
120 | Select, | 129 | Select, |
121 | Tooltip, | 130 | Tooltip, |
131 | + Modal, | ||
132 | + Textarea, | ||
122 | } from 'ant-design-vue'; | 133 | } from 'ant-design-vue'; |
123 | import { | 134 | import { |
124 | DeleteOutlined, | 135 | DeleteOutlined, |
@@ -143,6 +154,8 @@ | @@ -143,6 +154,8 @@ | ||
143 | CollapseContainer, | 154 | CollapseContainer, |
144 | EditOutlined, | 155 | EditOutlined, |
145 | PlusOutlined, | 156 | PlusOutlined, |
157 | + [Modal.name]: Modal, | ||
158 | + [Textarea.name]: Textarea, | ||
146 | [Tooltip.name]: Tooltip, | 159 | [Tooltip.name]: Tooltip, |
147 | [Button.name]: Button, | 160 | [Button.name]: Button, |
148 | [Input.name]: Input, | 161 | [Input.name]: Input, |
@@ -157,6 +170,7 @@ | @@ -157,6 +170,7 @@ | ||
157 | emits: ['prev'], | 170 | emits: ['prev'], |
158 | setup(_, { emit }) { | 171 | setup(_, { emit }) { |
159 | const alarmList = ref<alarmListItem[]>([]); | 172 | const alarmList = ref<alarmListItem[]>([]); |
173 | + const visible = ref(false); | ||
160 | const options = ref([ | 174 | const options = ref([ |
161 | { | 175 | { |
162 | value: '1', | 176 | value: '1', |
@@ -207,7 +221,9 @@ | @@ -207,7 +221,9 @@ | ||
207 | }; | 221 | }; |
208 | // 添加创建条件 | 222 | // 添加创建条件 |
209 | const addCreateRole = (index) => { | 223 | const addCreateRole = (index) => { |
210 | - alarmList.value[index].alarmRule.push('1'); | 224 | + alarmList.value[index].alarmRule.push({ |
225 | + detail: '', | ||
226 | + }); | ||
211 | }; | 227 | }; |
212 | const handleDeleteCondition = (index, index1) => { | 228 | const handleDeleteCondition = (index, index1) => { |
213 | alarmList.value[index].alarmRule.splice(index1, 1); | 229 | alarmList.value[index].alarmRule.splice(index1, 1); |
@@ -221,10 +237,17 @@ | @@ -221,10 +237,17 @@ | ||
221 | alarmList.value[index].removeRule.splice(index1, 1); | 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 | return { | 246 | return { |
225 | rules, | 247 | rules, |
226 | alarmList, | 248 | alarmList, |
227 | options, | 249 | options, |
250 | + visible, | ||
228 | prevStep, | 251 | prevStep, |
229 | addAlarmRule, | 252 | addAlarmRule, |
230 | addCreateRole, | 253 | addCreateRole, |
@@ -232,6 +255,7 @@ | @@ -232,6 +255,7 @@ | ||
232 | handleDeleteCondition, | 255 | handleDeleteCondition, |
233 | addRemoveRule, | 256 | addRemoveRule, |
234 | handleDeleteRemoveCondition, | 257 | handleDeleteRemoveCondition, |
258 | + editCreateDetail, | ||
235 | labelCol: { style: { width: '150px' } }, | 259 | labelCol: { style: { width: '150px' } }, |
236 | wrapperCol: { span: 18 }, | 260 | wrapperCol: { span: 18 }, |
237 | }; | 261 | }; |
@@ -152,7 +152,9 @@ | @@ -152,7 +152,9 @@ | ||
152 | const selectPosition = () => { | 152 | const selectPosition = () => { |
153 | visible.value = true; | 153 | visible.value = true; |
154 | if (!positionState.longitude) { | 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 | } else { | 158 | } else { |
157 | initMap(positionState.longitude, positionState.latitude); | 159 | initMap(positionState.longitude, positionState.latitude); |
158 | } | 160 | } |
@@ -191,7 +193,6 @@ | @@ -191,7 +193,6 @@ | ||
191 | map.enableScrollWheelZoom(true); | 193 | map.enableScrollWheelZoom(true); |
192 | map.addEventListener('click', (e) => { | 194 | map.addEventListener('click', (e) => { |
193 | const { lat, lng } = e.point; | 195 | const { lat, lng } = e.point; |
194 | - console.log(lat, lng); | ||
195 | positionState.latitude = lat + ''; | 196 | positionState.latitude = lat + ''; |
196 | positionState.longitude = lng + ''; | 197 | positionState.longitude = lng + ''; |
197 | let gc = new BMap.Geocoder(); | 198 | let gc = new BMap.Geocoder(); |