This commit is contained in:
aixianling
2023-03-31 10:24:12 +08:00
parent 8c89b3b418
commit daefc25b4b
3 changed files with 25 additions and 7 deletions

View File

@@ -40,6 +40,10 @@ import AiImage from '../AiImage/AiImage'
export default {
name: 'AiUploader',
components: {AiImage},
model:{
prop: 'def',
event: 'input'
},
props: {
limit: {default: 1}, //数量
placeholder: {default: '添加图片'}, // 文字提示
@@ -86,7 +90,7 @@ export default {
methods: {
remove(index) {
this.fileList.splice(index, 1)
this.$emit('list', this.fileList)
this.$emit('input', this.fileList)
},
upload(wait) {
let count = this.limit - (this.fileList?.length || 0)
@@ -145,8 +149,6 @@ export default {
this.$u.toast('上传成功!')
if (this.action.endsWith('/file/add')) {
this.fileList.push({url: res.data?.[0]?.split(";")?.[0], id: res.data?.[0]?.split(";")?.[1]})
this.$emit('input', [...this.fileList])
this.$emit('change', [...this.fileList])
} else if (this.action == '/admin/file/add2') {
let info = res.data
this.$emit('update:fileId', info?.id)
@@ -155,7 +157,7 @@ export default {
this.fileList.push({url: res.data?.split(";")?.[0], id: res.data?.split(";")?.[1]})
}
this.$emit("update:def", this.fileList)
this.$emit("list", this.fileList)
this.$emit("input", this.fileList)
} else {
this.$u.toast(res.msg)
}

View File

@@ -28,7 +28,7 @@
<i :style="{opacity: item.mustFill === '1' ? 1 : 0}">*</i>
<h2>请上传{{ item.annexName }}</h2>
</div>
<AiUploader :def="[{url:item.src}]" preview @list="imgs=>handleImage(item,imgs)" :limit="1"/>
<AiUploader :def="[{url:item.src}]" preview @input="imgs=>handleImage(item,imgs)" :limit="1"/>
</div>
</div>
<div class="service-example" v-if="exampleList.length">

View File

@@ -9,7 +9,9 @@
<AiItem label="所属网格" :value="info.girdName"/>
<AiItem label="上报时间" :value="info.createTime"/>
<AiItem label="照片" top-label>
<image v-for="(item, index) in info.files" @click="preview(item.url)" :key="index" :src="item.url"/>
<div class="flex wrap">
<image class="fill imageItem" v-for="(item, index) in info.files" @click="preview(item.url)" :key="index" :src="item.url"/>
</div>
<span v-if="!info.files.length">暂无照片</span>
</AiItem>
</AiGroup>
@@ -17,7 +19,9 @@
<AiGroup title="处理详情" v-if="info.eventStatus > 1" description noBorder labelColor="#999">
<AiItem label="处理结果" top-label :value="result.doExplain"/>
<AiItem label="照片" top-label>
<image v-for="(item, index) in result.files" @click="preview(item.url)" :key="index" :src="item.url"/>
<div class="flex wrap">
<image class="fill imageItem" v-for="(item, index) in result.files" @click="preview(item.url)" :key="index" :src="item.url"/>
</div>
<span v-if="!result.files.length">暂无照片</span>
</AiItem>
</AiGroup>
@@ -163,5 +167,17 @@ export default {
background: #FF4466;
}
}
.imageItem {
min-width: 30%;
height: 30vw;
flex-shrink: 0;
margin-right: 16px;
margin-bottom: 16px;
&:nth-of-type(3n) {
margin-right: 0;
}
}
}
</style>