Commit e07aeb57 authored by Damon's avatar Damon

上传组件调整

parent 3d175aa5
<!-- ******************* 文件上传 ******************* --> <!-- ******************* 文件上传 ******************* -->
<template> <template>
<view class="file-box"> <view>
<view class="file-box" v-if="!takeStatus">
<!-- <view class="u-flex"> <!-- <view class="u-flex">
<view class="txt u-flex-1">{{item.fieldsTitle}}</view> <view class="txt u-flex-1">{{item.fieldsTitle}}</view>
<u-icon name="arrow-right" color="#666" size="28"></u-icon> <u-icon name="arrow-right" color="#666" size="28"></u-icon>
...@@ -20,14 +21,19 @@ ...@@ -20,14 +21,19 @@
</view> </view>
<u-action-sheet :list="list" v-model="maskShow" :cancel-btn="true" @click="uploadSelect"></u-action-sheet> <u-action-sheet :list="list" v-model="maskShow" :cancel-btn="true" @click="uploadSelect"></u-action-sheet>
</view> </view>
<take-photo v-else @close="closeTake"></take-photo>
</view>
</template> </template>
<script> <script>
import arrMixin from './arrMixin' 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 { export default {
name: 'XhFiles', name: 'XhFiles',
components: {}, components: {
'take-photo': takePhoto
},
mixins: [arrMixin,baseFile], mixins: [arrMixin,baseFile],
props: { props: {
files: { files: {
...@@ -57,28 +63,6 @@ ...@@ -57,28 +63,6 @@
return process.uniEnv.qn_base_url + 'upload-file.png' 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() { mounted() {
if(this.value){ if(this.value){
this.imgList = this.value.map(img =>{ this.imgList = this.value.map(img =>{
...@@ -106,7 +90,7 @@ ...@@ -106,7 +90,7 @@
let config = { let config = {
options:{ options:{
sourceType:['album'],//['album', 'camera'] sourceType:['album'],//['album', 'camera']
count: 10, count: 3,
sizeType: ['compressed'] sizeType: ['compressed']
} }
} }
...@@ -124,6 +108,16 @@ ...@@ -124,6 +108,16 @@
}) })
this.valueChange(dataValue) 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) { prviewImage(url, index) {
uni.previewImage({ uni.previewImage({
urls: [url], urls: [url],
......
...@@ -39,8 +39,20 @@ uni.hideTabBar() ...@@ -39,8 +39,20 @@ uni.hideTabBar()
|事件称名 |说明 | 返回值 | |事件称名 |说明 | 返回值 |
|:-: |:-: | :-: | |:-: |:-: | :-: |
|@close | 关闭相机或完成拍照的时候触发 | 已拍照完成的图片数组| |@close | 关闭相机或完成拍照的时候触发 | 已拍照完成的图片数组 **格式见下文** |
```json
{
[
{
id: '',
key: 'https: //identity/cert/20210507wefew.png', // 七牛绝对路径地址
progress: 100, // 图片上传进度
src: 'wxfile://tmp_2324.png' // 微信临时文件地址
}
]
}
```
## 组件用法 ## 组件用法
......
<template> <template>
<view class="com-content"> <view class="com-content">
<complete-check :show="completeCheckStatus" :list-data="completeCheckResult" :pass="pass" @close="closeCheckResult" @handle="handerProgrom" @change="confirm"></complete-check> <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-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> <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"> <view class="u-menu-wrap">
...@@ -45,8 +45,7 @@ ...@@ -45,8 +45,7 @@
</xh-select> </xh-select>
<xh-files v-else-if="typeToComponentType(item.fieldsType)==='file'" <xh-files v-else-if="typeToComponentType(item.fieldsType)==='file'"
:groupIndex="groupIndex" :itemIndex="itemIndex" :item="item" :value='form[item.fieldsName] || []' :groupIndex="groupIndex" :itemIndex="itemIndex" :item="item" :value='form[item.fieldsName] || []'
:files="files[itemIndex.toString()]" @value-change="fieldValueChange">
@value-change="fieldValueChange" @getTakeStatus="getTakeStatus">
</xh-files> </xh-files>
<xh-location v-else-if="typeToComponentType(item.fieldsType)==='location'" <xh-location v-else-if="typeToComponentType(item.fieldsType)==='location'"
:groupIndex="groupIndex" :itemIndex="itemIndex" :item="item" :value='form[item.fieldsName] || ""' :groupIndex="groupIndex" :itemIndex="itemIndex" :item="item" :value='form[item.fieldsName] || ""'
...@@ -92,7 +91,6 @@ ...@@ -92,7 +91,6 @@
</u-button> </u-button>
</view> </view>
</view> </view>
<take-photo v-else @close="closeTake"></take-photo>
<u-toast ref="uToast" /> <u-toast ref="uToast" />
</view> </view>
</template> </template>
...@@ -108,7 +106,6 @@ ...@@ -108,7 +106,6 @@
import XhScan from '@/components/createCom/XhScan.vue' import XhScan from '@/components/createCom/XhScan.vue'
import XhPicker from '@/components/createCom/XhPicker.vue' import XhPicker from '@/components/createCom/XhPicker.vue'
import XhTime from '@/components/createCom/XhTime.vue' import XhTime from '@/components/createCom/XhTime.vue'
import takePhoto from '@/components/take/index.vue'
import XhServiceMeasure from '@/components/createCom/XhServiceMeasure.vue' import XhServiceMeasure from '@/components/createCom/XhServiceMeasure.vue'
// import XhRadio from '@/components/createCom/XhRadio.vue' // import XhRadio from '@/components/createCom/XhRadio.vue'
export default { export default {
...@@ -160,9 +157,6 @@ ...@@ -160,9 +157,6 @@
}] }]
}, },
submitBtnStatus: false, submitBtnStatus: false,
takeStatus: false,
fileIndex: null,
files: [],
completeCheckStatus: false, completeCheckStatus: false,
completeCheckResult: [], completeCheckResult: [],
waitHandlerPanelIndex: 0, waitHandlerPanelIndex: 0,
...@@ -182,8 +176,7 @@ ...@@ -182,8 +176,7 @@
XhScan, XhScan,
XhPicker, XhPicker,
XhTime, XhTime,
XhServiceMeasure, XhServiceMeasure
'take-photo': takePhoto
}, },
created() { created() {
// console.log(allComponents,'allComponents') // console.log(allComponents,'allComponents')
...@@ -360,11 +353,6 @@ ...@@ -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){ tabsChange(index){
this.tabIndex = index this.tabIndex = index
this.arr = [] this.arr = []
...@@ -375,11 +363,6 @@ ...@@ -375,11 +363,6 @@
this.getMenuItemTop() this.getMenuItemTop()
}) })
}, },
closeTake(images) {
this.takeStatus = false
//const newFile = this.files[this.fileIndex].concat(images)
this.$set(this.files, this.fileIndex, images)
},
// 字段的值更新 // 字段的值更新
fieldValueChange(data) { fieldValueChange(data) {
const groupItem = this.list[this.tabIndex].items[data.groupIndex] 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