From 8572e2e0c1655f1cf2a71da6b80ce132cbf545e6 Mon Sep 17 00:00:00 2001 From: gerson <1405270578@qq.com> Date: 星期日, 09 二月 2025 21:13:14 +0800 Subject: [PATCH] 主题设置问题 --- src/components/chat/chatComponents/summaryCom/components/deviceLastValue/DeviceLastValueCom.vue | 69 ++++++++++++++++++++++++++-------- 1 files changed, 52 insertions(+), 17 deletions(-) diff --git a/src/components/chat/chatComponents/summaryCom/components/deviceLastValue/DeviceLastValueCom.vue b/src/components/chat/chatComponents/summaryCom/components/deviceLastValue/DeviceLastValueCom.vue index 088955c..7bb398f 100644 --- a/src/components/chat/chatComponents/summaryCom/components/deviceLastValue/DeviceLastValueCom.vue +++ b/src/components/chat/chatComponents/summaryCom/components/deviceLastValue/DeviceLastValueCom.vue @@ -1,4 +1,5 @@ <template> + <!-- 瀹炴椂鐩戞祴鍒楄〃 --> <div ref="containerRef" class="w-full flex justify-center" v-resize="resizeHandler"> <div class="inline-block"> <div @@ -8,6 +9,9 @@ backgroundColor: BORDER_COLOR, }" > + <div class="flex-center font-bold text-base bg-[#8db4e2]" :style="{ height: `${CELL_HEIGHT}px` }"> + {{ data.title }} + </div> <div v-for="(rowChunk, index) in currentRowChunkList" :key="index" @@ -49,7 +53,9 @@ :restColWidth="restColWidth" :title="firstRow.title" :type="firstRow.id" + :row="firstRow" :values="rowChunk" + @itemClick="valueClick" /> </div> <!-- 鍓╀綑琛� --> @@ -60,7 +66,9 @@ :restColWidth="restColWidth" :title="row.title" :type="row.id" + :row="row" :values="rowChunk" + @itemClick="valueClick" /> </div> </div> @@ -75,16 +83,18 @@ @current-change="handleCurrentChange" /> </div> + <RecordSetDialog v-model="chartDlgIsShow" :lastValueItem="chartDlgMapRow" :metricsInfo="chartDlgMapMetricsInfo"/> </div> </template> <script setup lang="ts"> -import _ from 'lodash'; -import { computed, onActivated, onMounted, ref } from 'vue'; +import { computed, onMounted, ref } from 'vue'; import MonitorContent from './MonitorContent.vue'; import { debounce, getTextWidth } from '/@/utils/util'; +import { chunk, fill } from 'lodash-es'; import { chatComProps } from '../../../common'; +import RecordSetDialog from '../recordSet/RecordSetDialog.vue'; import { BORDER_COLOR, CELL_HEIGHT, @@ -97,10 +107,19 @@ THIN_BORDER_WIDTH, } from './constants'; import type { Monitor, MonitorValue } from './types'; +import { isSharePage } from '/@/stores/chatRoom'; const props = defineProps(chatComProps) as { data: Monitor; }; +if (!props.data?.rows || props.data?.rows?.length === 0) { + // 涓虹┖鏃讹紝闅忎究鍔犱竴鍒楋紝闃叉鍑虹幇 height 閫愭笎鍙樼煭鐨勯棶棰� + props.data.rows.push({ + id: 'aaaaa', + title: '', + }); +} + const total = props.data?.values?.length ?? 0; const pageIndex = ref(null); const pageSize = ref(null); @@ -121,7 +140,7 @@ } } let maxWidth = getTextWidth(maxTitle, { - size: '0.875rem', + // size: '0.875rem', }); maxWidth += measureWidthOffset; @@ -147,7 +166,7 @@ } let maxWidth = getTextWidth(maxTitle, { - size: '0.875rem', + // size: '0.875rem', }); maxWidth += measureWidthOffset; @@ -162,12 +181,15 @@ const restColWidth = ref(colHeaderCellContentWidth.value); const calcMaxRowsNum = (groupCount: number, height, extraHeight = 0) => { return Math.floor( - (height - THICK_BORDER_WIDTH - extraHeight) / + (height - 2 * THICK_BORDER_WIDTH - CELL_HEIGHT - extraHeight) / (CELL_HEIGHT * groupCount + 2 * THICK_BORDER_WIDTH + THIN_BORDER_WIDTH * (groupCount - 2)) ); }; let maxColsNum = ref<number>(null); const resizeEvent = ({ width, height }) => { + if (width === 0 || height === 0) { + return; + } // 鎸夋渶澶у搴︾畻鏈�澶у垪鏁� maxColsNum.value = Math.floor( (width - THICK_BORDER_WIDTH + colHeaderCellContentWidth.value - rowHeaderCellContentWidth.value) / @@ -208,7 +230,11 @@ const isNeedPage = maxColsRowsNum > rowsNum; rowsNum = isNeedPage ? calcMaxRowsNum(groupCount, height, PAGE_HEIGHT) : maxColsRowsNum; // rowsNum 琛岋紝maxColsNum鍒楋紝绗竴鍒椾笉绠� - pageSize.value = isNeedPage ? rowsNum * (maxColsNum.value - 1) : total; + pageSize.value = isNeedPage + ? rowsNum * (maxColsNum.value - 1) + : total % (maxColsNum.value - 1) === 0 + ? total + : (Math.floor(total / (maxColsNum.value - 1)) + 1) * (maxColsNum.value - 1); pageIndex.value = 1; // isNeedPage 鏄惁鍒嗛〉锛宺owsNum 琛屾暟锛宮axColsNum 鍒楁暟锛� }; @@ -219,11 +245,11 @@ const firstRow = computed(() => props.data?.rows?.[0]); const restRows = computed(() => props.data?.rows?.slice(1)); const pageChunkList = computed(() => { - const chunkResult = _.chunk(props.data.values ?? [], pageSize.value); + const chunkResult = chunk(props.data.values ?? [], pageSize.value); const last = chunkResult.at(-1); if (last) { const restNum = pageSize.value - last.length; - const emptyData = _.fill(Array(restNum), { + const emptyData = fill(Array(restNum), { ONAME: '', OTIME: '', OTITLE: '', @@ -245,9 +271,25 @@ const currentRowChunkList = computed(() => { if (!currentPageChunk.value || currentPageChunk.value.length === 0) return []; - const chunkResult = _.chunk(currentPageChunk.value, maxColsNum.value - 1); + const chunkResult = chunk(currentPageChunk.value, maxColsNum.value - 1); return chunkResult; }); + +//#region ====================== 鐐瑰嚮鐪嬫洸绾� ====================== + +const chartDlgIsShow = ref(false); +const chartDlgMapRow = ref(null); +const chartDlgMapMetricsInfo = ref(null); +const valueClick = (item,row) => { + if (isSharePage.value) return; + if(!row.query_detail_id){ + return; + } + chartDlgMapRow.value = item; + chartDlgIsShow.value = true; + chartDlgMapMetricsInfo.value = row; +}; +//#endregion // 璁$畻鏈�澶у垪鏁� // (x-1)* cellWidth + rowHeaderCellContentWidth.value+thickBorderWidth*(x-1)+thickBorderWidth*2 <= width; @@ -258,7 +300,7 @@ // const groupCount = (TEST_DATA?.rows?.length ?? 0) + 1; // 璁$畻鏈�澶ц鏁� // y * (cellHeight * groupCount) + -// (y - 1) * (2 * thickBorderWidth) + +// (y - 1) * (2 * thickBorderWidth) +cellHeight+thickBorderWidth // thickBorderWidth + // thickBorderWidth * 2 + // y * (groupCount - 2) * thinBorderWidth <= @@ -269,13 +311,6 @@ // y<= (height-thickBorderWidth)/(cellHeight * groupCount + 2 * thickBorderWidth + thinBorderWidth(groupCount - 2) ) onMounted(() => { - resizeEvent({ - width: containerRef.value.clientWidth, - height: 0.7 * document.body.clientHeight, - }); -}); - -onActivated(() => { resizeEvent({ width: containerRef.value.clientWidth, height: 0.7 * document.body.clientHeight, -- Gitblit v1.9.3