代码生成器模板小优化:生成的列表默认吸底、代码生成年、月、日存储格式修改

This commit is contained in:
JEECG
2025-07-01 10:15:32 +08:00
parent 4108ba54c3
commit d64e8b0adb
31 changed files with 535 additions and 29 deletions

View File

@@ -5,6 +5,7 @@ import type { FormSchema } from "@/components/Form";
import { unref } from 'vue';
import { isObject, isFunction, isString } from '/@/utils/is';
import Big from 'big.js';
import dayjs from "dayjs";
// update-begin--author:sunjianlei---date:20220408---for: 【VUEN-656】配置外部网址打不开原因是带了#号,需要替换一下
export const URL_HASH_TAB = `__AGWE4H__HASH__TAG__PWHRG__`;
// update-end--author:sunjianlei---date:20220408---for: 【VUEN-656】配置外部网址打不开原因是带了#号,需要替换一下
@@ -119,6 +120,30 @@ export function getValueTypeBySchema(schema: FormSchema) {
return valueType;
}
/**
* 通过picker属性获取日期数据
* @param data
* @param picker
*/
export function getDateByPicker(data, picker) {
if (!data || !picker) {
return data;
}
/**
* 需要把年、年月、设置成这段时间内的第一天([年季度]不需要处理antd回传的就是该季度的第一天[年周]也不处理)
* 例如日期格式是年传给数据库的时间必须是20240101
* 例如日期格式是年月选择了202502传给数据库的时间必须是20250201
*/
if (picker === 'year') {
return dayjs(data).set('month', 0).set('date', 1).format('YYYY-MM-DD');
} else if (picker === 'month') {
return dayjs(data).set('date', 1).format('YYYY-MM-DD');
} else if (picker === 'week') {
return dayjs(data).startOf('week').format('YYYY-MM-DD');
}
return data;
}
export function getRawRoute(route: RouteLocationNormalized): RouteLocationNormalized {
if (!route) return route;
const { matched, ...opt } = route;