feat(gerp): 「其它」说明字段统一按 visibleWhen 条件显示
以 EMPLOYEE_PROFILE_OTHER_FIELDS 登记表替代原先写死的一条,覆盖志愿工作与他人关系两处;选项值直接取自对应单选字段的选项表,两种「其它/其他」写法都算命中。
This commit is contained in:
1 parent
adc5e55532
commit
633cc71622
1 file changed
+22
-5
@@ -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
|
||||
|
||||
Reference in new issue
Block a user