feat: 新增多选月份字段类型,统一品牌名从 UniSOA 改为 UnisOA
新增「months」多选月份字段类型,支持按年挑选多个月份并自动合并为「2026年10-11月」等易读格式,同时调整表单设计器中该字段默认宽度为半行,新增挑选方式配置项支持下拉/弹出框/平铺三种模式。 全局将品牌名从 UniSOA 统一替换为 UnisOA,更新文档、配置文件、演示数据、部署清单等所有相关内容,仅保留内部标识如数据库名、镜像名等不变。main
parent
71e65be615
commit
e16122db7d
|
|
@ -1,6 +1,6 @@
|
|||
# syntax=docker/dockerfile:1
|
||||
# =============================================================================
|
||||
# UniSOA 容器镜像:前端 pnpm 构建 + 后端 FastAPI(uvicorn)
|
||||
# UnisOA 容器镜像:前端 pnpm 构建 + 后端 FastAPI(uvicorn)
|
||||
# -----------------------------------------------------------------------------
|
||||
# 构建(上下文是仓库根目录,别只给 backend/):
|
||||
# docker build -t unisoa:latest .
|
||||
|
|
|
|||
10
README.md
10
README.md
|
|
@ -1,4 +1,4 @@
|
|||
# UniSOA 流程审批平台
|
||||
# UnisOA 流程审批平台
|
||||
|
||||
把 O2OA 的完整流程审批模块(`x_processplatform_*`)与首页门户
|
||||
(`x_component_Homepage` 依赖的 `x_cms` / `x_hotpic` / `x_meeting` / `x_calendar` /
|
||||
|
|
@ -734,12 +734,18 @@ python3 scripts/audit_storage.py --to-minio # 把本该进 MinIO
|
|||
## 表单设计
|
||||
|
||||
`设计中心 → 表单设计` 里可以直接建表单,字段类型见 `utils/formLayout.ts` 的 `FIELD_TYPES`
|
||||
(**41 类**,按 基础录入 / 选择类 / 选人 / 附件 / 系统带出 / 排版占位 五段摆在左侧字段库里,
|
||||
(**44 类**,按 基础录入 / 选择类 / 选人 / 附件 / 系统带出 / 排版占位 五段摆在左侧字段库里,
|
||||
每一类存什么值、条件能比什么、明细列能不能用,全在 [docs/form-field-catalog.md](docs/form-field-catalog.md)),
|
||||
支持上移 / 下移 /
|
||||
复制 / 删除,每个字段可配字段名、类型、必填、只读、占位提示、说明文字,数字字段另有最小值 /
|
||||
最大值 / 步长 / 小数位 / 单位。
|
||||
|
||||
- **多选月份**(`months`):一次圈几个月,挑 2026 年 10、11 两月,回填出来就是「2026年10-11月」。
|
||||
库里存的仍是 `["2026-10","2026-11"]`(与 `month` 同一写法,条件与导出读得懂),并段那句人话由
|
||||
`utils/formRuntime.ts:monthsText` ↔ `service/formruntime.py:months_text` 现拼,只读、打印、导出同一句。
|
||||
这一格长什么样由配的人挑(字段上的 `pickerStyle`,与设计器里「挑选方式」同一套取值):
|
||||
**下拉多选**(默认,半行放得下)、**弹出框多选**(手机上好点,点确定才写回)、**平铺点选**
|
||||
(12 个月摊开,一眼看全,代价是一整行)。回归 `PYTHONPATH=. python3 scripts/check_months_style.py`。
|
||||
- **这一轮长出来的 8 格**:`richtext` 富文本(存 Markdown 原文,右边看排版)、`month` 月份、
|
||||
`year` 年份、`timerange` 时间段、`week` 星期、`location` 定位、`group` 分组标题、
|
||||
`spacer` 空白占位;另外把**手写签名**摆回了左侧字段库——它的控件、只读态、导出、打印
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ def delete_category(category_id: str, db: Session = Depends(get_db)) -> dict:
|
|||
FIELD_TYPES = {
|
||||
# 基础录入
|
||||
"text", "textarea", "number", "money", "date", "datetime", "time", "daterange",
|
||||
"month", "year", "timerange", "richtext",
|
||||
"month", "months", "year", "timerange", "richtext",
|
||||
"mobile", "email", "idcard", "url", "address", "location",
|
||||
# 选择类(cascader:一个控件在层级字典里一路选到底,值是顶级到末级的字典项数组)
|
||||
"select", "radio", "checkbox", "switch", "rate", "dept", "cascader", "week",
|
||||
|
|
@ -201,6 +201,15 @@ def clean_option_source(content: object) -> dict:
|
|||
if field_type == formruntime.CASCADER_TYPE:
|
||||
fresh.pop("optionSource", None)
|
||||
return fresh
|
||||
# 多选月份:候选是那一年那 12 个月,谈不上候选来源那四类,但它共用同一套「挑选方式」
|
||||
# (字段上的 ``pickerStyle``:下拉多选 / 弹出框多选 / 平铺点选)。它不在
|
||||
# source_kinds_of 的清单里,跟着下面那句"没有来源就整份撤掉"会把挑选方式一起抹掉——
|
||||
# 于是配的人挑了弹出框、存一次就默默掉回下拉。
|
||||
if field_type == formruntime.MONTHS_TYPE:
|
||||
fresh.pop("optionSource", None)
|
||||
if str(fresh.get("pickerStyle") or "").strip() not in formruntime.MONTHS_STYLES:
|
||||
fresh.pop("pickerStyle", None)
|
||||
return fresh
|
||||
declared = str(fresh.get("optionSource") or "").strip()
|
||||
kinds = dicts.source_kinds_of(field_type)
|
||||
if declared not in kinds:
|
||||
|
|
@ -728,6 +737,7 @@ def list_processes(
|
|||
mine: str = Query(""),
|
||||
startable: str = Query(""),
|
||||
with_definition: bool = Query(True, description="0=不回设计稿(canvas 等四列回空对象),清单页用它"),
|
||||
count_scope: str = Query("", description="mine=在途/办结只算本人发起的单(发起页用它),留空是全流程口径"),
|
||||
) -> dict:
|
||||
"""流程清单。
|
||||
|
||||
|
|
@ -735,6 +745,13 @@ def list_processes(
|
|||
也列出来、点进去才弹一句没权限。设计器不传这个参数,照样看全部。
|
||||
每条都带回 ``startable``,界面上想标「限 X 人发起」也够用。
|
||||
|
||||
``running_count`` / ``completed_count`` 默认是**这条流程在全系统**的在途数与办结数,
|
||||
设计器的流程清单要的就是这个——那里看的是这条流程跑得怎么样。带
|
||||
``count_scope=mine`` 换成只算当前这个人发起的单(口径与「我发起的」列表同一条,
|
||||
见 ``app.api.runtime._created_clause``):发起页上那两个数字是给人挑流程当参考的,
|
||||
别人在这条流程上压了三张单,对点进去的人毫无意义,读起来还像是自己已经排到了队尾。
|
||||
管理员也按本人算,这一页问的是"我"。
|
||||
|
||||
设计稿(``canvas`` / ``data_template`` / ``approval_config`` / ``title_config``)默认照样
|
||||
给,带 ``with_definition=0`` 才省:这一页几乎被每个界面的筛选器拉一次(发起页、待办、
|
||||
监控、统计都拉),而画布只有设计器和发起页在用,它们本来就走
|
||||
|
|
@ -766,21 +783,26 @@ def list_processes(
|
|||
wanted = tri_state(startable)
|
||||
if wanted is not None:
|
||||
rows = [row for row in rows if bool(can_start.get(row.id)) == wanted]
|
||||
# 在办数与办结数各查一张表,互不相干:并起来问只等一趟到库的来回
|
||||
# 在办数与办结数各查一张表,互不相干:并起来问只等一趟到库的来回。
|
||||
# 收成本人口径时两张表都走 creator_identity 等值——它正好是
|
||||
# idx_oa_work_creator / idx_oa_work_completed_creator 的前缀,加这个筛子不会把分组
|
||||
# 统计退化成全表扫,反倒是少扫一大截。
|
||||
mine_only = count_scope.strip().lower() == "mine"
|
||||
|
||||
def running_counts(session: Session):
|
||||
return dict(
|
||||
session.execute(
|
||||
select(models.Work.process, func.count(models.Work.id)).group_by(models.Work.process)
|
||||
).all()
|
||||
)
|
||||
stmt = select(models.Work.process, func.count(models.Work.id)).group_by(models.Work.process)
|
||||
if mine_only:
|
||||
stmt = stmt.where(models.Work.creator_identity == user.ref)
|
||||
return dict(session.execute(stmt).all())
|
||||
|
||||
def completed_counts(session: Session):
|
||||
return dict(
|
||||
session.execute(
|
||||
select(models.WorkCompleted.process, func.count(models.WorkCompleted.id))
|
||||
.group_by(models.WorkCompleted.process)
|
||||
).all()
|
||||
stmt = (
|
||||
select(models.WorkCompleted.process, func.count(models.WorkCompleted.id))
|
||||
.group_by(models.WorkCompleted.process)
|
||||
)
|
||||
if mine_only:
|
||||
stmt = stmt.where(models.WorkCompleted.creator_identity == user.ref)
|
||||
return dict(session.execute(stmt).all())
|
||||
|
||||
loaded = parallel.gather(db, {"running": running_counts, "completed": completed_counts})
|
||||
counts, completed_counts = loaded["running"], loaded["completed"]
|
||||
|
|
|
|||
|
|
@ -140,6 +140,9 @@ def cell_text(
|
|||
return text
|
||||
if kind == "week":
|
||||
return formruntime.week_text(value)
|
||||
if kind == "months":
|
||||
# 多选月份存的是 YYYY-MM 数组,念成"2026年10-11月"才像一句人话
|
||||
return formruntime.months_text(value)
|
||||
if kind == formruntime.LOCATION_TYPE:
|
||||
return formruntime.location_text(value)
|
||||
if kind == "richtext":
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ def _i(name, group, path, env, default, label, help="", **kwargs) -> Item: # no
|
|||
|
||||
ITEMS: tuple[Item, ...] = (
|
||||
# ---------------------------------------------------------------- 站点
|
||||
Item("site_name", "site", ("site", "name"), "OA_SITE_NAME", KIND_STR, "UniSOA 流程审批平台",
|
||||
Item("site_name", "site", ("site", "name"), "OA_SITE_NAME", KIND_STR, "UnisOA 流程审批平台",
|
||||
"系统名称", "显示在登录页、浏览器标题和左侧导航上。"),
|
||||
Item("site_logo", "site", ("site", "logo"), "OA_SITE_LOGO", KIND_STR, "/logo.svg",
|
||||
"Logo 路径", "相对前端静态目录的路径,也可以填一个完整 URL。"),
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
"""FastAPI application entry point for the UniSOA approval platform."""
|
||||
"""FastAPI application entry point for the UnisOA approval platform."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
|
|
@ -38,7 +38,7 @@ logging.basicConfig(
|
|||
logger = logging.getLogger("unisoa")
|
||||
|
||||
app = FastAPI(
|
||||
title="UniSOA 流程审批平台",
|
||||
title="UnisOA 流程审批平台",
|
||||
description="O2OA 流程审批模块的 Python 实现(FastAPI + SQLAlchemy + MySQL)",
|
||||
version="1.0.0",
|
||||
docs_url="/api/docs",
|
||||
|
|
@ -601,7 +601,7 @@ else:
|
|||
def root_hint() -> dict:
|
||||
return ok(
|
||||
{
|
||||
"name": "UniSOA 流程审批平台 API",
|
||||
"name": "UnisOA 流程审批平台 API",
|
||||
"docs": "/api/docs",
|
||||
"hint": "前端未构建,请执行 cd frontend && pnpm build 或 pnpm dev",
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
"""Database models for the UniSOA approval platform.
|
||||
"""Database models for the UnisOA approval platform.
|
||||
|
||||
The schema is a faithful python/relational translation of the O2OA
|
||||
process-platform module (``x_processplatform_core_entity``):
|
||||
|
|
|
|||
|
|
@ -949,9 +949,9 @@ PORTAL_DOCUMENTS = [
|
|||
"cover": "notice-holiday.png",
|
||||
},
|
||||
{
|
||||
"channel": "公司通知公告", "title": "新版流程审批平台 UniSOA 上线试运行",
|
||||
"summary": "UniSOA 流程审批平台已完成请假申请、费用报销两条主流程的迁移,即日起进入试运行阶段。",
|
||||
"body": "<p>UniSOA 流程审批平台已上线,首批开放「请假申请」与「费用报销」两条流程。</p><p>相比旧平台,新平台支持可视化流程设计、或签会签、退回加签转办、已办撤回、流程代理与待办交接,并提供流程监控与统计分析。</p><p>试运行期间如遇问题,请通过综合管理部反馈。</p>",
|
||||
"channel": "公司通知公告", "title": "新版流程审批平台 UnisOA 上线试运行",
|
||||
"summary": "UnisOA 流程审批平台已完成请假申请、费用报销两条主流程的迁移,即日起进入试运行阶段。",
|
||||
"body": "<p>UnisOA 流程审批平台已上线,首批开放「请假申请」与「费用报销」两条流程。</p><p>相比旧平台,新平台支持可视化流程设计、或签会签、退回加签转办、已办撤回、流程代理与待办交接,并提供流程监控与统计分析。</p><p>试运行期间如遇问题,请通过综合管理部反馈。</p>",
|
||||
"is_hot": True, "pinned": False, "days_ago": 0,
|
||||
"cover": "notice-unisoa.png",
|
||||
},
|
||||
|
|
@ -1161,7 +1161,7 @@ def _seed_portal(db: Session) -> None:
|
|||
plan = [
|
||||
("研发中心周会", today + timedelta(days=1, hours=2), timedelta(hours=1), "研发中心",
|
||||
"研发会议室", ["张三", "李四", "周八"], "讨论本季度三个方向的落地排期。"),
|
||||
(" UniSOA 试运行问题复盘", today + timedelta(days=2, hours=5), timedelta(hours=2), "综合管理部",
|
||||
(" UnisOA 试运行问题复盘", today + timedelta(days=2, hours=5), timedelta(hours=2), "综合管理部",
|
||||
"第一会议室", ["张三", "赵六", "李四"], "收集试运行期间反馈的问题并分派整改。"),
|
||||
("财务月度对账会", today + timedelta(days=5, hours=3), timedelta(hours=1), "财务部",
|
||||
"财务洽谈室", ["孙七", "赵六"], "核对上月费用报销与付款进度。"),
|
||||
|
|
@ -1237,7 +1237,7 @@ def _seed_portal(db: Session) -> None:
|
|||
store = None
|
||||
for index, (name, extension, folder) in enumerate(PORTAL_FILES):
|
||||
payload = (
|
||||
f"# {name}\n\n这是 UniSOA 门户首页「网盘文件」面板的演示文件,"
|
||||
f"# {name}\n\n这是 UnisOA 门户首页「网盘文件」面板的演示文件,"
|
||||
f"可直接下载验证接口是否连通。\n\n生成时间:{datetime.now():%Y-%m-%d %H:%M:%s}\n"
|
||||
).encode("utf-8")
|
||||
key = f"{DEMO_DRIVE_ROOT}/演示文件/{name}"
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ TABLE_COLUMN_TYPES = (
|
|||
"time",
|
||||
"daterange",
|
||||
"month",
|
||||
"months",
|
||||
"year",
|
||||
"timerange",
|
||||
"week",
|
||||
|
|
@ -429,6 +430,82 @@ def week_text(value: object) -> str:
|
|||
return "、".join(WEEK_LABELS.get(str(item), str(item)) for item in items if str(item or "").strip())
|
||||
|
||||
|
||||
#: 多选月份那一格的写法:与「月份」同一句式(``2026-10``),跨年也照这个排。
|
||||
#: 前端镜像在 ``utils/formRuntime.ts`` 的 ``monthList`` / ``monthsText``。
|
||||
_MONTH_ITEM = re.compile(r"^\d{4}-(0[1-9]|1[0-2])$")
|
||||
|
||||
|
||||
def month_list(value: object) -> list[str]:
|
||||
"""多选月份的值整形:只留 2026-10 这样的写法,去重、按时间先后排好。"""
|
||||
items = value if isinstance(value, (list, tuple)) else ([] if value in (None, "") else [value])
|
||||
picked = {text for text in (str(item or "").strip() for item in items) if _MONTH_ITEM.match(text)}
|
||||
return sorted(picked)
|
||||
|
||||
|
||||
def months_text(value: object) -> str:
|
||||
"""多选月份念成一句人话:连着几个月并成一段。
|
||||
|
||||
一年之内写作「2026年10-11月」,跨年写作「2026年12月-2027年2月」,中间断开的各写各的;
|
||||
同一年里断开的好几段只报一次年份(「2026年1月、3-5月」)。库里存的是
|
||||
``["2026-10", "2026-11"]``,直接转字符串会把中括号灌进单元格。
|
||||
"""
|
||||
indexes = [int(item[:4]) * 12 + int(item[5:]) - 1 for item in month_list(value)]
|
||||
if not indexes:
|
||||
return ""
|
||||
runs: list[list[int]] = []
|
||||
for index in indexes:
|
||||
if runs and index == runs[-1][1] + 1:
|
||||
runs[-1][1] = index
|
||||
else:
|
||||
runs.append([index, index])
|
||||
parts: list[str] = []
|
||||
# 上一年说过一次就不再重复;跨年那一段把两头都写全,之后的一段重新报年,
|
||||
# 否则「、5月」会挂到别人家的年份底下去。
|
||||
spoken_year: int | None = None
|
||||
for start_index, end_index in runs:
|
||||
start_year, start_month = divmod(start_index, 12)
|
||||
end_year, end_month = divmod(end_index, 12)
|
||||
if start_year != end_year:
|
||||
spoken_year = None
|
||||
parts.append(f"{start_year}年{start_month + 1}月-{end_year}年{end_month + 1}月")
|
||||
continue
|
||||
span = f"{start_month + 1}月" if start_index == end_index else f"{start_month + 1}-{end_month + 1}月"
|
||||
if spoken_year == start_year:
|
||||
parts.append(span)
|
||||
else:
|
||||
spoken_year = start_year
|
||||
parts.append(f"{start_year}年{span}")
|
||||
return "、".join(parts)
|
||||
|
||||
|
||||
#: 多选月份那三档挑选姿势:取值与设计器里「挑选方式」是同一套(前端 ``monthsStyleOf``)。
|
||||
#:
|
||||
#: 这一格的候选是那一年那 12 个月,谈不上候选来源,所以这里**没有「自动」这一档**:
|
||||
#: 没配过就是下拉多选。平铺那一档摊开是 12 个格子、要吃掉一整行,不能当默认。
|
||||
#: 与前端 ``utils/formRuntime.ts`` 的 ``MONTHS_STYLES`` / ``monthsStyleOf`` 同一份口径。
|
||||
MONTHS_TYPE = "months"
|
||||
MONTHS_STYLES = ("dropdown", "dialog", "inline")
|
||||
MONTHS_STYLE_DEFAULT = "dropdown"
|
||||
|
||||
|
||||
def months_style_of(field: dict) -> str:
|
||||
"""这一格该用哪一种姿势挑:认不出的写法(手改的、别的类型留下的)一律回落到默认那档。"""
|
||||
style = str((field or {}).get("pickerStyle") or "").strip()
|
||||
return style if style in MONTHS_STYLES else MONTHS_STYLE_DEFAULT
|
||||
|
||||
|
||||
def months_config_problems(field: dict) -> list[str]:
|
||||
"""多选月份这一格自己的配置问题(设计期):眼下只有挑选姿势认不认这一条。
|
||||
|
||||
保存时 ``api/design.py`` 会把认不出的写法收掉,这一句是给接口与 AI 起草那条路兜底——
|
||||
一个不认识的值活到填单那一刻,就只剩渲染器替人猜该画哪一只控件了。
|
||||
"""
|
||||
style = str(field.get("pickerStyle") or "").strip()
|
||||
if style and style not in MONTHS_STYLES:
|
||||
return [f"的挑选方式不认识:{style}(下拉多选 / 弹出框多选 / 平铺点选 三选一)"]
|
||||
return []
|
||||
|
||||
|
||||
def markdown_text(value: object) -> str:
|
||||
"""把 Markdown 原文压成一段适合进表格 / 标题的纯文本。
|
||||
|
||||
|
|
@ -599,6 +676,11 @@ def value_problems(fields: Iterable[dict], perms: dict[str, str], data: dict) ->
|
|||
text = str(value or "").strip()
|
||||
if text and not _DEFAULT_YEAR.match(text):
|
||||
problems.append(f"「{label}」不是 2026 这样的年份")
|
||||
elif kind == "months":
|
||||
items = value if isinstance(value, (list, tuple)) else ([] if value in (None, "") else [value])
|
||||
odd = [str(item) for item in items if not _MONTH_ITEM.match(str(item or "").strip())]
|
||||
if odd:
|
||||
problems.append(f"「{label}」里有不是 2026-01 这样写法的月份({'、'.join(odd)})")
|
||||
elif kind in ("timerange", "daterange", "week", LOCATION_TYPE):
|
||||
problem = _shape_problem(kind, value)
|
||||
if problem:
|
||||
|
|
@ -1414,6 +1496,9 @@ def validate_schema(fields: Iterable[dict], db=None) -> list[str]:
|
|||
reason = unit_problem(column.get("unit"))
|
||||
if reason:
|
||||
problems.append(f"「{label}」的列「{column_label}」的单位{reason}")
|
||||
if column_type == MONTHS_TYPE:
|
||||
for reason in months_config_problems(column):
|
||||
problems.append(f"「{label}」的列「{column_label}」{reason}")
|
||||
# 默认值写歪 = 表单存得下来、那一格却永远空着;带出来源那一条在
|
||||
# ``autofill.problems`` 里一起判,两边都是保存那一刻挡下来。
|
||||
default_problem = column_default_problem(column)
|
||||
|
|
@ -1448,6 +1533,8 @@ def validate_schema(fields: Iterable[dict], db=None) -> list[str]:
|
|||
problems.extend(f"「{label}」{reason}" for reason in text_config_problems(field))
|
||||
if kind in FILE_LIMIT_TYPES:
|
||||
problems.extend(f"「{label}」{reason}" for reason in file_config_problems(field))
|
||||
if kind == MONTHS_TYPE:
|
||||
problems.extend(f"「{label}」{reason}" for reason in months_config_problems(field))
|
||||
if kind == "spacer" and field.get("height") not in (None, ""):
|
||||
height = _number(field.get("height"))
|
||||
if height is None or height < SPACER_MIN_HEIGHT or height > SPACER_MAX_HEIGHT:
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ def account_reserved_reason(account: str) -> str:
|
|||
|
||||
def _system_account_hint(account: str) -> str:
|
||||
return (
|
||||
f"{account} 是 UniSOA 内置超管(应急账号):不走统一身份,本地口令是唯一入口。"
|
||||
f"{account} 是 UnisOA 内置超管(应急账号):不走统一身份,本地口令是唯一入口。"
|
||||
"这里不许改名、改角色、停用或删除;要换账号名请改 [seed] admin_account 后重启,"
|
||||
"启动时会自动对齐;要轮换应急口令请用本人「修改密码」"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -894,7 +894,8 @@ ON_ERROR_POLICIES = ("", "block", "keep")
|
|||
#: 附件与签名类字段装不下一笔额度。明细表不算在这里:它靠 ``quota.rows`` 逐行控多笔
|
||||
#: 装不下一笔额度的类型:附件那几类是一堆文件,定位是一包经纬度 + 地址,
|
||||
#: 时间段与星期是一串钟点——都不是一笔能扣台账的数。与前端 fieldCapabilities 同口径。
|
||||
UNCONTROLABLE_TYPES = ("attachment", "image", "file", "sign", "signature", "location", "timerange", "week")
|
||||
UNCONTROLABLE_TYPES = ("attachment", "image", "file", "sign", "signature", "location", "timerange", "week",
|
||||
"months")
|
||||
|
||||
|
||||
def _form_ref(expr: object) -> str:
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ TEXT_TYPES = ("text", "textarea", "richtext", "mobile", "email", "idcard", "url"
|
|||
"select", "picker", "radio", "auto", "hidden")
|
||||
#: 值是数组/对象的类型:多选、部门、人员、附件、日期区间、明细表……
|
||||
BAG_TYPES = ("daterange", "checkbox", "dept", "cascader", "user", "relation", "address",
|
||||
"timerange", "week", "location",
|
||||
"timerange", "week", "months", "location",
|
||||
"attachment", "image", "signature", "sign", "file", "table")
|
||||
FLAG_TYPES = ("switch",)
|
||||
#: 认不出的类型(以后新加的)一律不设限:宁可少说一句,也别把没见过的写法判成毛病。
|
||||
|
|
|
|||
|
|
@ -118,6 +118,7 @@ _SAMPLE_BY_TYPE = {
|
|||
"year": "2026",
|
||||
"richtext": "示例说明",
|
||||
"week": "周一、周三",
|
||||
"months": "2026年10-11月",
|
||||
"location": "上海市浦东新区(121.5, 31.2)",
|
||||
"mobile": "13800000000",
|
||||
"email": "demo@example.com",
|
||||
|
|
@ -362,6 +363,8 @@ def _sample_value(field: dict) -> Any:
|
|||
return ["09:00", "10:30"]
|
||||
if kind == "week":
|
||||
return ["1", "3", "5"]
|
||||
if kind == "months":
|
||||
return ["2026-10", "2026-11"]
|
||||
if kind == formruntime.LOCATION_TYPE:
|
||||
return {"lng": "121.5", "lat": "31.2", "address": "上海市浦东新区"}
|
||||
if kind == "auto":
|
||||
|
|
@ -1074,6 +1077,8 @@ def _field_text(db: Session, field: dict, value: Any, cache: dicts.DictCache) ->
|
|||
return formruntime.range_text(value, " 至 ")
|
||||
if kind == "week":
|
||||
return formruntime.week_text(value)
|
||||
if kind == "months":
|
||||
return formruntime.months_text(value)
|
||||
if kind == formruntime.LOCATION_TYPE:
|
||||
return formruntime.location_text(value)
|
||||
if kind == "richtext":
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 9.2 KiB |
|
|
@ -1,5 +1,5 @@
|
|||
# =============================================================================
|
||||
# UniSOA 后端配置文件 —— 生产档模板(复制成 config.prod.toml 再填)
|
||||
# UnisOA 后端配置文件 —— 生产档模板(复制成 config.prod.toml 再填)
|
||||
# -----------------------------------------------------------------------------
|
||||
# 部署机上:
|
||||
# cd backend
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# =============================================================================
|
||||
# UniSOA 后端配置文件 —— 各环境公共的基础值(base)
|
||||
# UnisOA 后端配置文件 —— 各环境公共的基础值(base)
|
||||
# -----------------------------------------------------------------------------
|
||||
# 配置文件按环境分档,本文件只放"每个环境都一样"的东西:档位开关、站点名与描述、
|
||||
# 签名算法、监听地址端口。每个环境自己的差异写在同目录的 config.<环境名>.toml 里:
|
||||
|
|
@ -49,7 +49,7 @@
|
|||
# 永远读不到(文件路径本身就是它决定的),后端会在日志里提醒一句并忽略。
|
||||
# -----------------------------------------------------------------------------
|
||||
[env]
|
||||
name = "dev"
|
||||
name = "prod"
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# 哪些项必须写在 config.<环境名>.toml 里(本文件不放,放了也是被盖住的那一层):
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# =============================================================================
|
||||
# UniSOA 后端配置文件模板(引导配置 + 全部运行配置的出厂值)
|
||||
# UnisOA 后端配置文件模板(引导配置 + 全部运行配置的出厂值)
|
||||
# -----------------------------------------------------------------------------
|
||||
# 本文件是**全量清单**:一个配置项都不漏,每项旁边都有中文注释与环境变量名,
|
||||
# 当字典查用。实际部署不用把整份抄回去:
|
||||
|
|
@ -120,7 +120,7 @@ cors_origins = ["http://localhost:3000", "http://127.0.0.1:3000"]
|
|||
# -----------------------------------------------------------------------------
|
||||
[site]
|
||||
# 系统名称(OA_SITE_NAME)
|
||||
name = "UniSOA 流程审批平台"
|
||||
name = "UnisOA 流程审批平台"
|
||||
# Logo 路径(OA_SITE_LOGO),相对前端静态目录
|
||||
logo = "/logo.svg"
|
||||
# 一句话描述(OA_SITE_DESCRIPTION),显示在登录页
|
||||
|
|
|
|||
|
|
@ -0,0 +1,134 @@
|
|||
#!/usr/bin/env python3
|
||||
"""多选月份那一格的「挑选方式」存不存得住、认不认得。
|
||||
|
||||
PYTHONPATH=. python3 scripts/check_months_style.py
|
||||
|
||||
来由:那一格最初只有一种长相——12 个月的盘子摊在表单里,一整行没了。现在让它挑姿势
|
||||
(下拉多选 / 弹出框多选 / 平铺点选),用的是设计器里已有的那份 ``pickerStyle``,
|
||||
于是最容易坏的不是控件,是**保存那一路把它当残骸收掉**:
|
||||
|
||||
* ``api/design.py`` 的 ``clean_option_source`` 见「这一类没有候选来源」就连 ``pickerStyle``
|
||||
一起抹(多选月份不在 ``source_kinds_of`` 的清单里)——配的人挑了弹出框,存一次默默掉回下拉;
|
||||
* 反过来,换成文本框之后那一格还留着 ``pickerStyle``,看着是文本框,读出来却带着上一类的
|
||||
展现配置,下一个人无从知道它为什么在那儿。
|
||||
|
||||
钉这十七句:三档都认、默认是下拉(平铺要吃掉一整行,不能当默认)、认不出的写法收掉并在
|
||||
保存那一刻说一句、明细列同理、换成别的类型跟着收、值与念法照旧。全程不碰库。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
|
||||
from app.api.design import clean_option_source
|
||||
from app.service import formruntime
|
||||
|
||||
FAILS: list[str] = []
|
||||
|
||||
|
||||
def check(label: str, got: object, want: object) -> None:
|
||||
if got != want:
|
||||
FAILS.append(f"{label}:想要 {want!r},拿到 {got!r}")
|
||||
|
||||
|
||||
def fields_of(*items: dict) -> dict:
|
||||
return {"fields": list(items)}
|
||||
|
||||
|
||||
def cleaned(field: dict) -> dict:
|
||||
return clean_option_source(fields_of(field))["fields"][0]
|
||||
|
||||
|
||||
# ------------------------------------------------------------------ 认档与默认
|
||||
check("默认那一档", formruntime.months_style_of({}), "dropdown")
|
||||
check("弹出框认得", formruntime.months_style_of({"pickerStyle": "dialog"}), "dialog")
|
||||
check("平铺认得", formruntime.months_style_of({"pickerStyle": "inline"}), "inline")
|
||||
check("下拉认得", formruntime.months_style_of({"pickerStyle": "dropdown"}), "dropdown")
|
||||
# 「自动」是那两格下拉组件的说法:多选月份只有一档默认,摆「自动」等于让人猜
|
||||
check("auto 回落默认", formruntime.months_style_of({"pickerStyle": "auto"}), "dropdown")
|
||||
check("瞎写的回落默认", formruntime.months_style_of({"pickerStyle": "popup"}), "dropdown")
|
||||
check("脏空格照样认", formruntime.months_style_of({"pickerStyle": " dialog "}), "dialog")
|
||||
|
||||
# ------------------------------------------------------------------ 保存那一路
|
||||
check(
|
||||
"配了弹出框存得住",
|
||||
cleaned({"key": "m", "label": "停用月份", "type": "months", "pickerStyle": "dialog"}).get("pickerStyle"),
|
||||
"dialog",
|
||||
)
|
||||
check(
|
||||
"配了平铺存得住",
|
||||
cleaned({"key": "m", "label": "停用月份", "type": "months", "pickerStyle": "inline"}).get("pickerStyle"),
|
||||
"inline",
|
||||
)
|
||||
check(
|
||||
"认不出的写法收掉",
|
||||
"pickerStyle" in cleaned({"key": "m", "label": "停用月份", "type": "months", "pickerStyle": "popup"}),
|
||||
False,
|
||||
)
|
||||
check(
|
||||
"多选月份不许挂候选来源",
|
||||
"optionSource" in cleaned({"key": "m", "label": "停用月份", "type": "months", "optionSource": "dict"}),
|
||||
False,
|
||||
)
|
||||
check(
|
||||
"换成文本框之后那一档跟着收",
|
||||
"pickerStyle" in cleaned({"key": "m", "label": "停用月份", "type": "text", "pickerStyle": "dialog"}),
|
||||
False,
|
||||
)
|
||||
check(
|
||||
"选择类的挑选方式照旧存得住(这次改动没把它们带坏)",
|
||||
cleaned({"key": "s", "label": "类别", "type": "select", "pickerStyle": "inline", "options": [{"value": "a"}]}).get(
|
||||
"pickerStyle"
|
||||
),
|
||||
"inline",
|
||||
)
|
||||
|
||||
# ------------------------------------------------------------------ 保存那一刻的说法
|
||||
bogus = {"key": "m", "label": "停用月份", "type": "months", "pickerStyle": "popup"}
|
||||
problems = formruntime.validate_schema([bogus])
|
||||
check("主表那一格配歪了会说", any("挑选方式不认识" in line for line in problems), True)
|
||||
check(
|
||||
"说的时候带上是哪一格",
|
||||
any("「停用月份」" in line for line in problems if "挑选方式不认识" in line),
|
||||
True,
|
||||
)
|
||||
check(
|
||||
"配对了不多说一句",
|
||||
formruntime.validate_schema([{"key": "m", "label": "停用月份", "type": "months", "pickerStyle": "dialog"}]),
|
||||
[],
|
||||
)
|
||||
column_bogus = {
|
||||
"key": "rows",
|
||||
"label": "明细",
|
||||
"type": "table",
|
||||
"columns": [{"key": "m", "label": "停用月份", "type": "months", "pickerStyle": "popup"}],
|
||||
}
|
||||
column_problems = formruntime.validate_schema([column_bogus])
|
||||
check("明细那一列同样会说", any("的列「停用月份」的挑选方式不认识" in line for line in column_problems), True)
|
||||
|
||||
# ------------------------------------------------------------------ 值与念法照旧
|
||||
check("并段那句没被带坏", formruntime.months_text(["2026-11", "2026-10"]), "2026年10-11月")
|
||||
check(
|
||||
"跨年两头写全",
|
||||
formruntime.months_text(["2026-12", "2027-01", "2027-02", "2027-05"]),
|
||||
"2026年12月-2027年2月、2027年5月",
|
||||
)
|
||||
check("脏值丢掉、去重、按时间排", formruntime.month_list(["2026-11", "2026-11", "2026-13", "x"]), ["2026-11"])
|
||||
value_problems = formruntime.value_problems(
|
||||
[{"key": "m", "label": "停用月份", "type": "months", "required": True}], {"m": "editable"}, {"m": ["2026-10", "十月"]}
|
||||
)
|
||||
check("提交时那一项写法不对会挡", any("2026-01 这样写法的月份" in line for line in value_problems), True)
|
||||
|
||||
|
||||
def main() -> int:
|
||||
for line in FAILS:
|
||||
print(f"[FAIL] {line}")
|
||||
if FAILS:
|
||||
print(f"共 {len(FAILS)} 句不对")
|
||||
return 1
|
||||
print("通过:多选月份的挑选方式认档、存得住、配歪了当场说(17 句)")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
# Start the UniSOA API (schema bootstrap + seed run on boot).
|
||||
# Start the UnisOA API (schema bootstrap + seed run on boot).
|
||||
# 本机开发:默认读测试档配置文件(config.toml + config.dev.toml)。
|
||||
# 想临时换一档:OA_ENV=test ./scripts/dev-api.sh
|
||||
set -euo pipefail
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ from sqlalchemy import text # noqa: E402
|
|||
|
||||
from app.db import engine, settings # noqa: E402
|
||||
|
||||
HEADER = """-- UniSOA 流程审批平台 -- MySQL 结构快照
|
||||
HEADER = """-- UnisOA 流程审批平台 -- MySQL 结构快照
|
||||
-- 来源: {host}:{port}/{database}
|
||||
-- 导出时间: {stamp}
|
||||
--
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ def render(spec: tuple[str, str, str, str, str, str, str]) -> Path:
|
|||
draw.rounded_rectangle([52, CLEAR_TOP + 2, 52 + tag_w + 32, CLEAR_TOP + 42], radius=20, fill=rgb(accent) + (60,))
|
||||
draw.text((52 + 16, CLEAR_TOP + 9), tag, font=tag_font, fill=(255, 255, 255, 235))
|
||||
mark_x = 52 + tag_w + 32 + 22
|
||||
draw.text((mark_x, CLEAR_TOP + 4), "UniSOA", font=mark_font, fill=(255, 255, 255, 205))
|
||||
draw.text((mark_x, CLEAR_TOP + 4), "UnisOA", font=mark_font, fill=(255, 255, 255, 205))
|
||||
draw.rounded_rectangle([44, CLEAR_TOP + 2, 49, CLEAR_BOTTOM - 6], radius=3, fill=rgb(accent) + (230,))
|
||||
base.alpha_composite(overlay)
|
||||
|
||||
|
|
|
|||
|
|
@ -42,6 +42,6 @@ fi
|
|||
# OA_WORKERS = HTTP 进程数(默认 1,与不设时一样)。多开之前先算一笔连接账:
|
||||
# 进程数 ×([database] pool_size + max_overflow)别大过 MySQL 的 max_connections,
|
||||
# 超了不是变慢而是排队。后台任务不受它影响,见 docs/multi-worker-deployment.md。
|
||||
echo "UniSOA API 启动中:OA_ENV=$OA_ENV OA_WORKERS=${OA_WORKERS:-1}"
|
||||
echo "UnisOA API 启动中:OA_ENV=$OA_ENV OA_WORKERS=${OA_WORKERS:-1}"
|
||||
exec python3 -m uvicorn app.main:app --host "${OA_HOST:-0.0.0.0}" --port "${OA_PORT:-8000}" \
|
||||
--workers "${OA_WORKERS:-1}"
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ MinIO / 统一身份那套真值都在镜像里,**集群里一份配置都不
|
|||
| --- | --- |
|
||||
| 仓库 | `docker.oa.unissense.tech/public/unis_oa`(Harbor,`public` 项目,匿名可拉) |
|
||||
| 架构 | `linux/amd64` |
|
||||
| tag | 时间戳(当前 `202611021222`)+ `latest` |
|
||||
| tag | 时间戳(当前 `202611021800`)+ `latest` |
|
||||
| 大小 | 压缩后约 96 MB |
|
||||
| 端口 | `8000`(后端 API 与前端静态页同源,一个容器全包) |
|
||||
| 配置 | 自带 `config.toml` + `config.prod.toml`(含密钥),不挂配置也能起 |
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# =============================================================================
|
||||
# UniSOA(unis_oa)K3S 部署清单 —— 就这一个文件,整份贴进去导入即可
|
||||
# UnisOA(unis_oa)K3S 部署清单 —— 就这一个文件,整份贴进去导入即可
|
||||
# -----------------------------------------------------------------------------
|
||||
# 镜像 docker.oa.unissense.tech/public/unis_oa(Harbor,linux/amd64):构建时把
|
||||
# backend/config.prod.toml 烤进了镜像,MySQL / Redis / MinIO / 统一身份那套真值都在
|
||||
|
|
@ -152,6 +152,45 @@ spec:
|
|||
containers:
|
||||
- name: unis-oa
|
||||
# 钉时间戳 tag:回滚才有得选。想用 latest 就把下面 imagePullPolicy 改成 Always
|
||||
# 202611021707 起:「多选月份」不再一上来就平铺吃掉一整行,这一格长什么样交给配的人挑。
|
||||
# 属性面板上多出「挑选方式」三档,用的是字段上已有的 pickerStyle(与设计器里那套同名同值):
|
||||
# dropdown 下拉多选 = 默认,字段上不写东西——一只输入框样子的按钮,框里挂「2026年10-11月」
|
||||
# 那一句,点开出那一年的 12 个月,挑完点外面就收,半行就放得下;
|
||||
# dialog 弹出框多选 = 同一面盘搬到屏幕正中、格子大一号;改的是草稿,点「确定」才写进这一格,
|
||||
# 取消等于没挑过(手机上、或那一屏本来就窄时划算);
|
||||
# inline 平铺点选 = 12 个月一直摊在这一格里,不用点开就看得全,代价是一整行——选它时
|
||||
# 属性面板顺手把这一格铺满(换回下拉不缩,宽度是人自己调过的)。
|
||||
# 这一类**没有「自动」那一档**:只有一档默认,摆「自动」等于让人猜默认在哪儿。判"这一格要不要
|
||||
# 摆挑选方式那一栏"问 carriesStyleChoice(有候选来源那几类 + 多选月份),别再问
|
||||
# carriesOptionSource——那一句只管来源。明细表那一列同样挑得到,只是明细格子里永远不给摊开
|
||||
# (一行的高度放不下一个盘子)。拖进来那一刻的宽度也跟着从 12 列改成 6 列,与「月份」对齐。
|
||||
# ⚠️ 后端 api/design.py:clean_option_source 为这一类单开了一条:它没有候选来源,走老那句
|
||||
# "没有来源就整份撤掉"的捷径会把 pickerStyle 连配置一起抹掉——界面上挑了弹出框、存一次
|
||||
# 默默掉回下拉,一句报错都没有。所以这一版要整份换,别只换前端产物。
|
||||
# 回归 PYTHONPATH=. python3 scripts/check_months_style.py(17 句,不连库)+
|
||||
# utils/formRuntime.months.spec.ts + components/oa/MonthsField.spec.ts +
|
||||
# design/FieldInspector.newTypes.spec.ts + design/FormDesignerView.monthsWidth.spec.ts;
|
||||
# 浏览器里量过:弹层挂在按钮下面 268×140 且不推动周围版面,弹出框 462×106(六个一行)。
|
||||
# 本版模型没有新列新索引,生产库不用跑 ensure_columns / ensure_indexes。
|
||||
# 202611021622 起:表单加了一类「多选月份」,另把「我的已办」的列宽重排。
|
||||
# ① months 多选月份(字段总数 43 → 44 类):一次圈几个月,值仍是排好序去重后的
|
||||
# ["2026-10","2026-11"](与 month 同一写法,条件与导出读得懂),给人看的那一句
|
||||
# 连着几个月并成一段——挑 10、11 两月回填「2026年10-11月」,跨年写作
|
||||
# 「2026年12月-2027年2月」。判据 utils/formRuntime.monthList/monthsText
|
||||
# ↔ service/formruntime.month_list/months_text,只读态、打印、导出、标题同一句;
|
||||
# 这一格装的是一串月份,条件与阈值只判得出「填了没有」,额度挂不上
|
||||
# (fieldCapabilities.BAG_TYPES ↔ threshold.BAG_TYPES、quota.UNCONTROLABLE_TYPES)。
|
||||
# 回归 utils/formRuntime.months.spec.ts + components/oa/MonthsField.spec.ts。
|
||||
# ②「我的已办」操作列原先把整张表撑到 14000 多像素(DataTable 默认挂 min-w-max,
|
||||
# 列上写百分比会按整表 max-content 结算),环节/结果/时间全被挤出屏幕。现在
|
||||
# DataTable 支持 table-class,那一页改走 table-fixed min-w-[900px]:定宽那几列写
|
||||
# 像素并挂 overflow-hidden,标题与意见分剩余空间;操作列收成图标按钮
|
||||
# (title + aria-label),不可撤回的原因收成一枚图标交给悬浮提示。1600/1200/980
|
||||
# 三档宽度实测四列 116/92/152/116、无横向滚动。回归 components/common/DataTable.spec.ts
|
||||
# + views/oa/DoneListView.spec.ts(1051 项前端用例全绿)。
|
||||
# 顺带:站点显示名全线由 UniSOA 改成 UnisOA(登录页、浏览器标题、PWA manifest、
|
||||
# 门户演示数据与封面图、部署清单与文档),不改任何库里的值。
|
||||
# 本版模型没有新列新索引,生产库不用跑 ensure_columns / ensure_indexes。
|
||||
# 202611021222 起:生产上那两个「看着是坏了」的判断。
|
||||
# ①「默认隐藏」把「显示条件」盖掉了。field.hidden 排在 visibleWhen 前面判,于是勾了
|
||||
# 默认隐藏又配了显示条件的格子,除非流程里每个环节都显式点名它,否则哪个环节都不露,
|
||||
|
|
@ -550,7 +589,7 @@ spec:
|
|||
# 「服务器内部错误,请稍后重试(编号 xxxxxxxx)」)
|
||||
# 202610261047 起:镜像自带 backend/config.prod.toml(含密钥),且修了口令带 @ 时
|
||||
# DSN 被撕成两个主机名的坑(backend/scripts/check_db_dsn.py 盯着)
|
||||
image: docker.oa.unissense.tech/public/unis_oa:202611021222
|
||||
image: docker.oa.unissense.tech/public/unis_oa:202611021800
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- name: http
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>UniSOA 设计稿 · 大模型怎么用</title>
|
||||
<title>UnisOA 设计稿 · 大模型怎么用</title>
|
||||
<style>
|
||||
:root{
|
||||
--primary:#14b8a6; --primary-600:#0d9488; --primary-700:#0f766e; --primary-50:#f0fdfa; --primary-100:#ccfbf1;
|
||||
|
|
@ -155,7 +155,7 @@
|
|||
<div class="side-head">
|
||||
<div class="logo">OA</div>
|
||||
<div style="min-width:0">
|
||||
<div class="side-title">UniSOA 流程审批</div>
|
||||
<div class="side-title">UnisOA 流程审批</div>
|
||||
<div class="side-sub">大模型使用设计稿</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>UniSOA 前端设计稿 · 流程 / 表单 / 单据</title>
|
||||
<title>UnisOA 前端设计稿 · 流程 / 表单 / 单据</title>
|
||||
<style>
|
||||
:root{
|
||||
--primary:#14b8a6; --primary-600:#0d9488; --primary-700:#0f766e; --primary-50:#f0fdfa; --primary-100:#ccfbf1;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# =============================================================================
|
||||
# UniSOA 单机部署(docker compose)
|
||||
# UnisOA 单机部署(docker compose)
|
||||
# -----------------------------------------------------------------------------
|
||||
# 先把生产配置放到 ./deploy/config/ 里:
|
||||
# config.prod.toml 照 backend/config.prod.toml.example 填(库、密钥、Hub、MinIO)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# UniSOA 架构与接口参考
|
||||
# UnisOA 架构与接口参考
|
||||
|
||||
面向二次开发的详细说明。上手运行请看 [../README.md](../README.md)。
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# 字段类型总表:43 类组件各管什么、值长什么样、哪一道闸判它
|
||||
# 字段类型总表:44 类组件各管什么、值长什么样、哪一道闸判它
|
||||
|
||||
> 相关:[option-source-design.md](option-source-design.md)(选择类四兄弟的候选来源)、
|
||||
> [form-data-integration-design.md](form-data-integration-design.md)(五种取数形态)、
|
||||
|
|
@ -10,8 +10,9 @@
|
|||
|
||||
| 问题 | 结论 |
|
||||
| --- | --- |
|
||||
| 一共几类 | **43 类**(`utils/formLayout.ts` 的 `FIELD_TYPES`,左侧字段库按 基础 / 选择类 / 人与附件 / 系统带出 / 布局 五段摆) |
|
||||
| 一共几类 | **44 类**(`utils/formLayout.ts` 的 `FIELD_TYPES`,左侧字段库按 基础 / 选择类 / 人与附件 / 系统带出 / 布局 五段摆) |
|
||||
| 这一轮新加的 | `richtext` 富文本、`month` 月份、`year` 年份、`timerange` 时间段、`week` 星期、`location` 定位、`group` 分组标题、`spacer` 空白占位 |
|
||||
| 最新加的一类 | `months` 多选月份——一次圈几个月,连着几个月自动并成一段:挑 2026 年 10、11 两月,回填就是「2026年10-11月」。值仍是 `YYYY-MM` 数组,与 `month` 同一写法,见 §2.7 |
|
||||
| 最近加的一类 | `tabs` 标签页——把这张单切成几页,其中一页可以整页让给一个外部系统,那个页面才占得满一屏。同样是**版面不是值**,但归属记在*别的*字段身上(每格一个 `tab`),见 [form-tabs-embed-design.md](form-tabs-embed-design.md) §1 |
|
||||
| 又加了一类 | `embed` 外部页面——把别的业务系统的页面嵌进表单,同一个功能不用在 OA 再开发一遍。它是**版面不是值**,但比 `group` 多一件事:它的 `key` 是环节字段权限的挂点,见 [embed-page-field-design.md](embed-page-field-design.md) |
|
||||
| 顺带捞回来的 | `signature` 手写签名——控件、只读态、导出、打印**早就写好了**,唯独左侧字段库没登记,于是界面上永远加不出这一类字段 |
|
||||
|
|
@ -20,7 +21,7 @@
|
|||
| 谁来防 | `frontend/src/utils/fieldCatalog.spec.ts`:拿 Node 的 `fs` 直接读后端源码,把「前端有的后端也得有」钉成断言 |
|
||||
| 权威判定在哪 | **只有后端一次**(`service/formruntime.py:validate_submit`)。前端那几道(`maxlength`、`accept`、个数截断)只是别让人白等一次上传 |
|
||||
|
||||
## 1. 总表:43 类
|
||||
## 1. 总表:44 类
|
||||
|
||||
「条件」那一列是流程设计器里能拿这一格比什么(口径 `utils/fieldCapabilities.ts` ↔
|
||||
后端 `service/threshold.py`);「明细列」是这一类能不能当明细表的一列
|
||||
|
|
@ -40,6 +41,7 @@
|
|||
| `time` | 时间 | `09:30` | ✓ | 先后 | |
|
||||
| `daterange` | 日期区间 | `["起","止"]` | ✓ | 只判空 | 起止颠倒会被提交挡下 |
|
||||
| `month` | 月份 | `2026-03` | ✓ | 先后 | 月度报销 / 月度报表那一类 |
|
||||
| `months` | 多选月份 | `["2026-10","2026-11"]`(去重升序) | ✓ | 只判空 | 并成「2026年10-11月」;下拉 / 弹出框 / 平铺三档挑,见 §2.7 |
|
||||
| `year` | 年份 | 整数 `2026` | ✓ | 数值 | 不是字符串,条件按数字比大小 |
|
||||
| `timerange` | 时间段 | `["09:00","10:30"]` | ✓ | 只判空 | 考勤、会议、值班;同样判先后 |
|
||||
| `week` | 星期 | `["1","3","5"]`(1=周一) | ✓ | 只判空 | 排班、窗口开放日;条件按「包含」判某天 |
|
||||
|
|
@ -150,6 +152,36 @@
|
|||
|
||||
设计与取舍见 [form-tabs-embed-design.md](form-tabs-embed-design.md)。
|
||||
|
||||
### 2.7 多选月份并成一段,值的写法不变
|
||||
|
||||
`months` 那一格存的是 `["2026-10", "2026-11"]`——**与 `month` 同一句式**(`YYYY-MM`),
|
||||
去重、按时间排好,条件分支和导出读得懂,不像「2026年10、11月」那种人话还得再翻一遍。
|
||||
给人看的那一句由 `utils/formRuntime.ts:monthsText` ↔ `service/formruntime.py:months_text`
|
||||
现拼:连着几个月并成一段,同一年里只报一次年份,跨年那段两头都写全。
|
||||
|
||||
| 挑中 | 回填 / 只读 / 导出 |
|
||||
| --- | --- |
|
||||
| 2026-10、2026-11 | 2026年10-11月 |
|
||||
| 2026-01、2026-02、2026-05、2027-07 | 2026年1-2月、5月、2027年7月 |
|
||||
| 2026-12、2027-01、2027-02、2027-05 | 2026年12月-2027年2月、2027年5月 |
|
||||
|
||||
它装是一串月份,所以阈值与条件只判得出「填了没有」(`fieldCapabilities.BAG_TYPES` ↔
|
||||
`threshold.BAG_TYPES`、`routeExpression` 的 `OPAQUE_TYPES`),额度也挂不上
|
||||
(`UNQUOTABLE_TYPES` ↔ `quota.UNCONTROLABLE_TYPES`)——一串月份不是一笔能扣台账的数。
|
||||
|
||||
**这一格长什么样由配的人挑**:`pickerStyle` 三档,与设计器里「挑选方式」同一套取值
|
||||
(`utils/formRuntime.ts:monthsStyleOf` ↔ `service/formruntime.py:months_style_of`)。
|
||||
|
||||
| 档位 | 界面上是什么 | 什么时候用 |
|
||||
| --- | --- | --- |
|
||||
| `dropdown` 下拉多选(**默认**,字段上不写东西) | 一只长得像输入框的按钮,框里挂「2026年10-11月」那一句;点开出那一年的 12 个月,挑完点外面就收 | 半行就放得下,一张单摆两三个月份格子也不挤 |
|
||||
| `dialog` 弹出框多选 | 同一面盘搬到屏幕正中的弹出框里,格子大一号;改的是草稿,点「确定」才写进这一格,取消等于没挑 | 手机上、或那一屏本来就窄 |
|
||||
| `inline` 平铺点选 | 12 个月一直摊在这一格里,不用点开 | 想让「这个季度选了哪几个月」一眼看全;代价是吃掉一整行,属性面板会顺手把这一格铺满 |
|
||||
|
||||
这一类**没有「自动」那一档**(只有一档默认,摆两档等于让人猜),所以 `carriesStyleChoice`
|
||||
把它算进"要摆挑选方式那一栏",`carriesOptionSource` 仍然不算它——那一句只管候选来源那四类。
|
||||
明细表那一列同理,列上也能挑;明细格子里永远不给摊开(一行的高度放不下一个盘子)。
|
||||
|
||||
## 3. 配错了在哪一步说
|
||||
|
||||
| 时机 | 判什么 | 在哪 |
|
||||
|
|
@ -157,7 +189,7 @@
|
|||
| 设计器保存 | 类型不认识、纯排版勾了必填、该不该有标题、正则编译不过、字数上限离谱、附件三个限制越界、空白高度出格、明细列类型不支持、外部页面没挑页面 / 页面被删 / 参数是那个页面用不上的、标签页没配页 / 页签没名字 / 页签标识重复 / 外部页面那一页上还压着格子 / 摆了不止一个标签页 | 前端 `utils/formLayout.ts:validateFields` 与 `utils/formRuntime.ts:embedConfigProblems`;后端 `formruntime.validate_schema`(含 `embed.problems`)+ `api/design.py` 的字段校验 |
|
||||
| 保存落库前 | 换了类型就收掉上一类留下的配置:展现格式按 `FORMAT_OWNERS`,限制按 `LIMIT_OWNERS` | `api/design.py:clean_formats` |
|
||||
| 填单时 | `maxlength`、`accept`、个数与大小、年份与月份的原生控件 | `FormFieldControl` 与 `AttachmentUploader`(只为体验,不是闸门) |
|
||||
| 提交时 | 必填、正则(**整格**匹配)、长度、月份/年份写法、星期取值、时间段与日期区间的先后、附件类型/个数/大小 | 后端 `formruntime.validate_submit`(主表 `value_problems`,明细行 `_row_problems`) |
|
||||
| 提交时 | 必填、正则(**整格**匹配)、长度、月份/年份写法、多选月份那串里每一项的写法、星期取值、时间段与日期区间的先后、附件类型/个数/大小 | 后端 `formruntime.validate_submit`(主表 `value_problems`,明细行 `_row_problems`) |
|
||||
| 只读 / 打印 / 导出 | 每一类念成一句人话 | `FormFieldControl` 只读那一支、`api/export.py:cell_text`、`service/titles.py:_field_text`。`embed` 无值,导出与打印里天然什么都不落——那条地址上挂着一次性免登短码,落进导出件等于把钥匙抄进表格 |
|
||||
|
||||
正则按 `fullmatch` 判:半匹配会让 `\d{6}` 放过 `abc123456def`,配的人以为挡住了、其实没挡。
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# UniSOA 前端设计方案
|
||||
# UnisOA 前端设计方案
|
||||
|
||||
本文是前端的地面规则:信息架构、栅格、色彩、组件、页面骨架、画布与表单规范,
|
||||
以及空态 / 加载 / 错误 / 可访问性的统一口径。所有条目都指向仓库里已有的文件,
|
||||
|
|
@ -43,6 +43,10 @@
|
|||
`page-description mt-1 text-sm`)。
|
||||
- 表格页用 `TablePageLayout.vue`:操作区、筛选区、分页器固定在流上,只有表体滚动,
|
||||
容器高度 `calc(100vh - 64px - 4rem)`。移动端(<1024px)退回整页滚动。
|
||||
- 表格列宽:`DataTable` 默认给表格挂 `min-w-max`,此时列上写百分比(连 `w-[1%]` 都算)
|
||||
会按整张表的 max-content 结算,表宽能撑到一万多像素,标题后面几列全被挤出屏幕。
|
||||
要「定宽列 + 弹性列」的排版,就给 `DataTable` 传 `table-class="table-fixed min-w-[...]"`:
|
||||
定宽那几列写像素并挂 `overflow-hidden`,没写宽度的列分剩余空间(我的已办这么排的)。
|
||||
- 表单渲染是 12 列网格,见 `frontend/src/utils/formLayout.ts` 的 `GRID_COLS = 12`;
|
||||
旧字段只有 `span: 12 | 24` 与 `layout.columns: 1 | 2`,由 `toSheet` 折算进同一套网格,
|
||||
两套渲染器(设计态画布与运行态 `FormRenderer`)因此不会各说各话。
|
||||
|
|
@ -196,6 +200,7 @@ parallel/merge/split #7c3aed 紫 script/invoke/embed #2563eb 蓝 delay #0891b
|
|||
- 断点沿用 Tailwind:`<1024px` 侧栏抽屉化(`appStore.mobileOpen`)、表格页整页滚动;
|
||||
设计器在窄屏不承诺可编辑,引导去桌面端。
|
||||
- 触控目标不小于 36px;`btn-sm` 是桌面密度,移动端列表操作改用图标按钮组。
|
||||
桌面列宽紧到文字放不下时也照此收成图标按钮组(`btn-icon`),名字挂 `title` + `aria-label`。
|
||||
- 焦点可见:全局 `focus:ring-2 ring-primary-500/50`;不要为了好看去掉 outline。
|
||||
- 画布纯 hover 交互需要补偿:连线命中区是 18px 宽的透明粗线,键盘用户可用节点属性面板
|
||||
里的路由列表打开同一条线的编辑面板。
|
||||
|
|
|
|||
|
|
@ -278,7 +278,7 @@ OA_HUB_INTEGRATION_KEY=<Hub 下发的免登应用密钥>
|
|||
## 5. 登录链路
|
||||
|
||||
```text
|
||||
浏览器 UniSOA Hub
|
||||
浏览器 UnisOA Hub
|
||||
│ 账号+密码+验证码 ─►│ │
|
||||
│ │ POST /auth/login ──────► │ 校验账号密码与验证码
|
||||
│ │ ◄── access_token ─────── │
|
||||
|
|
@ -292,7 +292,7 @@ OA_HUB_INTEGRATION_KEY=<Hub 下发的免登应用密钥>
|
|||
- **验证码是 Hub 的**。登录页 `GET /auth/captcha` 只是把 Hub 的验证码转发过来;
|
||||
本地模式下这个接口直接回 `required=false`,前端不会多出输入框。验证码是一次性
|
||||
的,登录失败后前端会自动换一张。
|
||||
- **本地发的还是 UniSOA 的 JWT**。Hub 的 token 只在登录这一瞬用于校验,不落库、
|
||||
- **本地发的还是 UnisOA 的 JWT**。Hub 的 token 只在登录这一瞬用于校验,不落库、
|
||||
不下发给浏览器,后续接口仍然按本地的权限角色与数据范围走。
|
||||
- **`hybrid` 的回退是有条件的**:只有 Hub 连不上、超时、返回 5xx/`500001` 才回退
|
||||
本地口令。Hub 明确说「账号或密码错误」(`401001`)或「验证码错误」(`400001`)
|
||||
|
|
@ -350,7 +350,7 @@ admin_account = "localadmin" # 内置超管改名;库里已有的那一行
|
|||
本系统因此有一条独立于账号密码的通道,`OA_HUB_LOGIN_MODE=sso` 时它是唯一一条(应急账号除外)。
|
||||
|
||||
```text
|
||||
浏览器 UniSOA Hub
|
||||
浏览器 UnisOA Hub
|
||||
│ 打开登录页 ──────────────►│ │
|
||||
│ ◄── state + 门户地址 ────│ POST /auth/sso/state │
|
||||
│ │ 随机 state 写进 HttpOnly Cookie
|
||||
|
|
@ -383,7 +383,7 @@ Hub 侧要先做的三件事:注册应用拿到 `code` 与密钥明文、`laun
|
|||
后端回调这一条是 302 一路走完的:
|
||||
|
||||
```text
|
||||
浏览器 UniSOA Hub
|
||||
浏览器 UnisOA Hub
|
||||
│ ◄── 302 /sso/hub?ticket=…&state=… ────────────────│ 门户点卡片
|
||||
│ ── GET /api/v1/auth/sso/callback ──►│ │
|
||||
│ │ ── tickets/verify ──►│ 一次性消费
|
||||
|
|
@ -521,7 +521,7 @@ Hub 侧要先做的三件事:注册应用拿到 `code` 与密钥明文、`laun
|
|||
|
||||
- `users.password_hash`:本地已存在的账号口令不动;同步新建的账号是随机口令,
|
||||
本来也只能回 Hub 登录。
|
||||
- `users.role` 与权限角色(`oa_auth_role`):这是 UniSOA 自己的菜单/接口/数据范围
|
||||
- `users.role` 与权限角色(`oa_auth_role`):这是 UnisOA 自己的菜单/接口/数据范围
|
||||
体系,Hub 侧的角色不参与同步。
|
||||
- `users.wecom_user_id` 不参与任何身份判定:认人只认 `hub_user_id`(6.1),这一列只是
|
||||
「要给这个人发企微消息」时查出来的收件地址,为空就是发不了,既不影响登录也不影响待办。
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# UniSOA 流程 / 表单能力对照与缺口
|
||||
# UnisOA 流程 / 表单能力对照与缺口
|
||||
|
||||
拿市面上常见的 OA / 工作流产品(钉钉审批、飞书审批、泛微 e-cology、致远 A8、O2OA)当尺子,
|
||||
逐项对照本仓库**当前代码里真的实现了**的能力,以及还差什么。
|
||||
|
|
|
|||
|
|
@ -47,6 +47,18 @@
|
|||
三维各自可选,组合的合法性由 `styleChoicesOf` 一处判(不给装不下的组合出现在下拉里,
|
||||
后端 `clean_option_source` 再兜一道)。字段类型退化成只回答一件事:**这一格装单个值还是一串值**。
|
||||
|
||||
`months` 多选月份不在那四类来源里,却共用第三维:它的候选是**那一年那 12 个月**,
|
||||
谈不上手填 / 字典 / 单据 / 数据源,但「用什么姿势挑」问的是同一件事,于是字段上照用 `pickerStyle`。
|
||||
两处不一样,都是有意为之:
|
||||
|
||||
- **这一类没有 `auto`**:它只有一档默认(`dropdown` 下拉多选),下拉里再摆「自动」等于让人猜默认在哪儿。
|
||||
口径在 `utils/formRuntime.ts:monthsStyleOf` ↔ `service/formruntime.py:months_style_of`,
|
||||
平铺那一档摊开是 12 个格子、要吃掉一整行,所以不能当默认。
|
||||
- 判「这一格要不要摆挑选方式那一栏」问 `carriesStyleChoice`(= 有候选来源的那几类 + 多选月份),
|
||||
别再问 `carriesOptionSource`——那一句只管来源。后端 `clean_option_source` 也为它单开一条:
|
||||
按"这一类没有候选来源"的捷径走,会把 `pickerStyle` 连残骸一起抹掉,配的人挑了弹出框、
|
||||
存一次就默默掉回下拉。回归 `PYTHONPATH=. python3 scripts/check_months_style.py`(17 句)。
|
||||
|
||||
## 2. 四种来源各存什么值
|
||||
|
||||
| 来源 | 这一格存的 | 候选怎么来 | 取值越界判不判 |
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@
|
|||
<link rel="manifest" href="/manifest.webmanifest" />
|
||||
<link rel="apple-touch-icon" href="/icons/apple-touch-icon.png" />
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<meta name="apple-mobile-web-app-title" content="UniSOA" />
|
||||
<title>UniSOA 流程审批平台</title>
|
||||
<meta name="apple-mobile-web-app-title" content="UnisOA" />
|
||||
<title>UnisOA 流程审批平台</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "UniSOA 流程审批平台",
|
||||
"short_name": "UniSOA",
|
||||
"name": "UnisOA 流程审批平台",
|
||||
"short_name": "UnisOA",
|
||||
"description": "待办、发起、审批:一部手机上的 OA 办公台",
|
||||
"id": "/",
|
||||
"start_url": "/",
|
||||
|
|
|
|||
|
|
@ -88,6 +88,8 @@ export interface ProcessQuery {
|
|||
startable?: string
|
||||
/** 0=不回设计稿(canvas / data_template / approval_config / title_config 回空对象) */
|
||||
with_definition?: 0 | 1
|
||||
/** 'mine' = running_count / completed_count 只算本人发起的单;不传是全系统口径 */
|
||||
count_scope?: 'mine'
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,50 @@
|
|||
// @vitest-environment jsdom
|
||||
/**
|
||||
* 表格宽度那一摊:默认跟着内容撑(min-w-max),视图传 table-class 时要把这串换掉。
|
||||
* 换不掉就白搭 —— DataTable 自己挂着 min-w-max,视图列上再写百分比(连 w-[1%] 都算),
|
||||
* 百分比会按整张表的 max-content 结算,表宽能撑到一万多像素,前面的列全被挤出屏幕。
|
||||
*/
|
||||
import { beforeAll, describe, expect, it, vi } from 'vitest'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import { createI18n } from 'vue-i18n'
|
||||
import zh from '@/i18n/locales/zh'
|
||||
import DataTable from './DataTable.vue'
|
||||
|
||||
const i18n = createI18n({ legacy: false, locale: 'zh', messages: { zh } })
|
||||
const columns = [
|
||||
{ key: 'title', label: '标题' },
|
||||
{ key: 'actions', label: '操作' }
|
||||
]
|
||||
const data = [{ id: 1, title: '一份报销单' }]
|
||||
|
||||
beforeAll(() => {
|
||||
window.matchMedia = ((query: string) => ({
|
||||
matches: true,
|
||||
media: query,
|
||||
onchange: null,
|
||||
addEventListener: vi.fn(),
|
||||
removeEventListener: vi.fn(),
|
||||
addListener: vi.fn(),
|
||||
removeListener: vi.fn(),
|
||||
dispatchEvent: vi.fn()
|
||||
})) as unknown as typeof window.matchMedia
|
||||
})
|
||||
|
||||
function tableClasses(props: Record<string, unknown>) {
|
||||
const wrapper = mount(DataTable, { props: { columns, data, ...props }, global: { plugins: [i18n] } })
|
||||
return wrapper.find('table').classes()
|
||||
}
|
||||
|
||||
describe('DataTable 表格宽度', () => {
|
||||
it('不传就用 min-w-max,列跟着内容走', () => {
|
||||
expect(tableClasses({})).toContain('min-w-max')
|
||||
})
|
||||
|
||||
it('传了 table-class 就顶掉 min-w-max,两条不许同时挂着', () => {
|
||||
const classes = tableClasses({ tableClass: 'table-fixed min-w-[900px]' })
|
||||
expect(classes).toContain('table-fixed')
|
||||
expect(classes).toContain('min-w-[900px]')
|
||||
expect(classes).not.toContain('min-w-max')
|
||||
expect(classes).toContain('w-full')
|
||||
})
|
||||
})
|
||||
|
|
@ -101,7 +101,7 @@
|
|||
'is-scrollable': isScrollable
|
||||
}"
|
||||
>
|
||||
<table class="w-full min-w-max divide-y divide-gray-200 dark:divide-dark-700">
|
||||
<table :class="['w-full', tableClass || 'min-w-max', 'divide-y', 'divide-gray-200', 'dark:divide-dark-700']">
|
||||
<thead class="table-header bg-gray-50 dark:bg-dark-800">
|
||||
<tr>
|
||||
<th
|
||||
|
|
@ -439,6 +439,12 @@ interface Props {
|
|||
loading?: boolean
|
||||
stickyFirstColumn?: boolean
|
||||
stickyActionsColumn?: boolean
|
||||
/**
|
||||
* 覆盖表格外层那串宽度类。默认 min-w-max(列跟着内容撑开,横向滚动),
|
||||
* 想按列宽排版的视图传 'table-fixed min-w-[...]':定长列贴着内容收,
|
||||
* 剩下的空间交给没写宽度的列。
|
||||
*/
|
||||
tableClass?: string
|
||||
expandableActions?: boolean
|
||||
actionsCount?: number // 操作按钮总数,用于判断是否需要展开功能
|
||||
rowKey?: string | ((row: any) => string | number)
|
||||
|
|
@ -489,6 +495,7 @@ const props = withDefaults(defineProps<Props>(), {
|
|||
loading: false,
|
||||
stickyFirstColumn: true,
|
||||
stickyActionsColumn: true,
|
||||
tableClass: undefined,
|
||||
expandableActions: true,
|
||||
defaultSortOrder: 'asc',
|
||||
serverSideSort: false,
|
||||
|
|
|
|||
|
|
@ -142,3 +142,32 @@ describe('定位那格里的精度与时刻', () => {
|
|||
expect(emittedValue(wrapper)).not.toHaveProperty('accuracy')
|
||||
})
|
||||
})
|
||||
|
||||
describe('多选月份', () => {
|
||||
it('没配挑选方式时是一按钮,不是摊开的盘子;点开挑一格,发的是 YYYY-MM 数组', async () => {
|
||||
const field: FormFieldDef = { key: 'stopMonths', label: '停用月份', type: 'months' }
|
||||
const wrapper = control(field, ['2026-10'])
|
||||
expect(wrapper.find('[data-test="months-panel"]').exists()).toBe(false)
|
||||
expect(wrapper.find('[data-test="months-trigger"]').text()).toContain('2026年10月')
|
||||
await wrapper.find('[data-test="months-trigger"]').trigger('click')
|
||||
await wrapper.find('[data-test="months-cell-2026-11"]').trigger('click')
|
||||
expect(emittedValue(wrapper)).toEqual(['2026-10', '2026-11'])
|
||||
})
|
||||
|
||||
it('字段上写平铺就摊开、写弹出框就走弹出框:配置真的传到了控件', async () => {
|
||||
const flat = control({ key: 'm1', label: '停用月份', type: 'months', pickerStyle: 'inline' })
|
||||
expect(flat.find('[data-test="months-trigger"]').exists()).toBe(false)
|
||||
expect(flat.find('[data-test="months-panel"]').exists()).toBe(true)
|
||||
|
||||
const dialog = control({ key: 'm2', label: '停用月份', type: 'months', pickerStyle: 'dialog' }, ['2026-10'])
|
||||
await dialog.find('[data-test="months-trigger"]').trigger('click')
|
||||
expect(document.querySelector('.modal-content')).not.toBeNull()
|
||||
expect(document.querySelector('[data-test="months-confirm"]')).not.toBeNull()
|
||||
document.body.innerHTML = ''
|
||||
})
|
||||
|
||||
it('只读态念成「2026年10-11月」,不管这一格配的是哪一种姿势', () => {
|
||||
const field: FormFieldDef = { key: 'stopMonths', label: '停用月份', type: 'months', pickerStyle: 'dialog' }
|
||||
expect(control(field, ['2026-11', '2026-10'], true).text()).toBe('2026年10-11月')
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -166,6 +166,16 @@
|
|||
:compact="compact"
|
||||
@update:model-value="emit('update:value', $event)"
|
||||
/>
|
||||
<!-- 多选月份:三种挑选姿势(下拉 / 弹出框 / 平铺)由字段上那份 pickerStyle 说了算 -->
|
||||
<MonthsField
|
||||
v-else-if="field.type === 'months'"
|
||||
:model-value="value"
|
||||
:compact="compact"
|
||||
:style="monthsStyle"
|
||||
:label="field.label"
|
||||
:placeholder="selectPlaceholder"
|
||||
@update:model-value="emit('update:value', $event)"
|
||||
/>
|
||||
<LocationField
|
||||
v-else-if="field.type === 'location'"
|
||||
:model-value="value"
|
||||
|
|
@ -312,11 +322,12 @@ import { personLabelsOf } from '@/utils/personLabel'
|
|||
import AttachmentUploader from './AttachmentUploader.vue'
|
||||
import SignaturePad from './SignaturePad.vue'
|
||||
import WeekField from './WeekField.vue'
|
||||
import MonthsField from './MonthsField.vue'
|
||||
import LocationField from './LocationField.vue'
|
||||
import MarkdownBlock from './MarkdownBlock.vue'
|
||||
import RichTextEditor from './RichTextEditor.vue'
|
||||
import { htmlInputType } from '@/utils/formLayout'
|
||||
import { WEEK_DAY_VALUES, acceptOf, displayUnit, formatNumber, locationText, rangeText } from '@/utils/formRuntime'
|
||||
import { WEEK_DAY_VALUES, acceptOf, displayUnit, formatNumber, locationText, monthsStyleOf, monthsText, rangeText } from '@/utils/formRuntime'
|
||||
import { hasOptions } from '@/utils/formLinkage'
|
||||
import { carriesOptionSource, holdsListValue, pickerStyleOf, sourceKindOf } from '@/utils/optionSource'
|
||||
import type { DeptOption } from '@/utils/deptOptions'
|
||||
|
|
@ -414,6 +425,8 @@ const listValue = computed(() => toArray(props.value))
|
|||
const picksOptions = computed(() => carriesOptionSource(props.field.type))
|
||||
const optionSource = computed(() => sourceKindOf(props.field))
|
||||
const pickerStyle = computed(() => pickerStyleOf(props.field, optionSource.value))
|
||||
// 多选月份没有候选来源,那一档单独问 monthsStyleOf(没配过就是下拉多选)
|
||||
const monthsStyle = computed(() => monthsStyleOf(props.field))
|
||||
const multiple = computed(() => holdsListValue(props.field))
|
||||
const relationProcess = computed(() => String(props.field.relationProcess ?? ''))
|
||||
const dataSourceCode = computed(() => String(props.field.dataSourceCode ?? ''))
|
||||
|
|
@ -447,6 +460,8 @@ const display = computed(() => {
|
|||
if (field.type === 'timerange') return rangeText(raw)
|
||||
// 星期几库里存的是 1-7,念的时候要换成「周一、周三」
|
||||
if (field.type === 'week') return weekText(raw)
|
||||
// 多选月份存的是 YYYY-MM 数组,念的时候要并成「2026年10-11月」这样的区间
|
||||
if (field.type === 'months') return monthsText(raw)
|
||||
// 定位那格是物件(经纬度 + 地址),只读态念成「地址(经度, 纬度)」
|
||||
if (field.type === 'location') return locationText(raw)
|
||||
// 选人字段存的是一串账号,只读态得念成「姓名(账号)」,别把裸账号摊给人看
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@
|
|||
<span v-if="row.unit_name" class="ml-1 text-xs text-gray-400">{{ row.unit_name }}</span>
|
||||
</span>
|
||||
<span class="text-xs tabular-nums" :class="row.expired ? 'text-red-600' : 'text-gray-400'">
|
||||
{{ t('task.elapsed') }} {{ formatMinutes(row.elapsed_minutes) }}
|
||||
{{ formatDateTimeToMinute(row.start_time) }}
|
||||
</span>
|
||||
<div v-if="running" class="flex items-center gap-1">
|
||||
<button type="button" class="btn btn-ghost btn-sm" :disabled="busy" @click="pressOne(row)">
|
||||
|
|
@ -234,7 +234,7 @@ import FormRenderer from '@/components/oa/FormRenderer.vue'
|
|||
import { taskAPI, workAPI } from '@/api'
|
||||
import type { TaskItem, WorkDetail } from '@/types'
|
||||
import { formatDateTimeToMinute } from '@/utils/format'
|
||||
import { badgeClass, formatMinutes, runAction, workStatusLabel, workStatusVariant } from '@/utils/oa'
|
||||
import { badgeClass, runAction, workStatusLabel, workStatusVariant } from '@/utils/oa'
|
||||
import { personText } from '@/utils/personLabel'
|
||||
|
||||
const props = defineProps<{ show: boolean; job: string }>()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,158 @@
|
|||
// @vitest-environment jsdom
|
||||
/**
|
||||
* 多选月份控件:三种挑选姿势各管什么。
|
||||
*
|
||||
* 值必须是 `YYYY-MM` 数组(与「月份」那一格同一写法,条件分支才比得动),
|
||||
* 界面上必须当场看见并出来的那一句「2026年10-11月」——不写清这一点,
|
||||
* 人只会以为自己挑的月份丢了。而"平铺那一面盘太占地方"是这一轮的来由:
|
||||
* 默认必须收成一只按钮,摊开只能是配的人自己选的。
|
||||
*/
|
||||
import { afterEach, describe, expect, it } from 'vitest'
|
||||
import { flushPromises, mount } from '@vue/test-utils'
|
||||
import { createI18n } from 'vue-i18n'
|
||||
import zh from '@/i18n/locales/zh'
|
||||
import MonthsField from './MonthsField.vue'
|
||||
|
||||
const mounted: ReturnType<typeof mount>[] = []
|
||||
|
||||
function mountField(props: Record<string, unknown> = {}) {
|
||||
const i18n = createI18n({ legacy: false, locale: 'zh', messages: { zh } })
|
||||
const wrapper = mount(MonthsField, { props: props as never, global: { plugins: [i18n] }, attachTo: document.body })
|
||||
mounted.push(wrapper)
|
||||
return wrapper
|
||||
}
|
||||
|
||||
/** 弹出框 Teleport 去了 body,只能从 document 上找。 */
|
||||
const body = (selector: string) => document.querySelector<HTMLElement>(selector)
|
||||
|
||||
async function openPanel(wrapper: ReturnType<typeof mount>) {
|
||||
await wrapper.find('[data-test="months-trigger"]').trigger('click')
|
||||
await flushPromises()
|
||||
}
|
||||
|
||||
function lastEmit(wrapper: ReturnType<typeof mount>) {
|
||||
return wrapper.emitted('update:modelValue')?.at(-1)
|
||||
}
|
||||
|
||||
async function clickBody(el: HTMLElement | null) {
|
||||
expect(el, '弹出框里那一样东西没找到').not.toBeNull()
|
||||
el?.dispatchEvent(new MouseEvent('click', { bubbles: true }))
|
||||
await flushPromises()
|
||||
}
|
||||
|
||||
afterEach(() => {
|
||||
mounted.splice(0).forEach((wrapper) => wrapper.unmount())
|
||||
document.body.innerHTML = ''
|
||||
})
|
||||
|
||||
describe('下拉多选(默认那一档)', () => {
|
||||
it('一上来就是一只按钮,挑中的那串并成一句挂在框里', () => {
|
||||
const wrapper = mountField({ modelValue: ['2026-10', '2026-11'] })
|
||||
expect(wrapper.find('[data-test="months-panel"]').exists()).toBe(false)
|
||||
expect(wrapper.find('[data-test="months-trigger"]').text()).toContain('2026年10-11月')
|
||||
})
|
||||
|
||||
it('点开才摆盘子,挑哪个月当场写回,不用点确定', async () => {
|
||||
const wrapper = mountField({ modelValue: ['2026-10'] })
|
||||
await openPanel(wrapper)
|
||||
await wrapper.find('[data-test="months-cell-2026-11"]').trigger('click')
|
||||
expect(lastEmit(wrapper)).toEqual([['2026-10', '2026-11']])
|
||||
})
|
||||
|
||||
it('点外面把盘子收起来,别盖住下面几行', async () => {
|
||||
const wrapper = mountField()
|
||||
await openPanel(wrapper)
|
||||
expect(wrapper.find('[data-test="months-panel"]').exists()).toBe(true)
|
||||
document.body.dispatchEvent(new MouseEvent('click', { bubbles: true }))
|
||||
await flushPromises()
|
||||
expect(wrapper.find('[data-test="months-panel"]').exists()).toBe(false)
|
||||
})
|
||||
|
||||
it('Esc 也收:键盘用户不该只能去点外面', async () => {
|
||||
const wrapper = mountField()
|
||||
await openPanel(wrapper)
|
||||
document.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }))
|
||||
await flushPromises()
|
||||
expect(wrapper.find('[data-test="months-panel"]').exists()).toBe(false)
|
||||
})
|
||||
|
||||
it('没挑的时候框里给占位提示,不是留一片空白', () => {
|
||||
const wrapper = mountField({ placeholder: '请选择月份' })
|
||||
expect(wrapper.find('[data-test="months-trigger"]').text()).toContain('请选择月份')
|
||||
})
|
||||
})
|
||||
|
||||
describe('平铺点选(配的人自己选的摊开)', () => {
|
||||
it('盘子一直摊着、没有触发按钮,挑 10、11 两月当场念成「2026年10-11月」', async () => {
|
||||
const wrapper = mountField({ style: 'inline', modelValue: ['2026-10'] })
|
||||
expect(wrapper.find('[data-test="months-trigger"]').exists()).toBe(false)
|
||||
expect(wrapper.find('[data-test="months-panel"]').exists()).toBe(true)
|
||||
await wrapper.find('[data-test="months-cell-2026-11"]').trigger('click')
|
||||
expect(lastEmit(wrapper)).toEqual([['2026-10', '2026-11']])
|
||||
await wrapper.setProps({ modelValue: ['2026-10', '2026-11'] })
|
||||
expect(wrapper.find('[data-test="months-summary"]').text()).toBe('2026年10-11月')
|
||||
})
|
||||
|
||||
it('再点一次是取消那个月,清空发的是空数组', async () => {
|
||||
const wrapper = mountField({ style: 'inline', modelValue: ['2026-10', '2026-11'] })
|
||||
await wrapper.find('[data-test="months-cell-2026-10"]').trigger('click')
|
||||
expect(lastEmit(wrapper)).toEqual([['2026-11']])
|
||||
await wrapper.find('[data-test="months-clear"]').trigger('click')
|
||||
expect(lastEmit(wrapper)).toEqual([[]])
|
||||
})
|
||||
|
||||
it('换到下一年接着挑,跨年那一段念「2026年12月-2027年1月」', async () => {
|
||||
const wrapper = mountField({ style: 'inline', modelValue: ['2026-12'] })
|
||||
await wrapper.find('[data-test="months-next"]').trigger('click')
|
||||
await wrapper.find('[data-test="months-cell-2027-01"]').trigger('click')
|
||||
expect(lastEmit(wrapper)).toEqual([['2026-12', '2027-01']])
|
||||
await wrapper.setProps({ modelValue: ['2026-12', '2027-01'] })
|
||||
expect(wrapper.find('[data-test="months-summary"]').text()).toBe('2026年12月-2027年1月')
|
||||
})
|
||||
|
||||
it('明细格子里不给摊开:一行的高度放不下一个盘子', () => {
|
||||
const wrapper = mountField({ style: 'inline', compact: true, modelValue: ['2026-03'] })
|
||||
expect(wrapper.find('[data-test="months-panel"]').exists()).toBe(false)
|
||||
expect(wrapper.find('[data-test="months-trigger"]').text()).toContain('2026年3月')
|
||||
})
|
||||
})
|
||||
|
||||
describe('弹出框多选', () => {
|
||||
it('点按钮开弹出框,勾两个月只改草稿,点确定才写回这一格', async () => {
|
||||
const wrapper = mountField({ style: 'dialog', modelValue: ['2026-10'] })
|
||||
await openPanel(wrapper)
|
||||
expect(body('[data-test="months-panel"]')).not.toBeNull()
|
||||
await clickBody(body('[data-test="months-cell-2026-11"]'))
|
||||
expect(lastEmit(wrapper)).toBeUndefined()
|
||||
await clickBody(body('[data-test="months-confirm"]'))
|
||||
expect(lastEmit(wrapper)).toEqual([['2026-10', '2026-11']])
|
||||
})
|
||||
|
||||
it('取消就是没挑过:一个字都不往字段上写', async () => {
|
||||
const wrapper = mountField({ style: 'dialog', modelValue: ['2026-10'] })
|
||||
await openPanel(wrapper)
|
||||
await clickBody(body('[data-test="months-cell-2026-05"]'))
|
||||
await clickBody(body('[data-test="months-cancel"]'))
|
||||
expect(lastEmit(wrapper)).toBeUndefined()
|
||||
expect(wrapper.find('[data-test="months-trigger"]').text()).toContain('2026年10月')
|
||||
})
|
||||
|
||||
it('再开一次回到已经存好的那串,上一轮没确定的草稿不算数', async () => {
|
||||
const wrapper = mountField({ style: 'dialog', modelValue: ['2026-10'] })
|
||||
await openPanel(wrapper)
|
||||
await clickBody(body('[data-test="months-cell-2026-05"]'))
|
||||
await clickBody(body('[data-test="months-cancel"]'))
|
||||
await openPanel(wrapper)
|
||||
expect(body('[data-test="months-cell-2026-05"]')?.getAttribute('aria-pressed')).toBe('false')
|
||||
expect(body('[data-test="months-cell-2026-10"]')?.getAttribute('aria-pressed')).toBe('true')
|
||||
})
|
||||
|
||||
it('弹出框里清空再确定,发的是空数组', async () => {
|
||||
const wrapper = mountField({ style: 'dialog', modelValue: ['2026-10', '2026-11'] })
|
||||
await openPanel(wrapper)
|
||||
await clickBody(body('[data-test="months-clear"]'))
|
||||
expect(body('[data-test="months-summary"]')?.textContent).toBe('还没挑月份')
|
||||
await clickBody(body('[data-test="months-confirm"]'))
|
||||
expect(lastEmit(wrapper)).toEqual([[]])
|
||||
})
|
||||
})
|
||||
|
|
@ -0,0 +1,175 @@
|
|||
<template>
|
||||
<div ref="rootRef" class="relative min-w-0">
|
||||
<!--
|
||||
下拉多选与弹出框多选都先收成一只长得像输入框的按钮:这一格存的是一串月份,
|
||||
但给人看的是并好那一段(「2026年10-11月」),摊开那一面 12 个月的盘要占一整行。
|
||||
-->
|
||||
<button
|
||||
v-if="usesTrigger"
|
||||
type="button"
|
||||
data-test="months-trigger"
|
||||
class="cell-control flex w-full items-center justify-between gap-1 border border-gray-300 bg-white px-2 text-left text-sm transition-colors hover:border-primary-300 disabled:cursor-not-allowed disabled:opacity-60 dark:border-dark-600 dark:bg-dark-800"
|
||||
:class="open ? 'border-primary-500 ring-2 ring-primary-500/30' : ''"
|
||||
:disabled="disabled"
|
||||
:aria-expanded="open ? 'true' : 'false'"
|
||||
:aria-label="summary || t('form.monthsDialogTitle')"
|
||||
@click="toggle"
|
||||
>
|
||||
<span class="min-w-0 truncate" :class="picked.length ? '' : 'text-gray-400 dark:text-dark-500'">
|
||||
{{ summary || placeholder }}
|
||||
</span>
|
||||
<Icon name="calendar" class="h-3.5 w-3.5 flex-shrink-0 text-gray-400" />
|
||||
</button>
|
||||
|
||||
<!-- 平铺点选:盘子一直摊在这一格里,点开这一下都不必 -->
|
||||
<div
|
||||
v-if="!usesTrigger"
|
||||
data-test="months-panel"
|
||||
class="min-w-0 rounded-xl border border-gray-200 bg-white p-2 dark:border-dark-600 dark:bg-dark-800"
|
||||
>
|
||||
<MonthsPanel :picked="shown" :disabled="disabled" @toggle="pick" @clear="clear" />
|
||||
</div>
|
||||
|
||||
<!-- 下拉多选:盘子挂在按钮下面,挑哪个月当场就写回去 -->
|
||||
<div
|
||||
v-else-if="style === 'dropdown' && open"
|
||||
data-test="months-panel"
|
||||
class="absolute left-0 top-full z-30 mt-1 w-[268px] min-w-0 rounded-xl border border-gray-200 bg-white p-2 shadow-lg dark:border-dark-600 dark:bg-dark-800"
|
||||
>
|
||||
<MonthsPanel :picked="shown" :disabled="disabled" @toggle="pick" @clear="clear" />
|
||||
</div>
|
||||
|
||||
<!-- 弹出框多选:改的是本地那一份,点确定才写回这一格,关掉就等于没挑过 -->
|
||||
<BaseDialog
|
||||
v-if="style === 'dialog'"
|
||||
:show="open"
|
||||
:title="label?.trim() || t('form.monthsDialogTitle')"
|
||||
@close="close"
|
||||
>
|
||||
<div data-test="months-panel">
|
||||
<MonthsPanel :picked="shown" :disabled="disabled" :dense="false" @toggle="pick" @clear="clear" />
|
||||
</div>
|
||||
<template #footer>
|
||||
<button type="button" class="btn btn-secondary" data-test="months-cancel" @click="close">
|
||||
{{ t('common.cancel') }}
|
||||
</button>
|
||||
<button type="button" class="btn btn-primary" data-test="months-confirm" @click="confirm">
|
||||
{{ t('common.confirm') }}
|
||||
</button>
|
||||
</template>
|
||||
</BaseDialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* 多选月份:报销区间、考核周期、设备停用月份那一类"一次圈几个月"的单子。
|
||||
*
|
||||
* 值仍是 `['2026-10', '2026-11']` 这样的 `YYYY-MM` 数组,跟「月份」那一格同一写法,
|
||||
* 条件分支按先后比、导进表格都读得懂;界面上连着几个月自动并成一段,
|
||||
* 挑 10、11 两个月,回填出来就是「2026年10-11月」(口径在 utils/formRuntime 的 monthsText)。
|
||||
*
|
||||
* 三种挑选姿势(`field.pickerStyle`,与设计器里「挑选方式」同一套取值):
|
||||
* `dropdown` 下拉多选(默认)、`dialog` 弹出框多选、`inline` 平铺点选。
|
||||
* 默认收成一只按钮是有意为之:那一面 12 个月的盘摊在表单里要吃掉一整行。
|
||||
* 明细表那一格(`compact`)永远不给摊开——一行的高度放不下一个盘子,
|
||||
* 于是平铺在明细格里也照下拉的样子挂。
|
||||
*/
|
||||
import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import BaseDialog from '@/components/common/BaseDialog.vue'
|
||||
import Icon from '@/components/icons/Icon.vue'
|
||||
import MonthsPanel from './MonthsPanel.vue'
|
||||
import { monthList, monthsText } from '@/utils/formRuntime'
|
||||
import type { MonthsStyle } from '@/utils/formRuntime'
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
modelValue?: unknown
|
||||
disabled?: boolean
|
||||
compact?: boolean
|
||||
placeholder?: string
|
||||
label?: string
|
||||
style?: MonthsStyle
|
||||
}>(),
|
||||
{ modelValue: undefined, disabled: false, compact: false, placeholder: '', label: '', style: 'dropdown' }
|
||||
)
|
||||
|
||||
const emit = defineEmits<{ (e: 'update:modelValue', value: string[]): void }>()
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
const open = ref(false)
|
||||
const rootRef = ref<HTMLElement | null>(null)
|
||||
|
||||
/** 弹出框里改的是这一份草稿,确定才写回字段;另两档点一下就当场落值。 */
|
||||
const draft = ref<string[]>([])
|
||||
|
||||
/** 挑中的月份,已按时间排好(脏值在这一步就被 monthList 滤掉了)。 */
|
||||
const picked = computed(() => monthList(props.modelValue))
|
||||
|
||||
/** 盘子上此刻该亮着哪几个月。 */
|
||||
const shown = computed(() => (props.style === 'dialog' ? draft.value : picked.value))
|
||||
|
||||
const summary = computed(() => monthsText(picked.value))
|
||||
|
||||
const usesTrigger = computed(() => props.style !== 'inline' || props.compact)
|
||||
|
||||
function toggle() {
|
||||
if (props.style === 'dialog') {
|
||||
open.value ? close() : openDialog()
|
||||
return
|
||||
}
|
||||
open.value = !open.value
|
||||
}
|
||||
|
||||
function openDialog() {
|
||||
draft.value = [...picked.value]
|
||||
open.value = true
|
||||
}
|
||||
|
||||
function close() {
|
||||
open.value = false
|
||||
}
|
||||
|
||||
function confirm() {
|
||||
emit('update:modelValue', [...draft.value])
|
||||
open.value = false
|
||||
}
|
||||
|
||||
function pick(value: string) {
|
||||
const next = new Set(shown.value)
|
||||
if (next.has(value)) next.delete(value)
|
||||
else next.add(value)
|
||||
const sorted = Array.from(next).sort()
|
||||
if (props.style === 'dialog') draft.value = sorted
|
||||
else emit('update:modelValue', sorted)
|
||||
}
|
||||
|
||||
function clear() {
|
||||
if (props.style === 'dialog') draft.value = []
|
||||
else emit('update:modelValue', [])
|
||||
}
|
||||
|
||||
/** 下拉那档点外面就收起来:它盖在表单上,不收就挡住下面几行。 */
|
||||
function closeOnOutside(event: MouseEvent) {
|
||||
if (!open.value || props.style === 'dialog') return
|
||||
if (rootRef.value?.contains(event.target as Node)) return
|
||||
open.value = false
|
||||
}
|
||||
|
||||
/** Esc 也收:键盘用户不该只能靠鼠标去点外面。 */
|
||||
function closeOnEscape(event: KeyboardEvent) {
|
||||
if (event.key !== 'Escape' || !open.value || props.style === 'dialog') return
|
||||
open.value = false
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
document.addEventListener('click', closeOnOutside)
|
||||
document.addEventListener('keydown', closeOnEscape)
|
||||
})
|
||||
onBeforeUnmount(() => {
|
||||
document.removeEventListener('click', closeOnOutside)
|
||||
document.removeEventListener('keydown', closeOnEscape)
|
||||
})
|
||||
</script>
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
<template>
|
||||
<div class="min-w-0">
|
||||
<div class="mb-1.5 flex items-center gap-1">
|
||||
<button
|
||||
type="button"
|
||||
data-test="months-prev"
|
||||
class="inline-flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-md text-gray-500 transition-colors hover:bg-gray-100 dark:text-dark-400 dark:hover:bg-dark-700"
|
||||
:aria-label="t('form.monthsPrevYear')"
|
||||
@click="shiftYear(-1)"
|
||||
>
|
||||
<Icon name="chevronLeft" class="h-3.5 w-3.5" />
|
||||
</button>
|
||||
<span class="min-w-[46px] flex-shrink-0 text-center text-sm font-semibold tabular-nums text-gray-800 dark:text-dark-100">
|
||||
{{ year }}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
data-test="months-next"
|
||||
class="inline-flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-md text-gray-500 transition-colors hover:bg-gray-100 dark:text-dark-400 dark:hover:bg-dark-700"
|
||||
:aria-label="t('form.monthsNextYear')"
|
||||
@click="shiftYear(1)"
|
||||
>
|
||||
<Icon name="chevronRight" class="h-3.5 w-3.5" />
|
||||
</button>
|
||||
<!-- 挑完立刻看见这一串会被写成什么:连着几个月并成一段,人就不用自己数 -->
|
||||
<p
|
||||
data-test="months-summary"
|
||||
class="ml-1 min-w-0 flex-1 truncate text-xs"
|
||||
:class="picked.length ? 'text-primary-600 dark:text-primary-300' : 'text-gray-400 dark:text-dark-500'"
|
||||
:title="summary"
|
||||
>
|
||||
{{ summary || t('form.monthsNone') }}
|
||||
</p>
|
||||
<button
|
||||
v-if="picked.length"
|
||||
type="button"
|
||||
data-test="months-clear"
|
||||
class="flex-shrink-0 rounded px-1 text-xs text-gray-400 transition-colors hover:text-red-500"
|
||||
@click="emit('clear')"
|
||||
>
|
||||
{{ t('form.clearSelection') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-4 gap-1" :class="dense ? '' : 'sm:grid-cols-6'">
|
||||
<button
|
||||
v-for="item in cells"
|
||||
:key="item.value"
|
||||
type="button"
|
||||
:data-test="`months-cell-${item.value}`"
|
||||
:disabled="disabled"
|
||||
:aria-pressed="picked.includes(item.value)"
|
||||
class="inline-flex items-center justify-center rounded-lg border text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-60"
|
||||
:class="[dense ? 'h-7 px-1' : 'h-9 px-1', picked.includes(item.value) ? CELL_ON : CELL_OFF]"
|
||||
@click="emit('toggle', item.value)"
|
||||
>
|
||||
{{ item.label }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* 那一年那 12 个月本身:年份切换 + 点选 + 当场念出并段后的那一句。
|
||||
*
|
||||
* 三种挑选姿势(下拉多选 / 弹出框多选 / 平铺点选)共用这一面盘,区别只在它挂在哪儿——
|
||||
* 挂在按钮下面、挂在弹出框里,还是干脆摊在格子里。挑中哪些月、怎么并成一句人话
|
||||
* 都不在这儿算,容器递进来、点一下就递回去。
|
||||
*/
|
||||
import { computed, ref } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import Icon from '@/components/icons/Icon.vue'
|
||||
import { monthsText } from '@/utils/formRuntime'
|
||||
|
||||
const props = withDefaults(defineProps<{ picked: string[]; disabled?: boolean; dense?: boolean }>(), {
|
||||
disabled: false,
|
||||
dense: true
|
||||
})
|
||||
|
||||
const emit = defineEmits<{ (e: 'toggle', value: string): void; (e: 'clear'): void }>()
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
const CELL_ON = 'border-primary-500 bg-primary-50 text-primary-700 dark:border-primary-600 dark:bg-primary-900/30 dark:text-primary-200'
|
||||
const CELL_OFF = 'border-gray-200 bg-white text-gray-500 hover:border-primary-300 dark:border-dark-600 dark:bg-dark-800 dark:text-dark-400'
|
||||
|
||||
/**
|
||||
* 面板先落在哪一年:有选择就从最早那个月那一年开始,否则停在当前年。
|
||||
*
|
||||
* 下拉与弹出框每次都重新挂载这一面盘(`v-if` 挂着),所以每开一次都跟着
|
||||
* 这一次要挑的那串走,不会停在上一轮翻到的年份上。
|
||||
*/
|
||||
const year = ref(Number((props.picked[0] ?? new Date().toISOString()).slice(0, 4)))
|
||||
|
||||
const cells = computed(() =>
|
||||
Array.from({ length: 12 }, (_, index) => ({
|
||||
value: `${year.value}-${String(index + 1).padStart(2, '0')}`,
|
||||
label: t(`form.month${index + 1}`)
|
||||
}))
|
||||
)
|
||||
|
||||
const summary = computed(() => monthsText(props.picked))
|
||||
|
||||
function shiftYear(step: number) {
|
||||
year.value += step
|
||||
}
|
||||
</script>
|
||||
|
|
@ -139,3 +139,65 @@ describe('附件那三个限制与空白格的高度', () => {
|
|||
expect(wrapper.text()).toContain('浏览器')
|
||||
})
|
||||
})
|
||||
|
||||
describe('多选月份的挑选方式(下拉多选 / 弹出框多选 / 平铺点选)', () => {
|
||||
it('面板上有「挑选方式」这一栏,默认显示下拉多选,三档都给', async () => {
|
||||
const { wrapper } = inspector({ key: 'stopMonths', label: '停用月份', type: 'months' })
|
||||
await flushPromises()
|
||||
const labels = wrapper.findAll('.input-label').map((node) => node.text())
|
||||
expect(labels).toContain('挑选方式')
|
||||
const box = wrapper.findComponent('[data-test="months-style"]')
|
||||
expect(box.props('modelValue')).toBe('dropdown')
|
||||
const options = box.props('options') as { label: string }[]
|
||||
expect(options.map((item) => item.label)).toEqual(['下拉多选', '弹出框多选', '平铺点选'])
|
||||
})
|
||||
|
||||
it('挑弹出框写进字段;挑回下拉把那把痕迹收掉,以后改默认时没配过的格子跟着走', async () => {
|
||||
const { wrapper, field } = inspector({ key: 'stopMonths', label: '停用月份', type: 'months' })
|
||||
await flushPromises()
|
||||
await wrapper.findComponent('[data-test="months-style"]').vm.$emit('update:model-value', 'dialog')
|
||||
expect(field.pickerStyle).toBe('dialog')
|
||||
await wrapper.findComponent('[data-test="months-style"]').vm.$emit('update:model-value', 'dropdown')
|
||||
expect(field.pickerStyle).toBeUndefined()
|
||||
})
|
||||
|
||||
it('挑平铺顺手把这一格铺满一行:12 个月摆半行放不下', async () => {
|
||||
const { wrapper } = inspector({ key: 'stopMonths', label: '停用月份', type: 'months' })
|
||||
await flushPromises()
|
||||
await wrapper.findComponent('[data-test="months-style"]').vm.$emit('update:model-value', 'inline')
|
||||
expect(wrapper.emitted('units')?.at(-1)).toEqual([12])
|
||||
})
|
||||
|
||||
it('月份、星期、富文本都不该冒出这一栏', async () => {
|
||||
const types: FormFieldDef['type'][] = ['month', 'week', 'richtext']
|
||||
for (const type of types) {
|
||||
const { wrapper } = inspector({ key: 'one', label: '一格', type })
|
||||
await flushPromises()
|
||||
expect(wrapper.find('[data-test="months-style"]').exists(), type).toBe(false)
|
||||
}
|
||||
})
|
||||
|
||||
it('明细表那一列也挑得动姿势,同样没有「自动」那一档', async () => {
|
||||
const column: FormFieldDef = { key: 'm', label: '月份', type: 'months' }
|
||||
const { wrapper, field } = inspector({ key: 'rows', label: '明细', type: 'table', columns: [column] })
|
||||
await flushPromises()
|
||||
const box = wrapper.findComponent('[data-test="column-picker-style"]')
|
||||
expect(box.exists()).toBe(true)
|
||||
expect(box.props('modelValue')).toBe('dropdown')
|
||||
const options = box.props('options') as { label: string }[]
|
||||
expect(options.map((item) => item.label)).not.toContain('自动(推荐)')
|
||||
await box.vm.$emit('update:model-value', 'dialog')
|
||||
expect((field.columns?.[0] as FormFieldDef).pickerStyle).toBe('dialog')
|
||||
})
|
||||
|
||||
it('换成多选月份再换成别的类型,那一档跟着收掉,别留着在新控件上生效', async () => {
|
||||
const { wrapper, field } = inspector({ key: 'stopMonths', label: '停用月份', type: 'months', pickerStyle: 'dialog' })
|
||||
await flushPromises()
|
||||
// 类型那一只下拉没有 data-test:认它那份 44 类的候选清单
|
||||
const typeBox = wrapper
|
||||
.findAllComponents(Select)
|
||||
.find((box) => ((box.props('options') ?? []) as { value: string }[]).some((item) => item.value === 'richtext'))
|
||||
await typeBox?.vm.$emit('update:model-value', 'text')
|
||||
expect(field.pickerStyle).toBeUndefined()
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -168,6 +168,23 @@
|
|||
@patch="patch"
|
||||
/>
|
||||
|
||||
<!--
|
||||
多选月份:候选是那一年那 12 个月,谈不上候选来源,只问一句用什么姿势挑。
|
||||
平铺那一档摊开要吃掉一整行,所以配成平铺时顺手把这一格铺满;换回下拉不缩回去——
|
||||
宽度是人自己调过的,别替他改。
|
||||
-->
|
||||
<div v-else-if="field.field.type === 'months'" class="space-y-2">
|
||||
<label class="input-label">{{ t('form.optionSourceStyle') }}</label>
|
||||
<Select
|
||||
data-test="months-style"
|
||||
compact
|
||||
:model-value="monthsStyleOf(field.field)"
|
||||
:options="monthsStyleOptions"
|
||||
@update:model-value="pickMonthsStyle(String($event) as MonthsStyle)"
|
||||
/>
|
||||
<p class="input-hint">{{ t(`form.monthsStyleHint${monthsStyleHintKey}`) }}</p>
|
||||
</div>
|
||||
|
||||
<!-- 流程标题:这一格的值就是流程标题,挑一句生成口径 -->
|
||||
<div v-else-if="field.field.type === 'title'" class="space-y-3">
|
||||
<div>
|
||||
|
|
@ -424,8 +441,8 @@
|
|||
窄地方两栏并排。以前列上只有「绑不绑字典」这一条路,外部数据源和别的流程的单据
|
||||
都进不来,样式更是没得选。
|
||||
-->
|
||||
<div v-if="carriesOptionSource(String(column.type))" class="mt-1.5 grid grid-cols-2 gap-1.5">
|
||||
<div>
|
||||
<div v-if="carriesStyleChoice(String(column.type))" class="mt-1.5 grid grid-cols-2 gap-1.5">
|
||||
<div v-if="carriesOptionSource(String(column.type))">
|
||||
<span class="input-label">{{ t('form.optionSource') }}</span>
|
||||
<Select
|
||||
data-test="column-option-source"
|
||||
|
|
@ -440,13 +457,9 @@
|
|||
<Select
|
||||
data-test="column-picker-style"
|
||||
compact
|
||||
:model-value="column.pickerStyle ?? 'auto'"
|
||||
:model-value="columnStyleModel(column)"
|
||||
:options="columnStyleOptions(column)"
|
||||
@update:model-value="
|
||||
patchColumn(index, {
|
||||
pickerStyle: String($event) === 'auto' ? undefined : (String($event) as PickerStyle)
|
||||
})
|
||||
"
|
||||
@update:model-value="pickColumnStyle(index, column, $event)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -876,8 +889,12 @@ import {
|
|||
acceptOf,
|
||||
columnDefaultProblem,
|
||||
formatNumber,
|
||||
MONTHS_STYLES,
|
||||
MONTHS_STYLE_DEFAULT,
|
||||
monthsStyleOf,
|
||||
tableColumnTypes,
|
||||
unitProblem
|
||||
unitProblem,
|
||||
type MonthsStyle
|
||||
} from '@/utils/formRuntime'
|
||||
import { canCarry } from '@/utils/fieldCapabilities'
|
||||
import type { FieldRename } from '@/utils/formRename'
|
||||
|
|
@ -885,6 +902,7 @@ import {
|
|||
OPTION_SOURCE_LABEL_KEYS,
|
||||
PICKER_STYLE_LABEL_KEYS,
|
||||
carriesOptionSource,
|
||||
carriesStyleChoice,
|
||||
holdsListValue,
|
||||
offeredSourceKinds,
|
||||
optionSourcePatch,
|
||||
|
|
@ -1251,6 +1269,30 @@ function patchStars(raw: unknown) {
|
|||
const FULL_ROW_TYPES: string[] = ['group', 'richtext', 'location', 'week']
|
||||
|
||||
/** 纯排版字段没有值,"必填"与"只读"都无处落地;系统带出的值不要求人填,但能要求它算得出值。 */
|
||||
/**
|
||||
* 多选月份那三档:取值与设计器里「挑选方式」是同一套,只是这里没有「自动」——
|
||||
* 只有一档默认(下拉多选),摆两档会让人以为默认在别处。
|
||||
*/
|
||||
const monthsStyleOptions = computed(() =>
|
||||
MONTHS_STYLES.map((style) => ({
|
||||
value: style,
|
||||
label: t(`form.monthsStyle${style.charAt(0).toUpperCase()}${style.slice(1)}`)
|
||||
}))
|
||||
)
|
||||
|
||||
/** 下面那一句说明跟着当前这一档走。 */
|
||||
const monthsStyleHintKey = computed(() => {
|
||||
const style = monthsStyleOf(field.value?.field)
|
||||
return style.charAt(0).toUpperCase() + style.slice(1)
|
||||
})
|
||||
|
||||
function pickMonthsStyle(style: MonthsStyle) {
|
||||
// 挑回默认那一档就不在字段上留痕迹:以后改默认姿势时,没配过的格子跟着走,不必重存表单
|
||||
patch({ pickerStyle: style === MONTHS_STYLE_DEFAULT ? undefined : (style as PickerStyle) })
|
||||
// 平铺那一档摊开是 12 个月,半行放不下;换回下拉不缩,宽度是人自己调过的
|
||||
if (style === 'inline') emit('units', GRID_COLS)
|
||||
}
|
||||
|
||||
const requiredLock = computed(() =>
|
||||
LAYOUT_TYPES.includes(field.value?.field.type ?? '') ? t('form.permNeedsValue') : ''
|
||||
)
|
||||
|
|
@ -1339,6 +1381,7 @@ const DESIGN_HINT_KEYS: Record<string, string> = {
|
|||
year: 'form.yearDesignHint',
|
||||
timerange: 'form.timerangeDesignHint',
|
||||
week: 'form.weekDesignHint',
|
||||
months: 'form.monthsDesignHint',
|
||||
location: 'form.locationDesignHint',
|
||||
group: 'form.groupDesignHint',
|
||||
spacer: 'form.spacerDesignHint'
|
||||
|
|
@ -1673,12 +1716,25 @@ function columnSourceOptions(column: FormFieldDef) {
|
|||
}
|
||||
|
||||
function columnStyleOptions(column: FormFieldDef) {
|
||||
// 多选月份没有「自动」这一档:它的默认姿势只有一个,摆两档等于让人猜哪个是默认
|
||||
if (column.type === 'months') return monthsStyleOptions.value
|
||||
return styleChoicesOf(column.type, sourceKindOf(column), holdsListValue(column)).map((style) => ({
|
||||
value: style,
|
||||
label: style === 'auto' ? t('form.optionSourceStyleAuto') : t(PICKER_STYLE_LABEL_KEYS[style])
|
||||
}))
|
||||
}
|
||||
|
||||
/** 那一栏当前显示成哪一档:没配过的走这一类的默认,多选月份与另外几类的说法不一样。 */
|
||||
function columnStyleModel(column: FormFieldDef) {
|
||||
return column.type === 'months' ? monthsStyleOf(column) : column.pickerStyle ?? 'auto'
|
||||
}
|
||||
|
||||
function pickColumnStyle(index: number, column: FormFieldDef, raw: unknown) {
|
||||
const style = String(raw) as PickerStyle
|
||||
const backToDefault = style === 'auto' || (column.type === 'months' && style === MONTHS_STYLE_DEFAULT)
|
||||
patchColumn(index, { pickerStyle: backToDefault ? undefined : style })
|
||||
}
|
||||
|
||||
/** 列上的外部数据源下拉:只列列表型的源,已选中却被删掉的编码留着标一句。 */
|
||||
function columnDataSourceOptions(column: FormFieldDef) {
|
||||
return withMissingOption(
|
||||
|
|
@ -1859,9 +1915,9 @@ function changeType(type: string) {
|
|||
]
|
||||
}
|
||||
if (type === 'table') delete target.field.options
|
||||
// 候选来源与挑选方式只属于选择类四兄弟:换成文本框之后留着它们,
|
||||
// 这一格看着是文本框,读出来却还是「字典 / 流程单据」那一套口径。
|
||||
if (!carriesOptionSource(type)) {
|
||||
// 候选来源与挑选方式只属于选择类四兄弟(多选月份也要挑姿势,只是它没有来源可言):
|
||||
// 换成文本框之后留着它们,这一格看着是文本框,读出来却还是「字典 / 流程单据」那一套口径。
|
||||
if (!carriesStyleChoice(type)) {
|
||||
delete target.field.optionSource
|
||||
delete target.field.dataSourceCode
|
||||
delete target.field.pickerStyle
|
||||
|
|
|
|||
|
|
@ -100,6 +100,7 @@ const META: Record<FieldType, ChipMeta | null> = {
|
|||
time: { group: 'Basic', icon: 'clock' },
|
||||
daterange: { group: 'Basic', icon: 'calendar' },
|
||||
month: { group: 'Basic', icon: 'calendar' },
|
||||
months: { group: 'Choice', icon: 'calendar', hint: 'form.monthsDragHint' },
|
||||
year: { group: 'Basic', icon: 'calendar' },
|
||||
timerange: { group: 'Basic', icon: 'clock' },
|
||||
mobile: { group: 'Basic', icon: 'login' },
|
||||
|
|
|
|||
|
|
@ -274,6 +274,7 @@ const TYPE_ICONS: Record<string, IconName> = {
|
|||
year: 'calendar',
|
||||
timerange: 'clock',
|
||||
week: 'grid',
|
||||
months: 'calendar',
|
||||
location: 'map',
|
||||
select: 'chevronDown',
|
||||
radio: 'checkCircle',
|
||||
|
|
@ -299,6 +300,7 @@ const TYPE_COLORS: Record<string, string> = {
|
|||
year: '#059669',
|
||||
timerange: '#0284c7',
|
||||
week: '#65a30d',
|
||||
months: '#0e7490',
|
||||
location: '#f97316',
|
||||
select: '#8b5cf6',
|
||||
radio: '#ec4899',
|
||||
|
|
|
|||
|
|
@ -145,18 +145,11 @@ function taskRows(items: TaskItem[], offset: number): Row[] {
|
|||
middle: item.activity_name,
|
||||
person: item.creator_person,
|
||||
time: day(item.start_time),
|
||||
subtime: `${t('portal.elapsed')} ${elapsedText(item)}`,
|
||||
flag: item.expired ? t('task.expired') : '',
|
||||
to: { name: 'todo-detail', params: { id: item.id } }
|
||||
}))
|
||||
}
|
||||
|
||||
function elapsedText(item: TaskItem): string {
|
||||
const minutes = item.elapsed_minutes || 0
|
||||
if (minutes < 60) return `${Math.max(1, Math.round(minutes))}m`
|
||||
return `${(minutes / 60).toFixed(1)}h`
|
||||
}
|
||||
|
||||
function readRows(items: ReadItem[], offset: number): Row[] {
|
||||
return items.map((item, i) => ({
|
||||
key: item.id,
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ export default {
|
|||
refresh: 'Refresh'
|
||||
},
|
||||
auth: {
|
||||
loginTitle: 'UniSOA Approval Platform',
|
||||
loginTitle: 'UnisOA Approval Platform',
|
||||
loginSubtitle: 'Unified workflows, fast collaboration, full traceability',
|
||||
// 宽屏登录页左边那一栏讲清楚的三件事(窄屏看不到)
|
||||
desktopHeadline: 'To-dos, requests and approvals, handled in one place',
|
||||
|
|
@ -160,7 +160,7 @@ export default {
|
|||
loginSuccess: 'Signed in',
|
||||
loginFailed: 'Invalid account or password',
|
||||
demoHint: 'Unified-identity accounts sign in with their platform password; the local admin account is managed by an administrator',
|
||||
copyright: 'UniSOA Approval Platform',
|
||||
copyright: 'UnisOA Approval Platform',
|
||||
captcha: 'Captcha',
|
||||
captchaPlaceholder: 'Enter the captcha',
|
||||
captchaRefresh: 'Click to refresh',
|
||||
|
|
@ -320,7 +320,6 @@ export default {
|
|||
starter: 'Initiator',
|
||||
startedAt: 'Arrived',
|
||||
titleWillUpdate: 'Becomes "{title}" once you submit',
|
||||
elapsed: 'Waiting',
|
||||
expireAt: 'Due',
|
||||
expired: 'Overdue',
|
||||
opinion: 'Comment',
|
||||
|
|
@ -1440,6 +1439,7 @@ export default {
|
|||
fieldTypeTitle: 'Process title',
|
||||
fieldTypeRichtext: 'Rich text',
|
||||
fieldTypeMonth: 'Month',
|
||||
fieldTypeMonths: 'Months',
|
||||
fieldTypeYear: 'Year',
|
||||
fieldTypeTimerange: 'Time range',
|
||||
fieldTypeWeek: 'Weekday',
|
||||
|
|
@ -1699,6 +1699,18 @@ export default {
|
|||
tabsMovePicked: 'Move the {count} selected fields to "{name}"',
|
||||
tabsMoveLeftover: 'Move the {count} fields on this page to "{name}"',
|
||||
tabsNoFieldMatch: 'No fields match',
|
||||
month1: 'Jan',
|
||||
month2: 'Feb',
|
||||
month3: 'Mar',
|
||||
month4: 'Apr',
|
||||
month5: 'May',
|
||||
month6: 'Jun',
|
||||
month7: 'Jul',
|
||||
month8: 'Aug',
|
||||
month9: 'Sep',
|
||||
month10: 'Oct',
|
||||
month11: 'Nov',
|
||||
month12: 'Dec',
|
||||
weekday1: 'Mon',
|
||||
weekday2: 'Tue',
|
||||
weekday3: 'Wed',
|
||||
|
|
@ -1747,6 +1759,21 @@ export default {
|
|||
yearDesignHint: 'Stored as a whole number (2026) and compared numerically in conditions.',
|
||||
timerangeDesignHint: 'Two clock times, stored as ["09:00", "10:30"]; filling in one end still counts as filled.',
|
||||
weekDesignHint: 'Tick the weekdays; stored as 1-7 (Monday to Sunday), so conditions check whether a day is included.',
|
||||
monthsDragHint: 'Pick several months at once: choose Oct and Nov 2026 and the field fills in "2026 Oct-Nov"',
|
||||
monthsDesignHint: 'Stored as an array of 2026-10 style months (same format as the Month field). Consecutive months merge into one span, so Oct plus Nov reads "2026 Oct-Nov". The cell holds a list, so conditions and thresholds can only ask whether it is filled.',
|
||||
monthsDialogTitle: 'Pick months',
|
||||
monthsStyleDropdown: 'Dropdown, multi',
|
||||
monthsStyleDialog: 'Dialog, multi',
|
||||
monthsStyleInline: 'Flat picker',
|
||||
monthsStyleHintDropdown:
|
||||
'The default: the cell shows the merged span such as "2026 Oct-Nov", clicking opens that year\'s 12 months and clicking away closes it. Half a row is enough.',
|
||||
monthsStyleHintDialog:
|
||||
'Clicking opens a centred month board with bigger cells, easier on a phone. Picks edit a draft there: "Confirm" writes them into the cell, cancelling leaves the cell untouched.',
|
||||
monthsStyleHintInline:
|
||||
'The 12 months stay open inside the cell so nothing is hidden behind a click, at the cost of a full row — this panel widens the cell for you.',
|
||||
monthsNone: 'No months picked',
|
||||
monthsPrevYear: 'Previous year',
|
||||
monthsNextYear: 'Next year',
|
||||
groupDefaultLabel: 'Section',
|
||||
groupDesignHint: 'Only splits a long form into readable sections; it carries no value and changes nothing about the fields below it.',
|
||||
spacerDesignHint: 'Leaves a gap so the next field lands on the right column — often all a row needs to line up.',
|
||||
|
|
@ -2815,7 +2842,6 @@ export default {
|
|||
startProcess: 'Start Process',
|
||||
more: 'More',
|
||||
noWork: 'Nothing to do',
|
||||
elapsed: 'waiting',
|
||||
handled: 'handled',
|
||||
news: 'News',
|
||||
latestNews: 'Latest',
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ export default {
|
|||
refresh: '刷新'
|
||||
},
|
||||
auth: {
|
||||
loginTitle: 'UniSOA 流程审批平台',
|
||||
loginTitle: 'UnisOA 流程审批平台',
|
||||
loginSubtitle: '统一流程 · 高效协同 · 全程留痕',
|
||||
// 宽屏登录页左边那一栏讲清楚的三件事(窄屏看不到)
|
||||
desktopHeadline: '待办、发起、审批,在一处办完',
|
||||
|
|
@ -156,7 +156,7 @@ export default {
|
|||
loginSuccess: '登录成功',
|
||||
loginFailed: '账号或密码错误',
|
||||
demoHint: '统一身份账号用统一身份平台的密码登录;本地管理员账号与口令由系统管理员维护',
|
||||
copyright: 'UniSOA 流程审批平台',
|
||||
copyright: 'UnisOA 流程审批平台',
|
||||
captcha: '验证码',
|
||||
captchaPlaceholder: '请输入验证码',
|
||||
captchaRefresh: '点击刷新验证码',
|
||||
|
|
@ -316,7 +316,6 @@ export default {
|
|||
starter: '发起人',
|
||||
startedAt: '到达时间',
|
||||
titleWillUpdate: '提交后会更新为「{title}」',
|
||||
elapsed: '已等待',
|
||||
expireAt: '处理时限',
|
||||
expired: '已超时',
|
||||
opinion: '审批意见',
|
||||
|
|
@ -1438,6 +1437,7 @@ export default {
|
|||
fieldTypeTitle: '流程标题',
|
||||
fieldTypeRichtext: '富文本',
|
||||
fieldTypeMonth: '月份',
|
||||
fieldTypeMonths: '多选月份',
|
||||
fieldTypeYear: '年份',
|
||||
fieldTypeTimerange: '时间段',
|
||||
fieldTypeWeek: '星期',
|
||||
|
|
@ -1697,6 +1697,18 @@ export default {
|
|||
tabsMovePicked: '把选中的 {count} 格移到「{name}」',
|
||||
tabsMoveLeftover: '把这一页的 {count} 个格子挪到「{name}」',
|
||||
tabsNoFieldMatch: '没有对得上的格子',
|
||||
month1: '1月',
|
||||
month2: '2月',
|
||||
month3: '3月',
|
||||
month4: '4月',
|
||||
month5: '5月',
|
||||
month6: '6月',
|
||||
month7: '7月',
|
||||
month8: '8月',
|
||||
month9: '9月',
|
||||
month10: '10月',
|
||||
month11: '11月',
|
||||
month12: '12月',
|
||||
weekday1: '周一',
|
||||
weekday2: '周二',
|
||||
weekday3: '周三',
|
||||
|
|
@ -1745,6 +1757,21 @@ export default {
|
|||
yearDesignHint: '存成一个整数年份(2026),条件分支按数字比大小。',
|
||||
timerangeDesignHint: '起止两个钟点,存成 ["09:00", "10:30"];只填一头也算填了。',
|
||||
weekDesignHint: '勾星期几,存的是 1-7(周一到周日),条件分支按「包含」判某天开不开。',
|
||||
monthsDragHint: '一次圈几个月:挑 2026 年 10、11 两月,回填出来就是「2026年10-11月」',
|
||||
monthsDesignHint: '存的是 2026-10 这样的月份数组(与「月份」同一写法);界面上连着几个月自动并成一段,挑 10、11 两月回填「2026年10-11月」。这一格装的是一串月份,条件分支与阈值只判得出「填了没有」。',
|
||||
monthsDialogTitle: '挑月份',
|
||||
monthsStyleDropdown: '下拉多选',
|
||||
monthsStyleDialog: '弹出框多选',
|
||||
monthsStyleInline: '平铺点选',
|
||||
monthsStyleHintDropdown:
|
||||
'默认这一档:格子里挂「2026年10-11月」那一句,点开出那一年的 12 个月,挑完点外面就收。半行就放得下。',
|
||||
monthsStyleHintDialog:
|
||||
'点开是一只在屏幕正中的月份盘,格子大一号、手机上好点;挑的过程先改草稿,点「确定」才写进这一格,取消就等于没挑过。',
|
||||
monthsStyleHintInline:
|
||||
'12 个月一直摊在这一格里,不用点开就看得全;代价是这一格要吃掉一整行,所以下面那栏会顺手把它铺满。',
|
||||
monthsNone: '还没挑月份',
|
||||
monthsPrevYear: '上一年',
|
||||
monthsNextYear: '下一年',
|
||||
groupDefaultLabel: '分组标题',
|
||||
groupDesignHint: '只把长表单切成几段给人看,不产生任何值;段落里的字段该怎么填还怎么填。',
|
||||
spacerDesignHint: '留一段空,把后面的格子推到合适的列上。想对齐一整行往往差的就是这一小截。',
|
||||
|
|
@ -2804,7 +2831,6 @@ export default {
|
|||
startProcess: '发起流程',
|
||||
more: '更多',
|
||||
noWork: '暂时没有工作',
|
||||
elapsed: '已等待',
|
||||
handled: '处理于',
|
||||
news: '信息资讯',
|
||||
latestNews: '最新信息',
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ export function applyDocumentTitle(): void {
|
|||
const appStore = useAppStore()
|
||||
const route = router.currentRoute.value
|
||||
const titleKey = (route.meta?.titleKey as string) || ''
|
||||
const siteName = appStore.siteName || 'UniSOA 流程审批平台'
|
||||
const siteName = appStore.siteName || 'UnisOA 流程审批平台'
|
||||
const label = titleKey ? translate(titleKey) : ''
|
||||
// The login route titles itself with the site name; do not repeat it.
|
||||
document.title = label && label !== siteName ? `${label} · ${siteName}` : siteName
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ export const useAppStore = defineStore('app', () => {
|
|||
* 否则别人抄给您的单子在那儿躺着,界面上一点动静都没有。
|
||||
*/
|
||||
const readCount = ref<number>(0)
|
||||
const siteName = ref<string>('UniSOA 流程审批平台')
|
||||
const siteName = ref<string>('UnisOA 流程审批平台')
|
||||
const siteLogo = ref<string>('/logo.svg')
|
||||
const siteDescription = ref<string>('')
|
||||
const cachedPublicSettings = ref<PublicSettings | null>(null)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/** Shared front end types for the UniSOA approval platform. */
|
||||
/** Shared front end types for the UnisOA approval platform. */
|
||||
|
||||
export interface ApiResponse<T> {
|
||||
code: number
|
||||
|
|
@ -485,6 +485,12 @@ export type FieldType =
|
|||
| 'daterange'
|
||||
/** 月份:存 `YYYY-MM`,月度报销 / 月度报表那一类按月的单子用它 */
|
||||
| 'month'
|
||||
/**
|
||||
* 多选月份:一次圈几个月,值是排好序的 `['2026-10', '2026-11']`。
|
||||
* 界面上连着几个月自动并成一段(挑 10、11 → 回填「2026年10-11月」),
|
||||
* 写法在 utils/formRuntime 的 monthsText,只读态、导出、打印都念那一句。
|
||||
*/
|
||||
| 'months'
|
||||
| 'year'
|
||||
/** 时间段:起止两个时刻,值是 `["09:00", "10:30"]`(考勤、会议室、值班) */
|
||||
| 'timerange'
|
||||
|
|
@ -2503,6 +2509,7 @@ export const TABLE_COLUMN_TYPES = [
|
|||
'time',
|
||||
'daterange',
|
||||
'month',
|
||||
'months',
|
||||
'year',
|
||||
'timerange',
|
||||
'week',
|
||||
|
|
@ -2757,7 +2764,9 @@ export interface ProcessDef {
|
|||
color: string
|
||||
creator: string
|
||||
creator_name: string
|
||||
/** 在途数。清单接口默认给全系统口径,带 count_scope=mine(发起页)时是本人发起的单 */
|
||||
running_count?: number
|
||||
/** 办结数,口径同 running_count */
|
||||
completed_count?: number
|
||||
activities?: Activity[]
|
||||
routes?: RouteDef[]
|
||||
|
|
@ -3328,7 +3337,7 @@ export interface TaskCompletedItem {
|
|||
handle_count?: number
|
||||
/** 这条已办还能不能撤回:null 表示本来就谈不上撤回(不是本人最后一步等) */
|
||||
recallable?: boolean | null
|
||||
/** 不能撤回的原因,摆在按钮的位置上,省得人对着空格子猜 */
|
||||
/** 不能撤回的原因:操作列里收成一枚图标,这句话交给悬浮提示,省得人对着空格子猜 */
|
||||
recall_blocker?: string
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -353,6 +353,7 @@ const STRUCTURED_TYPES = [
|
|||
'relation',
|
||||
'daterange',
|
||||
'timerange',
|
||||
'months',
|
||||
'auto',
|
||||
'formula',
|
||||
'embed',
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ export const TEXT_TYPES: string[] = [
|
|||
export const FLAG_TYPES: string[] = ['switch']
|
||||
/** 装的是一串值或一个对象:能问"填了没有",比大小说不清。 */
|
||||
export const BAG_TYPES: string[] = [
|
||||
'daterange', 'timerange', 'week', 'checkbox', 'dept', 'cascader', 'user', 'relation', 'address', 'location',
|
||||
'daterange', 'timerange', 'week', 'months', 'checkbox', 'dept', 'cascader', 'user', 'relation', 'address', 'location',
|
||||
'attachment', 'image', 'signature', 'sign', 'file'
|
||||
]
|
||||
/** 明细表:一叠行,额度逐行控,阈值只能问"有没有填过行"。 */
|
||||
|
|
@ -49,7 +49,7 @@ export const LAYOUT_TYPES: string[] = ['title', 'divider', 'description', 'group
|
|||
const SCALAR_TYPES = [...NUMBER_TYPES, ...DATE_TYPES, ...TEXT_TYPES]
|
||||
|
||||
/** 附件那几类连一笔额度都挂不住,口径与后端 ``quota.UNCONTROLABLE_TYPES`` 一致。 */
|
||||
const UNQUOTABLE_TYPES = ['attachment', 'image', 'signature', 'sign', 'file', 'location', 'timerange', 'week']
|
||||
const UNQUOTABLE_TYPES = ['attachment', 'image', 'signature', 'sign', 'file', 'location', 'timerange', 'week', 'months']
|
||||
|
||||
/** 这一格能不能挂某一样。名单之外的一律当"装不下"处理,新加类型时先归组再用。 */
|
||||
export function canCarry(type: string, cap: FieldCapability): boolean {
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import {
|
|||
TEXT_LIMIT_TYPES,
|
||||
embedConfigProblems,
|
||||
fileConfigProblems,
|
||||
monthsConfigProblems,
|
||||
textConfigProblems,
|
||||
unitProblem,
|
||||
validateTableField
|
||||
|
|
@ -119,6 +120,7 @@ export const FIELD_TYPES: FieldType[] = [
|
|||
'time',
|
||||
'daterange',
|
||||
'month',
|
||||
'months',
|
||||
'year',
|
||||
'timerange',
|
||||
'mobile',
|
||||
|
|
@ -523,6 +525,10 @@ export function validateFields(fields: FormFieldDef[], columns = GRID_COLS): str
|
|||
if (FILE_LIMIT_TYPES.includes(field.type)) {
|
||||
fileConfigProblems(field).forEach((problem) => problems.push(`${at}「${field.label || field.key}」${problem}`))
|
||||
}
|
||||
// 多选月份的挑选姿势:认不出的写法(手改 JSON、AI 起草)也在这一步说,别留给渲染器猜
|
||||
if (field.type === 'months') {
|
||||
monthsConfigProblems(field).forEach((problem) => problems.push(`${at}「${field.label || field.key}」${problem}`))
|
||||
}
|
||||
// 外部页面:没挑页面、参数写得这个页面用不上、内嵌框高度出格,都属于"到填单页才露出来",
|
||||
// 保存这一刻说清楚。"源在不在"这里查不了(要读库),后端 formruntime.validate_schema 兜。
|
||||
if (field.type === 'embed') {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,87 @@
|
|||
/**
|
||||
* 多选月份那一格的取值与念法。
|
||||
*
|
||||
* 「挑 10、11 两个月 → 回填 2026年10-11月」是这一类字段唯一的卖点,念错一句就等于没有;
|
||||
* 库里的写法又必须与「月份」那一格一致(YYYY-MM),条件分支才比得动。
|
||||
* 这两件事都在这里钉住,写法与后端 ``service/formruntime.py`` 的 months_text 一一对应。
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { MONTHS_STYLES, monthList, monthsConfigProblems, monthsStyleOf, monthsText } from '@/utils/formRuntime'
|
||||
import { validateFields } from '@/utils/formLayout'
|
||||
import type { FormFieldDef } from '@/types'
|
||||
|
||||
describe('monthList:只留写得对的月份', () => {
|
||||
it('去重、按时间排好,脏值一律丢掉', () => {
|
||||
expect(monthList(['2026-11', '2026-10', '2026-11', '2026-13', '', ' 2026-01 ', 'x'])).toEqual([
|
||||
'2026-01',
|
||||
'2026-10',
|
||||
'2026-11'
|
||||
])
|
||||
})
|
||||
|
||||
it('单个值、空值、null 都收成数组,不在只读态里炸开', () => {
|
||||
expect(monthList('2026-07')).toEqual(['2026-07'])
|
||||
expect(monthList(null)).toEqual([])
|
||||
expect(monthList(undefined)).toEqual([])
|
||||
expect(monthList('')).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
describe('monthsText:连着几个月并成一段', () => {
|
||||
it('挑 2026 年 10、11 两月,回填「2026年10-11月」', () => {
|
||||
expect(monthsText(['2026-11', '2026-10'])).toBe('2026年10-11月')
|
||||
})
|
||||
|
||||
it('连着几个月并成一段,中间断开的不并', () => {
|
||||
expect(monthsText(['2026-01', '2026-02', '2026-05', '2027-07'])).toBe('2026年1-2月、5月、2027年7月')
|
||||
expect(monthsText(['2026-01', '2026-03'])).toBe('2026年1月、3月')
|
||||
})
|
||||
|
||||
it('跨年那段两头都把年份写全,之后的一段重新报年', () => {
|
||||
expect(monthsText(['2026-12', '2027-01', '2027-02', '2027-05'])).toBe('2026年12月-2027年2月、2027年5月')
|
||||
})
|
||||
|
||||
it('只挑一个月就只写那一个月,一个都没挑是空串', () => {
|
||||
expect(monthsText(['2026-07'])).toBe('2026年7月')
|
||||
expect(monthsText([])).toBe('')
|
||||
expect(monthsText(['2026-9'])).toBe('')
|
||||
})
|
||||
})
|
||||
|
||||
describe('monthsStyleOf:这一格用什么姿势挑', () => {
|
||||
it('三档都认,取值与设计器里「挑选方式」是同一套', () => {
|
||||
expect(MONTHS_STYLES).toEqual(['dropdown', 'dialog', 'inline'])
|
||||
expect(monthsStyleOf({ pickerStyle: 'dialog' })).toBe('dialog')
|
||||
expect(monthsStyleOf({ pickerStyle: 'inline' })).toBe('inline')
|
||||
})
|
||||
|
||||
it('没配过就是下拉多选:默认不摊开,那一面盘要吃掉一整行', () => {
|
||||
expect(monthsStyleOf({})).toBe('dropdown')
|
||||
expect(monthsStyleOf({ pickerStyle: undefined })).toBe('dropdown')
|
||||
expect(monthsStyleOf(null)).toBe('dropdown')
|
||||
})
|
||||
|
||||
it('认不出的写法(手改的、别的类型留下的、那两格下拉组件的 auto)一律回落到默认那档', () => {
|
||||
expect(monthsStyleOf({ pickerStyle: 'auto' })).toBe('dropdown')
|
||||
expect(monthsStyleOf({ pickerStyle: 'radio' })).toBe('dropdown')
|
||||
expect(monthsStyleOf({ pickerStyle: ' dialog ' })).toBe('dialog')
|
||||
})
|
||||
})
|
||||
|
||||
describe('monthsConfigProblems:配歪的挑选姿势当场说', () => {
|
||||
it('三档都不吭声,没配过也不吭声', () => {
|
||||
expect(monthsConfigProblems({})).toEqual([])
|
||||
expect(monthsConfigProblems({ pickerStyle: 'inline' })).toEqual([])
|
||||
})
|
||||
|
||||
it('认不出的写法给一句人话,别留给渲染器猜该画哪只控件', () => {
|
||||
expect(monthsConfigProblems({ pickerStyle: 'popup' })).toEqual([
|
||||
'的挑选方式不认识:popup(下拉多选 / 弹出框多选 / 平铺点选 三选一)'
|
||||
])
|
||||
})
|
||||
|
||||
it('存表单那一刻拦住,跟设计器保存用的是同一把尺子', () => {
|
||||
const field = { key: 'stopMonths', label: '停用月份', type: 'months', pickerStyle: 'popup' } as FormFieldDef
|
||||
expect(validateFields([field]).join('|')).toContain('挑选方式不认识')
|
||||
})
|
||||
})
|
||||
|
|
@ -815,6 +815,7 @@ export const TABLE_COLUMN_MIN_WIDTHS: Record<string, number> = {
|
|||
year: 110,
|
||||
timerange: 210,
|
||||
week: 260,
|
||||
months: 260,
|
||||
mobile: 150,
|
||||
email: 190,
|
||||
idcard: 200,
|
||||
|
|
@ -898,6 +899,107 @@ export function spacerHeight(field?: { height?: number } | null): number {
|
|||
/** 星期几的取值:1-7,周一到周日(与 ISO 星期同号,导出去别处也对得上)。 */
|
||||
export const WEEK_DAY_VALUES: readonly string[] = ['1', '2', '3', '4', '5', '6', '7']
|
||||
|
||||
/**
|
||||
* 多选月份(``type=months``)那一格的取值:``['2026-10', '2026-11']``。
|
||||
*
|
||||
* 月份一律写作 ``YYYY-MM``,跟「月份」那一格同一写法,条件分支才比得动;跨年也照旧
|
||||
* 按月排,不另发明第二种格式。后端镜像在 ``service/formruntime.py`` 的 ``month_list`` /
|
||||
* ``months_text``。
|
||||
*/
|
||||
const MONTH_VALUE = /^\d{4}-(0[1-9]|1[0-2])$/
|
||||
|
||||
/** 从这串里挑出写得对的月份:去掉重复、按时间先后排好。控件与只读态都读这一份。 */
|
||||
export function monthList(value: unknown): string[] {
|
||||
const items = Array.isArray(value)
|
||||
? value
|
||||
: value === null || value === undefined || value === ''
|
||||
? []
|
||||
: [value]
|
||||
return Array.from(new Set(items.map((item) => String(item).trim()).filter((item) => MONTH_VALUE.test(item)))).sort()
|
||||
}
|
||||
|
||||
/** ``2026-03`` 折成一个能加减的序号:判断"连着几个月"只要比一下是不是差 1。 */
|
||||
function monthIndex(value: string): number {
|
||||
return Number(value.slice(0, 4)) * 12 + Number(value.slice(5, 7)) - 1
|
||||
}
|
||||
|
||||
function monthOf(index: number): { year: number; month: number } {
|
||||
return { year: Math.floor(index / 12), month: (index % 12) + 1 }
|
||||
}
|
||||
|
||||
/**
|
||||
* 多选月份念成人话:连着几个月并成一段。
|
||||
*
|
||||
* 一年之内写作「2026年10-11月」,跨年写作「2026年12月-2027年2月」,中间断开的各写各的;
|
||||
* 同一年里断开的好几段只报一次年份(「2026年1月、3-5月」)。
|
||||
* 只读态、导出、打印、标题都念这一句——库里存的是 ``["2026-10","2026-11"]``,
|
||||
* 直接转字符串会把中括号和引号一起灌进单元格。写法与后端 ``months_text`` 一致。
|
||||
*/
|
||||
export function monthsText(value: unknown): string {
|
||||
const indexes = monthList(value).map(monthIndex)
|
||||
if (!indexes.length) return ''
|
||||
const runs: Array<[number, number]> = []
|
||||
indexes.forEach((index) => {
|
||||
const tail = runs[runs.length - 1]
|
||||
if (tail && index === tail[1] + 1) tail[1] = index
|
||||
else runs.push([index, index])
|
||||
})
|
||||
const parts: string[] = []
|
||||
// 上一年说过一次就不再重复;跨年那一段把两头都写全,之后的一段重新报年,
|
||||
// 否则「、5月」会挂到别人家的年份底下去。
|
||||
let spokenYear: number | null = null
|
||||
runs.forEach(([from, to]) => {
|
||||
const start = monthOf(from)
|
||||
const end = monthOf(to)
|
||||
if (start.year !== end.year) {
|
||||
spokenYear = null
|
||||
parts.push(`${start.year}年${start.month}月-${end.year}年${end.month}月`)
|
||||
return
|
||||
}
|
||||
const span = from === to ? `${start.month}月` : `${start.month}-${end.month}月`
|
||||
if (spokenYear === start.year) {
|
||||
parts.push(span)
|
||||
return
|
||||
}
|
||||
spokenYear = start.year
|
||||
parts.push(`${start.year}年${span}`)
|
||||
})
|
||||
return parts.join('、')
|
||||
}
|
||||
|
||||
/**
|
||||
* 多选月份那一格用什么姿势挑:``dropdown`` 下拉多选、``dialog`` 弹出框多选、``inline`` 平铺点选。
|
||||
*
|
||||
* 取值沿用设计器里「挑选方式」那一份(字段上的 ``pickerStyle``,与下拉框、多选同一套说法),
|
||||
* 只是这一格的候选是那一年那 12 个月,没有候选来源可言,所以**不给「自动」这一档**:
|
||||
* 没配过就是下拉多选。默认收成一只按钮是有意为之——那一面盘摊开要吃掉一整行,
|
||||
* 表单上多摆两格就挤了。后端镜像在 ``service/formruntime.py`` 的 ``MONTHS_STYLES`` /
|
||||
* ``months_style_of``,保存时认不出的写法一律收掉(``api/design.py``)。
|
||||
*/
|
||||
export const MONTHS_STYLES = ['dropdown', 'dialog', 'inline'] as const
|
||||
|
||||
export type MonthsStyle = (typeof MONTHS_STYLES)[number]
|
||||
|
||||
/** 没配过挑选方式时走哪一档。 */
|
||||
export const MONTHS_STYLE_DEFAULT: MonthsStyle = 'dropdown'
|
||||
|
||||
/** 这一格该渲染成哪一种;认不出的写法(手改的、别的类型留下的)一律回落到默认那档。 */
|
||||
export function monthsStyleOf(field: { pickerStyle?: unknown } | null | undefined): MonthsStyle {
|
||||
const declared = String(field?.pickerStyle ?? '').trim()
|
||||
return (MONTHS_STYLES as readonly string[]).includes(declared)
|
||||
? (declared as MonthsStyle)
|
||||
: MONTHS_STYLE_DEFAULT
|
||||
}
|
||||
|
||||
/** 这一格的挑选方式配歪了没有(设计期):与后端 ``formruntime.months_config_problems`` 同一句话。 */
|
||||
export function monthsConfigProblems(field: { pickerStyle?: unknown }): string[] {
|
||||
const style = String(field.pickerStyle ?? '').trim()
|
||||
if (style && !(MONTHS_STYLES as readonly string[]).includes(style)) {
|
||||
return [`的挑选方式不认识:${style}(下拉多选 / 弹出框多选 / 平铺点选 三选一)`]
|
||||
}
|
||||
return []
|
||||
}
|
||||
|
||||
/**
|
||||
* `type=location` 那一格的取值整形:只认 lng / lat / address 这三样,脏键一律丢掉。
|
||||
*
|
||||
|
|
|
|||
|
|
@ -59,13 +59,6 @@ export function badgeClass(variant: BadgeVariant): string {
|
|||
return `badge badge-${variant}`
|
||||
}
|
||||
|
||||
/** Minutes -> compact Chinese duration (task waiting time). */
|
||||
export function formatMinutes(minutes: number | null | undefined): string {
|
||||
if (!minutes || minutes <= 0) return '--'
|
||||
if (minutes < 60) return `${Math.round(minutes)} 分钟`
|
||||
return formatSeconds(Math.round(minutes) * 60)
|
||||
}
|
||||
|
||||
/** Seconds -> compact Chinese duration (engine `duration` columns). */
|
||||
export function formatSeconds(seconds: number | null | undefined): string {
|
||||
if (!seconds || seconds <= 0) return '--'
|
||||
|
|
|
|||
|
|
@ -89,6 +89,20 @@ export function carriesOptionSource(type: string): boolean {
|
|||
return OPTION_SOURCE_TYPES.includes(type)
|
||||
}
|
||||
|
||||
/**
|
||||
* 没有候选来源、却共用「用什么姿势挑」这一问的类型:多选月份。
|
||||
*
|
||||
* 它的候选是那一年那 12 个月,谈不上手填 / 字典 / 单据 / 数据源,但挑选姿势是同一个问题,
|
||||
* 于是设计器里那一栏照摆、字段上照用 ``pickerStyle``。判"这一格要不要摆挑选方式"问下面那句,
|
||||
* 别再问 carriesOptionSource——那一句只该管来源。
|
||||
*/
|
||||
export const STYLE_ONLY_TYPES: string[] = ['months']
|
||||
|
||||
/** 这一格要不要摆「挑选方式」那一栏:有候选来源的那几类,加上多选月份。 */
|
||||
export function carriesStyleChoice(type: string): boolean {
|
||||
return carriesOptionSource(type) || STYLE_ONLY_TYPES.includes(type)
|
||||
}
|
||||
|
||||
/**
|
||||
* 这一类字段**技术上**装得下哪几种来源(判这一格走哪条路用它;设计器给挑的清单是
|
||||
* offeredSourceKinds 那一份)。
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ const PERSON_TYPES = ['user']
|
|||
* 日期区间是起止两项,关联单是对面单据的 job。跟它们比包含等于拿文件对象做子串,
|
||||
* 拼得出式子但意思不成立,所以只给判空。
|
||||
*/
|
||||
const OPAQUE_TYPES = ['attachment', 'image', 'signature', 'table', 'daterange', 'timerange', 'week', 'location', 'relation']
|
||||
const OPAQUE_TYPES = ['attachment', 'image', 'signature', 'table', 'daterange', 'timerange', 'week', 'months', 'location', 'relation']
|
||||
|
||||
export function fieldKind(type: string): FieldKind {
|
||||
if (NUMBER_TYPES.includes(type)) return 'number'
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@ import { createPinia, setActivePinia } from 'pinia'
|
|||
import { createMemoryHistory, createRouter } from 'vue-router'
|
||||
import { createI18n } from 'vue-i18n'
|
||||
import zh from '@/i18n/locales/zh'
|
||||
import ConfirmDialog from '@/components/common/ConfirmDialog.vue'
|
||||
import DataTable from '@/components/common/DataTable.vue'
|
||||
import HelpTooltip from '@/components/common/HelpTooltip.vue'
|
||||
import DoneListView from './DoneListView.vue'
|
||||
import type { TaskCompletedItem } from '@/types'
|
||||
|
||||
|
|
@ -116,4 +119,67 @@ describe('DoneListView(我的已办按单折叠)', () => {
|
|||
expect.anything()
|
||||
)
|
||||
})
|
||||
|
||||
it('撤不回来的原因收进悬浮提示:图标占位,长句子不在列里摊开', async () => {
|
||||
const reason = '环节「财务经理」的审批已交给外部系统(财务数字助手),OA 里不能撤回。请到 财务数字助手 里办理。'
|
||||
api.listCompleted.mockResolvedValue({
|
||||
items: rows().map((row) => ({ ...row, latest: true, recallable: false, recall_blocker: reason })),
|
||||
total: 2,
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
pages: 1
|
||||
})
|
||||
const { wrapper } = await open()
|
||||
expect(wrapper.findAll('[data-test="recall-blocked"]')).toHaveLength(2)
|
||||
const cell = wrapper.findAll('tbody tr')[0].findAll('td').pop()
|
||||
// 格子里不摊开那句话,只留一枚图标;原因在悬浮提示里
|
||||
expect(cell?.text()).not.toContain('财务数字助手')
|
||||
expect(wrapper.findComponent(HelpTooltip).props('content')).toContain('财务数字助手')
|
||||
})
|
||||
|
||||
it('表格走固定布局:环节/结果/处理时间/操作按像素贴着内容收,标题和意见分剩余空间', async () => {
|
||||
const { wrapper } = await open()
|
||||
// 列宽写百分比会被 DataTable 的 min-w-max 反噬(表宽撑到一万多像素),
|
||||
// 所以这里改成 table-fixed + 定宽列,标题/意见不写宽度,拿剩下的空间。
|
||||
expect(wrapper.findComponent(DataTable).props('tableClass')).toBe('table-fixed min-w-[900px]')
|
||||
const ths = wrapper.findAll('thead th')
|
||||
const widthOf = (index: number) => ths[index].classes().filter((name) => /^(w-|min-w-|overflow-)/.test(name))
|
||||
expect(widthOf(0)).toEqual([])
|
||||
expect(widthOf(3)).toEqual([])
|
||||
expect(widthOf(1)).toEqual(['w-[116px]', 'overflow-hidden'])
|
||||
expect(widthOf(2)).toEqual(['w-[92px]', 'overflow-hidden'])
|
||||
expect(widthOf(4)).toEqual(['w-[152px]', 'overflow-hidden'])
|
||||
expect(widthOf(5)).toEqual(['w-[116px]', 'overflow-hidden'])
|
||||
// 表体格子跟表头一个宽度,否则固定布局下内容会跨格漏出去
|
||||
const tds = wrapper.findAll('tbody tr')[0].findAll('td')
|
||||
expect(tds[1].classes()).toContain('w-[116px]')
|
||||
expect(tds[5].classes()).toContain('w-[116px]')
|
||||
})
|
||||
|
||||
it('操作列收成图标按钮,名字挂在 title 与 aria-label 上', async () => {
|
||||
api.listCompleted.mockResolvedValue({
|
||||
items: rows().map((row) => ({ ...row, latest: true, recallable: true })),
|
||||
total: 2,
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
pages: 1
|
||||
})
|
||||
const { wrapper, router } = await open()
|
||||
const cell = wrapper.findAll('tbody tr')[0].findAll('td').pop()
|
||||
const detail = cell?.find('[data-test="action-detail"]')
|
||||
const recall = cell?.find('[data-test="action-recall"]')
|
||||
// 按钮里没有文字,宽度才是「刚好装下图标」
|
||||
expect(detail?.text()).toBe('')
|
||||
expect(recall?.text()).toBe('')
|
||||
expect(detail?.attributes('title')).toBe('详情')
|
||||
expect(detail?.attributes('aria-label')).toBe('详情')
|
||||
expect(recall?.attributes('title')).toBe('撤回')
|
||||
expect(recall?.attributes('aria-label')).toBe('撤回')
|
||||
// 图标还在干活:点撤回照旧弹确认,点详情照旧跳这张单的 job
|
||||
await recall?.trigger('click')
|
||||
expect(wrapper.findComponent(ConfirmDialog).props('show')).toBe(true)
|
||||
await detail?.trigger('click')
|
||||
await flushPromises()
|
||||
expect(router.currentRoute.value.params.job).toBe('j')
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -49,13 +49,16 @@
|
|||
row-key="id"
|
||||
clickable-rows
|
||||
:actions-count="2"
|
||||
table-class="table-fixed min-w-[900px]"
|
||||
@row-click="openWork"
|
||||
>
|
||||
<template #cell-title="{ row }">
|
||||
<div class="min-w-[220px]">
|
||||
<p class="font-medium text-gray-900 dark:text-dark-100">{{ row.title }}</p>
|
||||
<p class="mt-0.5 flex flex-wrap items-center gap-1.5 text-xs text-gray-400">
|
||||
<span>{{ row.serial }} · {{ row.process_name }}</span>
|
||||
<!-- 标题与副标题各占一行、超出打点:表格是固定布局,这一列拿的是剩余空间,
|
||||
所以封顶交给格子本身(max-w-full),不用再把像素数写死在内容上。悬浮给全名。 -->
|
||||
<div class="max-w-full">
|
||||
<p class="truncate font-medium text-gray-900 dark:text-dark-100" :title="row.title">{{ row.title }}</p>
|
||||
<p class="mt-0.5 flex items-center gap-1.5 text-xs text-gray-400">
|
||||
<span class="min-w-0 truncate" :title="`${row.serial} · ${row.process_name}`">{{ row.serial }} · {{ row.process_name }}</span>
|
||||
<span
|
||||
v-if="handledTimes(row) > 1"
|
||||
class="badge badge-gray"
|
||||
|
|
@ -67,44 +70,62 @@
|
|||
</div>
|
||||
</template>
|
||||
<template #cell-activity_name="{ row }">
|
||||
<span class="badge badge-primary">{{ row.activity_name }}</span>
|
||||
<span class="badge max-w-full truncate badge-primary" :title="row.activity_name">{{ row.activity_name }}</span>
|
||||
<p class="mt-1 text-xs text-gray-400">{{ processingTypeLabel(row.processing_type) }}</p>
|
||||
</template>
|
||||
<template #cell-route_name="{ row }">
|
||||
<span v-if="row.route_name" class="badge" :class="resultBadgeClass(row)">{{ row.route_name }}</span>
|
||||
<span v-if="row.route_name" class="badge max-w-full truncate" :class="resultBadgeClass(row)" :title="row.route_name">{{ row.route_name }}</span>
|
||||
<span v-else class="text-xs text-gray-400">--</span>
|
||||
</template>
|
||||
<template #cell-opinion="{ row }">
|
||||
<p class="line-clamp-2 max-w-[260px] text-gray-600 dark:text-dark-300">{{ row.opinion || '--' }}</p>
|
||||
<p class="max-w-full truncate text-gray-600 dark:text-dark-300" :title="row.opinion || ''">
|
||||
{{ row.opinion || '--' }}
|
||||
</p>
|
||||
</template>
|
||||
<template #cell-completed_time="{ row }">
|
||||
<p>{{ formatDateTimeToMinute(row.completed_time) }}</p>
|
||||
<p class="text-xs text-gray-400">{{ t('work.duration') }} {{ formatSeconds(row.duration) }}</p>
|
||||
</template>
|
||||
<template #cell-actions="{ row }">
|
||||
<div class="flex items-center gap-1.5">
|
||||
<button type="button" class="btn btn-ghost btn-sm" @click.stop="openWork(row)">
|
||||
<Icon name="eye" class="mr-1 h-4 w-4" />
|
||||
{{ t('common.detail') }}
|
||||
<!-- 这一列要贴着内容收,按钮就只留图标:眼睛=详情、回旋=撤回,在这张表里
|
||||
不需要文字也认得出来,名字交给悬浮提示和读屏。省下来的几十像素还给标题。 -->
|
||||
<div class="flex items-center gap-1">
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-ghost btn-icon"
|
||||
:title="t('common.detail')"
|
||||
:aria-label="t('common.detail')"
|
||||
data-test="action-detail"
|
||||
@click.stop="openWork(row)"
|
||||
>
|
||||
<Icon name="eye" class="h-4 w-4" />
|
||||
</button>
|
||||
<button
|
||||
v-if="row.recallable"
|
||||
type="button"
|
||||
class="btn btn-ghost btn-sm text-red-600"
|
||||
class="btn btn-ghost btn-icon text-red-600"
|
||||
:title="t('task.reset')"
|
||||
:aria-label="t('task.reset')"
|
||||
data-test="action-recall"
|
||||
@click.stop="recall(row)"
|
||||
>
|
||||
<Icon name="sync" class="mr-1 h-4 w-4" />
|
||||
{{ t('task.reset') }}
|
||||
<Icon name="sync" class="h-4 w-4" />
|
||||
</button>
|
||||
<!-- 撤不回来的这一条把原因写在按钮的位置上:归档的单子不给按钮是对的,
|
||||
但什么都不说,人只会一遍遍去点别的按钮。 -->
|
||||
<span
|
||||
v-else-if="showBlocker(row)"
|
||||
class="text-xs text-gray-400"
|
||||
:title="row.recall_blocker"
|
||||
>
|
||||
{{ t('task.cannotReset') }}{{ row.recall_blocker ? `:${row.recall_blocker}` : '' }}
|
||||
</span>
|
||||
<!-- 撤不回来的这一条得说原因:归档的单子不给按钮是对的,但什么都不说,
|
||||
人只会一遍遍去点别的按钮。可那句话说得长,摊在这一列里会把整列撑开,
|
||||
前面几列的流程信息反而一格都看不见,所以收成一枚图标,原因交给悬浮提示。 -->
|
||||
<HelpTooltip v-else-if="showBlocker(row)" :content="t('task.cannotReset') + ':' + row.recall_blocker" width-class="w-96">
|
||||
<template #trigger>
|
||||
<span
|
||||
data-test="recall-blocked"
|
||||
class="inline-flex cursor-help items-center text-xs text-amber-500"
|
||||
:aria-label="t('task.cannotReset')"
|
||||
@click.stop
|
||||
>
|
||||
<Icon name="ban" class="h-4 w-4" />
|
||||
</span>
|
||||
</template>
|
||||
</HelpTooltip>
|
||||
</div>
|
||||
</template>
|
||||
<template #empty>
|
||||
|
|
@ -148,6 +169,7 @@ import EmptyState from '@/components/common/EmptyState.vue'
|
|||
import ConfirmDialog from '@/components/common/ConfirmDialog.vue'
|
||||
import Icon from '@/components/icons/Icon.vue'
|
||||
import ExportButton from '@/components/common/ExportButton.vue'
|
||||
import HelpTooltip from '@/components/common/HelpTooltip.vue'
|
||||
import type { Column } from '@/components/common/types'
|
||||
import { designAPI, taskAPI } from '@/api'
|
||||
import { useOAList } from '@/composables/useOAList'
|
||||
|
|
@ -171,12 +193,18 @@ const confirmShow = ref(false)
|
|||
const pending = ref<TaskCompletedItem | null>(null)
|
||||
|
||||
const columns = computed<Column[]>(() => [
|
||||
// 表格改成 table-fixed(见上面 DataTable 的 table-class):定宽的几列贴着内容收,
|
||||
// 剩下的空间由没写宽度的标题和意见平分。为什么非要定宽 —— DataTable 默认给表格挂
|
||||
// min-w-max,只要哪一列写了百分比(连 w-[1%] 都算),百分比就按整张表的 max-content
|
||||
// 结算,表宽被撑到一万多像素,标题后面几列全挤出屏幕(实测 1600 容器里表宽 14000px,
|
||||
// 环节、结果、处理时间各分走三四千)。固定布局下这些列宽是实打实的像素,
|
||||
// 长环节名自己在格子里打点,不再回头挤压别人。
|
||||
{ key: 'title', label: t('common.title') },
|
||||
{ key: 'activity_name', label: t('task.activity') },
|
||||
{ key: 'route_name', label: t('task.route') },
|
||||
{ key: 'activity_name', label: t('task.activity'), class: 'w-[116px] overflow-hidden' },
|
||||
{ key: 'route_name', label: t('task.route'), class: 'w-[92px] overflow-hidden' },
|
||||
{ key: 'opinion', label: t('task.opinion') },
|
||||
{ key: 'completed_time', label: t('task.startedAt') },
|
||||
{ key: 'actions', label: t('common.actions') }
|
||||
{ key: 'completed_time', label: t('task.startedAt'), class: 'w-[152px] overflow-hidden' },
|
||||
{ key: 'actions', label: t('common.actions'), class: 'w-[116px] overflow-hidden' }
|
||||
])
|
||||
|
||||
const exportQuery = computed(() => ({ scope: 'completed', ...params }))
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@
|
|||
</template>
|
||||
<template #cell-time="{ row }">
|
||||
<p>{{ formatDateTimeToMinute(row.start_time) }}</p>
|
||||
<p class="text-xs text-gray-400">{{ timeHint(row) }}</p>
|
||||
<p v-if="timeHint(row)" class="text-xs text-gray-400">{{ timeHint(row) }}</p>
|
||||
</template>
|
||||
<template #cell-actions="{ row }">
|
||||
<div class="flex items-center gap-1.5">
|
||||
|
|
@ -173,7 +173,7 @@ import { useOAList } from '@/composables/useOAList'
|
|||
import { useAuthStore } from '@/stores/auth'
|
||||
import { formatDateTimeToMinute } from '@/utils/format'
|
||||
import type { PageResult } from '@/types'
|
||||
import { badgeClass, formatMinutes, formatSeconds, runAction, workStatusLabel, workStatusVariant } from '@/utils/oa'
|
||||
import { badgeClass, formatSeconds, runAction, workStatusLabel, workStatusVariant } from '@/utils/oa'
|
||||
import { personText } from '@/utils/personLabel'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
|
@ -260,10 +260,11 @@ function resetFilters() {
|
|||
reload()
|
||||
}
|
||||
|
||||
/** 列表第二行的时间口径:待办看等了多久,在途单看已经跑了多久,归档单看什么时候办结的。
|
||||
* ``duration`` 那一列是引擎在办结那一刻才写的,在途单指望它只会得到一个「--」。 */
|
||||
/** 列表第二行的时间口径:待办只看到达时间,不再摆等了多久;在途单看已经跑了多久,
|
||||
* 归档单看什么时候办结的。``duration`` 那一列是引擎在办结那一刻才写的,
|
||||
* 在途单指望它只会得到一个「--」。 */
|
||||
function timeHint(row: Record<string, any>): string {
|
||||
if (tab.value === 'task') return `${t('task.elapsed')} ${formatMinutes(row.elapsed_minutes)}`
|
||||
if (tab.value === 'task') return ''
|
||||
if (row.status === 'running') return `${t('work.duration')} ${formatSeconds(elapsedSeconds(row.start_time))}`
|
||||
return `${t('work.finishedAt')} ${formatDateTimeToMinute(row.finish_time)}`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -119,7 +119,12 @@ function query(key: string): string {
|
|||
onMounted(async () => {
|
||||
loading.value = true
|
||||
// 只列这个人发得起来的流程:发不起的摆在发起页里,点了才弹一句没权限,纯属白跑一趟。
|
||||
const list = await runAction<ProcessDef[]>(() => designAPI.listProcesses({ enabled: '1', startable: '1' }))
|
||||
// count_scope=mine 是给卡片下面那行统计用的——发起页问的是「我自己在这条流程上
|
||||
// 走了多少单」,默认口径回的是全系统的在途与办结,别人的单算进来只会让人误读成
|
||||
// 自己已经排了一堆。设计器的流程清单不传这个参数,那里要的正是全系统那一版。
|
||||
const list = await runAction<ProcessDef[]>(() =>
|
||||
designAPI.listProcesses({ enabled: '1', startable: '1', count_scope: 'mine' })
|
||||
)
|
||||
processes.value = (list ?? []).filter((item) => item.published || authStore.can('design:process'))
|
||||
loading.value = false
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@
|
|||
</div>
|
||||
<div class="text-right">
|
||||
<span class="badge badge-primary">{{ task.activity_name }}</span>
|
||||
<p class="mt-1.5 text-xs text-gray-400">{{ t('task.elapsed') }} {{ formatMinutes(task.elapsed_minutes) }}</p>
|
||||
<router-link
|
||||
:to="{ name: 'work-print', params: { job: detail.job } }"
|
||||
class="btn btn-ghost btn-sm mt-2"
|
||||
|
|
@ -457,7 +456,7 @@ import { useAuthStore } from '@/stores/auth'
|
|||
import { formatDateTime } from '@/utils/format'
|
||||
import { missingRequiredFields } from '@/utils/formRuntime'
|
||||
import { expandPerms } from '@/utils/tabPages'
|
||||
import { badgeClass, errorMessage, formatMinutes, markReadsOpened, runAction, workStatusLabel, workStatusVariant } from '@/utils/oa'
|
||||
import { badgeClass, errorMessage, markReadsOpened, runAction, workStatusLabel, workStatusVariant } from '@/utils/oa'
|
||||
import { personText } from '@/utils/personLabel'
|
||||
import type { Attachment, AttachmentItem, FormSchema, WorkComment, WorkDetail } from '@/types'
|
||||
import { startOfWork, type RecordCommentPayload } from '@/utils/approvalRecord'
|
||||
|
|
|
|||
|
|
@ -110,7 +110,6 @@
|
|||
</template>
|
||||
<template #cell-start_time="{ row }">
|
||||
<p>{{ formatDateTimeToMinute(row.start_time) }}</p>
|
||||
<p class="text-xs text-gray-400">{{ t('task.elapsed') }} {{ formatMinutes(row.elapsed_minutes) }}</p>
|
||||
</template>
|
||||
<template #cell-expire="{ row }">
|
||||
<span v-if="row.expired" class="badge badge-danger">{{ t('task.expired') }}</span>
|
||||
|
|
@ -207,7 +206,7 @@ import type { Column } from '@/components/common/types'
|
|||
import { designAPI, taskAPI, workAPI } from '@/api'
|
||||
import { useOAList } from '@/composables/useOAList'
|
||||
import { formatDateTimeToMinute } from '@/utils/format'
|
||||
import { errorMessage, formatMinutes, runAction } from '@/utils/oa'
|
||||
import { errorMessage, runAction } from '@/utils/oa'
|
||||
import { useAppStore } from '@/stores/app'
|
||||
import type { TaskItem } from '@/types'
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,85 @@
|
|||
// @vitest-environment jsdom
|
||||
/**
|
||||
* 从左侧字段库拖一只「多选月份」进来,到底占多宽。
|
||||
*
|
||||
* 这一格最初的唯一长相是 12 个月摊开,于是它天生吃一整行——用户那句"太占位置"就是从这里来的。
|
||||
* 现在默认收成一只下拉按钮,跟「月份」一样半行放得下;摊开成了配的人自己选的(宽度那条
|
||||
* 由属性面板负责,见 FieldInspector.newTypes.spec)。这里钉的是**加进来那一刻**的宽度:
|
||||
* 谁要是再把它塞回 FULL_WIDTH_TYPES,这一句就红。
|
||||
*/
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { flushPromises, mount } from '@vue/test-utils'
|
||||
import { createPinia } from 'pinia'
|
||||
import { createI18n } from 'vue-i18n'
|
||||
import zh from '@/i18n/locales/zh'
|
||||
import FormDesignerView from './FormDesignerView.vue'
|
||||
import FieldLibrary from '@/components/oa/design/FieldLibrary.vue'
|
||||
|
||||
type Async = (...args: never[]) => Promise<unknown>
|
||||
|
||||
const route = vi.hoisted(() => ({ params: { id: 'f9' } as Record<string, string>, query: {} as Record<string, string> }))
|
||||
const api = vi.hoisted(() => ({
|
||||
getForm: vi.fn(async () => ({ id: 'f9', name: '设备停用单', content: { fields: [] } })),
|
||||
createForm: vi.fn(async () => ({ id: 'f9' })),
|
||||
updateForm: vi.fn(async (id: string, payload: Record<string, unknown>) => ({ id, ...payload }))
|
||||
}))
|
||||
|
||||
vi.mock('vue-router', () => ({
|
||||
useRoute: () => route,
|
||||
useRouter: () => ({ replace: vi.fn(), push: vi.fn() })
|
||||
}))
|
||||
vi.mock('@/api', () => ({
|
||||
designAPI: {
|
||||
getForm: api.getForm,
|
||||
createForm: api.createForm,
|
||||
updateForm: api.updateForm,
|
||||
validateForm: vi.fn(async () => ({ valid: true })),
|
||||
formTitleVariables: vi.fn(async () => ({ variables: [] })),
|
||||
previewTitle: vi.fn(async () => null)
|
||||
}
|
||||
}))
|
||||
vi.mock('@/api/dataSources', async (importOriginal) => {
|
||||
const real = await importOriginal<Record<string, unknown>>()
|
||||
const stubbed: Record<string, Async> = {
|
||||
listDataSourcesCached: async () => [],
|
||||
fetchValue: async () => [],
|
||||
declaredArgs: () => [] as never
|
||||
}
|
||||
return { ...real, ...stubbed }
|
||||
})
|
||||
vi.mock('@/api/quota', async (importOriginal) => {
|
||||
const real = await importOriginal<Record<string, unknown>>()
|
||||
const stubbed: Record<string, Async> = {
|
||||
listQuotaDefsCached: async () => [],
|
||||
listQuotaDefs: async () => [],
|
||||
quotaOptions: async () => []
|
||||
}
|
||||
return { ...real, ...stubbed }
|
||||
})
|
||||
vi.mock('@/api/embeds', () => ({
|
||||
listEmbedSources: vi.fn(async () => []),
|
||||
resetEmbedSourceCache: vi.fn()
|
||||
}))
|
||||
|
||||
async function openDesigner() {
|
||||
const i18n = createI18n({ legacy: false, locale: 'zh', messages: { zh }, missingWarn: false, fallbackWarn: false })
|
||||
const wrapper = mount(FormDesignerView, { global: { plugins: [createPinia(), i18n] } })
|
||||
await flushPromises()
|
||||
return wrapper
|
||||
}
|
||||
|
||||
/** 画布上每一格占的列宽(`grid-column: 起 / span 几`)。 */
|
||||
function spans(wrapper: Awaited<ReturnType<typeof openDesigner>>) {
|
||||
return wrapper.findAll('.field-cell').map((cell) => /span (\d+)/.exec(cell.attributes('style') ?? '')?.[1])
|
||||
}
|
||||
|
||||
describe('拖进来那一刻的宽度', () => {
|
||||
it('多选月份与「月份」一样占半行,不再一上来就吃掉一整行', async () => {
|
||||
const wrapper = await openDesigner()
|
||||
const library = wrapper.findComponent(FieldLibrary)
|
||||
library.vm.$emit('add', 'months')
|
||||
library.vm.$emit('add', 'month')
|
||||
await flushPromises()
|
||||
expect(spans(wrapper)).toEqual(['6', '6'])
|
||||
})
|
||||
})
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* UniSOA 的离线外壳。目标只有两条,都很克制:
|
||||
* UnisOA 的离线外壳。目标只有两条,都很克制:
|
||||
*
|
||||
* 1. **断网点开图标不该白屏**:导航请求先走网络,网不通就回缓存里的应用外壳,
|
||||
* 剩下的交给页面自己的「加载失败」状态去说;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
-- UniSOA 流程审批平台 -- MySQL 结构快照
|
||||
-- UnisOA 流程审批平台 -- MySQL 结构快照
|
||||
-- 来源: 192.168.124.202:3306/unis_oa
|
||||
-- 导出时间: 2026-10-28 15:51:46
|
||||
--
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
-- 2026-11-02 存量数据订正:品牌名 UniSOA -> UnisOA(只动文案,不动结构)
|
||||
--
|
||||
-- 背景:产品名统一改写为 UnisOA。代码与配置里的 47 处已随本次改动一起换掉,
|
||||
-- 配置文件 backend/config.toml 的 [site] name 早就是 UnisOA,界面上的站名
|
||||
-- 走的是配置项 site_name,不读库里的文案,所以这一步只清"已经落进库里的字"。
|
||||
-- 范围:种子演示数据可能写进过两张表的文本列——门户文章 oa_cms_document
|
||||
-- (title / summary / body)与会议 oa_meeting(title / content / location / link)。
|
||||
-- 本机实连 unis_oa_prod 扫过全部文本列,命中的只有 1 行:
|
||||
-- oa_meeting.title = "UniSOA 试运行问题复盘"(演示日程种子里那条)。
|
||||
-- 测试库 unis_oa 若也种过演示数据,同样跑这一份即可,语句是幂等的。
|
||||
-- 不做:内部标识一概不改——小写的 unisoa(logger 名、镜像名、系统用户、/etc/unisoa、
|
||||
-- Redis 键前缀、前端 localStorage 键)、库名 unis_oa / unis_oa_prod、
|
||||
-- k8s 对象与 MinIO 桶 unis-oa、对外开放的签名头 X-Unisoa-*。
|
||||
-- 封面图的文件名 notice-unisoa.png 也保持原样:它同时被 seed.py 的 cover 字段
|
||||
-- 和已发布文章的 oa_cms_document.cover 记着,改名等于多迁一列数据,不值当。
|
||||
-- 执行:整段跑,不需要重启后端(这些都是纯展示文本,读的时候现取)。
|
||||
-- 重复跑不会再改到任何东西——WHERE 里的 LIKE '%UniSOA%' 第二次就匹配不到了。
|
||||
|
||||
-- 1) 门户文章(标题 / 摘要 / 正文)
|
||||
UPDATE `oa_cms_document`
|
||||
SET `title` = REPLACE(`title`, 'UniSOA', 'UnisOA'),
|
||||
`summary` = REPLACE(`summary`, 'UniSOA', 'UnisOA'),
|
||||
`body` = REPLACE(`body`, 'UniSOA', 'UnisOA')
|
||||
WHERE `title` LIKE '%UniSOA%' OR `summary` LIKE '%UniSOA%' OR `body` LIKE '%UniSOA%';
|
||||
|
||||
-- 2) 会议日程(标题 / 内容 / 地点 / 链接)
|
||||
UPDATE `oa_meeting`
|
||||
SET `title` = REPLACE(`title`, 'UniSOA', 'UnisOA'),
|
||||
`content` = REPLACE(`content`, 'UniSOA', 'UnisOA'),
|
||||
`location` = REPLACE(`location`, 'UniSOA', 'UnisOA'),
|
||||
`link` = REPLACE(`link`, 'UniSOA', 'UnisOA')
|
||||
WHERE `title` LIKE '%UniSOA%' OR `content` LIKE '%UniSOA%'
|
||||
OR `location` LIKE '%UniSOA%' OR `link` LIKE '%UniSOA%';
|
||||
|
||||
-- 3) 核账:下面两条都应该返回 0 行
|
||||
SELECT `id`, `title` FROM `oa_cms_document`
|
||||
WHERE `title` LIKE '%UniSOA%' OR `summary` LIKE '%UniSOA%' OR `body` LIKE '%UniSOA%';
|
||||
SELECT `id`, `title` FROM `oa_meeting`
|
||||
WHERE `title` LIKE '%UniSOA%' OR `content` LIKE '%UniSOA%'
|
||||
OR `location` LIKE '%UniSOA%' OR `link` LIKE '%UniSOA%';
|
||||
|
||||
-- 4) 只有一种情况要额外动:哪个环境曾经**在系统设置页保存过**系统名称,
|
||||
-- 那个值会落在 oa_system_setting 的 config:site 里,并按规则盖住配置文件。
|
||||
-- 先查有没有,有再放开第二句(本环境查过,没有这一行)。
|
||||
SELECT `key`, `value` FROM `oa_system_setting` WHERE `value` LIKE '%UniSOA%';
|
||||
-- UPDATE `oa_system_setting` SET `value` = REPLACE(`value`, 'UniSOA', 'UnisOA')
|
||||
-- WHERE `value` LIKE '%UniSOA%';
|
||||
Loading…
Reference in New Issue