Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
monorepo
/
venus
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
1
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 5edbc1ba
authored
Mar 25, 2026
by
yancanhua
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat: 自定义组件开发
1 parent
c54f3162
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
91 additions
and
22 deletions
apps/web/venus-usedcar-quality/src/components/CustomizeForm/Index.vue
apps/web/venus-usedcar-quality/src/components/CustomizeForm/customizeUploadFile.vue
apps/web/venus-usedcar-quality/src/components/CustomizeForm/radioSelect.vue
apps/web/venus-usedcar-quality/src/components/CustomizeForm/selectDatePicker.vue
apps/web/venus-usedcar-quality/src/components/CustomizeForm/selectDropdown.vue
apps/web/venus-usedcar-quality/src/components/CustomizeForm/Index.vue
View file @
5edbc1b
<
script
setup
lang=
"ts"
>
import
type
{
CustomizeFormValidateResult
}
from
"@/types/views/car-detail"
;
import
{
ref
,
watch
}
from
"vue"
;
import
type
{
CustomizeFormValidateResult
}
from
"@/types/views/car-detail"
;
import
selectDatePicker
from
"@/components/customizeForm/selectDatePicker.vue"
;
import
selectDropdown
from
"@/components/customizeForm/selectDropdown.vue"
;
import
buttonSelect
from
"@/components/customizeForm/buttonSelect.vue"
;
...
...
@@ -29,11 +27,25 @@ const form = ref({});
const
rules
=
ref
({});
watch
(()
=>
props
.
leafNodes
,
(
nodes
)
=>
{
columnsList
.
value
=
nodes
||
[]
;
columnsList
.
value
=
(
nodes
||
[]).
map
((
item
:
any
)
=>
({
...
item
,
value
:
getValueText
(
item
),
}))
;
console
.
log
(
'watchLeafNodes'
,
columnsList
.
value
);
},
{
immediate
:
true
,
deep
:
true
});
function
getValueText
(
item
:
any
)
{
let
valueText
=
''
;
if
(
item
?.
inspectionResultVO
)
{
const
inspectionValueList
=
item
?.
inspectionResultVO
?.
inspectionValueList
||
[];
if
(
inspectionValueList
&&
inspectionValueList
.
length
>
0
)
{
const
inputList
=
[
'text_input'
,
'textarea_input'
,
'number_input'
,
'date_picker'
];
if
(
inputList
.
includes
(
item
.
interactionType
))
{
valueText
=
inspectionValueList
[
0
].
valueText
||
''
;
}
}
}
return
valueText
;
}
// 提交数据
function
setSubmitData
()
{
let
returnData
:
never
[]
=
[];
...
...
@@ -90,6 +102,7 @@ function setSubmitData() {
returnData
.
push
({
nodeId
:
item
.
id
,
nodeName
:
item
.
nodeName
,
resultStatus
:
resultStatus
.
value
?
3
:
1
,
remark
:
''
,
data
:
dataList
});
}
});
console
.
log
(
'validate'
,
returnData
);
return
returnData
;
}
...
...
@@ -124,6 +137,17 @@ function getValidationRules(item: any) {
return
JSON
.
parse
(
item
.
validationRules
||
'{}'
);
}
function
setImgWidth
(
item
:
any
)
{
let
resultStatus
=
false
;
if
(
item
.
interactionType
==
'image_upload'
||
item
.
interactionType
==
'video_upload'
)
{
const
validationRules
=
JSON
.
parse
(
item
.
validationRules
||
'{}'
);
if
(
validationRules
.
maxCount
&&
validationRules
.
maxCount
==
1
)
{
resultStatus
=
true
;
}
}
return
resultStatus
}
defineExpose
({
validate
,
saveData
,
...
...
@@ -134,17 +158,18 @@ defineExpose({
<
template
>
<div>
<van-form
ref=
"customizeFormRef"
:model=
"form"
:rules=
"rules"
>
<div
class=
"formTitle"
>
<!--
<div>
{{
subTabLabel
}}
</div>
-->
<div
v-if=
"allowNoStructure"
class=
"formRadio"
@
click=
"resultStatus = !resultStatus"
>
<div
v-if=
"allowNoStructure"
class=
"formTitle"
>
<div
@
click=
"resultStatus = !resultStatus"
>
<van-icon
v-if=
"!resultStatus"
name=
"circle"
size=
"14"
color=
"#666666"
/>
<van-icon
v-if=
"resultStatus"
name=
"checked"
size=
"14"
color=
"#185EFE"
/>
<span
class=
"radioText"
>
无此结构
</span>
</div>
</div>
<div
v-for=
"(item, index) in columnsList"
:key=
"index"
class=
"customizeList"
:class=
"
{ 'border-bottom': index
< columnsList
.
length
-
1
&&
item
.
interactionType
!=
'
image_upload
'
}"
>
<div
v-for=
"(item, index) in columnsList"
:key=
"index"
class=
"customizeList"
:class=
"
{
'border-bottom': index
< columnsList
.
length
-
1
&&
item
.
interactionType
!=
'
image_upload
',
'
customizeList50
'
:
setImgWidth
(
item
)
}"
>
<!-- 文本输入框 -->
<div
v-if=
"item.interactionType == 'text_input'"
>
...
...
@@ -201,18 +226,11 @@ defineExpose({
.formTitle
{
width
:
100%
;
float
:
left
;
color
:
#333333
;
font-size
:
18px
;
line-height
:
24px
;
background
:
#ffffff
;
padding
:
16px
12px
;
display
:
flex
;
}
.formRadio
{
margin-left
:
14px
;
}
.radioText
{
color
:
#666666
;
font-size
:
12px
;
...
...
@@ -225,7 +243,7 @@ defineExpose({
}
.customizeList50
{
width
:
50%
;
width
:
50%
!important
;
float
:
left
;
}
...
...
apps/web/venus-usedcar-quality/src/components/CustomizeForm/customizeUploadFile.vue
View file @
5edbc1b
<
script
setup
lang=
"ts"
>
import
{
ref
}
from
"vue"
;
import
{
ref
,
watch
}
from
"vue"
;
import
{
uploadFile
}
from
"@/utils/upload.js"
;
const
uploading
=
ref
(
false
);
...
...
@@ -13,15 +13,31 @@ const props = defineProps({
});
const
emit
=
defineEmits
([
"update"
]);
const
pickerValue
=
ref
([]);
const
fileInputRef
=
ref
<
HTMLInputElement
|
null
>
(
null
);
function
pickFile
()
{
fileInputRef
.
value
?.
click
();
}
//页面加载时初始化数据
onMounted
(()
=>
{
initData
();
});
// 初始化数据
function
initData
()
{
if
(
props
?.
item
?.
inspectionResultVO
)
{
const
inspectionValueList
=
props
?.
item
?.
inspectionResultVO
?.
inspectionValueList
||
[];
for
(
const
i
of
inspectionValueList
)
{
if
(
i
.
valueText
)
{
pickerValue
.
value
.
push
(
i
.
valueText
)
}
}
if
(
pickerValue
.
value
.
length
>
0
)
{
updateData
();
}
}
}
// 计算属性
const
validationRules
=
computed
(()
=>
{
return
JSON
.
parse
(
props
.
item
.
validationRules
||
'{}'
);
...
...
apps/web/venus-usedcar-quality/src/components/CustomizeForm/radioSelect.vue
View file @
5edbc1b
...
...
@@ -10,6 +10,22 @@ const props = defineProps({
const
emit
=
defineEmits
([
"update"
]);
const
pickerValue
=
ref
(
''
);
//页面加载时初始化数据
onMounted
(()
=>
{
initData
();
});
// 初始化数据
function
initData
()
{
if
(
props
?.
item
?.
inspectionResultVO
)
{
const
inspectionValueList
=
props
?.
item
?.
inspectionResultVO
?.
inspectionValueList
||
[];
if
(
inspectionValueList
&&
inspectionValueList
.
length
>
0
)
{
pickerValue
.
value
=
inspectionValueList
[
0
].
valueKey
||
''
;
}
}
}
// 计算属性
const
columnsList
=
computed
(()
=>
{
const
optionsList
=
JSON
.
parse
(
props
.
item
.
options
||
'[]'
).
map
(
item
=>
{
...
...
apps/web/venus-usedcar-quality/src/components/CustomizeForm/selectDatePicker.vue
View file @
5edbc1b
...
...
@@ -8,6 +8,8 @@ const props = defineProps({
},
});
const
columnsType
=
ref
([
'year'
,
'month'
]);
const
emit
=
defineEmits
([
"update"
]);
const
showPicker
=
ref
(
false
);
const
pickerValue
=
ref
([]);
...
...
@@ -37,7 +39,7 @@ function onConfirm() {
<van-field
v-model=
"item.value"
clearable
is-link
:label=
"item.nodeName"
name=
"datePicker"
:placeholder=
"item.placeholder"
readonly
:required=
"item.required === 1"
@
click=
"handleShowPicker"
/>
<van-popup
v-model:show=
"showPicker"
destroy-on-close
position=
"bottom"
>
<van-date-picker
v-model=
"pickerValue"
:title=
"item.nodeName"
@
cancel=
"showPicker = false"
<van-date-picker
v-model=
"pickerValue"
:title=
"item.nodeName"
:columns-type=
"columnsType"
@
cancel=
"showPicker = false"
@
confirm=
"onConfirm"
/>
</van-popup>
</div>
...
...
apps/web/venus-usedcar-quality/src/components/CustomizeForm/selectDropdown.vue
View file @
5edbc1b
...
...
@@ -12,6 +12,23 @@ const emit = defineEmits(["update"]);
const
showPicker
=
ref
(
false
);
const
pickerValue
=
ref
([]);
//页面加载时初始化数据
onMounted
(()
=>
{
initData
();
});
// 初始化数据
function
initData
()
{
if
(
props
?.
item
?.
inspectionResultVO
)
{
const
inspectionValueList
=
props
?.
item
?.
inspectionResultVO
?.
inspectionValueList
||
[];
if
(
inspectionValueList
&&
inspectionValueList
.
length
>
0
&&
inspectionValueList
[
0
].
valueKey
)
{
pickerValue
.
value
=
[
inspectionValueList
[
0
].
valueKey
];
}
onConfirm
();
}
}
// 计算属性
const
columnsList
=
computed
(()
=>
{
const
optionsList
=
JSON
.
parse
(
props
.
item
.
options
||
'[]'
).
map
(
item
=>
{
...
...
@@ -27,7 +44,7 @@ const columnsList = computed(() => {
function
onConfirm
()
{
const
picker
=
pickerValue
.
value
&&
pickerValue
.
value
.
length
>
0
?
pickerValue
.
value
[
0
]
:
""
;
showPicker
.
value
=
false
;
const
ObjectItem
=
columnsList
.
value
.
find
(
item
=>
item
.
value
==
picker
);
const
ObjectItem
=
columnsList
.
value
.
find
(
item
=>
item
.
value
==
picker
)
||
{}
;
props
.
item
.
valueText
=
ObjectItem
.
text
||
''
;
props
.
item
.
valueKey
=
ObjectItem
.
value
||
''
;
props
.
item
.
value
=
picker
||
''
;
...
...
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