|
1
|
1
|
<script lang="ts" setup>
|
|
2
|
2
|
import { Button, PageHeader, Empty, Spin, Tooltip } from 'ant-design-vue';
|
|
3
|
|
- import { LineChartOutlined } from '@ant-design/icons-vue';
|
|
|
3
|
+ import { LineChartOutlined, RollbackOutlined } from '@ant-design/icons-vue';
|
|
4
|
4
|
import { GridItem, GridLayout } from 'vue3-grid-layout';
|
|
5
|
5
|
import { nextTick, onMounted, ref } from 'vue';
|
|
6
|
6
|
import WidgetWrapper from '../components/WidgetWrapper/WidgetWrapper.vue';
|
|
...
|
...
|
@@ -8,11 +8,17 @@ |
|
8
|
8
|
import { DropMenu } from '/@/components/Dropdown';
|
|
9
|
9
|
import DataBindModal from './components/DataBindModal.vue';
|
|
10
|
10
|
import { useModal } from '/@/components/Modal';
|
|
11
|
|
- import { DEFAULT_WIDGET_HEIGHT, DEFAULT_WIDGET_WIDTH, MoreActionEvent } from '../config/config';
|
|
|
11
|
+ import {
|
|
|
12
|
+ DEFAULT_WIDGET_HEIGHT,
|
|
|
13
|
+ DEFAULT_WIDGET_WIDTH,
|
|
|
14
|
+ isBataBoardSharePage,
|
|
|
15
|
+ MoreActionEvent,
|
|
|
16
|
+ } from '../config/config';
|
|
12
|
17
|
import {
|
|
13
|
18
|
addDataComponent,
|
|
14
|
19
|
deleteDataComponent,
|
|
15
|
20
|
getDataComponent,
|
|
|
21
|
+ getShareBoardComponentInfo,
|
|
16
|
22
|
updateDataBoardLayout,
|
|
17
|
23
|
} from '/@/api/dataBoard';
|
|
18
|
24
|
import { useRoute, useRouter } from 'vue-router';
|
|
...
|
...
|
@@ -33,21 +39,32 @@ |
|
33
|
39
|
const ROUTER = useRouter();
|
|
34
|
40
|
|
|
35
|
41
|
const { createMessage, createConfirm } = useMessage();
|
|
|
42
|
+
|
|
36
|
43
|
const getBoardId = computed(() => {
|
|
37
|
44
|
return (ROUTE.params as { id: string }).id;
|
|
38
|
45
|
});
|
|
39
|
46
|
|
|
|
47
|
+ const getSharePageParams = computed(() => {
|
|
|
48
|
+ const { boardId, tenantId } = ROUTE.params as { boardId: string; tenantId: string };
|
|
|
49
|
+ return { boardId, tenantId };
|
|
|
50
|
+ });
|
|
|
51
|
+
|
|
|
52
|
+ const getIsSharePage = computed(() => {
|
|
|
53
|
+ return isBataBoardSharePage(ROUTE.path);
|
|
|
54
|
+ });
|
|
|
55
|
+
|
|
40
|
56
|
const widgetEl = new Map<string, Fn>();
|
|
41
|
57
|
|
|
42
|
58
|
const dataBoardList = ref<DataBoardLayoutInfo[]>([]);
|
|
43
|
59
|
|
|
44
|
|
- const draggable = ref(true);
|
|
45
|
|
- const resizable = ref(true);
|
|
|
60
|
+ const draggable = ref(!unref(getIsSharePage));
|
|
|
61
|
+ const resizable = ref(!unref(getIsSharePage));
|
|
46
|
62
|
|
|
47
|
63
|
const GirdLayoutColNum = 24;
|
|
48
|
64
|
const GridLayoutMargin = 10;
|
|
49
|
65
|
|
|
50
|
66
|
const handleBack = () => {
|
|
|
67
|
+ if (unref(getIsSharePage)) return;
|
|
51
|
68
|
ROUTER.go(-1);
|
|
52
|
69
|
};
|
|
53
|
70
|
|
|
...
|
...
|
@@ -168,12 +185,36 @@ |
|
168
|
185
|
|
|
169
|
186
|
const { beginSendMessage } = useSocketConnect(dataBoardList);
|
|
170
|
187
|
|
|
|
188
|
+ const getBasePageComponentData = async () => {
|
|
|
189
|
+ try {
|
|
|
190
|
+ return await getDataComponent(unref(getBoardId));
|
|
|
191
|
+ } catch (error) {}
|
|
|
192
|
+ return [];
|
|
|
193
|
+ };
|
|
|
194
|
+
|
|
|
195
|
+ const getSharePageComponentData = async () => {
|
|
|
196
|
+ try {
|
|
|
197
|
+ const params = unref(getSharePageParams);
|
|
|
198
|
+ return await getShareBoardComponentInfo(params);
|
|
|
199
|
+ } catch (error) {}
|
|
|
200
|
+ return [];
|
|
|
201
|
+ };
|
|
|
202
|
+
|
|
|
203
|
+ const getDataBoradDetail = async () => {
|
|
|
204
|
+ try {
|
|
|
205
|
+ return unref(getIsSharePage)
|
|
|
206
|
+ ? await getSharePageComponentData()
|
|
|
207
|
+ : await getBasePageComponentData();
|
|
|
208
|
+ } catch (error) {}
|
|
|
209
|
+ return [];
|
|
|
210
|
+ };
|
|
|
211
|
+
|
|
171
|
212
|
const loading = ref(false);
|
|
172
|
213
|
const getDataBoardComponent = async () => {
|
|
173
|
214
|
try {
|
|
174
|
215
|
// dataBoardList.value = [];
|
|
175
|
216
|
loading.value = true;
|
|
176
|
|
- const data = await getDataComponent(unref(getBoardId));
|
|
|
217
|
+ const data = await getDataBoradDetail();
|
|
177
|
218
|
dataBoardList.value = data.data.componentData.map((item) => {
|
|
178
|
219
|
const index = data.data.componentLayout.findIndex((each) => item.id === each.id);
|
|
179
|
220
|
let layout;
|
|
...
|
...
|
@@ -258,10 +299,18 @@ |
|
258
|
299
|
|
|
259
|
300
|
<template>
|
|
260
|
301
|
<section class="bg-light-50 flex flex-col overflow-hidden h-full w-full">
|
|
261
|
|
- <PageHeader title="水电表看板" @back="handleBack">
|
|
|
302
|
+ <PageHeader>
|
|
|
303
|
+ <template #title>
|
|
|
304
|
+ <div class="flex items-center">
|
|
|
305
|
+ <RollbackOutlined v-if="!getIsSharePage" class="mr-3" @click="handleBack" />
|
|
|
306
|
+ <span>看板名称</span>
|
|
|
307
|
+ </div>
|
|
|
308
|
+ </template>
|
|
262
|
309
|
<template #extra>
|
|
263
|
310
|
<Authority value="api:yt:dataBoardDetail:post">
|
|
264
|
|
- <Button type="primary" @click="handleOpenCreatePanel">创建组件</Button>
|
|
|
311
|
+ <Button v-if="!getIsSharePage" type="primary" @click="handleOpenCreatePanel"
|
|
|
312
|
+ >创建组件</Button
|
|
|
313
|
+ >
|
|
265
|
314
|
</Authority>
|
|
266
|
315
|
</template>
|
|
267
|
316
|
<div>
|
|
...
|
...
|
@@ -313,6 +362,7 @@ |
|
313
|
362
|
<template #moreAction>
|
|
314
|
363
|
<Tooltip title="趋势">
|
|
315
|
364
|
<LineChartOutlined
|
|
|
365
|
+ v-if="!getIsSharePage"
|
|
316
|
366
|
class="cursor-pointer mx-1"
|
|
317
|
367
|
@click="handleOpenHistroyDataModal(item.record.dataSource)"
|
|
318
|
368
|
/>
|
...
|
...
|
|