From 633cc71622c3ec142cde9f9d8c0a5cd4460b797e Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Thu, 1 Oct 2026 19:53:54 +0800 Subject: [PATCH] =?UTF-8?q?feat(gerp):=20=E3=80=8C=E5=85=B6=E5=AE=83?= =?UTF-8?q?=E3=80=8D=E8=AF=B4=E6=98=8E=E5=AD=97=E6=AE=B5=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E6=8C=89=20visibleWhen=20=E6=9D=A1=E4=BB=B6=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 以 EMPLOYEE_PROFILE_OTHER_FIELDS 登记表替代原先写死的一条,覆盖志愿工作与他人关系两处;选项值直接取自对应单选字段的选项表,两种「其它/其他」写法都算命中。 --- gvsds/apps/gerp/form_service.py | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/gvsds/apps/gerp/form_service.py b/gvsds/apps/gerp/form_service.py index 2fa8d7a4..40bd307e 100644 --- a/gvsds/apps/gerp/form_service.py +++ b/gvsds/apps/gerp/form_service.py @@ -569,6 +569,16 @@ class FormService(FormServiceBase): ], } + #: 「其它」选项的标签写法(两种都算命中,用于条件显示判定) + OTHER_OPTION_LABELS = ('其它', '其他') + + #: 单选字段 → 配套「其它」说明字段:选中「其它/其他」时说明字段才显示 + #: (选项值直接取自该字段的选项表,新增同类字段只需在此登记一行) + EMPLOYEE_PROFILE_OTHER_FIELDS = { + 'VolunteerWork': 'VolunteerWorkOther', + 'EmergencyRelation': 'EmergencyRelationOther', + } + #: 档案里用多行文本框的字段(长文本) EMPLOYEE_PROFILE_TEXTAREA_FIELDS = ('VolunteerWish', 'Remark') @@ -1020,11 +1030,18 @@ class FormService(FormServiceBase): if pascal_name in ('AcceptDispatchDevice', 'AcceptRewardPunish'): col['type'] = 'switch' col['defaultValue'] = False - if pascal_name == 'VolunteerWorkOther': - # 条件显示:只在「志愿工作 = 其它」时出现 - # (前端统一按 visibleWhen 判定,表单与只读展示同一口径) - col['visibleWhen'] = {'field': 'VolunteerWork', 'value': ['其它']} - col['placeholder'] = '选「其它」时填写' + # 「其它」说明字段:条件显示 —— 只在对应单选选中「其它/其他」时出现 + # (选项取值直接来自该单选字段的选项表,前端按 visibleWhen 统一判定) + for _owner, _other in self.EMPLOYEE_PROFILE_OTHER_FIELDS.items(): + if pascal_name == _other: + col['visibleWhen'] = { + 'field': _owner, + 'value': [ + _v for _v in self.EMPLOYEE_PROFILE_SELECT_OPTIONS.get(_owner, []) + if _v in self.OTHER_OPTION_LABELS + ], + } + col['placeholder'] = '选「其它」时填写' if pascal_name in self.EMPLOYEE_PROFILE_FORM_HIDDEN_FIELDS: col['editable'] = False col['hideInForm'] = True