Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas_plus
/
dj-car-life-system
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit e60211c8
authored
Jul 20, 2026
by
张立顺
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat 功能自测
1 parent
61c1a904
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
899 additions
and
32 deletions
src/api/adapters/journalRecord/mapDetailResponse.js
src/views/financeManage/exceptionOrderManage/detail.vue
src/views/financeManage/exceptionOrderManage/index.vue
src/views/residentManage/journalRecord/components/DynamicFormReadonly.vue
src/views/residentManage/journalRecord/constants.js
src/views/residentManage/journalRecord/index.vue
src/views/residentManage/journalRecord/utils/journalDateTime.js
src/views/residentManage/journalRecord/utils/journalFormEcho.js
src/views/residentManage/journalRecord/utils/journalFormVisibility/fieldTypes.js
src/views/residentManage/journalRecord/utils/journalFormVisibility/groupShowRuleEval.js
src/views/residentManage/journalRecord/utils/journalFormVisibility/groupVisibility.js
src/views/residentManage/journalRecord/utils/journalFormVisibility/index.js
src/views/residentManage/journalRecord/utils/journalFormVisibility/radioValue.js
src/views/residentManage/journalRecord/utils/journalFormVisibility/visibilityHelpers.js
src/views/residentManage/journalRecord/utils/journalFormVisibility/visibilitySpecs.js
tests/unit/views/residentManage/journalRecord/journalFormVisibility.spec.js
src/api/adapters/journalRecord/mapDetailResponse.js
View file @
e60211c
...
@@ -27,6 +27,8 @@ export function mapDetailResponse(res = {}, fallback = {}) {
...
@@ -27,6 +27,8 @@ export function mapDetailResponse(res = {}, fallback = {}) {
reportTemplateId
:
res
.
reportTemplateId
,
reportTemplateId
:
res
.
reportTemplateId
,
baseSceneCode
:
res
.
baseSceneCode
,
baseSceneCode
:
res
.
baseSceneCode
,
schema
:
res
.
schema
,
schema
:
res
.
schema
,
brandIds
:
res
.
brandIds
??
fallback
.
brandIds
??
[],
sceneList
:
res
.
sceneList
??
fallback
.
sceneList
??
[],
};
};
}
}
...
...
src/views/financeManage/exceptionOrderManage/detail.vue
View file @
e60211c
...
@@ -667,8 +667,8 @@ export default {
...
@@ -667,8 +667,8 @@ export default {
return
Number
(
row
.
declarationApprovalStatus
)
===
APPROVAL_STATUS
.
WAIT_BACKEND
return
Number
(
row
.
declarationApprovalStatus
)
===
APPROVAL_STATUS
.
WAIT_BACKEND
},
},
async
fetchShopLockConfig
()
{
async
fetchShopLockConfig
()
{
const
{
merchantId
,
merchantName
}
=
this
.
routerInfo
const
{
merchantId
,
merchantName
,
storeType
}
=
this
.
routerInfo
if
(
!
merchantId
)
{
if
(
!
merchantId
||
storeType
===
undefined
||
storeType
===
""
)
{
return
return
}
}
try
{
try
{
...
@@ -676,7 +676,7 @@ export default {
...
@@ -676,7 +676,7 @@ export default {
const
res
=
await
getShopLockConfig
({
const
res
=
await
getShopLockConfig
({
merchantId
,
merchantId
,
merchantName
,
merchantName
,
storeType
:
0
storeType
})
})
const
lockFlag
=
res
&&
res
.
lockFlag
?
res
.
lockFlag
:
"N"
const
lockFlag
=
res
&&
res
.
lockFlag
?
res
.
lockFlag
:
"N"
this
.
abnormalFlowLockFlag
=
lockFlag
this
.
abnormalFlowLockFlag
=
lockFlag
...
@@ -689,12 +689,17 @@ export default {
...
@@ -689,12 +689,17 @@ export default {
},
},
async
handleLockSwitchChange
(
val
)
{
async
handleLockSwitchChange
(
val
)
{
const
prev
=
this
.
previousLockFlag
const
prev
=
this
.
previousLockFlag
const
{
merchantId
,
merchantName
}
=
this
.
routerInfo
const
{
merchantId
,
merchantName
,
storeType
}
=
this
.
routerInfo
if
(
!
merchantId
||
storeType
===
undefined
||
storeType
===
""
)
{
this
.
$message
.
warning
(
"缺少门店类型参数,无法修改异常流水开关"
)
this
.
abnormalFlowLockFlag
=
prev
return
}
try
{
try
{
await
saveShopLockConfig
({
await
saveShopLockConfig
({
merchantId
,
merchantId
,
merchantName
,
merchantName
,
storeType
:
0
,
storeType
,
lockFlag
:
val
lockFlag
:
val
})
})
this
.
previousLockFlag
=
val
this
.
previousLockFlag
=
val
...
...
src/views/financeManage/exceptionOrderManage/index.vue
View file @
e60211c
...
@@ -476,6 +476,7 @@ export default {
...
@@ -476,6 +476,7 @@ export default {
query
:
{
query
:
{
merchantId
:
row
.
merchantId
,
merchantId
:
row
.
merchantId
,
merchantName
:
row
.
merchantName
,
merchantName
:
row
.
merchantName
,
storeType
:
row
.
storeType
,
startTime
:
this
.
searchFormSearch
.
startTime
,
startTime
:
this
.
searchFormSearch
.
startTime
,
endTime
:
this
.
searchFormSearch
.
endTime
endTime
:
this
.
searchFormSearch
.
endTime
}
}
...
...
src/views/residentManage/journalRecord/components/DynamicFormReadonly.vue
View file @
e60211c
...
@@ -72,7 +72,10 @@
...
@@ -72,7 +72,10 @@
</div>
</div>
</
template
>
</
template
>
</template>
</template>
<el-empty
v-else
description=
"暂无汇报内容"
/>
<div
v-else
class=
"dynamic-form-readonly__empty"
>
暂无汇报内容
</div>
</div>
</div>
</template>
</template>
...
@@ -117,6 +120,13 @@ export default {
...
@@ -117,6 +120,13 @@ export default {
<
style
scoped
lang=
"scss"
>
<
style
scoped
lang=
"scss"
>
.dynamic-form-readonly
{
.dynamic-form-readonly
{
&__empty
{
padding
:
40px
0
;
text-align
:
center
;
color
:
#909399
;
font-size
:
14px
;
}
&
__section
,
&
__section
,
&
__group
,
&
__group
,
&
__subform
{
&
__subform
{
...
...
src/views/residentManage/journalRecord/constants.js
View file @
e60211c
import
{
formatJournalDate
,
formatJournalDateTime
,
JOURNAL_EMPTY_TEXT
,
}
from
"./utils/journalDateTime"
;
export
const
JOURNAL_TABS
=
[
export
const
JOURNAL_TABS
=
[
{
key
:
"staffDaily"
,
label
:
"驻店日报"
,
journalType
:
1
},
{
key
:
"staffDaily"
,
label
:
"驻店日报"
,
journalType
:
1
},
{
key
:
"storeDaily"
,
label
:
"门店日报"
,
journalType
:
2
},
{
key
:
"storeDaily"
,
label
:
"门店日报"
,
journalType
:
2
},
...
@@ -36,56 +42,81 @@ export function getTabKeyByTemplateType(templateType) {
...
@@ -36,56 +42,81 @@ export function getTabKeyByTemplateType(templateType) {
return
tab
?.
key
??
"staffDaily"
;
return
tab
?.
key
??
"staffDaily"
;
}
}
export
{
formatJournalDate
,
formatJournalDateTime
}
from
"./utils/journalDateTime"
;
const
bizTypeColumn
=
{
const
bizTypeColumn
=
{
label
:
"业务大类"
,
label
:
"业务大类"
,
prop
:
"bizTypeName"
,
prop
:
"bizTypeName"
,
width
:
"120px"
,
minWidth
:
"100px"
,
width
:
"100px"
,
addHtml
:
"bizType"
,
addHtml
:
"bizType"
,
isPopConfig
:
{
text
:
BIZ_TYPE_TOOLTIP
},
isPopConfig
:
{
text
:
BIZ_TYPE_TOOLTIP
},
};
};
function
createDateTimeColumn
(
label
,
prop
)
{
return
{
label
,
prop
,
minWidth
:
"170px"
,
formatter
:
(
row
)
=>
formatJournalDateTime
(
row
[
prop
]),
};
}
function
createEmptyTextColumn
(
label
,
prop
,
options
=
{})
{
return
{
label
,
prop
,
formatter
:
(
row
)
=>
{
const
value
=
row
[
prop
];
return
value
!=
null
&&
value
!==
""
?
value
:
"—"
;
},
...
options
,
};
}
export
const
TABLE_COLUMNS_MAP
=
{
export
const
TABLE_COLUMNS_MAP
=
{
staffDaily
:
[
staffDaily
:
[
{
label
:
"驻店人员"
,
prop
:
"staffName"
,
minWidth
:
"1
20px"
},
{
label
:
"驻店人员"
,
prop
:
"staffName"
,
minWidth
:
"1
00px"
,
showOverFlow
:
true
},
bizTypeColumn
,
bizTypeColumn
,
{
label
:
"所属门店"
,
prop
:
"merchantName"
,
minWidth
:
"
200px"
,
showOverFlow
:
true
},
{
label
:
"所属门店"
,
prop
:
"merchantName"
,
minWidth
:
"
160px"
,
showOverFlow
:
true
,
align
:
"left"
},
{
label
:
"今日出勤"
,
prop
:
"attendanceStatus"
,
width
:
"100px"
}
,
createEmptyTextColumn
(
"今日出勤"
,
"attendanceStatus"
,
{
width
:
"100px"
})
,
{
label
:
"最近保存时间"
,
prop
:
"lastSaveTime"
,
width
:
"160px"
}
,
createDateTimeColumn
(
"最近保存时间"
,
"lastSaveTime"
)
,
],
],
storeDaily
:
[
storeDaily
:
[
{
label
:
"所属门店"
,
prop
:
"merchantName"
,
minWidth
:
"180px"
,
showOverFlow
:
true
},
{
label
:
"所属门店"
,
prop
:
"merchantName"
,
minWidth
:
"160px"
,
showOverFlow
:
true
,
align
:
"left"
,
},
bizTypeColumn
,
bizTypeColumn
,
{
{
label
:
"今日驻店人数"
,
label
:
"今日驻店人数"
,
prop
:
"staffCount"
,
prop
:
"staffCount"
,
width
:
"1
3
0px"
,
width
:
"1
2
0px"
,
formatter
:
(
row
)
=>
(
row
.
staffCount
!=
null
?
`
${
row
.
staffCount
}
人`
:
"—"
),
formatter
:
(
row
)
=>
(
row
.
staffCount
!=
null
?
`
${
row
.
staffCount
}
人`
:
"—"
),
},
},
{
label
:
"最近保存时间"
,
prop
:
"lastSaveTime"
,
width
:
"160px"
},
createDateTimeColumn
(
"最近保存时间"
,
"lastSaveTime"
),
{
createDateTimeColumn
(
"提交时间"
,
"submitTime"
),
label
:
"提交时间"
,
createEmptyTextColumn
(
"提交人"
,
"submitUserName"
,
{
prop
:
"submitTime"
,
minWidth
:
"100px"
,
width
:
"160px"
,
formatter
:
(
row
)
=>
row
.
submitTime
||
"—"
,
},
{
label
:
"提交人"
,
prop
:
"submitUserName"
,
width
:
"120px"
,
width
:
"120px"
,
formatter
:
(
row
)
=>
row
.
submitUserName
||
"—"
,
showOverFlow
:
true
,
},
}
)
,
],
],
negotiation
:
[
negotiation
:
[
{
label
:
"驻店人员"
,
prop
:
"staffName"
,
minWidth
:
"1
20px"
},
{
label
:
"驻店人员"
,
prop
:
"staffName"
,
minWidth
:
"1
00px"
,
showOverFlow
:
true
},
bizTypeColumn
,
bizTypeColumn
,
{
label
:
"所属门店"
,
prop
:
"merchantName"
,
minWidth
:
"
200px"
,
showOverFlow
:
true
},
{
label
:
"所属门店"
,
prop
:
"merchantName"
,
minWidth
:
"
160px"
,
showOverFlow
:
true
,
align
:
"left"
},
{
label
:
"最近保存时间"
,
prop
:
"lastSaveTime"
,
width
:
"160px"
}
,
createDateTimeColumn
(
"最近保存时间"
,
"lastSaveTime"
)
,
],
],
};
};
export
function
getDetailTitle
(
detail
,
journalType
)
{
export
function
getDetailTitle
(
detail
,
journalType
)
{
const
{
staffName
,
merchantName
,
reportDate
}
=
detail
;
const
{
staffName
,
merchantName
,
reportDate
}
=
detail
;
const
dateText
=
reportDate
?
`(
${
reportDate
}
)`
:
""
;
const
formattedDate
=
formatJournalDate
(
reportDate
);
const
dateText
=
formattedDate
!==
JOURNAL_EMPTY_TEXT
?
`(
${
formattedDate
}
)`
:
""
;
const
titleMap
=
{
const
titleMap
=
{
staffDaily
:
`
${
staffName
}
的驻店日报
${
dateText
}
`
,
staffDaily
:
`
${
staffName
}
的驻店日报
${
dateText
}
`
,
storeDaily
:
`
${
merchantName
}
的门店日报
${
dateText
}
`
,
storeDaily
:
`
${
merchantName
}
的门店日报
${
dateText
}
`
,
...
...
src/views/residentManage/journalRecord/index.vue
View file @
e60211c
...
@@ -173,7 +173,10 @@ export default {
...
@@ -173,7 +173,10 @@ export default {
return
{
return
{
btnId
:
`journal-
${
this
.
activeTab
}
`
,
btnId
:
`journal-
${
this
.
activeTab
}
`
,
listName
:
"list"
,
listName
:
"list"
,
tableOption
:
{
label
:
"操作"
,
width
:
"100px"
},
tableOption
:
{
label
:
"操作"
,
width
:
this
.
activeTab
===
"storeDaily"
?
"90px"
:
"100px"
,
},
tableColumns
:
TABLE_COLUMNS_MAP
[
this
.
activeTab
],
tableColumns
:
TABLE_COLUMNS_MAP
[
this
.
activeTab
],
};
};
},
},
...
...
src/views/residentManage/journalRecord/utils/journalDateTime.js
0 → 100644
View file @
e60211c
import
dayjs
from
"dayjs"
;
export
const
JOURNAL_EMPTY_TEXT
=
"—"
;
function
formatByPattern
(
value
,
pattern
)
{
if
(
value
==
null
||
value
===
""
)
{
return
JOURNAL_EMPTY_TEXT
;
}
const
formatted
=
dayjs
(
value
).
format
(
pattern
);
return
formatted
===
"Invalid Date"
?
JOURNAL_EMPTY_TEXT
:
formatted
;
}
export
function
formatJournalDate
(
value
)
{
return
formatByPattern
(
value
,
"YYYY-MM-DD"
);
}
export
function
formatJournalDateTime
(
value
)
{
return
formatByPattern
(
value
,
"YYYY-MM-DD HH:mm:ss"
);
}
src/views/residentManage/journalRecord/utils/journalFormEcho.js
View file @
e60211c
import
{
formatJournalDate
,
formatJournalDateTime
,
}
from
"./journalDateTime"
;
import
{
filterFormListForDisplay
}
from
"./journalFormVisibility"
;
const
EMPTY_TEXT
=
"—"
;
const
EMPTY_TEXT
=
"—"
;
function
sortBySortNum
(
list
=
[])
{
function
sortBySortNum
(
list
=
[])
{
...
@@ -102,9 +108,11 @@ export function formatEchoValue(field = {}) {
...
@@ -102,9 +108,11 @@ export function formatEchoValue(field = {}) {
return
`
${
raw
}${
unit
}
`
;
return
`
${
raw
}${
unit
}
`
;
}
}
case
"textarea"
:
case
"textarea"
:
return
String
(
raw
);
case
"date"
:
case
"date"
:
return
formatJournalDate
(
raw
);
case
"datetime"
:
case
"datetime"
:
return
String
(
raw
);
return
formatJournalDateTime
(
raw
);
default
:
default
:
return
String
(
raw
);
return
String
(
raw
);
}
}
...
@@ -213,7 +221,9 @@ export function buildSubformTable(field = {}) {
...
@@ -213,7 +221,9 @@ export function buildSubformTable(field = {}) {
* 解析详情并生成展示块
* 解析详情并生成展示块
*/
*/
export
function
parseJournalEcho
(
detail
=
{})
{
export
function
parseJournalEcho
(
detail
=
{})
{
return
buildEchoBlocks
(
parseFormList
(
detail
));
const
formList
=
parseFormList
(
detail
);
const
visibleFormList
=
filterFormListForDisplay
(
formList
,
detail
);
return
buildEchoBlocks
(
visibleFormList
);
}
}
export
default
{
export
default
{
...
...
src/views/residentManage/journalRecord/utils/journalFormVisibility/fieldTypes.js
0 → 100644
View file @
e60211c
export
function
isSubform
(
field
=
{})
{
return
field
.
type
===
"subform"
;
}
export
function
isStaticGroup
(
field
=
{})
{
return
field
.
type
===
"group"
;
}
export
function
getStaticGroupChildren
(
field
=
{})
{
const
children
=
field
.
children
;
if
(
!
Array
.
isArray
(
children
))
{
return
[];
}
return
Array
.
isArray
(
children
[
0
])
?
children
[
0
]
:
children
;
}
export
function
getSubformRowTemplate
(
field
=
{})
{
const
children
=
field
.
children
;
if
(
!
Array
.
isArray
(
children
)
||
!
children
.
length
)
{
return
[];
}
return
Array
.
isArray
(
children
[
0
])
?
children
[
0
]
:
children
;
}
src/views/residentManage/journalRecord/utils/journalFormVisibility/groupShowRuleEval.js
0 → 100644
View file @
e60211c
function
evalPart
(
part
=
""
,
ctx
=
{})
{
const
trimmed
=
part
.
trim
();
const
eqMatch
=
trimmed
.
match
(
/^val
(\d
+
)\s
*==
\s
*
(?:
'
([^
'
]
*
)
'|"
([^
"
]
*
)
"
)
$/
);
if
(
eqMatch
)
{
const
actual
=
ctx
[
`val
${
eqMatch
[
1
]}
`
];
const
expected
=
eqMatch
[
2
]
!=
null
?
eqMatch
[
2
]
:
eqMatch
[
3
];
return
actual
==
expected
;
}
const
neNullMatch
=
trimmed
.
match
(
/^val
(\d
+
)\s
*!=
\s
*null$/
);
if
(
neNullMatch
)
{
const
actual
=
ctx
[
`val
${
neNullMatch
[
1
]}
`
];
return
actual
!=
null
&&
actual
!==
""
;
}
return
false
;
}
function
fallbackEvaluate
(
expr
=
""
,
ctx
=
{})
{
if
(
!
expr
)
{
return
true
;
}
return
expr
.
split
(
"&&"
).
every
((
part
)
=>
evalPart
(
part
,
ctx
));
}
export
function
evaluateShowRule
(
keys
=
[],
resultExpr
=
""
,
rowFields
=
[],
getRowFieldValue
)
{
if
(
!
keys
.
length
||
!
resultExpr
)
{
return
true
;
}
try
{
const
ctx
=
{};
keys
.
forEach
((
key
,
index
)
=>
{
ctx
[
`val
${
index
+
1
}
`
]
=
getRowFieldValue
(
rowFields
,
key
);
});
return
fallbackEvaluate
(
resultExpr
,
ctx
);
}
catch
(
error
)
{
console
.
error
(
"[evaluateShowRule] eval error"
,
resultExpr
,
error
);
return
false
;
}
}
src/views/residentManage/journalRecord/utils/journalFormVisibility/groupVisibility.js
0 → 100644
View file @
e60211c
import
{
evaluateShowRule
}
from
"./groupShowRuleEval"
;
function
getRowFieldValue
(
rowFields
=
[],
key
=
""
,
rowMap
=
null
)
{
const
field
=
(
rowFields
||
[]).
find
((
item
)
=>
item
.
key
===
key
);
if
(
field
)
{
if
(
field
.
value
!=
null
&&
field
.
value
!==
""
)
{
return
field
.
value
;
}
const
metaKey
=
field
.
key
;
if
(
metaKey
!=
null
&&
field
[
metaKey
]
!=
null
&&
field
[
metaKey
]
!==
""
)
{
const
meta
=
field
[
metaKey
];
if
(
typeof
meta
===
"object"
&&
!
Array
.
isArray
(
meta
))
{
return
meta
.
name
??
meta
.
label
??
meta
.
id
??
meta
;
}
return
meta
;
}
}
if
(
rowMap
&&
rowMap
[
key
]
!=
null
&&
rowMap
[
key
]
!==
""
)
{
return
rowMap
[
key
];
}
return
null
;
}
function
isGroupChildVisibleInRow
(
group
=
{},
child
=
{},
rowFields
=
[],
rowMap
=
null
)
{
const
rules
=
group
.
childrenShowRules
;
if
(
!
rules
||
!
child
?.
key
)
{
return
true
;
}
const
rule
=
rules
[
child
.
key
];
if
(
!
rule
)
{
return
true
;
}
const
keys
=
rule
.
keys
||
[];
const
resultExpr
=
rule
.
result
;
if
(
!
keys
.
length
||
!
resultExpr
)
{
return
true
;
}
return
evaluateShowRule
(
keys
,
resultExpr
,
rowFields
,
(
rf
,
k
)
=>
getRowFieldValue
(
rf
,
k
,
rowMap
));
}
export
function
filterVisibleRowFields
(
group
=
{},
rowFields
=
[],
rowMap
=
null
)
{
return
(
rowFields
||
[]).
filter
((
field
)
=>
isGroupChildVisibleInRow
(
group
,
field
,
rowFields
,
rowMap
));
}
src/views/residentManage/journalRecord/utils/journalFormVisibility/index.js
0 → 100644
View file @
e60211c
import
{
getStaticGroupChildren
,
getSubformRowTemplate
,
isStaticGroup
,
isSubform
,
}
from
"./fieldTypes"
;
import
{
filterVisibleRowFields
}
from
"./groupVisibility"
;
import
{
isAttendanceOnDuty
}
from
"./radioValue"
;
import
{
flattenFields
,
schemaHasAttendanceField
,
}
from
"./visibilityHelpers"
;
import
{
isFieldVisible
,
isFieldVisibleBySpecs
}
from
"./visibilitySpecs"
;
function
sortBySortNum
(
list
=
[])
{
return
[
...
list
].
sort
((
a
,
b
)
=>
String
(
a
.
sortNum
||
""
).
localeCompare
(
String
(
b
.
sortNum
||
""
),
undefined
,
{
numeric
:
true
}));
}
function
getEchoKeysFromFormList
(
formList
=
[])
{
const
echoSubformKeys
=
formList
.
filter
((
item
)
=>
item
?.
key
&&
(
item
.
type
===
"subform"
||
item
.
type
===
"group"
))
.
map
((
item
)
=>
item
.
key
);
const
echoTopLevelKeys
=
formList
.
filter
((
item
)
=>
item
?.
key
).
map
((
item
)
=>
item
.
key
);
return
{
echoSubformKeys
,
echoTopLevelKeys
};
}
export
function
buildDetailPageContext
(
detail
=
{},
formList
=
[])
{
const
{
echoSubformKeys
,
echoTopLevelKeys
}
=
getEchoKeysFromFormList
(
formList
);
const
sceneList
=
Array
.
isArray
(
detail
.
sceneList
)
&&
detail
.
sceneList
.
length
?
detail
.
sceneList
:
(
detail
.
baseSceneCode
!=
null
&&
detail
.
baseSceneCode
!==
""
?
[{
baseSceneCode
:
detail
.
baseSceneCode
}]
:
[]);
return
{
hasDetailEcho
:
formList
.
length
>
0
,
echoSubformKeys
:
new
Set
(
echoSubformKeys
),
echoTopLevelKeys
:
new
Set
(
echoTopLevelKeys
),
sceneList
,
baseSceneCode
:
detail
.
baseSceneCode
,
brandIds
:
Array
.
isArray
(
detail
.
brandIds
)
?
detail
.
brandIds
:
[],
schemaList
:
detail
.
schema
?.
list
||
formList
,
};
}
export
function
buildValuesMap
(
formList
=
[])
{
const
values
=
{};
formList
.
forEach
((
field
)
=>
{
if
(
field
?.
key
&&
field
.
type
!==
"group"
&&
field
.
type
!==
"subform"
&&
field
.
type
!==
"divider"
)
{
values
[
field
.
key
]
=
field
.
value
;
}
});
return
values
;
}
function
findSchemaField
(
schemaList
=
[],
key
=
""
)
{
return
flattenFields
(
schemaList
).
find
((
field
)
=>
field
.
key
===
key
);
}
function
mergeFieldMeta
(
field
=
{},
schemaList
=
[])
{
const
schemaField
=
findSchemaField
(
schemaList
,
field
.
key
);
if
(
!
schemaField
)
{
return
field
;
}
return
{
...
schemaField
,
...
field
,
rules
:
field
.
rules
||
schemaField
.
rules
,
children
:
field
.
children
??
schemaField
.
children
,
childrenShowRules
:
field
.
childrenShowRules
||
schemaField
.
childrenShowRules
,
options
:
field
.
options
||
schemaField
.
options
,
};
}
function
buildVisibilityOptions
(
schemaList
=
[],
values
=
{},
ctx
=
{})
{
return
{
schemaList
,
hasAttendanceField
:
schemaHasAttendanceField
(
schemaList
),
attendanceOnDuty
:
isAttendanceOnDuty
(
schemaList
,
values
),
echoSubformKeys
:
ctx
.
echoSubformKeys
instanceof
Set
?
ctx
.
echoSubformKeys
:
new
Set
(
ctx
.
echoSubformKeys
||
[]),
};
}
export
function
getVisibleSubformChildren
(
group
,
ctx
,
values
,
schemaList
=
[])
{
if
(
!
group
||
!
isSubform
(
group
))
{
return
[];
}
const
visibilityOptions
=
{
...
buildVisibilityOptions
(
schemaList
,
values
,
ctx
),
echoParentKey
:
group
?.
key
,
};
return
getSubformRowTemplate
(
group
)
.
map
((
child
)
=>
mergeFieldMeta
(
child
,
schemaList
))
.
filter
((
child
)
=>
isFieldVisible
(
child
,
ctx
,
values
,
visibilityOptions
))
.
sort
((
a
,
b
)
=>
Number
(
a
.
sortNum
)
-
Number
(
b
.
sortNum
));
}
export
function
getVisibleGroupChildren
(
group
,
ctx
,
values
,
schemaList
=
[])
{
if
(
!
group
||
!
isStaticGroup
(
group
))
{
return
[];
}
const
visibilityOptions
=
{
...
buildVisibilityOptions
(
schemaList
,
values
,
ctx
),
echoParentKey
:
group
?.
key
,
};
return
getStaticGroupChildren
(
group
)
.
map
((
child
)
=>
mergeFieldMeta
(
child
,
schemaList
))
.
filter
((
child
)
=>
isFieldVisible
(
child
,
ctx
,
values
,
visibilityOptions
))
.
sort
((
a
,
b
)
=>
Number
(
a
.
sortNum
)
-
Number
(
b
.
sortNum
));
}
function
filterFieldNode
(
field
,
schemaList
,
ctx
,
values
,
options
)
{
const
merged
=
mergeFieldMeta
(
field
,
schemaList
);
const
visibilityOptions
=
{
...
options
};
if
(
!
isFieldVisibleBySpecs
(
merged
,
ctx
,
values
,
visibilityOptions
))
{
return
null
;
}
if
(
isStaticGroup
(
merged
))
{
const
visibleChildren
=
getVisibleGroupChildren
(
merged
,
ctx
,
values
,
schemaList
);
if
(
!
visibleChildren
.
length
)
{
return
null
;
}
const
childMap
=
new
Map
(
getStaticGroupChildren
(
merged
).
map
((
child
)
=>
[
child
.
key
,
child
]),
);
return
{
...
merged
,
children
:
visibleChildren
.
map
((
child
)
=>
({
...
child
,
...(
childMap
.
get
(
child
.
key
)
||
{}),
value
:
childMap
.
get
(
child
.
key
)?.
value
??
child
.
value
,
})),
};
}
if
(
isSubform
(
merged
))
{
const
visibleTemplate
=
getVisibleSubformChildren
(
merged
,
ctx
,
values
,
schemaList
);
if
(
!
visibleTemplate
.
length
)
{
return
null
;
}
const
templateMap
=
new
Map
(
getSubformRowTemplate
(
merged
).
map
((
col
)
=>
[
col
.
key
,
col
]),
);
const
mergedTemplate
=
visibleTemplate
.
map
((
col
)
=>
({
...
col
,
...(
templateMap
.
get
(
col
.
key
)
||
{}),
}));
const
rowFieldsList
=
Array
.
isArray
(
merged
.
value
)
?
merged
.
value
:
[];
const
groupDef
=
mergeFieldMeta
(
merged
,
schemaList
);
const
allowedKeys
=
new
Set
(
mergedTemplate
.
map
((
col
)
=>
col
.
key
));
const
filteredRows
=
rowFieldsList
.
map
((
rowCells
)
=>
{
const
cells
=
Array
.
isArray
(
rowCells
)
?
rowCells
:
[];
const
rowMap
=
{};
cells
.
forEach
((
cell
)
=>
{
if
(
cell
?.
key
)
{
rowMap
[
cell
.
key
]
=
cell
.
value
;
}
});
const
visibleInRow
=
filterVisibleRowFields
(
groupDef
,
cells
,
rowMap
);
return
visibleInRow
.
filter
((
cell
)
=>
allowedKeys
.
has
(
cell
.
key
));
})
.
filter
((
row
)
=>
row
.
length
);
return
{
...
merged
,
children
:
[
mergedTemplate
],
value
:
filteredRows
,
};
}
return
merged
;
}
export
function
filterFormListForDisplay
(
formList
=
[],
detail
=
{})
{
if
(
!
formList
.
length
)
{
return
[];
}
const
schemaList
=
detail
.
schema
?.
list
||
formList
;
const
values
=
buildValuesMap
(
formList
);
const
ctx
=
buildDetailPageContext
(
detail
,
formList
);
const
options
=
buildVisibilityOptions
(
schemaList
,
values
,
ctx
);
return
sortBySortNum
(
formList
.
map
((
field
)
=>
filterFieldNode
(
field
,
schemaList
,
ctx
,
values
,
options
))
.
filter
(
Boolean
),
);
}
export
{
isFieldVisible
,
isFieldVisibleBySpecs
,
};
src/views/residentManage/journalRecord/utils/journalFormVisibility/radioValue.js
0 → 100644
View file @
e60211c
import
{
ATTENDANCE_KEY
,
flattenFields
}
from
"./visibilityHelpers"
;
export
{
ATTENDANCE_KEY
};
export
const
ON_DUTY_LABEL
=
"在岗"
;
export
const
OFF_DUTY_LABEL
=
"调休"
;
export
const
LEGACY_ON_DUTY
=
"1"
;
export
const
LEGACY_OFF_DUTY
=
"2"
;
export
function
resolveRadioOptionValue
(
field
,
rawValue
)
{
if
(
rawValue
==
null
||
rawValue
===
""
||
!
field
?.
options
?.
length
)
{
return
rawValue
;
}
const
str
=
String
(
rawValue
);
const
byValue
=
field
.
options
.
find
((
option
)
=>
String
(
option
.
value
)
===
str
);
if
(
byValue
)
{
return
byValue
.
value
;
}
const
byLabel
=
field
.
options
.
find
(
(
option
)
=>
option
.
label
===
rawValue
||
option
.
label
===
str
,
);
if
(
byLabel
)
{
return
byLabel
.
value
;
}
if
(
str
===
LEGACY_ON_DUTY
)
{
const
onDuty
=
field
.
options
.
find
((
option
)
=>
option
.
label
===
ON_DUTY_LABEL
)
||
field
.
options
.
find
((
option
)
=>
String
(
option
.
value
)
===
LEGACY_ON_DUTY
)
||
field
.
options
[
0
];
return
onDuty
?.
value
??
rawValue
;
}
if
(
str
===
LEGACY_OFF_DUTY
)
{
const
offDuty
=
field
.
options
.
find
((
option
)
=>
option
.
label
===
OFF_DUTY_LABEL
)
||
field
.
options
.
find
((
option
)
=>
String
(
option
.
value
)
===
LEGACY_OFF_DUTY
)
||
field
.
options
[
1
];
return
offDuty
?.
value
??
rawValue
;
}
return
rawValue
;
}
export
function
getAttendanceField
(
list
=
[])
{
return
flattenFields
(
list
).
find
((
field
)
=>
field
.
key
===
ATTENDANCE_KEY
);
}
export
function
getOnDutyOption
(
field
)
{
if
(
!
field
?.
options
?.
length
)
{
return
null
;
}
return
field
.
options
.
find
((
option
)
=>
option
.
label
===
ON_DUTY_LABEL
)
||
field
.
options
.
find
((
option
)
=>
String
(
option
.
value
)
===
LEGACY_ON_DUTY
)
||
field
.
options
[
0
];
}
export
function
isAttendanceOnDuty
(
list
=
[],
values
=
{})
{
const
field
=
getAttendanceField
(
list
);
const
raw
=
values
[
ATTENDANCE_KEY
];
if
(
raw
==
null
||
raw
===
""
)
{
return
false
;
}
if
(
!
field
?.
options
?.
length
)
{
return
raw
===
LEGACY_ON_DUTY
||
raw
===
ON_DUTY_LABEL
;
}
const
onDutyOption
=
getOnDutyOption
(
field
);
if
(
!
onDutyOption
)
{
return
false
;
}
const
normalized
=
resolveRadioOptionValue
(
field
,
raw
);
return
String
(
normalized
)
===
String
(
onDutyOption
.
value
);
}
src/views/residentManage/journalRecord/utils/journalFormVisibility/visibilityHelpers.js
0 → 100644
View file @
e60211c
import
{
getStaticGroupChildren
,
getSubformRowTemplate
,
isStaticGroup
,
isSubform
,
}
from
"./fieldTypes"
;
const
DIVIDER_QY_SCENE_CODES
=
[
110101
,
110102
];
const
DIVIDER_YB_SCENE_CODES
=
[
110201
,
110202
];
export
const
ATTENDANCE_KEY
=
"F1-1"
;
export
function
hasIntersection
(
a
=
[],
b
=
[])
{
return
a
.
some
((
id
)
=>
b
.
includes
(
id
));
}
export
function
normalizeSceneCodeList
(
codes
)
{
if
(
codes
==
null
||
codes
===
""
)
{
return
[];
}
const
list
=
Array
.
isArray
(
codes
)
?
codes
:
[
codes
];
return
list
.
map
((
code
)
=>
Number
(
code
)).
filter
((
code
)
=>
!
Number
.
isNaN
(
code
));
}
export
function
flattenFields
(
list
=
[])
{
const
result
=
[];
for
(
const
field
of
list
)
{
if
(
isSubform
(
field
))
{
result
.
push
(...
flattenFields
(
getSubformRowTemplate
(
field
)));
}
else
if
(
isStaticGroup
(
field
))
{
result
.
push
(...
flattenFields
(
getStaticGroupChildren
(
field
)));
}
else
if
(
field
.
type
!==
"group"
&&
field
.
type
!==
"subform"
)
{
result
.
push
(
field
);
}
}
return
result
;
}
export
function
schemaHasAttendanceField
(
list
=
[])
{
return
flattenFields
(
list
).
some
((
field
)
=>
field
.
key
===
ATTENDANCE_KEY
);
}
export
function
getMerchantSceneCodes
(
sceneList
=
[])
{
return
normalizeSceneCodeList
((
sceneList
||
[]).
map
((
item
)
=>
item
?.
baseSceneCode
));
}
export
function
getEffectiveSceneCodes
(
ctx
=
{})
{
const
codes
=
getMerchantSceneCodes
(
ctx
.
sceneList
);
if
(
codes
.
length
)
{
return
codes
;
}
return
normalizeSceneCodeList
(
ctx
.
baseSceneCode
);
}
export
function
matchesBaseSceneCode
(
field
,
ctx
=
{})
{
const
fieldCodes
=
normalizeSceneCodeList
(
field
.
baseSceneCode
);
if
(
!
fieldCodes
.
length
)
{
return
true
;
}
const
effective
=
getEffectiveSceneCodes
(
ctx
);
return
fieldCodes
.
some
((
code
)
=>
effective
.
includes
(
code
));
}
export
function
isDividerVisible
(
field
,
ctx
=
{})
{
const
merchantCodes
=
getMerchantSceneCodes
(
ctx
.
sceneList
);
if
(
field
.
qgCode
?.
length
)
{
return
hasIntersection
(
normalizeSceneCodeList
(
field
.
qgCode
),
merchantCodes
);
}
const
merchantHasQY
=
hasIntersection
(
DIVIDER_QY_SCENE_CODES
,
merchantCodes
);
const
merchantHasYB
=
hasIntersection
(
DIVIDER_YB_SCENE_CODES
,
merchantCodes
);
const
fieldMatchesQY
=
hasIntersection
(
field
.
qyCode
||
[],
merchantCodes
);
const
fieldMatchesYB
=
hasIntersection
(
field
.
ybCode
||
[],
merchantCodes
);
if
(
field
.
isQY
||
field
.
isYB
)
{
if
(
field
.
isQY
)
{
return
fieldMatchesQY
&&
!
merchantHasYB
;
}
if
(
field
.
isYB
)
{
return
fieldMatchesYB
&&
!
merchantHasQY
;
}
}
return
merchantHasQY
&&
merchantHasYB
;
}
export
function
shouldHideByFilterBrandId
(
field
=
{},
brandIds
=
[])
{
if
(
!
field
.
filterBrandId
?.
length
||
!
brandIds
.
length
)
{
return
false
;
}
const
hasOtherBrand
=
brandIds
.
some
((
id
)
=>
!
field
.
filterBrandId
.
includes
(
id
));
return
!
hasOtherBrand
;
}
src/views/residentManage/journalRecord/utils/journalFormVisibility/visibilitySpecs.js
0 → 100644
View file @
e60211c
import
{
evaluateShowRule
}
from
"./groupShowRuleEval"
;
import
{
isStaticGroup
,
isSubform
}
from
"./fieldTypes"
;
import
{
resolveRadioOptionValue
}
from
"./radioValue"
;
import
{
flattenFields
,
hasIntersection
,
isDividerVisible
,
matchesBaseSceneCode
,
shouldHideByFilterBrandId
,
}
from
"./visibilityHelpers"
;
function
resolveEchoSubformKeys
(
ctx
=
{},
options
=
{})
{
if
(
options
.
echoSubformKeys
instanceof
Set
&&
options
.
echoSubformKeys
.
size
)
{
return
options
.
echoSubformKeys
;
}
const
fromCtx
=
ctx
.
echoSubformKeys
;
if
(
fromCtx
instanceof
Set
)
{
return
fromCtx
;
}
return
new
Set
(
Array
.
isArray
(
fromCtx
)
?
fromCtx
:
[]);
}
function
resolveEchoTopLevelKeys
(
ctx
=
{})
{
const
fromCtx
=
ctx
.
echoTopLevelKeys
;
if
(
fromCtx
instanceof
Set
)
{
return
fromCtx
;
}
return
new
Set
(
Array
.
isArray
(
fromCtx
)
?
fromCtx
:
[]);
}
function
isInDetailEchoScope
(
field
=
{},
ctx
=
{},
options
=
{})
{
if
(
!
ctx
.
hasDetailEcho
)
{
return
false
;
}
const
echoSubformKeys
=
resolveEchoSubformKeys
(
ctx
,
options
);
if
(
field
.
key
&&
echoSubformKeys
.
has
(
field
.
key
)
&&
(
isSubform
(
field
)
||
isStaticGroup
(
field
))
)
{
return
true
;
}
if
(
options
.
echoParentKey
&&
echoSubformKeys
.
has
(
options
.
echoParentKey
))
{
return
true
;
}
const
echoTopLevelKeys
=
resolveEchoTopLevelKeys
(
ctx
);
if
(
field
.
key
&&
echoTopLevelKeys
.
has
(
field
.
key
))
{
return
true
;
}
return
false
;
}
export
function
detailEchoSpec
(
field
,
ctx
,
_values
,
options
=
{})
{
if
(
!
ctx
.
hasDetailEcho
)
{
return
null
;
}
if
(
isInDetailEchoScope
(
field
,
ctx
,
options
))
{
if
(
field
.
type
===
"divider"
)
{
return
isDividerVisible
(
field
,
ctx
);
}
return
true
;
}
if
(
options
.
hasAttendanceField
&&
options
.
attendanceOnDuty
)
{
return
null
;
}
return
false
;
}
function
findFieldByKey
(
list
=
[],
key
=
""
)
{
return
flattenFields
(
list
).
find
((
field
)
=>
field
.
key
===
key
);
}
function
getTopLevelFieldValue
(
list
=
[],
values
=
{},
key
=
""
)
{
const
field
=
findFieldByKey
(
list
,
key
);
const
raw
=
values
[
key
];
if
(
!
field
)
{
return
raw
==
null
||
raw
===
""
?
null
:
raw
;
}
if
(
field
.
type
===
"radio"
)
{
const
resolved
=
resolveRadioOptionValue
(
field
,
raw
);
return
resolved
==
null
||
resolved
===
""
?
null
:
resolved
;
}
return
raw
==
null
||
raw
===
""
?
null
:
raw
;
}
export
function
fieldShowRuleSpec
(
field
,
ctx
,
values
,
options
=
{})
{
const
rules
=
field
.
rules
||
{};
const
keys
=
rules
.
keys
||
[];
const
resultExpr
=
rules
.
result
;
if
(
!
keys
.
length
||
!
resultExpr
)
{
return
true
;
}
const
list
=
options
.
schemaList
||
ctx
.
schemaList
||
[];
return
evaluateShowRule
(
keys
,
resultExpr
,
[],
(
_rowFields
,
key
)
=>
getTopLevelFieldValue
(
list
,
values
,
key
));
}
export
function
baseSceneSpec
(
field
,
ctx
)
{
if
(
field
.
type
===
"divider"
)
{
return
isDividerVisible
(
field
,
ctx
);
}
if
(
field
.
baseSceneCode
!=
null
&&
field
.
baseSceneCode
!==
""
)
{
return
matchesBaseSceneCode
(
field
,
ctx
);
}
return
true
;
}
export
function
brandSpec
(
field
,
ctx
)
{
if
(
field
.
brandId
?.
length
>
0
&&
!
hasIntersection
(
field
.
brandId
,
ctx
.
brandIds
||
[]))
{
return
false
;
}
if
(
shouldHideByFilterBrandId
(
field
,
ctx
.
brandIds
||
[]))
{
return
false
;
}
return
true
;
}
export
function
isFieldVisibleBySpecs
(
field
,
ctx
,
values
,
options
=
{})
{
const
echoResult
=
detailEchoSpec
(
field
,
ctx
,
values
,
options
);
if
(
echoResult
===
false
)
{
return
false
;
}
if
(
echoResult
===
true
)
{
return
baseSceneSpec
(
field
,
ctx
,
values
,
options
);
}
if
(
!
fieldShowRuleSpec
(
field
,
ctx
,
values
,
options
))
{
return
false
;
}
if
(
!
baseSceneSpec
(
field
,
ctx
,
values
,
options
))
{
return
false
;
}
if
(
!
brandSpec
(
field
,
ctx
,
values
,
options
))
{
return
false
;
}
return
true
;
}
export
function
isFieldVisible
(
field
,
ctx
,
values
,
options
=
{})
{
return
isFieldVisibleBySpecs
(
field
,
ctx
,
values
,
options
);
}
tests/unit/views/residentManage/journalRecord/journalFormVisibility.spec.js
0 → 100644
View file @
e60211c
const
{
filterFormListForDisplay
,
isFieldVisibleBySpecs
,
}
=
require
(
"@/views/residentManage/journalRecord/utils/journalFormVisibility"
);
const
staffSchemaList
=
[
{
key
:
"F1-1"
,
type
:
"radio"
,
sortNum
:
"1"
,
label
:
"今日出勤"
,
options
:
[
{
label
:
"在岗"
,
value
:
"1"
},
{
label
:
"调休"
,
value
:
"2"
},
],
},
{
key
:
"F1-2"
,
type
:
"numberInput"
,
sortNum
:
"2"
,
label
:
"延保退单"
,
rules
:
{
keys
:
[
"F1-1"
],
result
:
'val1 == "在岗"'
},
baseSceneCode
:
[
110201
,
110202
],
},
{
key
:
"F1-4"
,
type
:
"textarea"
,
sortNum
:
"4"
,
label
:
"备注"
,
},
{
key
:
"F1-5"
,
type
:
"group"
,
sortNum
:
"5"
,
label
:
"问界"
,
brandId
:
[
3454
],
rules
:
{
keys
:
[
"F1-1"
],
result
:
'val1 == "在岗"'
},
children
:
[
{
key
:
"F1-5-1"
,
type
:
"numberInput"
,
sortNum
:
"1"
,
label
:
"轻改个人大定触客/进群数"
,
baseSceneCode
:
[
100101
]
},
{
key
:
"F1-5-2"
,
type
:
"numberInput"
,
sortNum
:
"2"
,
label
:
"轻改个人售后触客数"
,
baseSceneCode
:
[
100101
]
},
],
},
];
function
buildOffDutyFormListWithBrandGroup
()
{
return
[
{
...
staffSchemaList
[
0
],
value
:
"调休"
},
{
...
staffSchemaList
[
2
],
value
:
"备注内容"
},
{
...
staffSchemaList
[
3
],
value
:
{},
children
:
[
{
...
staffSchemaList
[
3
].
children
[
0
],
value
:
2
},
{
...
staffSchemaList
[
3
].
children
[
1
],
value
:
3
},
],
},
];
}
function
buildOffDutyFormListWithoutBrandGroup
()
{
return
[
{
...
staffSchemaList
[
0
],
value
:
"调休"
},
{
...
staffSchemaList
[
2
],
value
:
"备注内容"
},
];
}
function
buildOnDutyFormList
()
{
return
[
{
...
staffSchemaList
[
0
],
value
:
"在岗"
},
{
...
staffSchemaList
[
1
],
value
:
1
},
{
...
staffSchemaList
[
2
],
value
:
"备注内容"
},
{
...
staffSchemaList
[
3
],
value
:
{},
children
:
staffSchemaList
[
3
].
children
,
},
];
}
describe
(
"journalFormVisibility"
,
()
=>
{
it
(
"调休且 jsonContent 含品牌 group 时应展示 F1-5 及轻改子字段"
,
()
=>
{
const
formList
=
buildOffDutyFormListWithBrandGroup
();
const
detail
=
{
schema
:
{
list
:
staffSchemaList
},
baseSceneCode
:
100101
,
brandIds
:
[
3454
],
sceneList
:
[{
baseSceneCode
:
100101
}],
};
const
visible
=
filterFormListForDisplay
(
formList
,
detail
);
const
keys
=
visible
.
map
((
item
)
=>
item
.
key
);
expect
(
keys
).
toEqual
([
"F1-1"
,
"F1-4"
,
"F1-5"
]);
const
f15
=
visible
.
find
((
item
)
=>
item
.
key
===
"F1-5"
);
expect
(
f15
.
children
.
map
((
child
)
=>
child
.
key
)).
toEqual
([
"F1-5-1"
,
"F1-5-2"
]);
});
it
(
"调休且 jsonContent 无品牌 group 时应仅保留 F1-1 与 F1-4"
,
()
=>
{
const
formList
=
buildOffDutyFormListWithoutBrandGroup
();
const
detail
=
{
schema
:
{
list
:
staffSchemaList
},
baseSceneCode
:
100101
,
brandIds
:
[
3454
],
sceneList
:
[{
baseSceneCode
:
100101
}],
};
const
visible
=
filterFormListForDisplay
(
formList
,
detail
);
const
keys
=
visible
.
map
((
item
)
=>
item
.
key
);
expect
(
keys
).
toEqual
([
"F1-1"
,
"F1-4"
]);
});
it
(
"在岗时应展示匹配 brandIds 的品牌 group"
,
()
=>
{
const
formList
=
buildOnDutyFormList
();
const
detail
=
{
schema
:
{
list
:
staffSchemaList
},
baseSceneCode
:
100101
,
brandIds
:
[
3454
],
sceneList
:
[{
baseSceneCode
:
100101
}],
};
const
visible
=
filterFormListForDisplay
(
formList
,
detail
);
const
keys
=
visible
.
map
((
item
)
=>
item
.
key
);
expect
(
keys
).
toContain
(
"F1-1"
);
expect
(
keys
).
toContain
(
"F1-5"
);
expect
(
keys
).
not
.
toContain
(
"F1-2"
);
});
it
(
"详情 echo 应绕过 brandId 但仍校验 baseSceneCode"
,
()
=>
{
const
field
=
{
key
:
"F3-1"
,
type
:
"subform"
,
baseSceneCode
:
[
110201
,
110202
],
brandId
:
[
999
],
};
const
ctx
=
{
hasDetailEcho
:
true
,
echoSubformKeys
:
new
Set
([
"F3-1"
]),
brandIds
:
[
3067
],
sceneList
:
[{
baseSceneCode
:
110201
}],
};
expect
(
isFieldVisibleBySpecs
(
field
,
ctx
,
{},
{
schemaList
:
[
field
]
})).
toBe
(
true
);
const
mismatchCtx
=
{
...
ctx
,
sceneList
:
[{
baseSceneCode
:
100101
}],
};
expect
(
isFieldVisibleBySpecs
(
field
,
mismatchCtx
,
{},
{
schemaList
:
[
field
]
})).
toBe
(
false
);
});
it
(
"subform 行内 childrenShowRules 应过滤不可见列"
,
()
=>
{
const
subformField
=
{
key
:
"F3-1"
,
type
:
"subform"
,
sortNum
:
"1"
,
label
:
"洽谈明细"
,
baseSceneCode
:
[
110201
,
110202
],
brandId
:
[
3067
],
children
:
[[
{
key
:
"F3-1-10"
,
type
:
"radio"
,
sortNum
:
"10"
,
label
:
"是否成交"
,
options
:
[{
label
:
"是"
,
value
:
"是"
},
{
label
:
"否"
,
value
:
"否"
}]
},
{
key
:
"F3-1-11"
,
type
:
"input"
,
sortNum
:
"11"
,
label
:
"订单号"
},
]],
childrenShowRules
:
{
"F3-1-11"
:
{
keys
:
[
"F3-1-10"
],
result
:
'val1 == "是"'
},
},
value
:
[[
{
key
:
"F3-1-10"
,
type
:
"radio"
,
value
:
"否"
},
{
key
:
"F3-1-11"
,
type
:
"input"
,
value
:
"ORDER-001"
},
]],
};
const
detail
=
{
schema
:
{
list
:
[
subformField
]
},
brandIds
:
[
3067
],
sceneList
:
[{
baseSceneCode
:
110201
}],
};
const
visible
=
filterFormListForDisplay
([
subformField
],
detail
);
expect
(
visible
).
toHaveLength
(
1
);
expect
(
visible
[
0
].
value
[
0
].
map
((
cell
)
=>
cell
.
key
)).
toEqual
([
"F3-1-10"
]);
});
});
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment