Commit 6adade03 authored by gengchunlei's avatar gengchunlei

慢综 图片上传数量限制

parent 0a98fb01
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
</div> </div>
<div class='img-btn mt-2' @click="toUpload('imgId')"> <div class='img-btn mt-2' @click="toUpload('imgId')">
<input type='file' id='imgId' multiple @change='choiceImg' style='display: none' <input type='file' id='imgId' multiple @change='choiceImg' style='display: none'
:key='new Date().getTime()' accept="image/*"> :key='new Date().getTime()' accept="image/*,.pdf">
<div class='flex items-center justify-center'> <div class='flex items-center justify-center'>
<div> <div>
<doc-icon type='doc-upload' class='doc-up' /> <doc-icon type='doc-upload' class='doc-up' />
...@@ -88,6 +88,8 @@ ...@@ -88,6 +88,8 @@
</div> </div>
</div> </div>
</div> </div>
<div v-if='imgList.length > 6' class='warn mt-2'>最多允许上传6张!</div>
</div> </div>
<div v-if='showOne && firstForm.visitSituation == 1'> <div v-if='showOne && firstForm.visitSituation == 1'>
...@@ -97,7 +99,7 @@ ...@@ -97,7 +99,7 @@
</div> </div>
<div class='img-btn mt-2' @click="toUpload('imgId2')"> <div class='img-btn mt-2' @click="toUpload('imgId2')">
<input type='file' id='imgId2' multiple @change='choiceImg2' style='display: none' <input type='file' id='imgId2' multiple @change='choiceImg2' style='display: none'
:key='new Date().getTime()-10000' accept="image/*"> :key='new Date().getTime()-10000' accept="image/*,.pdf">
<div class='flex items-center justify-center'> <div class='flex items-center justify-center'>
<div> <div>
<doc-icon type='doc-upload' class='doc-up' /> <doc-icon type='doc-upload' class='doc-up' />
...@@ -137,6 +139,7 @@ ...@@ -137,6 +139,7 @@
</div> </div>
</div> </div>
</div> </div>
<div v-if='imgList2.length > 8' class='warn mt-2'>最多允许上传8张!</div>
</div> </div>
<!-- 图片预览--> <!-- 图片预览-->
...@@ -342,11 +345,11 @@ export default { ...@@ -342,11 +345,11 @@ export default {
return form.visitHealthGuideList return form.visitHealthGuideList
}, },
toUpload(id) { toUpload(id) {
if (id === 'imgId' && this.imgList.length >= 6) { if (id === 'imgId' && this.imgList.length > 6) {
showToast('最多允许上传6张') showToast('最多允许上传6张')
return return
} }
if (id === 'imgId2' && this.imgList2.length >= 8) { if (id === 'imgId2' && this.imgList2.length > 8) {
showToast('最多允许上传8张') showToast('最多允许上传8张')
return return
} }
...@@ -422,6 +425,9 @@ export default { ...@@ -422,6 +425,9 @@ export default {
onSubmit() { onSubmit() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.$refs.form.validate().then(() => { this.$refs.form.validate().then(() => {
if (this.imgList.length > 6 || this.imgList2.length > 8) {
return
}
let par = { let par = {
img1: this.imgList || [], img1: this.imgList || [],
img2: this.imgList2 || [], img2: this.imgList2 || [],
...@@ -567,6 +573,10 @@ export default { ...@@ -567,6 +573,10 @@ export default {
border-bottom: 0px; border-bottom: 0px;
} }
.warn {
color: #ee0a24;
text-align: left;
}
</style> </style>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment