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 d8f0fabd
authored
Mar 24, 2026
by
yancanhua
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat: 自定义表单
1 parent
85d51400
Pipeline
#81
for
d8f0fabd
failed
in 0 seconds
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
198 additions
and
85 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/selectDatePicker.vue
apps/web/venus-usedcar-quality/src/components/CustomizeForm/selectDropdown.vue
apps/web/venus-usedcar-quality/src/components/CustomizeForm/Index.vue
View file @
d8f0fab
...
...
@@ -4,6 +4,8 @@ import { ref } from "vue";
import
selectDatePicker
from
"@/components/customizeForm/selectDatePicker.vue"
;
import
selectDropdown
from
"@/components/customizeForm/selectDropdown.vue"
;
import
buttonSelect
from
"@/components/customizeForm/buttonSelect.vue"
;
import
customizeUploadFile
from
"@/components/customizeForm/customizeUploadFile.vue"
;
// 获取父组件传递的model
const
props
=
defineProps
({
...
...
@@ -26,64 +28,15 @@ async function validate() {
};
}
const
formList
=
ref
([
{
interactionType
:
"text_input"
,
required
:
1
,
nodeName
:
"输入框"
,
placeholder
:
"请输入"
,
value
:
""
,
maxCount
:
10
,
},
{
interactionType
:
"textarea_input"
,
required
:
1
,
nodeName
:
"备注"
,
placeholder
:
"请输入"
,
value
:
""
,
maxCount
:
50
,
},
{
interactionType
:
"number_input"
,
required
:
1
,
nodeName
:
"数字输入框"
,
placeholder
:
"请输入"
,
value
:
""
,
maxCount
:
50
,
},
{
interactionType
:
"date_picker"
,
required
:
1
,
nodeName
:
"日期选择器"
,
placeholder
:
"请选择日期"
,
value
:
""
,
maxCount
:
50
,
},
{
interactionType
:
"dropdown"
,
required
:
1
,
nodeName
:
"下拉选择器"
,
placeholder
:
"请选择"
,
value
:
""
,
maxCount
:
50
,
},
{
interactionType
:
"button_select"
,
required
:
1
,
nodeName
:
"异常类型 (可多选)"
,
placeholder
:
"请选择"
,
value
:
""
,
maxCount
:
50
,
},
{
interactionType
:
"radio_button_select"
,
interactionType
:
"image_upload"
,
required
:
1
,
nodeName
:
"是否一手车"
,
placeholder
:
"请选择"
,
value
:
""
,
maxCount
:
50
,
}
,
}
]);
...
...
@@ -97,7 +50,6 @@ defineExpose({
<
template
>
<div>
<van-form
ref=
"customizeFormRef"
:model=
"form"
:rules=
"rules"
>
<div
class=
"formTitle"
>
<div>
车辆信息
</div>
<div
class=
"formRadio"
>
...
...
@@ -160,6 +112,11 @@ defineExpose({
<buttonSelect
:item=
"item"
:value=
"item.value"
@
update=
"item.value = $event"
/>
</div>
<!-- 图片上传 -->
<div
v-if=
"item.interactionType == 'image_upload'"
>
<customizeUploadFile
:item=
"item"
:value=
"item.value"
@
update=
"item.value = $event"
/>
</div>
</div>
</van-form>
</div>
...
...
apps/web/venus-usedcar-quality/src/components/CustomizeForm/customizeUploadFile.vue
0 → 100644
View file @
d8f0fab
<
script
setup
lang=
"ts"
>
import
{
ref
}
from
"vue"
;
import
{
uploadFile
}
from
"@/utils/upload.js"
;
const
uploading
=
ref
(
false
);
import
{
showToast
}
from
"vant"
;
const
props
=
defineProps
({
item
:
{
type
:
Object
,
default
:
()
=>
{
},
},
});
const
emit
=
defineEmits
([
"update"
]);
const
pickerValue
=
ref
([]);
const
fileInputRef
=
ref
<
HTMLInputElement
|
null
>
(
null
);
function
pickFile
()
{
fileInputRef
.
value
?.
click
();
}
async
function
onFileChange
(
ev
:
Event
)
{
const
input
=
ev
.
target
as
HTMLInputElement
;
const
file
=
input
.
files
?.[
0
];
input
.
value
=
""
;
if
(
!
file
)
return
;
uploading
.
value
=
true
;
try
{
const
res
=
await
uploadFile
(
file
);
const
url
=
(
typeof
res
.
aliyunAddress
===
"string"
&&
res
.
aliyunAddress
)
||
(
typeof
res
.
url
===
"string"
&&
res
.
url
)
||
""
;
showToast
(
"上传成功"
);
pickerValue
.
value
.
push
(
url
);
updateData
();
}
catch
(
e
:
unknown
)
{
const
msg
=
e
instanceof
Error
?
e
.
message
:
String
(
e
);
showToast
(
`上传失败:
${
msg
}
`
);
}
finally
{
uploading
.
value
=
false
;
}
}
function
handleDelete
(
item
:
string
)
{
pickerValue
.
value
=
pickerValue
.
value
.
filter
((
i
)
=>
i
!==
item
);
updateData
();
}
function
updateData
()
{
props
.
item
.
value
=
pickerValue
.
value
.
join
(
','
);
emit
(
"update"
,
pickerValue
.
value
.
join
(
','
));
}
</
script
>
<
template
>
<div
class=
"buttonSelect"
>
<div
class=
"title"
>
<div
class=
"titleContent"
>
<span
v-if=
"item.required === 1"
class=
"isRequired"
>
*
</span>
<span>
{{
item
.
nodeName
}}
</span>
</div>
<div
class=
"titleTip"
>
有损伤请拍摄图片,无损伤请忽略
</div>
</div>
<input
ref=
"fileInputRef"
accept=
"image/*"
class=
"hidden-input"
type=
"file"
@
change=
"onFileChange"
>
<div
class=
"uploadPage"
>
<div
class=
"uploadBox"
@
click=
"pickFile"
>
<van-icon
name=
"plus"
size=
"24"
color=
"#999999"
class=
"plusBox"
/>
<div
class=
"uploadTxt"
>
添加照片
</div>
</div>
<div
v-for=
"(item, index) in pickerValue"
:key=
"index"
class=
"uploadBox"
>
<div
class=
"deleteBox"
@
click=
"handleDelete(item)"
>
<van-icon
name=
"clear"
size=
"20"
color=
"#999999"
/>
</div>
<van-image
width=
"96"
height=
"96"
style=
"border-radius: 8px;"
:src=
"item"
/>
</div>
</div>
</div>
</
template
>
<
style
lang=
"scss"
scoped
>
.buttonSelect
{
width
:
100%
;
background
:
#ffffff
;
float
:
left
;
}
.title
{
width
:
100%
;
float
:
left
;
margin-top
:
16px
;
margin-bottom
:
10px
;
padding-left
:
16px
;
}
.titleContent
{
width
:
100%
;
height
:
24px
;
float
:
left
;
color
:
#141e34
;
font-size
:
14px
;
line-height
:
24px
;
}
.titleTip
{
width
:
100%
;
height
:
16px
;
line-height
:
16px
;
float
:
left
;
color
:
#999999
;
font-size
:
12px
;
font-weight
:
400
;
}
.isRequired
{
color
:
#ee3040
;
font-size
:
14px
;
padding-right
:
2px
;
}
.hidden-input
{
position
:
absolute
;
width
:
0
;
height
:
0
;
opacity
:
0
;
pointer-events
:
none
;
}
.uploadPage
{
width
:
-webkit-calc
(
100%
-
24px
);
width
:
-moz-calc
(
100%
-
24px
);
width
:
calc
(
100%
-
24px
);
float
:
left
;
margin-left
:
12px
;
}
.uploadBox
{
width
:
96px
;
height
:
96px
;
border-radius
:
8px
;
border
:
1px
solid
#dddddd
;
background
:
#f9f9f9
;
float
:
left
;
margin-bottom
:
16px
;
margin-right
:
12px
;
position
:
relative
;
}
.plusBox
{
float
:
left
;
margin-top
:
22px
;
margin-left
:
36px
;
margin-right
:
36px
;
}
.uploadTxt
{
width
:
100%
;
height
:
20px
;
float
:
left
;
margin-top
:
8px
;
line-height
:
20px
;
color
:
#999999
;
font-size
:
12px
;
font-weight
:
400
;
text-align
:
center
;
}
.deleteBox
{
position
:
absolute
;
top
:
2px
;
right
:
2px
;
width
:
20px
;
height
:
20px
;
z-index
:
99
;
cursor
:
pointer
;
}
</
style
>
apps/web/venus-usedcar-quality/src/components/CustomizeForm/selectDatePicker.vue
View file @
d8f0fab
...
...
@@ -4,7 +4,7 @@ import { ref } from "vue";
const
props
=
defineProps
({
item
:
{
type
:
Object
,
default
:
()
=>
{},
default
:
()
=>
{
},
},
});
...
...
@@ -34,21 +34,10 @@ function onConfirm() {
<
template
>
<div>
<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-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"
@
confirm=
"onConfirm"
/>
</van-popup>
</div>
...
...
apps/web/venus-usedcar-quality/src/components/CustomizeForm/selectDropdown.vue
View file @
d8f0fab
...
...
@@ -4,7 +4,7 @@ import { computed, ref } from "vue";
const
props
=
defineProps
({
item
:
{
type
:
Object
,
default
:
()
=>
{},
default
:
()
=>
{
},
},
});
...
...
@@ -37,22 +37,10 @@ function onConfirm() {
<
template
>
<div>
<van-field
v-model=
"item.value"
clearable
is-link
:label=
"item.nodeName"
name=
"datePicker"
:placeholder=
"item.placeholder"
readonly
:required=
"item.required === 1"
@
click=
"showPicker = true"
/>
<van-popup
v-model:show=
"showPicker"
destroy-on-close
position=
"bottom"
>
<van-picker
v-model=
"pickerValue"
:columns=
"columnsList"
:title=
"item.nodeName"
@
cancel=
"showPicker = false"
<van-field
v-model=
"item.value"
clearable
is-link
:label=
"item.nodeName"
name=
"datePicker"
:placeholder=
"item.placeholder"
readonly
:required=
"item.required === 1"
@
click=
"showPicker = true"
/>
<van-popup
v-model:show=
"showPicker"
destroy-on-close
position=
"bottom"
>
<van-picker
v-model=
"pickerValue"
:columns=
"columnsList"
:title=
"item.nodeName"
@
cancel=
"showPicker = false"
@
confirm=
"onConfirm"
/>
</van-popup>
</div>
...
...
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