<template>
|
<div id="index">
|
<el-container>
|
<el-main>
|
<el-row :gutter="20" id="images">
|
<el-col :span="12" v-for="(item, index) in items" :key="index">
|
<!-- <p class="title">{{ item.description }}</p>-->
|
<p class="title" :class="item.required?'image-title-required':''">{{ item.description }}</p>
|
<div class="imgList">
|
<div v-for="(image, index) in item.images" class="imgbox" :key="index">
|
<i class="el-icon-error" @click="handleDelete(image.attachmentno)"></i>
|
<!-- <img :src="image.url" @click="handleImageClick(image.attachmentno)" /> -->
|
<img :src="image.url" @click="handleImageClick(image,item.objectNo,item.docType)" />
|
</div>
|
<div @click="setIndex(index)" style="display: inline-block" >
|
<el-upload
|
action=""
|
:multiple="true"
|
list-type="picture-card"
|
:headers="uploadHeader"
|
:http-request="handleUpload"
|
:file-list="fileList"
|
:show-file-list="false"
|
>
|
<p><i class="el-icon-plus"></i><br />本地上传</p>
|
</el-upload>
|
</div>
|
</div>
|
</el-col>
|
</el-row>
|
</el-main>
|
</el-container>
|
</div>
|
</template>
|
|
<script>
|
import { queryBuildImageInfo, addBuildImage, deleteBuildImage } from '@/api/area/building'
|
import { mapState } from 'vuex'
|
import { communal } from '@/views/area/mixins'
|
export default {
|
mixins: [ communal ],
|
data: function() {
|
return {
|
// url: '',
|
// url:process.env.VUE_APP_API_HOST +'server/addBuildImage',
|
items: '',
|
index: '',
|
dialogImageUrl: '',
|
dialogVisible: false,
|
fileData: '',
|
fileList: [],
|
newWindow: null,
|
uploadHeader: {
|
'Content-Type': 'multipart/form-data; boundary=ReaquestHeader'
|
}
|
}
|
},
|
computed: {
|
...mapState({
|
buildParams: state => state.risk.buildParams
|
}),
|
},
|
created() {
|
this.getForm()
|
},
|
methods: {
|
getForm() {
|
let params = {
|
serialno: this.buildParams.serialNo,
|
}
|
queryBuildImageInfo(params).then(res => {
|
this.items = res.result
|
})
|
},
|
setIndex(index) {
|
this.index = index
|
},
|
handleDelete(value) {
|
this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning'
|
})
|
.then(() => {
|
deleteBuildImage(value).then(res => {
|
if (res.code === '00') {
|
this.$message.success('删除成功!')
|
this.getForm()
|
}
|
})
|
})
|
.catch(() => {})
|
},
|
handleUpload(file) {
|
this.fileData = file.file
|
let formData = new FormData()
|
formData.append('file', this.fileData)
|
formData.append('docNo', this.items[this.index].docNo)
|
formData.append('docType', this.items[this.index].docType)
|
formData.append('objectNo', this.buildParams.serialNo)
|
formData.append('objectType', this.buildParams.objectType)
|
if (this.fileData !== undefined) {
|
addBuildImage(formData).then(res => {
|
if (res.code === '00') {
|
this.getForm()
|
}
|
})
|
}
|
},
|
handleSubmit() {
|
let verifyItem = this.items.filter(item => item.required)
|
let imageNull = verifyItem.some(item => this._.isEmpty(item.images))
|
if (!imageNull) {
|
// this.$router.push({ path: '/area/building/index' })
|
return true
|
} else {
|
// this.$message.error('请检查必填项!')
|
return false
|
}
|
},
|
handleSave() {
|
this.$message.success('保存成功!')
|
},
|
handleImageClick(image,objectno,typeno) {
|
// 根据路由模式判断路径分割方式
|
const routeStr = location.href.includes('#') ? '#/' : ''
|
// 图片点击事件
|
let serialno = image.attachmentno
|
let objecttype = 'jbo.customer.SH_BUILD'
|
let type = '4' // 1-项目 2-企业 3-合作方 4-楼栋
|
let params = `serialno=${serialno}&objectno=${objectno}&objecttype=${objecttype}&typeno=${typeno}&type=${type}`
|
console.log(params);
|
this.newWindow = window.open(
|
`${location.origin}${process.env.VUE_APP_HOST_PATH}${routeStr}photoViewer?${params}`,
|
'newwindow',
|
'height=700px, width=800px, top=100px,left=400px, toolbar=no, menubar=no, scrollbars=yes, resizable=no,location=no, status=no'
|
)
|
},
|
/* handleImageClick (attachmentno) {
|
// 图片点击事件
|
let serialNo = this.buildParams.serialNo
|
this.newWindow = window.open(
|
`/#/area/building/imgDialog?serialNo=${serialNo}&attachmentno=${attachmentno}`,
|
'newwindow',
|
'height=600px, width=600px, top=100px,left=300px, toolbar=no, menubar=no, scrollbars=yes, resizable=no,location=no, status=no'
|
)
|
} */
|
}
|
}
|
</script>
|
|
<style scoped lang="stylus"></style>
|