Commit dcd325058583c6ada1b3ddfee8eb96e54aecb4da
1 parent
00889916
feat: basic implement share data borad page
Showing
7 changed files
with
101 additions
and
11 deletions
| @@ -27,6 +27,10 @@ enum DataComponentUrl { | @@ -27,6 +27,10 @@ enum DataComponentUrl { | ||
| 27 | UPDATE_DATA_COMPONENT = '/data_component', | 27 | UPDATE_DATA_COMPONENT = '/data_component', |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | +enum DataBoardShareUrl { | ||
| 31 | + GET_DATA_COMPONENT = '/noauth/share/dataBoard', | ||
| 32 | +} | ||
| 33 | + | ||
| 30 | enum DeviceUrl { | 34 | enum DeviceUrl { |
| 31 | GET_DEVICE = '/device/list/master', | 35 | GET_DEVICE = '/device/list/master', |
| 32 | GET_SLAVE_DEVICE = '/device/list/slave', | 36 | GET_SLAVE_DEVICE = '/device/list/slave', |
| @@ -141,6 +145,18 @@ export const updateDataComponent = (params: UpdateDataComponentParams) => { | @@ -141,6 +145,18 @@ export const updateDataComponent = (params: UpdateDataComponentParams) => { | ||
| 141 | }; | 145 | }; |
| 142 | 146 | ||
| 143 | /** | 147 | /** |
| 148 | + * @description 分享组件信息 | ||
| 149 | + * @param params | ||
| 150 | + * @returns | ||
| 151 | + */ | ||
| 152 | +export const getShareBoardComponentInfo = (params: { boardId: string; tenantId: string }) => { | ||
| 153 | + const { boardId, tenantId } = params; | ||
| 154 | + return defHttp.get({ | ||
| 155 | + url: `${DataBoardShareUrl.GET_DATA_COMPONENT}/${boardId}/${tenantId}`, | ||
| 156 | + }); | ||
| 157 | +}; | ||
| 158 | + | ||
| 159 | +/** | ||
| 144 | * @description 获取所有主设备 | 160 | * @description 获取所有主设备 |
| 145 | * @param params | 161 | * @param params |
| 146 | * @returns | 162 | * @returns |
| @@ -6,6 +6,7 @@ import { | @@ -6,6 +6,7 @@ import { | ||
| 6 | EXCEPTION_COMPONENT, | 6 | EXCEPTION_COMPONENT, |
| 7 | PAGE_NOT_FOUND_NAME, | 7 | PAGE_NOT_FOUND_NAME, |
| 8 | } from '/@/router/constant'; | 8 | } from '/@/router/constant'; |
| 9 | +import { DATA_BOARD_SHARE_URL } from '/@/views/data/board/config/config'; | ||
| 9 | 10 | ||
| 10 | // 404 on a page | 11 | // 404 on a page |
| 11 | export const PAGE_NOT_FOUND_ROUTE: AppRouteRecordRaw = { | 12 | export const PAGE_NOT_FOUND_ROUTE: AppRouteRecordRaw = { |
| @@ -76,3 +77,13 @@ export const ERROR_LOG_ROUTE: AppRouteRecordRaw = { | @@ -76,3 +77,13 @@ export const ERROR_LOG_ROUTE: AppRouteRecordRaw = { | ||
| 76 | }, | 77 | }, |
| 77 | ], | 78 | ], |
| 78 | }; | 79 | }; |
| 80 | + | ||
| 81 | +export const DATA_BOARD_SHARE: AppRouteRecordRaw = { | ||
| 82 | + path: DATA_BOARD_SHARE_URL(), | ||
| 83 | + name: 'dataBoardSharePage', | ||
| 84 | + component: () => import('/@/views/data/board/detail/index.vue'), | ||
| 85 | + meta: { | ||
| 86 | + ignoreAuth: true, | ||
| 87 | + title: '分享看板', | ||
| 88 | + }, | ||
| 89 | +}; |
| 1 | import type { AppRouteRecordRaw, AppRouteModule } from '/@/router/types'; | 1 | import type { AppRouteRecordRaw, AppRouteModule } from '/@/router/types'; |
| 2 | -import { PAGE_NOT_FOUND_ROUTE, REDIRECT_ROUTE } from '/@/router/routes/basic'; | 2 | +import { DATA_BOARD_SHARE, PAGE_NOT_FOUND_ROUTE, REDIRECT_ROUTE } from '/@/router/routes/basic'; |
| 3 | import { mainOutRoutes } from './mainOut'; | 3 | import { mainOutRoutes } from './mainOut'; |
| 4 | import { PageEnum } from '/@/enums/pageEnum'; | 4 | import { PageEnum } from '/@/enums/pageEnum'; |
| 5 | import { t } from '/@/hooks/web/useI18n'; | 5 | import { t } from '/@/hooks/web/useI18n'; |
| @@ -85,4 +85,5 @@ export const basicRoutes = [ | @@ -85,4 +85,5 @@ export const basicRoutes = [ | ||
| 85 | ...mainOutRoutes, | 85 | ...mainOutRoutes, |
| 86 | REDIRECT_ROUTE, | 86 | REDIRECT_ROUTE, |
| 87 | PAGE_NOT_FOUND_ROUTE, | 87 | PAGE_NOT_FOUND_ROUTE, |
| 88 | + DATA_BOARD_SHARE, | ||
| 88 | ]; | 89 | ]; |
| @@ -8,3 +8,11 @@ export enum MoreActionEvent { | @@ -8,3 +8,11 @@ export enum MoreActionEvent { | ||
| 8 | 8 | ||
| 9 | export const DEFAULT_WIDGET_WIDTH = 6; | 9 | export const DEFAULT_WIDGET_WIDTH = 6; |
| 10 | export const DEFAULT_WIDGET_HEIGHT = 6; | 10 | export const DEFAULT_WIDGET_HEIGHT = 6; |
| 11 | + | ||
| 12 | +export const DATA_BOARD_SHARE_URL = (boardId = ':boardId', tenantId = ':tenantId') => | ||
| 13 | + `/data/board/share/${boardId}/${tenantId}`; | ||
| 14 | + | ||
| 15 | +export const isBataBoardSharePage = (url: string) => { | ||
| 16 | + const reg = /^\/data\/board\/share/g; | ||
| 17 | + return reg.test(url); | ||
| 18 | +}; |
| 1 | <script lang="ts" setup> | 1 | <script lang="ts" setup> |
| 2 | import { Button, PageHeader, Empty, Spin, Tooltip } from 'ant-design-vue'; | 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 | import { GridItem, GridLayout } from 'vue3-grid-layout'; | 4 | import { GridItem, GridLayout } from 'vue3-grid-layout'; |
| 5 | import { nextTick, onMounted, ref } from 'vue'; | 5 | import { nextTick, onMounted, ref } from 'vue'; |
| 6 | import WidgetWrapper from '../components/WidgetWrapper/WidgetWrapper.vue'; | 6 | import WidgetWrapper from '../components/WidgetWrapper/WidgetWrapper.vue'; |
| @@ -8,11 +8,17 @@ | @@ -8,11 +8,17 @@ | ||
| 8 | import { DropMenu } from '/@/components/Dropdown'; | 8 | import { DropMenu } from '/@/components/Dropdown'; |
| 9 | import DataBindModal from './components/DataBindModal.vue'; | 9 | import DataBindModal from './components/DataBindModal.vue'; |
| 10 | import { useModal } from '/@/components/Modal'; | 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 | import { | 17 | import { |
| 13 | addDataComponent, | 18 | addDataComponent, |
| 14 | deleteDataComponent, | 19 | deleteDataComponent, |
| 15 | getDataComponent, | 20 | getDataComponent, |
| 21 | + getShareBoardComponentInfo, | ||
| 16 | updateDataBoardLayout, | 22 | updateDataBoardLayout, |
| 17 | } from '/@/api/dataBoard'; | 23 | } from '/@/api/dataBoard'; |
| 18 | import { useRoute, useRouter } from 'vue-router'; | 24 | import { useRoute, useRouter } from 'vue-router'; |
| @@ -33,21 +39,32 @@ | @@ -33,21 +39,32 @@ | ||
| 33 | const ROUTER = useRouter(); | 39 | const ROUTER = useRouter(); |
| 34 | 40 | ||
| 35 | const { createMessage, createConfirm } = useMessage(); | 41 | const { createMessage, createConfirm } = useMessage(); |
| 42 | + | ||
| 36 | const getBoardId = computed(() => { | 43 | const getBoardId = computed(() => { |
| 37 | return (ROUTE.params as { id: string }).id; | 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 | const widgetEl = new Map<string, Fn>(); | 56 | const widgetEl = new Map<string, Fn>(); |
| 41 | 57 | ||
| 42 | const dataBoardList = ref<DataBoardLayoutInfo[]>([]); | 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 | const GirdLayoutColNum = 24; | 63 | const GirdLayoutColNum = 24; |
| 48 | const GridLayoutMargin = 10; | 64 | const GridLayoutMargin = 10; |
| 49 | 65 | ||
| 50 | const handleBack = () => { | 66 | const handleBack = () => { |
| 67 | + if (unref(getIsSharePage)) return; | ||
| 51 | ROUTER.go(-1); | 68 | ROUTER.go(-1); |
| 52 | }; | 69 | }; |
| 53 | 70 | ||
| @@ -168,12 +185,36 @@ | @@ -168,12 +185,36 @@ | ||
| 168 | 185 | ||
| 169 | const { beginSendMessage } = useSocketConnect(dataBoardList); | 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 | const loading = ref(false); | 212 | const loading = ref(false); |
| 172 | const getDataBoardComponent = async () => { | 213 | const getDataBoardComponent = async () => { |
| 173 | try { | 214 | try { |
| 174 | // dataBoardList.value = []; | 215 | // dataBoardList.value = []; |
| 175 | loading.value = true; | 216 | loading.value = true; |
| 176 | - const data = await getDataComponent(unref(getBoardId)); | 217 | + const data = await getDataBoradDetail(); |
| 177 | dataBoardList.value = data.data.componentData.map((item) => { | 218 | dataBoardList.value = data.data.componentData.map((item) => { |
| 178 | const index = data.data.componentLayout.findIndex((each) => item.id === each.id); | 219 | const index = data.data.componentLayout.findIndex((each) => item.id === each.id); |
| 179 | let layout; | 220 | let layout; |
| @@ -258,10 +299,18 @@ | @@ -258,10 +299,18 @@ | ||
| 258 | 299 | ||
| 259 | <template> | 300 | <template> |
| 260 | <section class="bg-light-50 flex flex-col overflow-hidden h-full w-full"> | 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 | <template #extra> | 309 | <template #extra> |
| 263 | <Authority value="api:yt:dataBoardDetail:post"> | 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 | </Authority> | 314 | </Authority> |
| 266 | </template> | 315 | </template> |
| 267 | <div> | 316 | <div> |
| @@ -313,6 +362,7 @@ | @@ -313,6 +362,7 @@ | ||
| 313 | <template #moreAction> | 362 | <template #moreAction> |
| 314 | <Tooltip title="趋势"> | 363 | <Tooltip title="趋势"> |
| 315 | <LineChartOutlined | 364 | <LineChartOutlined |
| 365 | + v-if="!getIsSharePage" | ||
| 316 | class="cursor-pointer mx-1" | 366 | class="cursor-pointer mx-1" |
| 317 | @click="handleOpenHistroyDataModal(item.record.dataSource)" | 367 | @click="handleOpenHistroyDataModal(item.record.dataSource)" |
| 318 | /> | 368 | /> |
| @@ -100,7 +100,6 @@ export function useSocketConnect(dataSourceRef: Ref<DataBoardLayoutInfo[]>) { | @@ -100,7 +100,6 @@ export function useSocketConnect(dataSourceRef: Ref<DataBoardLayoutInfo[]>) { | ||
| 100 | const transformSocketMessageItem = () => { | 100 | const transformSocketMessageItem = () => { |
| 101 | const messageList: SocketMessageItem[] = []; | 101 | const messageList: SocketMessageItem[] = []; |
| 102 | let index = 0; | 102 | let index = 0; |
| 103 | - console.log(unref(dataSourceRef)); | ||
| 104 | unref(dataSourceRef).forEach((record, recordIndex) => { | 103 | unref(dataSourceRef).forEach((record, recordIndex) => { |
| 105 | const componentId = record.record.id; | 104 | const componentId = record.record.id; |
| 106 | record.record.dataSource.forEach((dataSource, dataSourceIndex) => { | 105 | record.record.dataSource.forEach((dataSource, dataSourceIndex) => { |
| @@ -7,7 +7,7 @@ | @@ -7,7 +7,7 @@ | ||
| 7 | import { useMessage } from '/@/hooks/web/useMessage'; | 7 | import { useMessage } from '/@/hooks/web/useMessage'; |
| 8 | import Dropdown from '/@/components/Dropdown/src/Dropdown.vue'; | 8 | import Dropdown from '/@/components/Dropdown/src/Dropdown.vue'; |
| 9 | import { DropMenu } from '/@/components/Dropdown'; | 9 | import { DropMenu } from '/@/components/Dropdown'; |
| 10 | - import { MoreActionEvent } from './config/config'; | 10 | + import { DATA_BOARD_SHARE_URL, MoreActionEvent } from './config/config'; |
| 11 | import { useModal } from '/@/components/Modal'; | 11 | import { useModal } from '/@/components/Modal'; |
| 12 | import PanelDetailModal from './components/PanelDetailModal.vue'; | 12 | import PanelDetailModal from './components/PanelDetailModal.vue'; |
| 13 | import { getDataBoardList, deleteDataBoard } from '/@/api/dataBoard'; | 13 | import { getDataBoardList, deleteDataBoard } from '/@/api/dataBoard'; |
| @@ -50,9 +50,14 @@ | @@ -50,9 +50,14 @@ | ||
| 50 | pageSize.value = size; | 50 | pageSize.value = size; |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | + const createShareUrl = (boardId: string, tenantId: string) => { | ||
| 54 | + const { origin } = location; | ||
| 55 | + return `${origin}${DATA_BOARD_SHARE_URL(boardId, tenantId)}`; | ||
| 56 | + }; | ||
| 57 | + | ||
| 53 | const { clipboardRef } = useCopyToClipboard(); | 58 | const { clipboardRef } = useCopyToClipboard(); |
| 54 | const handleCopyShareUrl = (record: DataBoardRecord) => { | 59 | const handleCopyShareUrl = (record: DataBoardRecord) => { |
| 55 | - clipboardRef.value = record.openUrl; | 60 | + clipboardRef.value = createShareUrl(record.id, record.tenantId); |
| 56 | unref(clipboardRef) ? createMessage.success('复制成功') : createMessage.error('未找到分享链接'); | 61 | unref(clipboardRef) ? createMessage.success('复制成功') : createMessage.error('未找到分享链接'); |
| 57 | }; | 62 | }; |
| 58 | 63 |