From 627cb088cf3579fa4b2e1e0e47ecc9fbef1b4184 Mon Sep 17 00:00:00 2001 From: fyy <2717885210@qq.com> Date: Fri, 11 Jul 2025 15:45:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=A4=A7=E5=B1=8Frem?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=BD=B1=E5=93=8D=E5=85=A8=E5=B1=80bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web-antd/src/main.ts | 1 - apps/web-antd/src/utils/flexible.ts | 12 --- apps/web-antd/src/utils/useFlexibleRem.ts | 29 ++++++ .../inspectionTask/data.ts | 90 ++++++++++--------- .../inspectionTask/index.vue | 1 + .../screen/digitalIntelligence/index.vue | 3 +- .../energyConsumptionAnalysis/index.vue | 3 +- .../src/views/screen/monitor/index.vue | 3 +- .../views/screen/navigation/Navigation.vue | 3 +- .../src/views/screen/property/index.vue | 3 +- .../src/views/screen/security/index.vue | 3 +- 11 files changed, 88 insertions(+), 63 deletions(-) delete mode 100644 apps/web-antd/src/utils/flexible.ts create mode 100644 apps/web-antd/src/utils/useFlexibleRem.ts diff --git a/apps/web-antd/src/main.ts b/apps/web-antd/src/main.ts index dd4b82e7..f58a0b98 100644 --- a/apps/web-antd/src/main.ts +++ b/apps/web-antd/src/main.ts @@ -1,7 +1,6 @@ import { initPreferences } from '@vben/preferences'; import { unmountGlobalLoading } from '@vben/utils'; import { overridesPreferences } from './preferences'; -import './utils/flexible' /** * 应用初始化完成之后再进行页面加载渲染 */ diff --git a/apps/web-antd/src/utils/flexible.ts b/apps/web-antd/src/utils/flexible.ts deleted file mode 100644 index 5040a06c..00000000 --- a/apps/web-antd/src/utils/flexible.ts +++ /dev/null @@ -1,12 +0,0 @@ -function setRootFontSize(): void { - const baseWidth = 1920 // 设计稿宽度 - const baseFontSize = 16 // 设计稿根字体 - const screenWidth = window.innerWidth - const fontSize = (screenWidth / baseWidth) * baseFontSize - document.documentElement.style.fontSize = fontSize + 'px' -} - -setRootFontSize() -window.addEventListener('resize', setRootFontSize) - -export default setRootFontSize \ No newline at end of file diff --git a/apps/web-antd/src/utils/useFlexibleRem.ts b/apps/web-antd/src/utils/useFlexibleRem.ts new file mode 100644 index 00000000..469b6a45 --- /dev/null +++ b/apps/web-antd/src/utils/useFlexibleRem.ts @@ -0,0 +1,29 @@ +//在需要的页面单独引入,不然会影响全局 +import { onMounted, onBeforeUnmount } from 'vue' + +export function useFlexibleRem() { + let originFontSize = '' + let resizeHandler: (() => void) | null = null + + const setRemBase = () => { + const html = document.documentElement + const width = window.innerWidth + html.style.fontSize = (width / 1920) * 16 + 'px' + } + + onMounted(() => { + // 记录原始 font-size + originFontSize = document.documentElement.style.fontSize + setRemBase() + resizeHandler = setRemBase + window.addEventListener('resize', resizeHandler) + }) + + onBeforeUnmount(() => { + // 离开页面时恢复原始 font-size + document.documentElement.style.fontSize = originFontSize + if (resizeHandler) { + window.removeEventListener('resize', resizeHandler) + } + }) +} diff --git a/apps/web-antd/src/views/property/inspectionManagement/inspectionTask/data.ts b/apps/web-antd/src/views/property/inspectionManagement/inspectionTask/data.ts index c12ee44d..df8d1f12 100644 --- a/apps/web-antd/src/views/property/inspectionManagement/inspectionTask/data.ts +++ b/apps/web-antd/src/views/property/inspectionManagement/inspectionTask/data.ts @@ -3,11 +3,7 @@ import type { VxeGridProps } from '#/adapter/vxe-table'; export const querySchema: FormSchemaGetter = () => [ - { - component: 'Input', - fieldName: 'inspectionPlanId', - label: '巡检计划id', - }, + { component: 'DatePicker', componentProps: { @@ -17,6 +13,7 @@ export const querySchema: FormSchemaGetter = () => [ }, fieldName: 'actInsTime', label: '实际巡检时间', + labelWidth: 120, }, { component: 'Input', @@ -30,11 +27,7 @@ export const querySchema: FormSchemaGetter = () => [ fieldName: 'taskType', label: '巡检方式', }, - { - component: 'Textarea', - fieldName: 'transferDesc', - label: '转移描述', - }, + { component: 'RadioGroup', componentProps: { @@ -44,50 +37,60 @@ export const querySchema: FormSchemaGetter = () => [ fieldName: 'status', label: '巡检状态', }, - { - component: 'Input', - fieldName: 'createById', - label: '创建人id', - }, - { - component: 'Input', - fieldName: 'updateById', - label: '更新人id', - }, - { - component: 'Input', - fieldName: 'searchValue', - label: '搜索值', - }, ]; // 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新 // export const columns: () => VxeGridProps['columns'] = () => [ export const columns: VxeGridProps['columns'] = [ { type: 'checkbox', width: 60 }, - { - title: '主键id', + { + title: '序号', field: 'id', + slots: { + default: ({ rowIndex }) => { + return (rowIndex + 1).toString(); + }, + }, + width:60 }, - { - title: '巡检计划id', - field: 'inspectionPlanId', + { + title: '巡检计划', + field: 'planName', + width:'auto' + }, + { + title: '巡检开始日期', + field: 'startDate', + width:180 + + }, + { + title: '巡检结束日期', + field: 'endDate', + width:180 + }, { title: '实际巡检时间', field: 'actInsTime', + width:180 }, { title: '当前巡检人', field: 'actUserId', + width:'auto' + }, { title: '巡检方式', field: 'taskType', + width:'auto' + }, { title: '转移描述', field: 'transferDesc', + width:200 }, { title: '巡检状态', @@ -96,18 +99,7 @@ export const columns: VxeGridProps['columns'] = [ { title: '备注', field: 'remark', - }, - { - title: '创建人id', - field: 'createById', - }, - { - title: '更新人id', - field: 'updateById', - }, - { - title: '搜索值', - field: 'searchValue', + }, { field: 'action', @@ -129,8 +121,18 @@ export const modalSchema: FormSchemaGetter = () => [ }, }, { - label: '巡检计划id', - fieldName: 'inspectionPlanId', + label: '巡检计划', + fieldName: 'planName', + component: 'Input', + }, + { + label: '巡检开始日期', + fieldName: 'startDate', + component: 'Input', + }, + { + label: '巡检结束日期', + fieldName: 'endDate', component: 'Input', }, { diff --git a/apps/web-antd/src/views/property/inspectionManagement/inspectionTask/index.vue b/apps/web-antd/src/views/property/inspectionManagement/inspectionTask/index.vue index e257535e..567c86d7 100644 --- a/apps/web-antd/src/views/property/inspectionManagement/inspectionTask/index.vue +++ b/apps/web-antd/src/views/property/inspectionManagement/inspectionTask/index.vue @@ -144,6 +144,7 @@ function handleDownloadExcel() { {{ $t('pages.common.delete') }} import { useRouter } from 'vue-router' import { preferences } from '@vben/preferences'; - +import { useFlexibleRem } from '#/utils/useFlexibleRem' +useFlexibleRem() const router = useRouter() // 退出方法 diff --git a/apps/web-antd/src/views/screen/property/index.vue b/apps/web-antd/src/views/screen/property/index.vue index 0adaa34c..2caa5bcb 100644 --- a/apps/web-antd/src/views/screen/property/index.vue +++ b/apps/web-antd/src/views/screen/property/index.vue @@ -113,7 +113,8 @@ import 'echarts-gl' import { getThreeDBarOption } from '#/utils/threeDBarOption' import { renderPie3DChart } from '#/utils/pie3d' import { addChartToResizeManager, removeChartFromResizeManager } from '#/utils/echartsResize' - +import { useFlexibleRem } from '#/utils/useFlexibleRem' +useFlexibleRem() // 路由 const router = useRouter() diff --git a/apps/web-antd/src/views/screen/security/index.vue b/apps/web-antd/src/views/screen/security/index.vue index 6062a0b3..5a2d6bdd 100644 --- a/apps/web-antd/src/views/screen/security/index.vue +++ b/apps/web-antd/src/views/screen/security/index.vue @@ -192,7 +192,8 @@ import 'echarts-gl' import { getThreeDBarOption } from '#/utils/threeDBarOption' import { renderPie3DChart } from '#/utils/pie3d' import { addChartToResizeManager, removeChartFromResizeManager } from '#/utils/echartsResize' - +import { useFlexibleRem } from '#/utils/useFlexibleRem' +useFlexibleRem() // 路由 const router = useRouter()