上传多张照片
This commit is contained in:
@@ -480,12 +480,7 @@ export const errorType = (row) => post('api/pda/sb/errorType', {})
|
||||
// 1.6故障等级
|
||||
export const errorLevel = (row) => post('api/pda/sb/errorLevel', {})
|
||||
// 1.7报修
|
||||
export const repairs = (code, id, desc, level) => post('api/pda/sb/repairs', {
|
||||
device_code: code,
|
||||
device_faultclass_id: id,
|
||||
fault_desc: desc,
|
||||
fault_level: level
|
||||
})
|
||||
export const repairs = (data) => post2('api/pda/sb/repairs', data)
|
||||
// 1.8查询设备维修执行
|
||||
export const queryRepairs = (code, mflag) => post('api/pda/sb/queryRepairs', {
|
||||
device_code: code,
|
||||
|
||||
@@ -3,8 +3,9 @@
|
||||
<nav-bar :inner="true" title="拍照"></nav-bar>
|
||||
<section class="content mgt186">
|
||||
<div class="image_wraper">
|
||||
<div class="li_box img_box">
|
||||
<img>
|
||||
<div v-for="e in photos" class="li_box img_box relative" :key='e.num'>
|
||||
<img :src="e.data">
|
||||
<div class="iconfont error_icon" @click="delPhoto(e)"></div>
|
||||
</div>
|
||||
<div class="li_box iconfont add_pict_icon relative">
|
||||
<input
|
||||
@@ -16,36 +17,15 @@
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="image_wraper">
|
||||
<div class="image_wraper_i">
|
||||
<img v-show="unimgsrc === ''" src="../../../images/xinrui/nopict.svg">
|
||||
<img v-show="unimgsrc !== ''" id="imgshow">
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="submit-bar">
|
||||
<button class="btn submit-button" :class="{'btn-disabled': formData === ''}" :disabled="disabled" @click="_uploadPict">确认</button>
|
||||
<button class="btn submit-button" @click="handleDelImg">取消</button>
|
||||
<div class="btn submit-button relative">
|
||||
上传
|
||||
<input
|
||||
type='file'
|
||||
id='H5moreUp'
|
||||
ref='H5moreUp'
|
||||
accept='image/*'
|
||||
@change="loadImg"
|
||||
/>
|
||||
</div>
|
||||
<button class="btn submit-button" @click="toSure">确认</button>
|
||||
</section>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import NavBar from '@components/NavBar.vue'
|
||||
import {uploadPict, rawmaterialSava} from '@config/getData2.js'
|
||||
// import {rawmaterialSava} from '@config/getData2.js'
|
||||
// import axios from 'axios'
|
||||
// import qs from 'qs'
|
||||
export default {
|
||||
name: 'UploadPicts',
|
||||
components: {
|
||||
@@ -53,11 +33,8 @@ export default {
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
upImgUrl: '',
|
||||
unimgsrc: '',
|
||||
formData: '',
|
||||
disabled: false,
|
||||
result: {}
|
||||
photos: [],
|
||||
num: 0
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -71,65 +48,21 @@ export default {
|
||||
// 为文件读取成功设置事件
|
||||
reader.onload = (e) => {
|
||||
imgFile = e.target.result
|
||||
document.getElementById('imgshow').setAttribute('src', imgFile)
|
||||
this.unimgsrc = imgFile
|
||||
this.num = this.num + 1
|
||||
let obj = {data: imgFile, file: file, num: this.num, photo: file.name}
|
||||
this.photos.push(obj)
|
||||
}
|
||||
// 正式读取文件
|
||||
reader.readAsDataURL(file)
|
||||
this.formData = new FormData()
|
||||
this.formData.append('file', file)
|
||||
this.formData.append('user', 'laotie')
|
||||
},
|
||||
async _uploadPict () {
|
||||
this.disabled = true
|
||||
if (this.formData === '') {
|
||||
this.disabled = false
|
||||
return
|
||||
}
|
||||
// let uploadUrl = this.$store.getters.imgip + '/api/localStorage/pictures/'
|
||||
// axios.post(this.$store.getters.imgip + '/api/localStorage/pictures/', this.formData, {
|
||||
// Headers: {
|
||||
// 'Content-type': 'application/x-www-form-urlencoded'
|
||||
// }
|
||||
// }).then(res => {
|
||||
// if (res.code === '1') {
|
||||
// this.toast(res.desc)
|
||||
// }
|
||||
// })
|
||||
try {
|
||||
let data = {
|
||||
'formData': this.formData,
|
||||
'flag': true
|
||||
}
|
||||
let res = await uploadPict(data)
|
||||
if (res.code === '1') {
|
||||
// this.upImgUrl = uploadUrl + res.result.path
|
||||
this.toast(res.desc)
|
||||
this.result = res.result
|
||||
// this.formData = ''
|
||||
this._rawmaterialSava()
|
||||
} else {
|
||||
this.Dialog(res.desc)
|
||||
}
|
||||
this.disabled = false
|
||||
} catch (e) {
|
||||
this.disabled = false
|
||||
}
|
||||
delPhoto (e) {
|
||||
this.photos = this.photos.filter(el => (el.num !== e.num))
|
||||
},
|
||||
async _rawmaterialSava () {
|
||||
let obj = this.$store.getters.materObj !== '' ? Object.assign({}, this.$store.getters.materObj, this.result, {business_type: '01'}) : Object.assign({}, this.result, {business_type: '01'})
|
||||
let res = await rawmaterialSava(obj)
|
||||
if (res.code === '1') {
|
||||
this.$router.back()
|
||||
} else {
|
||||
this.Dialog(res.desc)
|
||||
toSure () {
|
||||
if (this.photos.length) {
|
||||
this.$store.dispatch('receivePlateArr', this.photos)
|
||||
}
|
||||
},
|
||||
handleDelImg () {
|
||||
this.unimgsrc = ''
|
||||
this.formData = ''
|
||||
this.$refs.H5moreUp.value = ''
|
||||
document.getElementById('imgshow').removeAttribute('src')
|
||||
this.$router.back()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -137,23 +70,28 @@ export default {
|
||||
|
||||
<style lang="stylus" scoped>
|
||||
@import '~@style/mixin'
|
||||
// >>>.content
|
||||
// height calc(100% - 2rem)
|
||||
.image_wraper
|
||||
width 100%
|
||||
padding-top .5rem
|
||||
.li_box
|
||||
_fj(center)
|
||||
float left
|
||||
width 30%
|
||||
.image_wraper_i
|
||||
position relative
|
||||
_wh(100%, 100%)
|
||||
overflow-y auto
|
||||
z-index 99
|
||||
_wh(2rem, 2rem)
|
||||
border .03rem dashed #c9c9c9
|
||||
border-radius 3px
|
||||
margin-bottom .2rem
|
||||
overflow hidden
|
||||
img
|
||||
_wh(100%, auto)
|
||||
z-index 99
|
||||
border-radius .1rem
|
||||
&:nth-child(3n+2)
|
||||
margin 0 calc((100% - 6rem) / 2)
|
||||
.error_icon
|
||||
position absolute
|
||||
top .01rem
|
||||
right .01rem
|
||||
_wh(.5rem, .5rem)
|
||||
line-height .5rem
|
||||
background-color rgba(0,0,0,.7)
|
||||
#H5moreUp
|
||||
position absolute
|
||||
top 0
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<section>
|
||||
<nav-bar :inner="true" title="设备报修"></nav-bar>
|
||||
<nav-bar title="设备报修"></nav-bar>
|
||||
<section class="content mgt186">
|
||||
<div class="filter-wraper">
|
||||
<search-box
|
||||
@@ -62,7 +62,7 @@
|
||||
<th>图片编号</th>
|
||||
</tr>
|
||||
<tr v-for="(e, i) in dataList" :key="i">
|
||||
<td>{{e.workorder_code}}</td>
|
||||
<td>{{e.photo}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
@@ -93,15 +93,14 @@ export default {
|
||||
val2: '',
|
||||
val3: '',
|
||||
dataList: [],
|
||||
pkId: '',
|
||||
pkObj: {},
|
||||
option1: [],
|
||||
active1: '',
|
||||
open1: false,
|
||||
option2: [],
|
||||
active2: '',
|
||||
open2: false,
|
||||
disabled1: false
|
||||
disabled1: false,
|
||||
formData: new FormData()
|
||||
}
|
||||
},
|
||||
beforeRouteLeave (to, from, next) {
|
||||
@@ -110,7 +109,14 @@ export default {
|
||||
}
|
||||
next()
|
||||
},
|
||||
activated () {},
|
||||
activated () {
|
||||
if (this.$store.getters.receivePlateArr.length) {
|
||||
this.dataList = this.$store.getters.receivePlateArr
|
||||
this.dataList.map(el => {
|
||||
this.formData.append('file', el.file)
|
||||
})
|
||||
}
|
||||
},
|
||||
created () {
|
||||
this._errorType()
|
||||
this._errorLevel()
|
||||
@@ -144,7 +150,15 @@ export default {
|
||||
try {
|
||||
let type = this.active1 !== '' ? this.option1[this.active1].value : ''
|
||||
let level = this.active2 !== '' ? this.option2[this.active2].value : ''
|
||||
let res = await repairs(this.val1, type, this.val2, level)
|
||||
this.formData.append('device_code', this.val1)
|
||||
this.formData.append('device_faultclass_id', type)
|
||||
this.formData.append('fault_desc', this.val2)
|
||||
this.formData.append('fault_level', level)
|
||||
let data = {
|
||||
'formData': this.formData,
|
||||
'flag': true
|
||||
}
|
||||
let res = await repairs(data)
|
||||
if (res.code === '1') {
|
||||
this.toast(res.desc)
|
||||
Object.assign(this.$data, this.$options.data())
|
||||
@@ -164,10 +178,6 @@ export default {
|
||||
query: {url: 'EquipRepair'}
|
||||
})
|
||||
},
|
||||
toCheck (e) {
|
||||
this.pkId = this.pkId === e.worktask_id ? '' : e.worktask_id
|
||||
this.pkObj = this.pkId === e.worktask_id ? e : {}
|
||||
},
|
||||
toggleItem1 () {
|
||||
if (!this.open1) {
|
||||
this.open1 = true
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
label="设备"
|
||||
v-model="val1"
|
||||
@handleChange="handleChange1"
|
||||
:seaShow="false"
|
||||
></search-box>
|
||||
</div>
|
||||
<div class="grid-wraper">
|
||||
|
||||
@@ -72,9 +72,7 @@ export default {
|
||||
}
|
||||
next()
|
||||
},
|
||||
activated () {
|
||||
this._queryMaintenance(this.val1)
|
||||
},
|
||||
activated () {},
|
||||
methods: {
|
||||
handleChange1 (e, type) {
|
||||
if (type) {
|
||||
@@ -88,8 +86,8 @@ export default {
|
||||
/** 设备查询 */
|
||||
async _queryMaintenance (e) {
|
||||
let res = await queryMaintenance(e, '1')
|
||||
if (res.code === '1') {
|
||||
this.dataList = [...res.content.rows]
|
||||
if (res.code === '1' && res.rows !== null) {
|
||||
this.dataList = [...res.rows]
|
||||
} else {
|
||||
this.Dialog(res.desc)
|
||||
}
|
||||
|
||||
@@ -126,11 +126,10 @@
|
||||
.add_pict_icon
|
||||
width 2rem
|
||||
height 2rem
|
||||
font-size 1rem
|
||||
font-size .6rem
|
||||
line-height 2rem
|
||||
color #c9c9c9
|
||||
text-align center
|
||||
border: .03rem dashed
|
||||
overflow hidden
|
||||
.add_pict_icon::before
|
||||
content: '\e653'
|
||||
Reference in New Issue
Block a user