|
|
@@ -11,6 +11,15 @@ export const CONDITION_ELIGIBLE_TYPES = new Set([
|
|
|
'date'
|
|
|
])
|
|
|
|
|
|
+/** 系统条件伪字段:发起人(非常驻表单控件) */
|
|
|
+export const INITIATOR_CONDITION_FIELD = '__initiator__'
|
|
|
+
|
|
|
+export const INITIATOR_CONDITION_CANDIDATE: ConditionCandidate = {
|
|
|
+ field: INITIATOR_CONDITION_FIELD,
|
|
|
+ title: '发起人',
|
|
|
+ type: 'initiator'
|
|
|
+}
|
|
|
+
|
|
|
export type ConditionOp = '>' | '>=' | '<' | '<=' | '==' | '!=' | 'contains'
|
|
|
|
|
|
export interface ConditionCandidate {
|
|
|
@@ -22,7 +31,7 @@ export interface ConditionCandidate {
|
|
|
}
|
|
|
|
|
|
export function opsForFieldType(type: string): Array<{ value: ConditionOp; label: string }> {
|
|
|
- if (type === 'person') {
|
|
|
+ if (type === 'person' || type === 'initiator') {
|
|
|
return [{ value: 'contains', label: '包含' }]
|
|
|
}
|
|
|
// 单选/下拉为离散选项,仅等于/不等于;输入框常填数字参与区间比较,与数字/金额/日期同套运算符
|
|
|
@@ -66,9 +75,9 @@ export function flattenFormRules(schema: unknown): any[] {
|
|
|
return out
|
|
|
}
|
|
|
|
|
|
-/** 勾选了 useInCondition 的合格字段 */
|
|
|
+/** 勾选了 useInCondition 的合格字段 + 系统「发起人」 */
|
|
|
export function listConditionCandidates(schema: unknown): ConditionCandidate[] {
|
|
|
- const out: ConditionCandidate[] = []
|
|
|
+ const out: ConditionCandidate[] = [INITIATOR_CONDITION_CANDIDATE]
|
|
|
for (const rule of flattenFormRules(schema)) {
|
|
|
const type = String(rule.type || '')
|
|
|
if (!CONDITION_ELIGIBLE_TYPES.has(type)) continue
|
|
|
@@ -115,6 +124,13 @@ export function collectConditionReferencedFields(flow: unknown): Set<string> {
|
|
|
return refs
|
|
|
}
|
|
|
|
|
|
+/** 会锁定表单「参与条件」勾选的引用字段(排除系统伪字段) */
|
|
|
+export function collectFormConditionReferencedFields(flow: unknown): Set<string> {
|
|
|
+ const refs = collectConditionReferencedFields(flow)
|
|
|
+ refs.delete(INITIATOR_CONDITION_FIELD)
|
|
|
+ return refs
|
|
|
+}
|
|
|
+
|
|
|
/** 发布/保存前:useInCondition ⇒ $required / required = true;写回顶层 useInCondition */
|
|
|
export function normalizeSchemaConditionRequired(schema: unknown): {
|
|
|
rule: unknown[]
|