Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
usedCarAuction
/
aus
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 8bb778b2
authored
Sep 10, 2026
by
zhangxw
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
检测工单需求开发
1 parent
e7f3d8bd
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
607 additions
and
47 deletions
aus-front/admin/src/views/detection/order/DetectionOrderEdit.vue
aus-front/admin/src/views/detection/order/components/CustomizeFormButtonSelect.vue
aus-front/admin/src/views/detection/order/utils/inspectInitialValues.ts
aus-front/admin/src/views/detection/order/DetectionOrderEdit.vue
View file @
8bb778b
...
@@ -55,7 +55,10 @@ import { DetectionController } from "@/api/DetectionController";
...
@@ -55,7 +55,10 @@ import { DetectionController } from "@/api/DetectionController";
import
{
CheckCircleFilled
}
from
"@ant-design/icons-vue"
;
import
{
CheckCircleFilled
}
from
"@ant-design/icons-vue"
;
import
{
TrackHelper
}
from
"@/common/TrackHelper"
;
import
{
TrackHelper
}
from
"@/common/TrackHelper"
;
import
{
Modal
}
from
"ant-design-vue"
;
import
{
Modal
}
from
"ant-design-vue"
;
import
{
applyResolvedInitialValuesToLeafNodes
}
from
"@/views/detection/order/utils/inspectInitialValues"
;
import
{
applyResolvedInitialValuesToLeafNodes
,
extractScalarFromDefaultData
,
}
from
"@/views/detection/order/utils/inspectInitialValues"
;
@
Component
({
@
Component
({
components
:
{
components
:
{
...
@@ -150,7 +153,8 @@ export default class DetectionOrderEdit extends PaginationComponent<Vehicle> {
...
@@ -150,7 +153,8 @@ export default class DetectionOrderEdit extends PaginationComponent<Vehicle> {
taskId
:
routeData
.
id
,
taskId
:
routeData
.
id
,
}).
then
((
response
)
=>
{
}).
then
((
response
)
=>
{
this
.
defaultData
=
response
?.
data
?.
data
||
{};
this
.
defaultData
=
response
?.
data
?.
data
||
{};
return
this
.
getCarTypeList
(
this
.
defaultData
.
carSeriesId
);
const
csId
=
extractScalarFromDefaultData
(
this
.
defaultData
,
"carSeriesId"
);
return
this
.
getCarTypeList
(
csId
);
});
});
}
}
...
...
aus-front/admin/src/views/detection/order/components/CustomizeFormButtonSelect.vue
View file @
8bb778b
...
@@ -2,9 +2,9 @@
...
@@ -2,9 +2,9 @@
<div>
<div>
<div
class=
"selectList"
>
<div
class=
"selectList"
>
<div
v-for=
"(col, index) in columnsList"
:key=
"index"
class=
"selectBut"
<div
v-for=
"(col, index) in columnsList"
:key=
"index"
class=
"selectBut"
:class=
"
{ 'pitchOn': pickerValue.includes(col.value), 'selectBut--readonly': readonly }" @click="handleBut(col)">
:class=
"
{ 'pitchOn': pickerValue.includes(col.value)
|| pickerValue.includes(col.text)
, 'selectBut--readonly': readonly }" @click="handleBut(col)">
{{
col
.
text
}}
{{
col
.
text
}}
<div
v-if=
"pickerValue.includes(col.value)"
class=
"pitchImg"
></div>
<div
v-if=
"pickerValue.includes(col.value)
|| pickerValue.includes(col.text)
"
class=
"pitchImg"
></div>
</div>
</div>
</div>
</div>
</div>
</div>
...
@@ -44,14 +44,26 @@ export default class CustomizeFormButtonSelect extends Vue {
...
@@ -44,14 +44,26 @@ export default class CustomizeFormButtonSelect extends Vue {
this
.
pickerValue
=
[];
this
.
pickerValue
=
[];
return
;
return
;
}
}
this
.
pickerValue
=
const
valueList
=
this
.
item
?.
inspectionResultVO
?.
inspectionValueList
||
[];
this
.
item
?.
inspectionResultVO
?.
inspectionValueList
const
normalized
:
string
[]
=
[];
?.
filter
(
for
(
const
entry
of
valueList
)
{
(
entry
)
=>
if
(
!
entry
||
!
entry
.
valueText
)
continue
;
entry
.
valueKey
&&
if
(
String
(
entry
.
interactionType
??
""
)
!==
"button_select"
)
continue
;
entry
.
interactionType
==
"button_select"
,
const
preferredKey
=
String
(
entry
.
valueKey
??
""
);
)
const
preferredText
=
String
(
entry
.
valueText
??
""
);
?.
map
((
entry
)
=>
entry
.
valueKey
)
||
[];
const
matched
=
(
this
.
columnsList
||
[]).
find
(
(
col
)
=>
(
preferredKey
&&
String
(
col
.
value
)
===
preferredKey
)
||
(
preferredText
&&
String
(
col
.
text
)
===
preferredText
)
);
const
value
=
matched
?
String
(
matched
.
value
)
:
(
preferredKey
||
preferredText
);
if
(
value
&&
!
normalized
.
includes
(
value
))
{
normalized
.
push
(
value
);
}
}
this
.
pickerValue
=
normalized
;
this
.
setupdate
();
this
.
setupdate
();
}
}
...
@@ -75,8 +87,17 @@ export default class CustomizeFormButtonSelect extends Vue {
...
@@ -75,8 +87,17 @@ export default class CustomizeFormButtonSelect extends Vue {
const
object
=
const
object
=
(
this
.
columnsList
||
[]).
find
(
(
this
.
columnsList
||
[]).
find
(
(
finditem
)
=>
finditem
.
value
==
item
,
(
finditem
)
=>
finditem
.
value
==
item
,
)
||
(
this
.
columnsList
||
[]).
find
(
(
finditem
)
=>
finditem
.
text
==
item
,
)
||
{};
)
||
{};
return
{
valueText
:
object
.
text
||
""
,
valueKey
:
item
||
""
};
const
pickedKey
=
object
.
value
??
item
??
""
;
const
pickedText
=
object
.
text
||
(
item
&&
!
object
.
value
?
String
(
item
)
:
""
)
||
""
;
return
{
valueText
:
pickedText
,
valueKey
:
String
(
pickedKey
),
};
});
});
const
nextValue
=
const
nextValue
=
valueList
.
length
>
0
?
JSON
.
stringify
(
valueList
)
:
""
;
valueList
.
length
>
0
?
JSON
.
stringify
(
valueList
)
:
""
;
...
@@ -139,4 +160,4 @@ export default class CustomizeFormButtonSelect extends Vue {
...
@@ -139,4 +160,4 @@ export default class CustomizeFormButtonSelect extends Vue {
background-repeat
:
no-repeat
;
background-repeat
:
no-repeat
;
background-size
:
100%
;
background-size
:
100%
;
}
}
</
style
>
\ No newline at end of file
\ No newline at end of file
</
style
>
aus-front/admin/src/views/detection/order/utils/inspectInitialValues.ts
View file @
8bb778b
import
dayjs
from
"dayjs"
;
import
dayjs
from
"dayjs"
;
/** /inspectionTemplate/default 返回的模板默认值 */
export
type
TemplateDefaultValueEntry
=
{
export
type
TemplateDefaultData
=
Record
<
string
,
string
|
string
[]
|
null
|
undefined
>
;
valueKey
?:
string
;
valueText
:
string
;
};
export
type
TemplateDefaultNewEntry
=
{
interactionType
?:
string
;
values
:
TemplateDefaultValueEntry
[];
};
/** /inspectionTemplate/default 返回的模板默认值(混合新旧格式兼容) */
export
type
TemplateDefaultData
=
Record
<
string
,
|
string
|
string
[]
|
TemplateDefaultNewEntry
|
TemplateDefaultNewEntry
[]
|
number
|
null
|
undefined
>
;
const
SELECT_INTERACTION_TYPES
=
new
Set
([
const
SELECT_INTERACTION_TYPES
=
new
Set
([
"dropdown"
,
"dropdown"
,
...
@@ -9,10 +28,157 @@ const SELECT_INTERACTION_TYPES = new Set([
...
@@ -9,10 +28,157 @@ const SELECT_INTERACTION_TYPES = new Set([
"button_select"
,
"button_select"
,
]);
]);
/**
* interactionType 兼容性矩阵:
* - 以节点 interactionType(nodeType)为基准
* - apiType === undefined / "" 视为旧格式场景,恒兼容
* - text_input 视为"纯字符串通用源",任何节点类型都可以从 text_input 值里解析出自己需要的内容(如 dropdown/date_picker 都可以接受纯文本再做二次处理)
* - 下表之外的组合判定为不兼容,跳过默认值应用,避免类型错乱渲染
*/
const
COMPATIBLE_MAP
:
Record
<
string
,
string
[]
>
=
{
dropdown
:
[
"dropdown"
,
"radio_button_select"
,
"text_input"
,
""
],
radio_button_select
:
[
"radio_button_select"
,
"dropdown"
,
"text_input"
,
""
],
button_select
:
[
"button_select"
,
"text_input"
,
""
],
text_input
:
[
"text_input"
,
"textarea_input"
,
"number_input"
,
"date_picker"
,
""
],
textarea_input
:
[
"textarea_input"
,
"text_input"
,
"number_input"
,
"date_picker"
,
""
],
number_input
:
[
"number_input"
,
"text_input"
,
""
],
date_picker
:
[
"date_picker"
,
"text_input"
,
""
],
image_upload
:
[
"image_upload"
,
"video_upload"
,
"text_input"
,
""
],
video_upload
:
[
"video_upload"
,
"image_upload"
,
"text_input"
,
""
],
image_upload_and_button_select
:
[
"image_upload_and_button_select"
,
"image_upload"
,
"button_select"
,
"text_input"
,
""
,
],
};
function
normalizeInteractionType
(
t
:
unknown
):
string
{
return
String
(
t
??
""
).
trim
().
toLowerCase
();
}
function
isSelectInteractionType
(
interactionType
:
string
):
boolean
{
function
isSelectInteractionType
(
interactionType
:
string
):
boolean
{
return
SELECT_INTERACTION_TYPES
.
has
(
interactionType
);
return
SELECT_INTERACTION_TYPES
.
has
(
interactionType
);
}
}
/** 判断该字段是否为新格式 { interactionType, values } 对象结构 */
export
function
isNewFormatEntry
(
v
:
unknown
):
v
is
TemplateDefaultNewEntry
{
if
(
v
==
null
||
typeof
v
!==
"object"
)
{
return
false
;
}
const
obj
=
v
as
Record
<
string
,
unknown
>
;
return
(
Array
.
isArray
(
obj
.
values
)
&&
(
obj
.
interactionType
===
undefined
||
typeof
obj
.
interactionType
===
"string"
)
);
}
/** 判断该字段是否为后端真实部署的新格式:[{ interactionType, values }] 数组结构 */
export
function
isNewFormatEntryArray
(
v
:
unknown
):
v
is
TemplateDefaultNewEntry
[]
{
if
(
!
Array
.
isArray
(
v
))
{
return
false
;
}
if
(
v
.
length
===
0
)
{
return
false
;
}
return
v
.
every
((
item
)
=>
isNewFormatEntry
(
item
));
}
/** 是否是 _and_ 拼接的组合 interactionType(如 image_upload_and_button_select) */
export
function
isCompositeInteractionType
(
t
:
unknown
):
boolean
{
return
typeof
t
===
"string"
&&
t
.
includes
(
"_and_"
);
}
/** 将组合类型按 _and_ 拆成子类型数组,并过滤空串 */
export
function
splitCompositeInteractionType
(
t
:
unknown
):
string
[]
{
if
(
typeof
t
!==
"string"
||
!
t
)
{
return
[];
}
return
t
.
split
(
"_and_"
)
.
map
((
s
)
=>
s
.
trim
())
.
filter
((
s
)
=>
s
!==
""
);
}
/** 粗略判断一个 valueText 是否像图片/视频 URL(http(s) 开头或带常见扩展名) */
const
IMAGE_VIDEO_EXT_RE
=
/
\.(
png|jpe
?
g|gif|webp|bmp|mp4|mov|avi|mkv|m4v
)
$/i
;
export
function
looksLikeMediaUrl
(
text
:
string
):
boolean
{
if
(
!
text
)
return
false
;
const
t
=
text
.
trim
();
if
(
/^https
?
:
\/\/
/i
.
test
(
t
))
return
true
;
return
IMAGE_VIDEO_EXT_RE
.
test
(
t
);
}
/**
* 在组合(_and_)场景下,为单个默认值 entry 分配最合适的子类型 interactionType。
* 判定优先级:
* 1. 后端传的 values 里每个 value 本身就带 valueKey 且在子类型里属于"可选项"语义的(button_select)优先
* 2. valueText 像 URL → 分给 image_upload / video_upload(看父类型里包含哪个)
* 3. 其余按"先 button_select 后 image_upload"(组件层约定的顺序)
*/
export
function
assignChildInteractionType
(
parentType
:
string
,
entry
:
{
valueKey
:
string
;
valueText
:
string
},
index
:
number
,
total
:
number
,
):
string
{
if
(
!
isCompositeInteractionType
(
parentType
))
{
return
parentType
;
}
const
children
=
splitCompositeInteractionType
(
parentType
);
if
(
children
.
length
===
0
)
{
return
parentType
;
}
if
(
children
.
length
===
1
)
{
return
children
[
0
];
}
const
hasImageUpload
=
children
.
includes
(
"image_upload"
)
||
children
.
includes
(
"video_upload"
);
const
hasButtonSelect
=
children
.
includes
(
"button_select"
);
if
(
hasImageUpload
&&
hasButtonSelect
)
{
const
text
=
String
(
entry
.
valueText
??
""
).
trim
();
if
(
looksLikeMediaUrl
(
text
))
{
return
children
.
includes
(
"video_upload"
)
?
"video_upload"
:
"image_upload"
;
}
if
(
entry
.
valueKey
)
{
return
"button_select"
;
}
if
(
index
<
total
/
2
)
{
return
"button_select"
;
}
return
children
.
includes
(
"video_upload"
)
?
"video_upload"
:
"image_upload"
;
}
return
children
[
Math
.
min
(
index
,
children
.
length
-
1
)];
}
/**
* 判定 API 返回的 interactionType 与节点配置的 interactionType 是否兼容
* 不兼容时不应用默认值,防止表单按错误交互类型渲染
*/
export
function
interactionTypeCompatible
(
nodeType
:
unknown
,
apiType
:
unknown
,
):
boolean
{
const
node
=
normalizeInteractionType
(
nodeType
);
const
api
=
normalizeInteractionType
(
apiType
);
if
(
!
node
)
{
return
true
;
}
if
(
!
api
)
{
return
true
;
}
const
accepted
=
COMPATIBLE_MAP
[
node
];
if
(
!
accepted
)
{
return
node
===
api
;
}
return
accepted
.
includes
(
api
);
}
function
isLeafNode
(
node
:
Record
<
string
,
unknown
>
):
boolean
{
function
isLeafNode
(
node
:
Record
<
string
,
unknown
>
):
boolean
{
const
children
=
node
.
childrenNodes
as
unknown
[]
|
undefined
;
const
children
=
node
.
childrenNodes
as
unknown
[]
|
undefined
;
return
!
children
?.
length
;
return
!
children
?.
length
;
...
@@ -25,7 +191,7 @@ export function hasSavedInspectionResult(node: Record<string, unknown>): boolean
...
@@ -25,7 +191,7 @@ export function hasSavedInspectionResult(node: Record<string, unknown>): boolean
return
Array
.
isArray
(
list
)
&&
list
.
length
>
0
;
return
Array
.
isArray
(
list
)
&&
list
.
length
>
0
;
}
}
/** 解析单条默认值字符串为 valueKey / valueText */
/** 解析单条默认值字符串为 valueKey / valueText
(旧格式兼容保留)
*/
export
function
parseDefaultValueParts
(
export
function
parseDefaultValueParts
(
interactionType
:
string
,
interactionType
:
string
,
raw
:
string
,
raw
:
string
,
...
@@ -44,6 +210,10 @@ function resolveApiDefaultKey(node: Record<string, unknown>): string {
...
@@ -44,6 +210,10 @@ function resolveApiDefaultKey(node: Record<string, unknown>): string {
return
String
(
node
.
defaultField
||
node
.
nodeCode
||
""
).
trim
();
return
String
(
node
.
defaultField
||
node
.
nodeCode
||
""
).
trim
();
}
}
/* ─────────────────────────────────────────────────────────
旧格式读值 API(保留,用于 defaultType=1 固定值 / 老格式 fallback)
───────────────────────────────────────────────────────── */
function
readTemplateDefaultRaw
(
function
readTemplateDefaultRaw
(
templateDefaultData
:
TemplateDefaultData
,
templateDefaultData
:
TemplateDefaultData
,
apiKey
:
string
,
apiKey
:
string
,
...
@@ -51,10 +221,39 @@ function readTemplateDefaultRaw(
...
@@ -51,10 +221,39 @@ function readTemplateDefaultRaw(
if
(
!
apiKey
||
!
templateDefaultData
)
{
if
(
!
apiKey
||
!
templateDefaultData
)
{
return
undefined
;
return
undefined
;
}
}
if
(
templateDefaultData
[
apiKey
]
!=
null
)
{
const
val
=
templateDefaultData
[
apiKey
];
return
templateDefaultData
[
apiKey
];
if
(
val
==
null
)
{
return
undefined
;
}
if
(
typeof
val
===
"string"
||
typeof
val
===
"number"
)
{
return
String
(
val
);
}
}
return
undefined
;
if
(
isNewFormatEntryArray
(
val
))
{
const
texts
:
string
[]
=
[];
val
.
forEach
((
entry
)
=>
{
(
entry
.
values
||
[]).
forEach
((
v
)
=>
{
const
t
=
v
.
valueText
==
null
?
""
:
String
(
v
.
valueText
);
if
(
t
!==
""
)
{
texts
.
push
(
t
);
}
});
});
return
texts
.
length
?
texts
:
undefined
;
}
if
(
Array
.
isArray
(
val
))
{
if
(
val
.
length
===
0
)
{
return
undefined
;
}
const
first
=
val
[
0
];
if
(
typeof
first
===
"string"
||
typeof
first
===
"number"
)
{
return
val
as
string
[];
}
return
undefined
;
}
if
(
isNewFormatEntry
(
val
))
{
return
undefined
;
}
return
String
(
val
);
}
}
function
rawToValueTexts
(
raw
:
string
|
string
[]
|
null
|
undefined
):
string
[]
{
function
rawToValueTexts
(
raw
:
string
|
string
[]
|
null
|
undefined
):
string
[]
{
...
@@ -68,8 +267,95 @@ function rawToValueTexts(raw: string | string[] | null | undefined): string[] {
...
@@ -68,8 +267,95 @@ function rawToValueTexts(raw: string | string[] | null | undefined): string[] {
return
s
!==
""
?
[
s
]
:
[];
return
s
!==
""
?
[
s
]
:
[];
}
}
/* ─────────────────────────────────────────────────────────
新格式读值 + 归一化 API(优先使用,同时兼容旧格式 fallback)
───────────────────────────────────────────────────────── */
function
readNormalizedTemplateDefault
(
templateDefaultData
:
TemplateDefaultData
,
apiKey
:
string
,
):
{
interactionType
:
string
|
undefined
;
entries
:
TemplateDefaultValueEntry
[]
}
|
undefined
{
if
(
!
apiKey
||
!
templateDefaultData
)
{
return
undefined
;
}
const
val
=
templateDefaultData
[
apiKey
];
if
(
val
==
null
)
{
return
undefined
;
}
if
(
isNewFormatEntryArray
(
val
))
{
const
allEntries
:
TemplateDefaultValueEntry
[]
=
[];
let
commonInteractionType
:
string
|
undefined
;
val
.
forEach
((
entry
)
=>
{
(
entry
.
values
||
[]).
forEach
((
v
)
=>
{
const
t
=
v
.
valueText
==
null
?
""
:
String
(
v
.
valueText
);
const
k
=
v
.
valueKey
==
null
?
""
:
String
(
v
.
valueKey
);
if
(
t
!==
""
||
k
!==
""
)
{
allEntries
.
push
({
valueKey
:
k
,
valueText
:
t
});
}
});
if
(
!
commonInteractionType
&&
entry
.
interactionType
)
{
commonInteractionType
=
entry
.
interactionType
;
}
});
if
(
!
allEntries
.
length
)
{
return
undefined
;
}
return
{
interactionType
:
commonInteractionType
,
entries
:
allEntries
,
};
}
if
(
isNewFormatEntry
(
val
))
{
return
{
interactionType
:
val
.
interactionType
,
entries
:
(
val
.
values
||
[]).
map
((
v
)
=>
({
valueKey
:
v
.
valueKey
==
null
?
""
:
String
(
v
.
valueKey
),
valueText
:
v
.
valueText
==
null
?
""
:
String
(
v
.
valueText
),
})),
};
}
if
(
typeof
val
===
"string"
||
typeof
val
===
"number"
)
{
const
s
=
String
(
val
);
return
s
!==
""
?
{
interactionType
:
undefined
,
entries
:
[{
valueKey
:
""
,
valueText
:
s
}],
}
:
undefined
;
}
if
(
Array
.
isArray
(
val
))
{
if
(
val
.
length
===
0
)
{
return
undefined
;
}
const
first
=
val
[
0
];
if
(
typeof
first
===
"string"
||
typeof
first
===
"number"
)
{
const
texts
=
rawToValueTexts
(
val
as
string
[]);
return
texts
.
length
?
{
interactionType
:
undefined
,
entries
:
texts
.
map
((
t
)
=>
({
valueKey
:
""
,
valueText
:
t
})),
}
:
undefined
;
}
return
undefined
;
}
const
text
=
String
(
val
);
return
text
!==
""
?
{
interactionType
:
undefined
,
entries
:
[{
valueKey
:
""
,
valueText
:
text
}],
}
:
undefined
;
}
/**
/**
* 按节点配置与 templateDefaultData 解析默认值字符串列表(未写入 inspectionResultVO)
* 按节点配置与 templateDefaultData 解析默认值字符串列表(旧 API 保留向后兼容)
* defaultType=1 固定值场景仍走此函数
*/
*/
export
function
resolveDefaultValueTexts
(
export
function
resolveDefaultValueTexts
(
node
:
Record
<
string
,
unknown
>
,
node
:
Record
<
string
,
unknown
>
,
...
@@ -96,8 +382,12 @@ export function resolveDefaultValueTexts(
...
@@ -96,8 +382,12 @@ export function resolveDefaultValueTexts(
return
[
String
(
node
.
defaultValue
)];
return
[
String
(
node
.
defaultValue
)];
}
}
// defaultType=2,或未配置 type、或 type=1 但无固定值:从接口 Map 按 nodeCode/defaultField 取值
const
apiKey
=
resolveApiDefaultKey
(
node
);
const
apiKey
=
resolveApiDefaultKey
(
node
);
const
normalized
=
readNormalizedTemplateDefault
(
templateDefaultData
,
apiKey
);
if
(
normalized
&&
normalized
.
entries
.
length
)
{
return
normalized
.
entries
.
map
((
e
)
=>
e
.
valueText
||
""
);
}
const
apiTexts
=
rawToValueTexts
(
const
apiTexts
=
rawToValueTexts
(
readTemplateDefaultRaw
(
templateDefaultData
,
apiKey
),
readTemplateDefaultRaw
(
templateDefaultData
,
apiKey
),
);
);
...
@@ -112,6 +402,74 @@ export function resolveDefaultValueTexts(
...
@@ -112,6 +402,74 @@ export function resolveDefaultValueTexts(
return
[];
return
[];
}
}
/**
* 按节点配置解析归一化后的默认值 entries(新格式优先)
* 会先做 interactionType 兼容性校验,不兼容则返回空
*/
export
function
resolveNormalizedDefaultEntries
(
node
:
Record
<
string
,
unknown
>
,
templateDefaultData
:
TemplateDefaultData
,
):
{
valueKey
:
string
;
valueText
:
string
}[]
{
if
(
String
(
node
.
existsDefaultValue
??
""
)
!==
"1"
)
{
return
[];
}
const
defaultType
=
node
.
defaultType
!=
null
&&
node
.
defaultType
!==
""
?
Number
(
node
.
defaultType
)
:
null
;
if
(
defaultType
===
3
)
{
return
[];
}
if
(
defaultType
===
1
&&
node
.
defaultValue
!=
null
&&
node
.
defaultValue
!==
""
)
{
const
raw
=
String
(
node
.
defaultValue
);
const
{
valueKey
,
valueText
}
=
parseDefaultValueParts
(
String
(
node
.
interactionType
??
""
),
raw
,
);
return
[{
valueKey
,
valueText
}];
}
const
apiKey
=
resolveApiDefaultKey
(
node
);
const
normalized
=
readNormalizedTemplateDefault
(
templateDefaultData
,
apiKey
);
if
(
normalized
&&
normalized
.
entries
.
length
)
{
const
nodeType
=
String
(
node
.
interactionType
??
""
);
if
(
!
interactionTypeCompatible
(
nodeType
,
normalized
.
interactionType
))
{
return
[];
}
return
normalized
.
entries
.
map
((
e
)
=>
({
valueKey
:
e
.
valueKey
==
null
?
""
:
String
(
e
.
valueKey
),
valueText
:
e
.
valueText
==
null
?
""
:
String
(
e
.
valueText
),
}));
}
const
apiTexts
=
rawToValueTexts
(
readTemplateDefaultRaw
(
templateDefaultData
,
apiKey
),
);
if
(
apiTexts
.
length
)
{
return
apiTexts
.
map
((
raw
)
=>
parseDefaultValueParts
(
String
(
node
.
interactionType
??
""
),
raw
),
);
}
if
(
node
.
defaultValue
!=
null
&&
node
.
defaultValue
!==
""
)
{
const
raw
=
String
(
node
.
defaultValue
);
const
{
valueKey
,
valueText
}
=
parseDefaultValueParts
(
String
(
node
.
interactionType
??
""
),
raw
,
);
return
[{
valueKey
,
valueText
}];
}
return
[];
}
function
normalizeDatePickerValue
(
function
normalizeDatePickerValue
(
node
:
Record
<
string
,
unknown
>
,
node
:
Record
<
string
,
unknown
>
,
raw
:
string
,
raw
:
string
,
...
@@ -135,20 +493,70 @@ function normalizeDatePickerValue(
...
@@ -135,20 +493,70 @@ function normalizeDatePickerValue(
}
}
}
}
/** 从现成的 valueKey/valueText 构建 inspectionValueList entry(带组合类型子类型分配) */
function
buildInspectionValueEntryFromParts
(
node
:
Record
<
string
,
unknown
>
,
valueKey
:
string
,
valueText
:
string
,
valueSeq
:
number
,
totalCount
:
number
=
1
,
):
Record
<
string
,
unknown
>
{
const
nodeType
=
String
(
node
.
interactionType
??
""
);
const
normalizedText
=
normalizeDatePickerValue
(
node
,
valueText
||
""
);
let
finalKey
=
valueKey
||
""
;
let
finalText
=
normalizedText
;
const
selectTypeToUse
=
isCompositeInteractionType
(
nodeType
)
?
splitCompositeInteractionType
(
nodeType
).
includes
(
"button_select"
)
:
isSelectInteractionType
(
nodeType
);
if
(
!
finalKey
&&
selectTypeToUse
&&
normalizedText
.
includes
(
"-"
))
{
const
idx
=
normalizedText
.
indexOf
(
"-"
);
finalKey
=
normalizedText
.
slice
(
0
,
idx
);
finalText
=
normalizedText
.
slice
(
idx
+
1
);
}
const
interactionType
=
assignChildInteractionType
(
nodeType
,
{
valueKey
:
finalKey
,
valueText
:
finalText
},
valueSeq
-
1
,
totalCount
,
);
return
{
valueKey
:
finalKey
,
valueText
:
finalText
,
interactionType
,
valueSeq
,
};
}
function
buildInspectionValueEntry
(
function
buildInspectionValueEntry
(
node
:
Record
<
string
,
unknown
>
,
node
:
Record
<
string
,
unknown
>
,
raw
:
string
,
raw
:
string
,
valueSeq
:
number
,
valueSeq
:
number
,
totalCount
:
number
=
1
,
):
Record
<
string
,
unknown
>
{
):
Record
<
string
,
unknown
>
{
const
nodeType
=
String
(
node
.
interactionType
??
""
);
const
normalized
=
normalizeDatePickerValue
(
node
,
raw
);
const
normalized
=
normalizeDatePickerValue
(
node
,
raw
);
const
{
valueKey
,
valueText
}
=
parseDefaultValueParts
(
const
{
valueKey
,
valueText
}
=
parseDefaultValueParts
(
String
(
node
.
interactionType
??
""
),
isCompositeInteractionType
(
nodeType
)
?
splitCompositeInteractionType
(
nodeType
).
find
((
t
)
=>
[
"dropdown"
,
"radio_button_select"
,
"button_select"
].
includes
(
t
),
)
||
""
:
nodeType
,
normalized
,
normalized
,
);
);
const
interactionType
=
assignChildInteractionType
(
nodeType
,
{
valueKey
,
valueText
},
valueSeq
-
1
,
totalCount
,
);
return
{
return
{
valueKey
,
valueKey
,
valueText
,
valueText
,
interactionType
:
node
.
interactionType
,
interactionType
,
valueSeq
,
valueSeq
,
};
};
}
}
...
@@ -235,6 +643,122 @@ export function syncLeafNodeFormValue(
...
@@ -235,6 +643,122 @@ export function syncLeafNodeFormValue(
}
}
}
}
/** 从混合格式的 templateDefaultData 中抽取标量值(兼容 carSeriesId 等顶层标量) */
export
function
extractScalarFromDefaultData
(
templateDefaultData
:
TemplateDefaultData
,
key
:
string
,
):
string
{
if
(
!
templateDefaultData
||
!
key
)
{
return
""
;
}
const
val
=
templateDefaultData
[
key
];
if
(
val
==
null
)
{
return
""
;
}
if
(
typeof
val
===
"string"
||
typeof
val
===
"number"
)
{
return
String
(
val
);
}
if
(
isNewFormatEntryArray
(
val
)
&&
val
.
length
)
{
const
firstEntry
=
val
[
0
];
if
(
firstEntry
.
values
&&
firstEntry
.
values
.
length
)
{
const
v
=
firstEntry
.
values
[
0
];
const
result
=
v
.
valueKey
!=
null
&&
String
(
v
.
valueKey
)
!==
""
?
String
(
v
.
valueKey
)
:
String
(
v
.
valueText
??
""
);
return
result
;
}
return
""
;
}
if
(
isNewFormatEntry
(
val
)
&&
val
.
values
&&
val
.
values
.
length
)
{
const
v
=
val
.
values
[
0
];
return
(
(
v
.
valueKey
!=
null
&&
String
(
v
.
valueKey
)
!==
""
?
String
(
v
.
valueKey
)
:
String
(
v
.
valueText
??
""
))
||
""
);
}
if
(
Array
.
isArray
(
val
)
&&
val
.
length
)
{
return
String
(
val
[
0
]
??
""
);
}
return
""
;
}
/** 按 syncLeafNodeFormValue 相同的写入规则,把 inspectionValueList 同步到 node.value / node.valueKey / node.uploadValue 等表单字段 */
function
applyInspectionListToNodeFormValue
(
next
:
Record
<
string
,
unknown
>
,
inspectionValueList
:
Record
<
string
,
unknown
>
[],
carTypeList
:
{
text
:
string
;
value
:
string
}[]
=
[],
):
void
{
const
interactionType
=
String
(
next
.
interactionType
??
""
);
if
(
interactionType
===
"dropdown"
||
interactionType
===
"radio_button_select"
)
{
const
first
=
inspectionValueList
[
0
];
const
valueKey
=
String
(
first
.
valueKey
??
""
);
const
valueText
=
String
(
first
.
valueText
??
""
);
next
.
valueKey
=
valueKey
;
next
.
valueText
=
valueText
;
next
.
value
=
valueKey
||
resolveDropdownFormValue
(
next
,
valueKey
,
valueText
,
carTypeList
);
return
;
}
if
(
interactionType
===
"button_select"
||
isCompositeInteractionType
(
interactionType
)
)
{
const
isComposite
=
isCompositeInteractionType
(
interactionType
);
const
compositeChildren
=
splitCompositeInteractionType
(
interactionType
);
const
uploadChild
=
compositeChildren
.
find
(
(
t
)
=>
t
===
"image_upload"
||
t
===
"video_upload"
,
);
const
buttonChild
=
compositeChildren
.
includes
(
"button_select"
);
const
pickFromList
=
(
type
:
string
)
=>
inspectionValueList
.
filter
(
(
entry
)
=>
String
(
entry
.
interactionType
??
""
)
===
type
,
);
const
buttonList
=
interactionType
===
"button_select"
?
inspectionValueList
:
buttonChild
?
pickFromList
(
"button_select"
)
:
[];
const
buttonEntries
=
buttonList
.
map
((
entry
)
=>
({
valueKey
:
String
(
entry
.
valueKey
??
""
),
valueText
:
String
(
entry
.
valueText
??
""
),
}));
next
.
value
=
buttonEntries
.
length
>
0
?
JSON
.
stringify
(
buttonEntries
)
:
""
;
if
(
isComposite
&&
uploadChild
)
{
const
uploadList
=
pickFromList
(
uploadChild
);
const
uploadUrls
=
uploadList
.
map
((
entry
)
=>
String
(
entry
.
valueText
??
""
))
.
filter
((
text
)
=>
text
!==
""
);
next
.
uploadValue
=
uploadUrls
.
length
>
0
?
JSON
.
stringify
(
uploadUrls
)
:
""
;
}
return
;
}
if
(
interactionType
===
"image_upload"
||
interactionType
===
"video_upload"
)
{
const
urls
=
inspectionValueList
.
map
((
entry
)
=>
String
(
entry
.
valueText
??
""
))
.
filter
((
text
)
=>
text
!==
""
);
next
.
value
=
urls
.
length
>
0
?
JSON
.
stringify
(
urls
)
:
""
;
return
;
}
const
text
=
normalizeDatePickerValue
(
next
,
String
(
inspectionValueList
[
0
]?.
valueText
??
""
),
);
if
(
text
!==
""
)
{
next
.
value
=
text
;
}
}
function
applyDefaultsToSingleLeaf
(
function
applyDefaultsToSingleLeaf
(
node
:
Record
<
string
,
unknown
>
,
node
:
Record
<
string
,
unknown
>
,
templateDefaultData
:
TemplateDefaultData
,
templateDefaultData
:
TemplateDefaultData
,
...
@@ -247,14 +771,46 @@ function applyDefaultsToSingleLeaf(
...
@@ -247,14 +771,46 @@ function applyDefaultsToSingleLeaf(
return
next
;
return
next
;
}
}
const
entries
=
resolveNormalizedDefaultEntries
(
next
,
templateDefaultData
);
if
(
entries
.
length
)
{
const
total
=
entries
.
length
;
const
inspectionValueList
=
entries
.
map
((
e
,
index
)
=>
buildInspectionValueEntryFromParts
(
next
,
e
.
valueKey
||
""
,
e
.
valueText
||
""
,
index
+
1
,
total
,
),
);
const
resolvedInitialValue
=
inspectionValueList
.
map
((
entry
)
=>
String
(
entry
.
valueText
??
""
))
.
filter
((
text
)
=>
text
!==
""
)
.
join
(
", "
);
next
.
inspectionResultVO
=
{
...(
typeof
next
.
inspectionResultVO
===
"object"
&&
next
.
inspectionResultVO
?
next
.
inspectionResultVO
:
{}),
inspectionValueList
,
};
next
.
resolvedInitialValue
=
resolvedInitialValue
;
applyInspectionListToNodeFormValue
(
next
,
inspectionValueList
,
carTypeList
);
return
next
;
}
const
valueTexts
=
resolveDefaultValueTexts
(
next
,
templateDefaultData
);
const
valueTexts
=
resolveDefaultValueTexts
(
next
,
templateDefaultData
);
if
(
!
valueTexts
.
length
)
{
if
(
!
valueTexts
.
length
)
{
syncLeafNodeFormValue
(
next
,
carTypeList
);
syncLeafNodeFormValue
(
next
,
carTypeList
);
return
next
;
return
next
;
}
}
const
total
=
valueTexts
.
length
;
const
inspectionValueList
=
valueTexts
.
map
((
raw
,
index
)
=>
const
inspectionValueList
=
valueTexts
.
map
((
raw
,
index
)
=>
buildInspectionValueEntry
(
next
,
raw
,
index
+
1
),
buildInspectionValueEntry
(
next
,
raw
,
index
+
1
,
total
),
);
);
const
resolvedInitialValue
=
inspectionValueList
const
resolvedInitialValue
=
inspectionValueList
...
@@ -270,28 +826,7 @@ function applyDefaultsToSingleLeaf(
...
@@ -270,28 +826,7 @@ function applyDefaultsToSingleLeaf(
};
};
next
.
resolvedInitialValue
=
resolvedInitialValue
;
next
.
resolvedInitialValue
=
resolvedInitialValue
;
const
interactionType
=
String
(
next
.
interactionType
??
""
);
applyInspectionListToNodeFormValue
(
next
,
inspectionValueList
,
carTypeList
);
if
(
interactionType
===
"dropdown"
||
interactionType
===
"radio_button_select"
)
{
const
first
=
inspectionValueList
[
0
];
const
valueKey
=
String
(
first
.
valueKey
??
""
);
const
valueText
=
String
(
first
.
valueText
??
""
);
next
.
valueKey
=
valueKey
;
next
.
valueText
=
valueText
;
next
.
value
=
valueKey
||
resolveDropdownFormValue
(
next
,
valueKey
,
valueText
,
carTypeList
);
}
else
if
(
interactionType
===
"button_select"
)
{
const
entries
=
inspectionValueList
.
map
((
entry
)
=>
({
valueKey
:
String
(
entry
.
valueKey
??
""
),
valueText
:
String
(
entry
.
valueText
??
""
),
}));
next
.
value
=
JSON
.
stringify
(
entries
);
}
else
{
next
.
value
=
normalizeDatePickerValue
(
next
,
String
(
inspectionValueList
[
0
].
valueText
??
""
),
);
}
return
next
;
return
next
;
}
}
...
...
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