Commit f048a79b authored by 李俊赕's avatar 李俊赕

完工配置页面

parent e1a2a29d
import { request } from '@/utils/request'
// import { getToken } from '@/utils/auth'
// 提交文件信息
export function submitInfo(query) {
return request({
url: '/wxh-cloud-rest/rest/thirdparty/haier/getAppreciationService',
method: 'get',
headers: { 'Content-Type': 'application/form-data' },
data: query
})
}
// export function getVap(query) {
// return request({
// url: '/wxh-cloud-rest/rest/thirdparty/haier/getVap',
// method: 'get',
// params: query
// })
// }
<template>
<div class="input-item">
<div class="label">{{item.label}}<span class="required">*</span></div>
<!-- <div class="required">*</div> -->
<div class="input-box img-box">
<div :key="index" class="img-item" v-for="(item, index) in imgList">
<img :src="item.src" />
<div class="close" @click="deleteImg(index)">
x
</div>
</div>
<img-uploader
:empty-img-src="require('@/assets/img/icon-img-empty.png')"
:icon-src="require('@/assets/img/add.png')"
@update="addFile"
></img-uploader>
</div>
</div>
</template>
<script>
import ImgUploader from '@/components/uploader/img-uploader'
// import {
// uploadFile
// } from '@/api/shzhida/order/service'
import { Toast } from 'mint-ui'
export default {
name: 'XhFiles',
components: {
'img-uploader': ImgUploader
},
data() {
return {
imgList: []
}
},
props: {
item: {
type: Object,
default() {
return [
{}
]
}
}
},
computed: {
},
watch: {
// 'item.value': function() {
// this.item.value.map(item => {
// this.imgList.push({ src: item })
// })
// }
},
mounted() {},
methods: {
// async uploadFile(item) {
// console.log(item)
// const fromData = new FormData()
// fromData.append('file', item.file)
// const result = await uploadFile(this.orderId, fromData)
// if (result.data.code === 200) {
// if (this.item.value) {
// this.item.value.push(result.data.data)
// } else {
// this.item.value = [result.data.data]
// }
// } else {
// if (result.data.message) {
// Toast({
// message: result.data.message,
// duration: 3000
// })
// }
// }
// },
checkSize(file) {
const size = 1
if (file.size > size * 1024 * 1024) {
Toast({
message: '图片大小不能超过' + size + 'M',
icon: 'none'
})
return false
}
return true
},
addFile(item) {
console.log(item, 'item')
if (!this.checkSize(item.file)) {
return
}
this.imgList.push(item)
this.item.value = this.imgList
// this.uploadFile(item)
},
deleteImg(index) {
this.imgList.splice(index, 1)
this.item.value = this.imgList
}
}
}
</script>
<style lang="less" scoped>
@import '~@/assets/css/func.less';
.input-item{
display: flex;
// display: block!important;
}
.label{
min-width:px2rem(160);
text-align: left;
}
.input-box{
// margin-left:px2rem(20);
flex:1;
// width:100%;
// padding:px2rem(20) 0 0 px2rem(20);
// min-height: px2rem(212);
// background: #f3f3f3;
display: flex;
}
.img-box{
flex-wrap: wrap;
.img-item{
position: relative;
margin-right:px2rem(20);
margin-bottom:px2rem(20);
width:px2rem(160);
height:px2rem(160);
img{
display: block;
width:100%;height:100%;
}
}
}
.close{
position: absolute;
right:0;
top:0;
width:px2rem(40);
height:px2rem(40);
padding:0 px2rem(10);
background: rgba(0,0,0,0.5);
line-height: px2rem(40);
font-size: px2rem(28);
color:#fff;
text-align: center;
img{
display: block;
width:100%;
height:100%;
}
}
.upload-box{
position: relative;
}
</style>
export { default as XhFiles } from './XhFiles'
<template>
<div class="about">
<div class="form-item" v-for="(item,index) in formList" :key="index">
<XhFiles :item="item" v-if="item.inputType==='file'"/>
</div>
<div class="btn-group">
<mt-button type="primary" @click="submitInfo">提交信息</mt-button>
</div>
</div>
</template>
<script>
import {
submitInfo
} from '@/api/renbao/order/service.js'
import {
XhFiles
} from './components/index.js'
import { Toast, Indicator } from 'mint-ui'
export default {
name: 'RenbaoOrderService',
components: {
XhFiles
},
data() {
return {
formList: [{
fieldName: 'chargerPointType0',
label: '完工前照片',
value: [],
inputType: 'file',
required: true
}, {
fieldName: 'chargerPointType1',
label: '完工过程照片',
value: [],
inputType: 'file',
required: true
}, {
fieldName: 'chargerPointType2',
label: '完成照片',
value: [],
inputType: 'file',
required: true
}, {
fieldName: 'chargerPointType3',
label: '验收照片',
value: [],
inputType: 'file',
required: true
}],
form: {},
loading: true
}
},
watch: {},
computed: {
},
created() {
this.scrollY = 0
// if (this.$route.query.orderId) {
// this.getOrderId(this.$route.query.orderId)
// }
},
mounted() {
},
methods: {
checkInfo() {
const data = {}
const formList = this.formList
let flag = true
let txt = ''
for (let i = 0; i < formList.length; i++) {
const item = formList[i]
if (item.required && item.value.length < 1) {
flag = false
txt = '请上传' + item.label
break
}
}
Toast({
message: txt,
icon: 'none',
duration: 3000
})
return flag
},
submitInfo() {
const data = {}
this.formList.map(item => {
data[item.fieldName] = item.value
})
if (!this.checkInfo()) {
return
}
Indicator.open('Loading...')
submitInfo(data).then((result) => {
Indicator.close()
if (result.data.code !== 200) {
Toast({
message: result.data.message || '请求错误',
icon: 'none',
duration: 3000
})
return false
}
}).catch((error) => {
console.log(error)
Toast({
message: '服务异常',
icon: 'none',
duration: 3000
})
})
console.log(data, 'data')
},
handleAvatarSuccess(res, file) {
this.imageUrl = URL.createObjectURL(file.raw)
},
beforeAvatarUpload(file) {
const isJPG = file.type === 'image/jpeg'
const isLt2M = file.size / 1024 / 1024 < 2
if (!isJPG) {
this.$message.error('上传头像图片只能是 JPG 格式!')
}
if (!isLt2M) {
this.$message.error('上传头像图片大小不能超过 2MB!')
}
return isJPG && isLt2M
}
}
}
</script>
<style lang="less" scoped>
@import '~@/assets/css/func.less';
.form-box{
padding:px2rem(20) 0;
}
.form-item{
padding:px2rem(20) px2rem(20);
}
/deep/ .input-item {
.required{
padding:0 px2rem(5);
line-height:px2rem(40);
font-size: px2rem(20);
color:red;
}
}
.btn-group{
position: fixed;
left:0;
right:0;
bottom:0;
display: flex;
padding:px2rem(30) px2rem(30);
box-shadow: 0 px2rem(-1) px2rem(5) rgba(0,0,0,0.05);
background: #fff;
.mint-button{
flex:1;
margin-right:px2rem(20);
font-size:px2rem(28);
&:last-child{margin-right: 0;}
}
}
</style>
This diff is collapsed.
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