Commit e07aeb57 authored by Damon's avatar Damon

上传组件调整

parent 3d175aa5
<!-- ******************* 文件上传 ******************* -->
<template>
<view class="file-box">
<!-- <view class="u-flex">
<view class="txt u-flex-1">{{item.fieldsTitle}}</view>
<u-icon name="arrow-right" color="#666" size="28"></u-icon>
</view> -->
<view class="pics u-flex u-flex-wrap">
<view class="img-list" v-for="(item,index) in imgList" :key="index">
<u-image class="pic" width="160" height="160" :src="item.path" :border-radius="10" @click.stop="prviewImage(item.path,index)"></u-image>
<view class="icon-del-box" @click.stop="delFile(index)">
<view class="icon-del"></view>
<view class="icon-del rotate"></view>
</view>
</view>
<view class="img-list">
<u-image class="pic" width="160rpx" height="160rpx" :border-radius="10" @click="selectUpload" :src="uploadImage"></u-image>
</view>
<!-- <u-image class="pic" v-for="item in 6" width="170rpx" height="170" src="'https://cdn.uviewui.com/uview/example/fade.jpg"></u-image> -->
</view>
<u-action-sheet :list="list" v-model="maskShow" :cancel-btn="true" @click="uploadSelect"></u-action-sheet>
<template>
<view>
<view class="file-box" v-if="!takeStatus">
<!-- <view class="u-flex">
<view class="txt u-flex-1">{{item.fieldsTitle}}</view>
<u-icon name="arrow-right" color="#666" size="28"></u-icon>
</view> -->
<view class="pics u-flex u-flex-wrap">
<view class="img-list" v-for="(item,index) in imgList" :key="index">
<u-image class="pic" width="160" height="160" :src="item.path" :border-radius="10" @click.stop="prviewImage(item.path,index)"></u-image>
<view class="icon-del-box" @click.stop="delFile(index)">
<view class="icon-del"></view>
<view class="icon-del rotate"></view>
</view>
</view>
<view class="img-list">
<u-image class="pic" width="160rpx" height="160rpx" :border-radius="10" @click="selectUpload" :src="uploadImage"></u-image>
</view>
<!-- <u-image class="pic" v-for="item in 6" width="170rpx" height="170" src="'https://cdn.uviewui.com/uview/example/fade.jpg"></u-image> -->
</view>
<u-action-sheet :list="list" v-model="maskShow" :cancel-btn="true" @click="uploadSelect"></u-action-sheet>
</view>
<take-photo v-else @close="closeTake"></take-photo>
</view>
</template>
<script>
import arrMixin from './arrMixin'
import baseFile from '@/components/upload/index';
import baseFile from '@/components/upload/index';
import takePhoto from '@/components/take/index.vue'
export default {
name: 'XhFiles',
components: {},
components: {
'take-photo': takePhoto
},
mixins: [arrMixin,baseFile],
props: {
files: {
......@@ -57,28 +63,6 @@
return process.uniEnv.qn_base_url + 'upload-file.png'
},
},
watch: {
'takeStatus': function(val, oldVal){
this.$emit('getTakeStatus', {status: val, index: this.itemIndex})
},
'files': { // 处理相机拍照返回的图片
handler (val) {
if(val && val.length > 0){
val.forEach((item,index,array)=>{
item.path = item.src
this.imgList.push(item)
})
// this.imgList = val.map(v => {
// v.path = v.src
// return v
// })
this.setValue()
}
},
deep:true,
immediate: true,
},
},
mounted() {
if(this.value){
this.imgList = this.value.map(img =>{
......@@ -106,7 +90,7 @@
let config = {
options:{
sourceType:['album'],//['album', 'camera']
count: 10,
count: 3,
sizeType: ['compressed']
}
}
......@@ -123,6 +107,16 @@
dataValue.push(item.src)
})
this.valueChange(dataValue)
},
closeTake(val) {
if(val && val.length > 0){
val.forEach((item,index,array)=>{
item.path = item.src
this.imgList.push(item)
})
this.setValue()
}
this.takeStatus = false
},
prviewImage(url, index) {
uni.previewImage({
......
......@@ -39,8 +39,20 @@ uni.hideTabBar()
|事件称名 |说明 | 返回值 |
|:-: |:-: | :-: |
|@close | 关闭相机或完成拍照的时候触发 | 已拍照完成的图片数组|
|@close | 关闭相机或完成拍照的时候触发 | 已拍照完成的图片数组 **格式见下文** |
```json
{
[
{
id: '',
key: 'https: //identity/cert/20210507wefew.png', // 七牛绝对路径地址
progress: 100, // 图片上传进度
src: 'wxfile://tmp_2324.png' // 微信临时文件地址
}
]
}
```
## 组件用法
......
<template>
<view class="com-content">
<complete-check :show="completeCheckStatus" :list-data="completeCheckResult" :pass="pass" @close="closeCheckResult" @handle="handerProgrom" @change="confirm"></complete-check>
<view class="u-wrap" v-if="!takeStatus">
<view class="u-wrap">
<u-navbar :background="{background: '#2272FF'}" back-icon-color="#fff" :title-size="32" title-color="#fff" :border-bottom="false" title="完工信息"></u-navbar>
<u-tabs-swiper class="order-tabs" ref="tabs" :current="tabIndex" name="panelName" :list="list" @change="tabsChange" :is-scroll="false" bg-color="#2272FF" inactive-color="#a6c6ff" active-color="#fff" height="80" font-size="32"></u-tabs-swiper>
<view class="u-menu-wrap">
......@@ -45,8 +45,7 @@
</xh-select>
<xh-files v-else-if="typeToComponentType(item.fieldsType)==='file'"
:groupIndex="groupIndex" :itemIndex="itemIndex" :item="item" :value='form[item.fieldsName] || []'
:files="files[itemIndex.toString()]"
@value-change="fieldValueChange" @getTakeStatus="getTakeStatus">
@value-change="fieldValueChange">
</xh-files>
<xh-location v-else-if="typeToComponentType(item.fieldsType)==='location'"
:groupIndex="groupIndex" :itemIndex="itemIndex" :item="item" :value='form[item.fieldsName] || ""'
......@@ -91,8 +90,7 @@
下一步
</u-button>
</view>
</view>
<take-photo v-else @close="closeTake"></take-photo>
</view>
<u-toast ref="uToast" />
</view>
</template>
......@@ -108,7 +106,6 @@
import XhScan from '@/components/createCom/XhScan.vue'
import XhPicker from '@/components/createCom/XhPicker.vue'
import XhTime from '@/components/createCom/XhTime.vue'
import takePhoto from '@/components/take/index.vue'
import XhServiceMeasure from '@/components/createCom/XhServiceMeasure.vue'
// import XhRadio from '@/components/createCom/XhRadio.vue'
export default {
......@@ -160,9 +157,6 @@
}]
},
submitBtnStatus: false,
takeStatus: false,
fileIndex: null,
files: [],
completeCheckStatus: false,
completeCheckResult: [],
waitHandlerPanelIndex: 0,
......@@ -182,8 +176,7 @@
XhScan,
XhPicker,
XhTime,
XhServiceMeasure,
'take-photo': takePhoto
XhServiceMeasure
},
created() {
// console.log(allComponents,'allComponents')
......@@ -360,11 +353,6 @@
}
}
},
getTakeStatus(event) {
this.takeStatus = event.status
this.fileIndex = event.index.toString()
if(!this.files[event.index] || this.files[event.index].length < 1) this.files[event.index] = []
},
tabsChange(index){
this.tabIndex = index
this.arr = []
......@@ -375,11 +363,6 @@
this.getMenuItemTop()
})
},
closeTake(images) {
this.takeStatus = false
//const newFile = this.files[this.fileIndex].concat(images)
this.$set(this.files, this.fileIndex, images)
},
// 字段的值更新
fieldValueChange(data) {
const groupItem = this.list[this.tabIndex].items[data.groupIndex]
......
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