From c8d7fdd0f6b194772bc7467f9b7821b01061715c Mon Sep 17 00:00:00 2001 From: mll <1874467086> Date: Wed, 25 Feb 2026 15:46:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E9=BB=98=E8=AE=A4=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LowDesign/src/LowReport/index.vue | 29 +++++++- src/styles/index.scss | 4 +- src/utils/formatTime.ts | 2 +- .../general/components/useRenderVxeColumn.tsx | 69 +++++++++++++++++++ .../reportDesign/components/TableInfo.vue | 5 ++ .../lowdesign/reportDesign/designData.ts | 2 + 6 files changed, 108 insertions(+), 3 deletions(-) diff --git a/src/components/LowDesign/src/LowReport/index.vue b/src/components/LowDesign/src/LowReport/index.vue index 3a9d269..a27a470 100644 --- a/src/components/LowDesign/src/LowReport/index.vue +++ b/src/components/LowDesign/src/LowReport/index.vue @@ -169,6 +169,23 @@ const summaryMethod1=({columns,data})=>{ }) return result; } +function getCurrentDate() { + const now = new Date(); + // 补零函数:小于10则前面加0 + const padZero = (num) => num.toString().padStart(2, '0'); + + const year = now.getFullYear(); + const month = padZero(now.getMonth() + 1); + const day = padZero(now.getDate()); + + // 返回格式化后的字符串或对象,按需选择 + return { + year, + month, + day, + fullDate: `${year}-${month}-${day}` // 拼接成 2026-02-24 格式 + }; +} const initTable = async () => { isInit.value = false loading.value = true @@ -248,7 +265,17 @@ const initTable = async () => { _hasChildConfig: childFieldConfigs.has(item.fieldCode), _childConfigs: childFieldConfigs.get(item.fieldCode) || [] } - + if(!!item.searchDefaultValue){ + if(['年','年度','年份'].includes(item.fieldName)&&item.searchDefaultValue=='本年'){ + tableSearch.value[config.prop]=getCurrentDate().year + }else if( ['月','月度','月份'].includes(item.fieldName)&&item.searchDefaultValue=='本月'){ + tableSearch.value[config.prop]=new Date().getMonth() + 1 + }else if(item.fieldType=='Date'&&item.searchDefaultValue=='当日'){ + tableSearch.value[config.prop]=getCurrentDate().fullDate + }else{ + tableSearch.value[config.prop]=item.searchDefaultValue + } + } if(!!item.isAmount){ index==0?amountFieds.value.fistField=config.prop:'' amountFieds.value[item.isAmount]=config diff --git a/src/styles/index.scss b/src/styles/index.scss index cf00a7e..4145022 100644 --- a/src/styles/index.scss +++ b/src/styles/index.scss @@ -95,7 +95,9 @@ display: flex; justify-content: flex-start; } - +.width-50{ + width: 50% !important; +} /* nprogress 适配 element-plus 的主题色 */ #nprogress { & .bar { diff --git a/src/utils/formatTime.ts b/src/utils/formatTime.ts index 51461ae..af074dd 100644 --- a/src/utils/formatTime.ts +++ b/src/utils/formatTime.ts @@ -2,7 +2,7 @@ import dayjs from 'dayjs' import type { TableColumnCtx } from 'element-plus' /** - * 日期快捷选项适用于 el-date-picker + * 日期快捷选项适用于 -picker */ export const defaultShortcuts = [ { diff --git a/src/views/lowdesign/general/components/useRenderVxeColumn.tsx b/src/views/lowdesign/general/components/useRenderVxeColumn.tsx index 29c7502..395fc7c 100644 --- a/src/views/lowdesign/general/components/useRenderVxeColumn.tsx +++ b/src/views/lowdesign/general/components/useRenderVxeColumn.tsx @@ -74,6 +74,75 @@ export const useRenderVxeColumn = (useType = 'table') => { return } }, + LowInputDefualt: { + default: (renderOpts, { row, column, fieldProp }, isStop) => { + const prop = fieldProp || column.field + if (isStop) return (
{row[prop]} {stopIcon}
) + return {row[prop]} + }, + edit: (renderOpts, { row, column, fieldProp ,rowIndex}) => { + const { placeholder } = renderOpts + const prop = fieldProp || column.field + const dicData=[] + if(['年','年度','年份'].includes(row.fieldName)){ + dicData.push({label:'本年',value:'本年'}) + dicData.push({label:'指定年份',value:'指定'}) + }else if( ['月','月度','月份'].includes(row.fieldName)){ + dicData.push({label:'本月',value:'本月'}) + dicData.push({label:'指定月份',value:'指定'}) + }else if(row.fieldType=='Date'){ + dicData.push({label:'当日',value:'当日'}) + dicData.push({label:'指定日期',value:'指定'}) + } + if(dicData.length){ + return [ + { + if(value!=='指定') row[prop]=value + else row[prop]='' + // 再触发自定义事件 + if (renderOpts.events && renderOpts.events.change) { + renderOpts.events.change(row, column.field, rowIndex) + } + }} + onClear={() => { + // 触发清空事件 + if (renderOpts.events && renderOpts.events.clear) { + renderOpts.events.clear(row, column.field, rowIndex) + } + }} + />, + row.defaultSelect === "指定"&&row.fieldType!=='Date' && ( + + ), + row.defaultSelect === "指定"&&row.fieldType=='Date' && ( + + ) + ] + + } + else + return + } + }, + LowNumber: { default: (renderOpts, { row, column }, isStop) => { if (isStop) return (
{row[column.field]} {stopIcon}
) diff --git a/src/views/lowdesign/reportDesign/components/TableInfo.vue b/src/views/lowdesign/reportDesign/components/TableInfo.vue index b56fd5e..a9e38de 100644 --- a/src/views/lowdesign/reportDesign/components/TableInfo.vue +++ b/src/views/lowdesign/reportDesign/components/TableInfo.vue @@ -164,6 +164,11 @@ const fieldList = computed(() => { value: item.fieldCode, type: item.fieldType }) + if(item.searchDefaultValue&&['当日','本月','本年'].includes(item.searchDefaultValue)){ + item.defaultSelect=item.searchDefaultValue + }else if(item.searchDefaultValue){ + item.defaultSelect='指定' + } }) return dicData }) diff --git a/src/views/lowdesign/reportDesign/designData.ts b/src/views/lowdesign/reportDesign/designData.ts index 4f287cb..a2f22ab 100644 --- a/src/views/lowdesign/reportDesign/designData.ts +++ b/src/views/lowdesign/reportDesign/designData.ts @@ -158,6 +158,8 @@ const infoColumn = { fixedColumnValue: { title: '固定列内容', width: 110, align: "center", editRender: { name: 'LowButton', disabled: (row) => row.isFixedColumn !== 'Y', buttonText: '配置内容', buttonType: 'primary', buttonSize: 'small', events: {} } }, queryIsDb: { title: '接口查询', width: 75, align: "center", editRender: { name: 'LowCheckbox' } }, queryIsWeb: { title: '查询控件', width: 75, align: "center", editRender: { name: 'LowCheckbox' } }, + searchDefaultValue: { title: '默认值', width: 180, align: "center", editRender: { name: 'LowInputDefualt' , verifyEdit: true} }, + queryMode: { title: '查询模式', width: 130, editRender: { name: 'LowSelect', verifyEdit: true, dicData: dicObj.queryMode, dicObj: getDicObj('queryMode') } }, dictCode: { title: '字典Code', width: 180, editRender: { name: 'LowSelect', verifyEdit: true, filterable: true, noStop: true, dicData: [] } }, isExport: { title: '是否可导出', width: 90, align: "center", editRender: { name: 'LowCheckbox' } },