查询默认值

This commit is contained in:
mll
2026-02-25 15:46:17 +08:00
parent c47dba53d9
commit c8d7fdd0f6
6 changed files with 108 additions and 3 deletions

View File

@@ -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