From c953754bedcd2bfcd8a030c37b180665e8cf4987 Mon Sep 17 00:00:00 2001 From: insistence <3055204202@qq.com> Date: Mon, 3 Mar 2025 17:13:37 +0800 Subject: [PATCH 01/15] =?UTF-8?q?chore:=20pg=E4=BE=9D=E8=B5=96=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E6=96=B0=E5=A2=9Esqlglot=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-fastapi-backend/requirements-pg.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/ruoyi-fastapi-backend/requirements-pg.txt b/ruoyi-fastapi-backend/requirements-pg.txt index 3caa988..095197f 100644 --- a/ruoyi-fastapi-backend/requirements-pg.txt +++ b/ruoyi-fastapi-backend/requirements-pg.txt @@ -14,4 +14,5 @@ psycopg2==2.9.10 redis==5.2.1 requests==2.32.3 SQLAlchemy[asyncio]==2.0.38 +sqlglot[rs]==26.6.0 user-agents==2.2.0 -- Gitee From 2b6f0905a951d22844aff4baf11b061671eecede Mon Sep 17 00:00:00 2001 From: jiangbaihe <166293922+jiangbaihe@users.noreply.github.com> Date: Tue, 4 Mar 2025 14:58:04 +0800 Subject: [PATCH 02/15] =?UTF-8?q?chore:=20=E8=B0=83=E6=95=B4.gitignore?= =?UTF-8?q?=E7=AD=96=E7=95=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.gitignore b/.gitignore index 129a39b..5686ba6 100644 --- a/.gitignore +++ b/.gitignore @@ -136,3 +136,10 @@ dmypy.json # Cython debug symbols cython_debug/ + +# PyCharm +.idea/ + +# VSCode +.vscode/ + -- Gitee From ee376c477d34b22d9191783220492b4dbf5d16fa Mon Sep 17 00:00:00 2001 From: insistence <3055204202@qq.com> Date: Sun, 9 Mar 2025 18:43:57 +0800 Subject: [PATCH 03/15] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E7=AE=A1=E7=90=86=E6=97=B6=E9=97=B4=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E6=8A=A5=E9=94=99=20#27?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module_admin/dao/log_dao.py | 9 +- .../utils/time_format_util.py | 97 ++++++++++++++++++- 2 files changed, 98 insertions(+), 8 deletions(-) diff --git a/ruoyi-fastapi-backend/module_admin/dao/log_dao.py b/ruoyi-fastapi-backend/module_admin/dao/log_dao.py index 1e4ad41..684f3d7 100644 --- a/ruoyi-fastapi-backend/module_admin/dao/log_dao.py +++ b/ruoyi-fastapi-backend/module_admin/dao/log_dao.py @@ -5,6 +5,7 @@ from module_admin.entity.do.log_do import SysLogininfor, SysOperLog from module_admin.entity.vo.log_vo import LogininforModel, LoginLogPageQueryModel, OperLogModel, OperLogPageQueryModel from utils.common_util import SnakeCaseUtil from utils.page_util import PageUtil +from utils.time_format_util import TimeFormatUtil class OperationLogDao: @@ -38,8 +39,8 @@ class OperationLogDao: SysOperLog.business_type == query_object.business_type if query_object.business_type else True, SysOperLog.status == query_object.status if query_object.status else True, SysOperLog.oper_time.between( - datetime.combine(datetime.strptime(query_object.begin_time, '%Y-%m-%d'), time(00, 00, 00)), - datetime.combine(datetime.strptime(query_object.end_time, '%Y-%m-%d'), time(23, 59, 59)), + datetime.combine(TimeFormatUtil.parse_date(query_object.begin_time), time(00, 00, 00)), + datetime.combine(TimeFormatUtil.parse_date(query_object.end_time), time(23, 59, 59)), ) if query_object.begin_time and query_object.end_time else True, @@ -120,8 +121,8 @@ class LoginLogDao: SysLogininfor.user_name.like(f'%{query_object.user_name}%') if query_object.user_name else True, SysLogininfor.status == query_object.status if query_object.status else True, SysLogininfor.login_time.between( - datetime.combine(datetime.strptime(query_object.begin_time, '%Y-%m-%d'), time(00, 00, 00)), - datetime.combine(datetime.strptime(query_object.end_time, '%Y-%m-%d'), time(23, 59, 59)), + datetime.combine(TimeFormatUtil.parse_date(query_object.begin_time), time(00, 00, 00)), + datetime.combine(TimeFormatUtil.parse_date(query_object.end_time), time(23, 59, 59)), ) if query_object.begin_time and query_object.end_time else True, diff --git a/ruoyi-fastapi-backend/utils/time_format_util.py b/ruoyi-fastapi-backend/utils/time_format_util.py index 380537e..bfb0481 100644 --- a/ruoyi-fastapi-backend/utils/time_format_util.py +++ b/ruoyi-fastapi-backend/utils/time_format_util.py @@ -1,4 +1,7 @@ -import datetime +from copy import deepcopy +from datetime import datetime +from dateutil.parser import parse +from typing import Dict, List, Union def object_format_datetime(obj): @@ -8,7 +11,7 @@ def object_format_datetime(obj): """ for attr in dir(obj): value = getattr(obj, attr) - if isinstance(value, datetime.datetime): + if isinstance(value, datetime): setattr(obj, attr, value.strftime('%Y-%m-%d %H:%M:%S')) return obj @@ -21,7 +24,7 @@ def list_format_datetime(lst): for obj in lst: for attr in dir(obj): value = getattr(obj, attr) - if isinstance(value, datetime.datetime): + if isinstance(value, datetime): setattr(obj, attr, value.strftime('%Y-%m-%d %H:%M:%S')) return lst @@ -41,7 +44,7 @@ def format_datetime_dict_list(dicts): if isinstance(v, dict): # 递归遍历子字典 new_item[k] = format_datetime_dict_list([v])[0] - elif isinstance(v, datetime.datetime): + elif isinstance(v, datetime): # 如果值是 datetime 类型,则格式化为字符串 new_item[k] = v.strftime('%Y-%m-%d %H:%M:%S') else: @@ -50,3 +53,89 @@ def format_datetime_dict_list(dicts): result.append(new_item) return result + + +class TimeFormatUtil: + """ + 时间格式化工具类 + """ + + @classmethod + def format_time(cls, time_info: Union[str, datetime], format: str = '%Y-%m-%d %H:%M:%S'): + """ + 格式化时间字符串或datetime对象为指定格式 + + :param time_info: 时间字符串或datetime对象 + :param format: 格式化格式,默认为'%Y-%m-%d %H:%M:%S' + :return: 格式化后的时间字符串 + """ + if isinstance(time_info, datetime): + format_date = time_info.strftime(format) + else: + try: + date = parse(time_info) + format_date = date.strftime(format) + except Exception: + format_date = time_info + + return format_date + + @classmethod + def parse_date(cls, time_str: str): + """ + 解析时间字符串提取日期部分 + + :param time_str: 时间字符串 + :return: 日期部分 + """ + try: + dt = parse(time_str) + return dt.date() + except Exception: + return time_str + + @classmethod + def format_time_dict(cls, time_dict: Dict, format: str = '%Y-%m-%d %H:%M:%S'): + """ + 格式化时间字典 + + :param time_dict: 时间字典 + :param format: 格式化格式,默认为'%Y-%m-%d %H:%M:%S' + :return: 格式化后的时间字典 + """ + copy_time_dict = deepcopy(time_dict) + for k, v in copy_time_dict.items(): + if isinstance(v, (str, datetime)): + copy_time_dict[k] = cls.format_time(v, format) + elif isinstance(v, dict): + copy_time_dict[k] = cls.format_time_dict(v, format) + elif isinstance(v, list): + copy_time_dict[k] = cls.format_time_list(v, format) + else: + copy_time_dict[k] = v + + return copy_time_dict + + @classmethod + def format_time_list(cls, time_list: List, format: str = '%Y-%m-%d %H:%M:%S'): + """ + 格式化时间列表 + + :param time_list: 时间列表 + :param format: 格式化格式,默认为'%Y-%m-%d %H:%M:%S' + :return: 格式化后的时间列表 + """ + format_time_list = [] + for item in time_list: + if isinstance(item, (str, datetime)): + format_item = cls.format_time(item, format) + elif isinstance(item, dict): + format_item = cls.format_time_dict(item, format) + elif isinstance(item, list): + format_item = cls.format_time_list(item, format) + else: + format_item = item + + format_time_list.append(format_item) + + return format_time_list -- Gitee From 1789cb5a9b26c310e4f7f625360cacb1bbabd437 Mon Sep 17 00:00:00 2001 From: insistence <3055204202@qq.com> Date: Sat, 15 Mar 2025 21:59:28 +0800 Subject: [PATCH 04/15] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=AE=9A?= =?UTF-8?q?=E6=97=B6=E4=BB=BB=E5=8A=A1=E7=8A=B6=E6=80=81=E6=9A=82=E5=81=9C?= =?UTF-8?q?=E6=97=B6=E6=89=A7=E8=A1=8C=E5=8D=95=E6=AC=A1=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E4=BC=9A=E8=A7=A6=E5=8F=91cron=E8=A1=A8=E8=BE=BE=E5=BC=8F?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=20#31?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-fastapi-backend/config/get_scheduler.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ruoyi-fastapi-backend/config/get_scheduler.py b/ruoyi-fastapi-backend/config/get_scheduler.py index 4473390..4b0c298 100644 --- a/ruoyi-fastapi-backend/config/get_scheduler.py +++ b/ruoyi-fastapi-backend/config/get_scheduler.py @@ -201,9 +201,12 @@ class SchedulerUtil: job_executor = job_info.job_executor if iscoroutinefunction(job_func): job_executor = 'default' + job_trigger = DateTrigger() + if job_info.status == '0': + job_trigger = OrTrigger(triggers=[DateTrigger(), MyCronTrigger.from_crontab(job_info.cron_expression)]) scheduler.add_job( func=eval(job_info.invoke_target), - trigger=OrTrigger(triggers=[DateTrigger(), MyCronTrigger.from_crontab(job_info.cron_expression)]), + trigger=job_trigger, args=job_info.job_args.split(',') if job_info.job_args else None, kwargs=json.loads(job_info.job_kwargs) if job_info.job_kwargs else None, id=str(job_info.job_id), -- Gitee From b66d5459852df06da893d5f12e7f081f74e815b7 Mon Sep 17 00:00:00 2001 From: insistence <3055204202@qq.com> Date: Mon, 17 Mar 2025 08:25:39 +0800 Subject: [PATCH 05/15] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=AD=97=E5=85=B8=E7=B1=BB=E5=9E=8B=E6=97=B6=E8=8E=B7?= =?UTF-8?q?=E5=8F=96dict=5Fcode=E5=BC=82=E5=B8=B8=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-fastapi-backend/module_admin/service/dict_service.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ruoyi-fastapi-backend/module_admin/service/dict_service.py b/ruoyi-fastapi-backend/module_admin/service/dict_service.py index bfe6489..fdfd110 100644 --- a/ruoyi-fastapi-backend/module_admin/service/dict_service.py +++ b/ruoyi-fastapi-backend/module_admin/service/dict_service.py @@ -103,7 +103,7 @@ class DictTypeService: if dict_type_info.dict_type != page_object.dict_type: for dict_data in dict_data_list: edit_dict_data = DictDataModel( - dictCode=dict_data.dict_code, + dictCode=dict_data.get('dict_code'), dictType=page_object.dict_type, updateBy=page_object.update_by, ).model_dump(exclude_unset=True) -- Gitee From 6622c329fc2e7e3ed61105e8c191b8a24df93944 Mon Sep 17 00:00:00 2001 From: insistence <3055204202@qq.com> Date: Mon, 17 Mar 2025 08:27:39 +0800 Subject: [PATCH 06/15] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=AD=97=E5=85=B8=E7=B1=BB=E5=9E=8B=E6=97=B6=E5=AD=97?= =?UTF-8?q?=E5=85=B8=E6=95=B0=E6=8D=AE=E6=9B=B4=E6=96=B0=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-fastapi-backend/module_admin/service/dict_service.py | 1 + 1 file changed, 1 insertion(+) diff --git a/ruoyi-fastapi-backend/module_admin/service/dict_service.py b/ruoyi-fastapi-backend/module_admin/service/dict_service.py index fdfd110..0acfd73 100644 --- a/ruoyi-fastapi-backend/module_admin/service/dict_service.py +++ b/ruoyi-fastapi-backend/module_admin/service/dict_service.py @@ -106,6 +106,7 @@ class DictTypeService: dictCode=dict_data.get('dict_code'), dictType=page_object.dict_type, updateBy=page_object.update_by, + updateTime=page_object.update_time, ).model_dump(exclude_unset=True) await DictDataDao.edit_dict_data_dao(query_db, edit_dict_data) await DictTypeDao.edit_dict_type_dao(query_db, edit_dict_type) -- Gitee From 9ae2ac02eb822701267df84b612c194a7a1a396a Mon Sep 17 00:00:00 2001 From: insistence <3055204202@qq.com> Date: Mon, 17 Mar 2025 09:51:05 +0800 Subject: [PATCH 07/15] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E7=94=9F=E6=88=90=E6=96=B0=E5=A2=9E=E5=92=8C=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E5=AD=97=E6=AE=B5=E6=98=BE=E7=A4=BA=E5=92=8C=E6=B8=B2?= =?UTF-8?q?=E6=9F=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-fastapi-backend/config/constant.py | 2 ++ .../templates/python/dao.py.jinja2 | 2 +- .../templates/python/service.py.jinja2 | 2 +- .../templates/vue/index-tree.vue.jinja2 | 32 ++++++++++-------- .../templates/vue/index.vue.jinja2 | 30 +++++++++-------- .../templates/vue/v3/index-tree.vue.jinja2 | 33 +++++++++++-------- .../templates/vue/v3/index.vue.jinja2 | 31 +++++++++-------- ruoyi-fastapi-backend/utils/template_util.py | 2 ++ 8 files changed, 78 insertions(+), 56 deletions(-) diff --git a/ruoyi-fastapi-backend/config/constant.py b/ruoyi-fastapi-backend/config/constant.py index 1b124a0..eb77464 100644 --- a/ruoyi-fastapi-backend/config/constant.py +++ b/ruoyi-fastapi-backend/config/constant.py @@ -252,6 +252,8 @@ class GenConstant: 'double', 'decimal', ] + COLUMNNAME_NOT_ADD_SHOW = ['create_by', 'create_time'] + COLUMNNAME_NOT_EDIT_SHOW = ['update_by', 'update_time'] COLUMNNAME_NOT_EDIT = ['id', 'create_by', 'create_time', 'del_flag'] COLUMNNAME_NOT_LIST = ['id', 'create_by', 'create_time', 'del_flag', 'update_by', 'update_time'] COLUMNNAME_NOT_QUERY = ['id', 'create_by', 'create_time', 'del_flag', 'update_by', 'update_time', 'remark'] diff --git a/ruoyi-fastapi-backend/module_generator/templates/python/dao.py.jinja2 b/ruoyi-fastapi-backend/module_generator/templates/python/dao.py.jinja2 index 6cf19a1..ecf3040 100644 --- a/ruoyi-fastapi-backend/module_generator/templates/python/dao.py.jinja2 +++ b/ruoyi-fastapi-backend/module_generator/templates/python/dao.py.jinja2 @@ -145,7 +145,7 @@ class {{ BusinessName }}Dao: :param {{ businessName }}: {{ functionName }}对象 :return: """ - db_{{ businessName }} = {{ ClassName }}(**{{ businessName }}.model_dump(exclude={% raw %}{{% endraw %}{% if table.sub %}'{{ subclassName }}_list', {% endif %}{% for column in columns %}{% if not column.insert %}'{{ column.python_field | camel_to_snake }}'{% if not loop.last %}, {% endif %}{% endif %}{% endfor %}{% raw %}}{% endraw %})) + db_{{ businessName }} = {{ ClassName }}(**{{ businessName }}.model_dump(exclude={% raw %}{{% endraw %}{% if table.sub %}'{{ subclassName }}_list', {% endif %}{% for column in columns %}{% if not column.insert and column.column_name not in column_not_add_show + column_not_edit_show %}'{{ column.python_field | camel_to_snake }}'{% if not loop.last %}, {% endif %}{% endif %}{% endfor %}{% raw %}}{% endraw %})) db.add(db_{{ businessName }}) await db.flush() diff --git a/ruoyi-fastapi-backend/module_generator/templates/python/service.py.jinja2 b/ruoyi-fastapi-backend/module_generator/templates/python/service.py.jinja2 index 27d6979..5726c5d 100644 --- a/ruoyi-fastapi-backend/module_generator/templates/python/service.py.jinja2 +++ b/ruoyi-fastapi-backend/module_generator/templates/python/service.py.jinja2 @@ -103,7 +103,7 @@ class {{ BusinessName }}Service: :param page_object: 编辑{{ functionName }}对象 :return: 编辑{{ functionName }}校验结果 """ - edit_{{ businessName }} = page_object.model_dump(exclude_unset=True, exclude={% raw %}{{% endraw %}{% if table.sub %}'{{ subclassName }}_list', {% endif %}{% for column in columns %}{% if not column.edit and not column.pk %}'{{ column.python_field | camel_to_snake }}'{% if not loop.last %}, {% endif %}{% endif %}{% endfor %}{% raw %}}{% endraw %}) + edit_{{ businessName }} = page_object.model_dump(exclude_unset=True, exclude={% raw %}{{% endraw %}{% if table.sub %}'{{ subclassName }}_list', {% endif %}{% for column in columns %}{% if not column.edit and not column.pk and column.column_name not in column_not_edit_show %}'{{ column.python_field | camel_to_snake }}'{% if not loop.last %}, {% endif %}{% endif %}{% endfor %}{% raw %}}{% endraw %}) {{ businessName }}_info = await cls.{{ businessName }}_detail_services(query_db, page_object.{{ pk_field }}) if {{ businessName }}_info.{{ pk_field }}: {% for column in columns %} diff --git a/ruoyi-fastapi-backend/module_generator/templates/vue/index-tree.vue.jinja2 b/ruoyi-fastapi-backend/module_generator/templates/vue/index-tree.vue.jinja2 index 741f132..f71e378 100644 --- a/ruoyi-fastapi-backend/module_generator/templates/vue/index-tree.vue.jinja2 +++ b/ruoyi-fastapi-backend/module_generator/templates/vue/index-tree.vue.jinja2 @@ -161,33 +161,33 @@ {% for column in columns %} {% set field = column.python_field %} - {% if column.insert and not column.pk %} + {% if (column.insert or column.edit) and not column.pk and column.column_name not in column_not_add_show + column_not_edit_show %} {% if column.usable_column or not column.super_column %} {% set parentheseIndex = column.column_comment.find("(") %} {% set comment = column.column_comment[:parentheseIndex] if parentheseIndex != -1 else column.column_comment %} {% set dictType = column.dict_type %} {% if treeParentCode and column.python_field == treeParentCode %} - + {% elif column.html_type == "input" %} - + {% elif column.html_type == "imageUpload" %} - + {% elif column.html_type == "fileUpload" %} - + {% elif column.html_type == "editor" %} - + {% elif column.html_type == "select" and dictType %} - + {% elif column.html_type == "select" and not dictType %} - + {% elif column.html_type == "checkbox" and dictType %} - + {% elif column.html_type == "checkbox" and not dictType %} - + 请选择字典生成 {% elif column.html_type == "radio" and dictType %} - + {% elif column.html_type == "radio" and not dictType %} - + {% elif column.html_type == "datetime" %} - + {% elif column.html_type == "textarea" %} - + {% endif %} @@ -485,6 +485,10 @@ export default { this.getList(); this.$modal.msgSuccess("删除成功"); }).catch(() => {}); + }, + /** 是否渲染字段 */ + renderField(insert, edit) { + return this.form.{{ pkColumn.python_field }} == null ? insert : edit; } }, }; diff --git a/ruoyi-fastapi-backend/module_generator/templates/vue/index.vue.jinja2 b/ruoyi-fastapi-backend/module_generator/templates/vue/index.vue.jinja2 index a1b7f4b..7f2fc47 100644 --- a/ruoyi-fastapi-backend/module_generator/templates/vue/index.vue.jinja2 +++ b/ruoyi-fastapi-backend/module_generator/templates/vue/index.vue.jinja2 @@ -173,29 +173,29 @@ {% for column in columns %} {% set field = column.python_field %} - {% if column.insert and not column.pk %} + {% if (column.insert or column.edit) and not column.pk and column.column_name not in column_not_add_show + column_not_edit_show %} {% if column.usable_column or not column.super_column %} {% set parentheseIndex = column.column_comment.find("(") %} {% set comment = column.column_comment[:parentheseIndex] if parentheseIndex != -1 else column.column_comment %} {% set dictType = column.dict_type %} {% if column.html_type == "input" %} - + {% elif column.html_type == "imageUpload" %} - + {% elif column.html_type == "fileUpload" %} - + {% elif column.html_type == "editor" %} - + {% elif column.html_type == "select" and dictType %} - + {% elif column.html_type == "select" and not dictType %} - + {% elif column.html_type == "checkbox" and dictType %} - + {% elif column.html_type == "checkbox" and not dictType %} - + 请选择字典生成 {% elif column.html_type == "radio" and dictType %} - + {% elif column.html_type == "radio" and not dictType %} - + {% elif column.html_type == "datetime" %} - + {% elif column.html_type == "textarea" %} - + {% endif %} @@ -580,6 +580,10 @@ export default { this.download('{{ moduleName }}/{{ businessName }}/export', { ...this.queryParams }, `{{ businessName }}_${new Date().getTime()}.xlsx`); + }, + /** 是否渲染字段 */ + renderField(insert, edit) { + return this.form.{{ pkColumn.python_field }} == null ? insert : edit; } }, }; diff --git a/ruoyi-fastapi-backend/module_generator/templates/vue/v3/index-tree.vue.jinja2 b/ruoyi-fastapi-backend/module_generator/templates/vue/v3/index-tree.vue.jinja2 index 433c162..a7c1382 100644 --- a/ruoyi-fastapi-backend/module_generator/templates/vue/v3/index-tree.vue.jinja2 +++ b/ruoyi-fastapi-backend/module_generator/templates/vue/v3/index-tree.vue.jinja2 @@ -136,13 +136,13 @@ {% for column in columns %} {% set field = column.python_field %} - {% if column.insert and not column.pk %} + {% if (column.insert or column.edit) and not column.pk and column.column_name not in column_not_add_show + column_not_edit_show %} {% if column.usable_column or not column.super_column %} {% set parentheseIndex = column.column_comment.find("(") %} {% set comment = column.column_comment[:parentheseIndex] if parentheseIndex != -1 else column.column_comment %} {% set dictType = column.dict_type %} {% if treeParentCode and column.python_field == treeParentCode %} - + {% elif column.html_type == "input" %} - + {% elif column.html_type == "imageUpload" %} - + {% elif column.html_type == "fileUpload" %} - + {% elif column.html_type == "editor" %} - + {% elif column.html_type == "select" and dictType %} - + {% elif column.html_type == "select" and not dictType %} - + {% elif column.html_type == "checkbox" and dictType %} - + {% elif column.html_type == "checkbox" and not dictType %} - + 请选择字典生成 {% elif column.html_type == "radio" and dictType %} - + {% elif column.html_type == "radio" and not dictType %} - + {% elif column.html_type == "datetime" %} - + {% elif column.html_type == "textarea" %} - + {% endif %} @@ -450,5 +450,10 @@ function handleDelete(row) { }).catch(() => {}); } +/** 是否渲染字段 */ +function renderField(insert, edit) { + return form.value.{{ pkColumn.python_field }} == null ? insert : edit; +} + getList(); \ No newline at end of file diff --git a/ruoyi-fastapi-backend/module_generator/templates/vue/v3/index.vue.jinja2 b/ruoyi-fastapi-backend/module_generator/templates/vue/v3/index.vue.jinja2 index 981124f..ad79130 100644 --- a/ruoyi-fastapi-backend/module_generator/templates/vue/v3/index.vue.jinja2 +++ b/ruoyi-fastapi-backend/module_generator/templates/vue/v3/index.vue.jinja2 @@ -159,29 +159,29 @@ {% for column in columns %} {% set field = column.python_field %} - {% if column.insert and not column.pk %} + {% if (column.insert or column.edit) and not column.pk and column.column_name not in column_not_add_show + column_not_edit_show %} {% if column.usable_column or not column.super_column %} {% set parentheseIndex = column.column_comment.find("(") %} {% set comment = column.column_comment[:parentheseIndex] if parentheseIndex != -1 else column.column_comment %} {% set dictType = column.dict_type %} {% if column.html_type == "input" %} - + {% elif column.html_type == "imageUpload" %} - + {% elif column.html_type == "fileUpload" %} - + {% elif column.html_type == "editor" %} - + {% elif column.html_type == "select" and dictType %} - + {% elif column.html_type == "select" and not dictType %} - + {% elif column.html_type == "checkbox" and dictType %} - + {% elif column.html_type == "checkbox" and not dictType %} - + 请选择字典生成 {% elif column.html_type == "radio" and dictType %} - + {% elif column.html_type == "radio" and not dictType %} - + {% elif column.html_type == "datetime" %} - + {% elif column.html_type == "textarea" %} - + {% endif %} @@ -567,5 +567,10 @@ function handleExport() { }, `{{ businessName }}_${new Date().getTime()}.xlsx`); } +/** 是否渲染字段 */ +function renderField(insert, edit) { + return form.value.{{ pkColumn.python_field }} == null ? insert : edit; +} + getList(); \ No newline at end of file diff --git a/ruoyi-fastapi-backend/utils/template_util.py b/ruoyi-fastapi-backend/utils/template_util.py index 55a8f87..6765bd0 100644 --- a/ruoyi-fastapi-backend/utils/template_util.py +++ b/ruoyi-fastapi-backend/utils/template_util.py @@ -91,6 +91,8 @@ class TemplateUtils: 'table': gen_table, 'dicts': cls.get_dicts(gen_table), 'dbType': DataBaseConfig.db_type, + 'column_not_add_show': GenConstant.COLUMNNAME_NOT_ADD_SHOW, + 'column_not_edit_show': GenConstant.COLUMNNAME_NOT_EDIT_SHOW, } # 设置菜单、树形结构、子表的上下文 -- Gitee From 61073970fa425ec218672fbcb10a9abdb9e65716 Mon Sep 17 00:00:00 2001 From: insistence <3055204202@qq.com> Date: Mon, 17 Mar 2025 16:32:46 +0800 Subject: [PATCH 08/15] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E7=94=9F=E6=88=90=E6=A8=A1=E6=9D=BF=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E9=97=AE=E9=A2=98=20#28?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/python/dao.py.jinja2 | 8 ++++---- .../templates/python/vo.py.jinja2 | 17 ++++++++++++++--- .../templates/vue/index-tree.vue.jinja2 | 4 ++-- .../templates/vue/index.vue.jinja2 | 4 ++-- .../templates/vue/v3/index-tree.vue.jinja2 | 4 ++-- .../templates/vue/v3/index.vue.jinja2 | 4 ++-- 6 files changed, 26 insertions(+), 15 deletions(-) diff --git a/ruoyi-fastapi-backend/module_generator/templates/python/dao.py.jinja2 b/ruoyi-fastapi-backend/module_generator/templates/python/dao.py.jinja2 index ecf3040..3b186c5 100644 --- a/ruoyi-fastapi-backend/module_generator/templates/python/dao.py.jinja2 +++ b/ruoyi-fastapi-backend/module_generator/templates/python/dao.py.jinja2 @@ -118,12 +118,12 @@ class {{ BusinessName }}Dao: {{ ClassName }}.{{ field }} <= query_object.{{ field }} if query_object.{{ field }} else True, {% elif column.query_type == "LIKE" %} {{ ClassName }}.{{ field }}.like(f'%{% raw %}{{% endraw %}query_object.{{ field }}{% raw %}}{% endraw %}%') if query_object.{{ field }} else True, - {% elif column.query_type == "BETWEEN" %} + {% elif column.html_type == "datetime" and column.query_type == "BETWEEN" %} {{ ClassName }}.{{ field }}.between( - datetime.combine(datetime.strptime(query_object.begin_time, '%Y-%m-%d'), time(00, 00, 00)), - datetime.combine(datetime.strptime(query_object.end_time, '%Y-%m-%d'), time(23, 59, 59)), + datetime.combine(datetime.strptime(query_object.begin_{{ column.column_name }}, '%Y-%m-%d'), time(00, 00, 00)), + datetime.combine(datetime.strptime(query_object.end_{{ column.column_name }}, '%Y-%m-%d'), time(23, 59, 59)), ) - if query_object.begin_time and query_object.end_time + if query_object.begin_{{ column.column_name }} and query_object.end_{{ column.column_name }} else True, {% endif %} {% endif %} diff --git a/ruoyi-fastapi-backend/module_generator/templates/python/vo.py.jinja2 b/ruoyi-fastapi-backend/module_generator/templates/python/vo.py.jinja2 index 7634980..47abbf5 100644 --- a/ruoyi-fastapi-backend/module_generator/templates/python/vo.py.jinja2 +++ b/ruoyi-fastapi-backend/module_generator/templates/python/vo.py.jinja2 @@ -3,10 +3,14 @@ {% set pkParentheseIndex = pkColumn.column_comment.find("(") %} {% set pk_field_comment = pkColumn.column_comment[:pkParentheseIndex] if pkParentheseIndex != -1 else pkColumn.column_comment %} {% set vo_field_required = namespace(has_required=False) %} +{% set vo_field_daterange = namespace(has_daterange=False) %} {% for column in columns %} {% if column.required %} {% set vo_field_required.has_required = True %} {% endif %} +{% if column.html_type == "datetime" and column.query_type == "BETWEEN" %} + {% set vo_field_daterange.has_daterange = True %} +{% endif %} {% endfor %} {% set sub_vo_field_required = namespace(has_required=False) %} {% if table.sub %} @@ -142,9 +146,16 @@ class {{ BusinessName }}QueryModel({% if table.sub %}{{ BusinessName }}BaseModel """ {{ functionName }}不分页查询模型 """ - - begin_time: Optional[str] = Field(default=None, description='开始时间') - end_time: Optional[str] = Field(default=None, description='结束时间') + {% if vo_field_daterange.has_daterange %} + {% for column in columns %} + {% if column.html_type == "datetime" and column.query_type == "BETWEEN" %} + begin_{{ column.column_name }}: Optional[str] = Field(default=None, description='开始{{ column.column_comment }}') + end_{{ column.column_name }}: Optional[str] = Field(default=None, description='结束{{ column.column_comment }}') + {% endif %} + {% endfor %} + {% else %} + pass + {% endif %} @as_query diff --git a/ruoyi-fastapi-backend/module_generator/templates/vue/index-tree.vue.jinja2 b/ruoyi-fastapi-backend/module_generator/templates/vue/index-tree.vue.jinja2 index f71e378..4da71a0 100644 --- a/ruoyi-fastapi-backend/module_generator/templates/vue/index-tree.vue.jinja2 +++ b/ruoyi-fastapi-backend/module_generator/templates/vue/index-tree.vue.jinja2 @@ -351,8 +351,8 @@ export default { {% if column.html_type == "datetime" and column.query_type == "BETWEEN" %} {% set AttrName = column.python_field[0] | upper + column.python_field[1:] %} if (null != this.daterange{{ AttrName }} && '' != this.daterange{{ AttrName }}) { - this.queryParams.params["begin{{ AttrName }}"] = this.daterange{{ AttrName }}[0]; - this.queryParams.params["end{{ AttrName }}"] = this.daterange{{ AttrName }}[1]; + this.queryParams.begin{{ AttrName }} = this.daterange{{ AttrName }}[0]; + this.queryParams.end{{ AttrName }} = this.daterange{{ AttrName }}[1]; } {% endif %} {% endfor %} diff --git a/ruoyi-fastapi-backend/module_generator/templates/vue/index.vue.jinja2 b/ruoyi-fastapi-backend/module_generator/templates/vue/index.vue.jinja2 index 7f2fc47..673caf4 100644 --- a/ruoyi-fastapi-backend/module_generator/templates/vue/index.vue.jinja2 +++ b/ruoyi-fastapi-backend/module_generator/templates/vue/index.vue.jinja2 @@ -426,8 +426,8 @@ export default { {% if column.html_type == "datetime" and column.query_type == "BETWEEN" %} {% set AttrName = column.python_field[0] | upper + column.python_field[1:] %} if (null != this.daterange{{ AttrName }} && '' != this.daterange{{ AttrName }}) { - this.queryParams.params["begin{{ AttrName }}"] = this.daterange{{ AttrName }}[0]; - this.queryParams.params["end{{ AttrName }}"] = this.daterange{{ AttrName }}[1]; + this.queryParams.begin{{ AttrName }} = this.daterange{{ AttrName }}[0]; + this.queryParams.end{{ AttrName }} = this.daterange{{ AttrName }}[1]; } {% endif %} {% endfor %} diff --git a/ruoyi-fastapi-backend/module_generator/templates/vue/v3/index-tree.vue.jinja2 b/ruoyi-fastapi-backend/module_generator/templates/vue/v3/index-tree.vue.jinja2 index a7c1382..1e60ae8 100644 --- a/ruoyi-fastapi-backend/module_generator/templates/vue/v3/index-tree.vue.jinja2 +++ b/ruoyi-fastapi-backend/module_generator/templates/vue/v3/index-tree.vue.jinja2 @@ -315,8 +315,8 @@ function getList() { {% if column.html_type == "datetime" and column.query_type == "BETWEEN" %} {% set AttrName = column.python_field[0] | upper + column.python_field[1:] %} if (null != daterange{{ AttrName }} && '' != daterange{{ AttrName }}) { - queryParams.value.params["begin{{ AttrName }}"] = daterange{{ AttrName }}.value[0]; - queryParams.value.params["end{{ AttrName }}"] = daterange{{ AttrName }}.value[1]; + queryParams.value.begin{{ AttrName }} = daterange{{ AttrName }}.value[0]; + queryParams.value.end{{ AttrName }} = daterange{{ AttrName }}.value[1]; } {% endif %} {% endfor %} diff --git a/ruoyi-fastapi-backend/module_generator/templates/vue/v3/index.vue.jinja2 b/ruoyi-fastapi-backend/module_generator/templates/vue/v3/index.vue.jinja2 index ad79130..6356d85 100644 --- a/ruoyi-fastapi-backend/module_generator/templates/vue/v3/index.vue.jinja2 +++ b/ruoyi-fastapi-backend/module_generator/templates/vue/v3/index.vue.jinja2 @@ -397,8 +397,8 @@ function getList() { {% if column.html_type == "datetime" and column.query_type == "BETWEEN" %} {% set AttrName = column.python_field[0] | upper + column.python_field[1:] %} if (null != daterange{{ AttrName }} && '' != daterange{{ AttrName }}) { - queryParams.value.params["begin{{ AttrName }}"] = daterange{{ AttrName }}.value[0]; - queryParams.value.params["end{{ AttrName }}"] = daterange{{ AttrName }}.value[1]; + queryParams.value.begin{{ AttrName }} = daterange{{ AttrName }}.value[0]; + queryParams.value.end{{ AttrName }} = daterange{{ AttrName }}.value[1]; } {% endif %} {% endfor %} -- Gitee From 7645c6d9fd1ce0f0d902654c07919b5ebbb86716 Mon Sep 17 00:00:00 2001 From: insistence <3055204202@qq.com> Date: Tue, 18 Mar 2025 08:11:18 +0800 Subject: [PATCH 09/15] =?UTF-8?q?feat:=20=E6=96=87=E4=BB=B6=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E7=BB=84=E4=BB=B6=E6=96=B0=E5=A2=9Edisabled=E5=B1=9E?= =?UTF-8?q?=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/FileUpload/index.vue | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ruoyi-fastapi-frontend/src/components/FileUpload/index.vue b/ruoyi-fastapi-frontend/src/components/FileUpload/index.vue index a860a40..ed717fb 100644 --- a/ruoyi-fastapi-frontend/src/components/FileUpload/index.vue +++ b/ruoyi-fastapi-frontend/src/components/FileUpload/index.vue @@ -13,12 +13,13 @@ :headers="headers" class="upload-file-uploader" ref="fileUpload" + v-if="!disabled" > 选取文件 -
+
请上传 @@ -31,7 +32,7 @@ {{ getFileName(file.name) }}
- 删除 + 删除
@@ -62,6 +63,11 @@ const props = defineProps({ isShowTip: { type: Boolean, default: true + }, + // 禁用组件(仅查看文件) + disabled: { + type: Boolean, + default: false } }); -- Gitee From dd5b1c55c97bfce48690a31e9d212e8b1c1d62c7 Mon Sep 17 00:00:00 2001 From: insistence <3055204202@qq.com> Date: Tue, 18 Mar 2025 08:12:13 +0800 Subject: [PATCH 10/15] =?UTF-8?q?feat:=20=E6=96=87=E4=BB=B6=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E7=BB=84=E4=BB=B6=E6=96=B0=E5=A2=9E=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-fastapi-frontend/src/components/FileUpload/index.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ruoyi-fastapi-frontend/src/components/FileUpload/index.vue b/ruoyi-fastapi-frontend/src/components/FileUpload/index.vue index ed717fb..9a07847 100644 --- a/ruoyi-fastapi-frontend/src/components/FileUpload/index.vue +++ b/ruoyi-fastapi-frontend/src/components/FileUpload/index.vue @@ -47,17 +47,17 @@ const props = defineProps({ // 数量限制 limit: { type: Number, - default: 5, + default: 5 }, // 大小限制(MB) fileSize: { type: Number, - default: 5, + default: 5 }, // 文件类型, 例如['png', 'jpg', 'jpeg'] fileType: { type: Array, - default: () => ["doc", "xls", "ppt", "txt", "pdf"], + default: () => ["doc", "docx", "xls", "xlsx", "ppt", "pptx", "txt", "pdf"] }, // 是否显示提示 isShowTip: { -- Gitee From 5fe376f978019cb2b21d0bf6eabb59c90dbf1bf4 Mon Sep 17 00:00:00 2001 From: insistence <3055204202@qq.com> Date: Tue, 18 Mar 2025 08:28:46 +0800 Subject: [PATCH 11/15] =?UTF-8?q?perf:=20pagination=E6=9B=B4=E6=8D=A2?= =?UTF-8?q?=E6=88=90flex=E5=B8=83=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/assets/styles/index.scss | 4 ---- .../src/assets/styles/ruoyi.scss | 15 +++------------ .../src/components/Pagination/index.vue | 1 - 3 files changed, 3 insertions(+), 17 deletions(-) diff --git a/ruoyi-fastapi-frontend/src/assets/styles/index.scss b/ruoyi-fastapi-frontend/src/assets/styles/index.scss index 2b8dca5..efc1ddd 100644 --- a/ruoyi-fastapi-frontend/src/assets/styles/index.scss +++ b/ruoyi-fastapi-frontend/src/assets/styles/index.scss @@ -131,10 +131,6 @@ aside { position: relative; } -.pagination-container { - margin-top: 30px; -} - .text-center { text-align: center } diff --git a/ruoyi-fastapi-frontend/src/assets/styles/ruoyi.scss b/ruoyi-fastapi-frontend/src/assets/styles/ruoyi.scss index 4996ae5..db9b1f6 100755 --- a/ruoyi-fastapi-frontend/src/assets/styles/ruoyi.scss +++ b/ruoyi-fastapi-frontend/src/assets/styles/ruoyi.scss @@ -102,21 +102,12 @@ /** 表格布局 **/ .pagination-container { - position: relative; - height: 25px; - margin-bottom: 10px; - margin-top: 15px; - padding: 10px 20px !important; + display: flex; + justify-content: flex-end; + margin-top: 20px; background-color: transparent !important; } -/* 分页器定位 */ -.pagination-container .el-pagination { - position: absolute; - right: 0; - top: 0; -} - /* 弹窗中的分页器 */ .el-dialog .pagination-container { position: static !important; diff --git a/ruoyi-fastapi-frontend/src/components/Pagination/index.vue b/ruoyi-fastapi-frontend/src/components/Pagination/index.vue index 38de953..11d4caf 100644 --- a/ruoyi-fastapi-frontend/src/components/Pagination/index.vue +++ b/ruoyi-fastapi-frontend/src/components/Pagination/index.vue @@ -97,7 +97,6 @@ function handleCurrentChange(val) {