<!--
|
* @Descripttion:
|
* @version:
|
* @Author: Pengjiantian
|
* @Date: 2019-08-26 15:08:09
|
* @LastEditors : PengJianTian
|
* @LastEditTime : 2019-12-26 17:23:32
|
-->
|
<template>
|
<div>
|
<router-link to="/area/building/index">
|
<el-button circle size="mini" class="returnList" >
|
<i class="el-icon-back">返回列表</i>
|
</el-button>
|
</router-link>
|
<el-form label-position="right" :model="form" ref="form">
|
<el-row>
|
<p class="title">基本信息</p>
|
<!-- <form-input :config='config.productname' v-model='form.productname'></form-input>-->
|
<form-input :config="config.serialno" v-model="form.serialno" v-if="form.serialno" ></form-input>
|
<project-name v-model="form.productname" :config='config.productname' @setProjectName="handelProductName" :modify="buildParams.operation"></project-name>
|
<form-input :config="config.shproduct" v-model="form.shproduct"></form-input>
|
<form-input :config="config.ispairkingfloor" v-model="form.ispairkingfloor" @input="handelFloor"></form-input>
|
<!-- <form-input :config='config.buildname' v-model='form.buildname'></form-input>-->
|
<build-name
|
:shproduct="form.shproduct"
|
:projectId="projectId"
|
v-model="form.buildname"
|
@setBuildName="handleBuildName"
|
></build-name>
|
<!-- :ispairkingfloor="form.ispairkingfloor" -->
|
<!-- <form-input :config="config.buildcode" v-model="form.buildcode"></form-input> -->
|
<form-input :config="config.buildid" v-model="form.buildid"></form-input>
|
<form-input :config="config.codemodel" v-model="form.codemodel"></form-input>
|
<form-input :config="config.propertytype" v-model="form.propertytype"></form-input>
|
<form-input :config="config.buildtransstatus" v-model="form.buildtransstatus"></form-input>
|
<form-input :config="config.propertyyear" v-model="form.propertyyear"></form-input>
|
<form-input :config="config.housedate" v-model="form.housedate"></form-input>
|
<form-input :config="config.houseoutdate" v-model="form.houseoutdate"></form-input>
|
<form-input :config="config.houseproice" v-model="form.houseproice"></form-input>
|
<form-input :config="config.onehouse" v-model="form.onehouse"></form-input>
|
<form-input :config="config.twohouse" v-model="form.twohouse"></form-input>
|
<form-input :config="config.sum" v-model="form.sum"></form-input>
|
<bank-select :config="config.bank" v-model="form.bank"></bank-select>
|
<form-input :config="config.buildloanenddate" v-model="form.buildloanenddate"></form-input>
|
<form-input :config="config.buildtype" v-model="form.buildtype"></form-input>
|
<form-input :config="config.cloudloasize" v-model="form.cloudloasize"></form-input>
|
</el-row>
|
</el-form>
|
<el-form class='photoData' ref='imgForm'>
|
<el-row>
|
<p class="title">影像资料信息</p>
|
<div class="imageData">
|
<el-card class="box-card" v-if="state" style="border:none">
|
<div class="images" v-for="(item,index) in items" :key="index">
|
<p class="title-half"><!-- 标题 -->
|
<i v-if="item.required">*</i> <!-- 是否必填 -->
|
{{item.description}}
|
<span>{{item.count?`(${item.count}张)`:''}}</span><!-- 当前影像多少张 -->
|
</p>
|
<!-- -->
|
<div class="imagesList"> <!-- 包含所有图片的最外层 -->
|
<div v-for="(image,i) in item.images" :key="i" v-show="item.isShow?true:i>2?false:true">
|
<span class="el-icon-error" @click="handleDelete(image.attachmentno)"></span> <!-- 删除图片 -->
|
<img
|
src="@/assets/PDF.svg"
|
v-if="image.imagetype=='PDF'"
|
alt
|
@click="handleImageClick(image,item.objectNo,item.docType)"
|
/> <!--上传的pdf显示的图片 -->
|
<img
|
src="@/assets/excel.svg"
|
v-else-if="image.imagetype=='XLSX'"
|
alt
|
@click="handleImageClick(image,item.objectNo,item.docType)"
|
/>
|
<img
|
src="@/assets/ppt.svg"
|
v-else-if="image.imagetype=='PPTX'"
|
alt
|
@click="handleImageClick(image,item.objectNo,item.docType)"
|
/>
|
<img
|
src="@/assets/word.svg"
|
v-else-if="image.imagetype=='DOCX'"
|
alt
|
@click="handleImageClick(image,item.objectNo,item.docType)"
|
/>
|
<!-- <img :src="child.url" alt @click="previewImage(child,item.isedit)" /> --> <!-- 上传图片则图片显示正常 -->
|
<img :src="image.url" v-else @click="handleImageClick(image,item.objectNo,item.docType)" />
|
</div>
|
<img
|
src="@/assets/images/hide.png"
|
alt
|
v-show="item.isShow&&item.images.length > 3"
|
@click="hide(item,index)"
|
/><!-- 多张图右下角的显示图标 -->
|
<img
|
src="@/assets/images/show.png"
|
alt=""
|
v-show="!item.isShow&&item.images.length > 3"
|
@click="show(item)"
|
/><!-- 多张图右下角的显示图标 -->
|
<!-- 图片上传 -->
|
<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"
|
:disabled="isUpload"
|
>
|
<i class="el-icon-plus"></i>
|
</el-upload>
|
</div>
|
</div>
|
<!-- <div class="imagesFloat"></div> -->
|
</div>
|
</el-card>
|
</div>
|
</el-row>
|
</el-form>
|
</div>
|
</template>
|
|
<script>
|
import '@/views/area/style/images.styl'
|
import { saveNewBuild, qryBuildDetail, queryBuildImageInfo, addBuildImage, deleteBuildImage, saveTempBuild } from '@/api/area/building'
|
import FormInput from './components/FormInput'
|
import ProjectName from './components/ProjectName'
|
import BuildName from './components/BuildName'
|
import BankSelect from './components/BankSelect'
|
import BuildInfoData from './BuildInfoData'
|
import ImageInfo from './ImageInfo'
|
import { mapState } from 'vuex'
|
import { communal } from '@/views/area/mixins'
|
export default {
|
mixins: [ communal ],
|
components: { FormInput, ProjectName, BuildName, BankSelect, ImageInfo },
|
data: function() {
|
return {
|
projectId: '',
|
form: {
|
serialno: '',
|
projectid: '',
|
productname: '',
|
shproduct: '',
|
ispairkingfloor: '',
|
buildname: '',
|
buildid: '',
|
codemodel: '',
|
propertytype: '',
|
buildtransstatus: '',
|
propertyyear: '',
|
housedate: '',
|
houseoutdate: '',
|
houseproice: '',
|
onehouse: '',
|
twohouse: '',
|
sum: '',
|
bank: '',
|
buildloanenddate: '',
|
buildtype: '02',
|
cloudloasize: '',
|
// buildid: ''
|
},
|
oldForm: {},
|
objectno: '',
|
// 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'
|
},
|
serialno: '',
|
imagesNull: false,
|
state: false, // 图片请求是否请求回来的状态
|
uploadIndex: 0,
|
}
|
},
|
created() {
|
this.initForm()
|
this.getForm()
|
},
|
computed: {
|
isUpload() {
|
const { productname, ispairkingfloor, buildname, propertytype, buildtransstatus, propertyyear, housedate } = this.form
|
if (productname && ispairkingfloor && buildname && propertytype && buildtransstatus && propertyyear && housedate) {
|
return false
|
} else {
|
return true
|
}
|
},
|
...mapState({
|
buildParams: state => state.risk.buildParams
|
})
|
},
|
watch: {
|
'config.shproduct': function(newVal){},
|
// 社会化:否 车位楼层:否 => 房号编码模式不可选
|
'form.shproduct': function(newVal) {
|
if (newVal === '0' && (this.form.ispairkingfloor === '0' || this.form.ispairkingfloor === '')) {
|
this.config.codemodel.readonly = true
|
} else {
|
this.config.codemodel.readonly = false
|
}
|
}
|
},
|
methods: {
|
async initForm() {
|
this.config = BuildInfoData
|
// if (!this._.isEmpty(this.buildParams.serialNo)) {
|
let params = { serialNo: this.buildParams.serialNo }
|
this.serialno = this.buildParams.serialNo
|
let res = await qryBuildDetail(params)
|
Object.assign(this.form, res.result)
|
// 克隆一份旧数据
|
Object.assign(this.oldForm, this.form)
|
// console.log(this.oldForm)
|
// console.log(this.form)
|
// }
|
},
|
// 初始化图片列表
|
getForm(i) {
|
let params = {
|
serialno: this.buildParams.serialNo,
|
}
|
queryBuildImageInfo(params).then(res => {
|
if (res.code == '00') {
|
res.result.forEach((value, index) => {
|
if (value.images.length < 4) {
|
value.isShow = true
|
} else {
|
value.isShow = false
|
}
|
if (value.images.length >= 4) {
|
if (i === index) {
|
this.show(value)
|
} else {
|
this.hide(value)
|
}
|
}
|
value.images.forEach((item) => {
|
// item.imagetype = item.filename.split('.')[1].toUpperCase()
|
item.imagetype = item.filename.split('.').slice(-1).toString().toUpperCase()
|
})
|
})
|
}
|
this.items = res.result
|
this.state = true
|
})
|
},
|
setIndex(index) {
|
const { isUpload } = this
|
if (isUpload) {
|
this.$message.warning('请先录入基本信息!')
|
}
|
this.index = index
|
this.tempBuildMsg()
|
// if(index == 0){
|
// this.imagesNull = true
|
// }
|
},
|
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
|
if (this.serialno) {
|
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(this.index)
|
}
|
})
|
}
|
} else {
|
this.$message('图片上传失败,请检查必填项!')
|
}
|
},
|
/* 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 attachmentno = image.attachmentno
|
let serialno = objectno
|
let objectType = 'jbo.customer.SH_BUILD'
|
let type = '4' // 1-项目 2-企业 3-合作方 4-楼栋
|
let params = `attachmentno=${attachmentno}&serialno=${serialno}&objectno=${objectno}&objectType=${objectType}&typeno=${typeno}&type=${type}`
|
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'
|
)
|
},
|
handleSubmit() {
|
this.$refs['form'].validate(valid => {
|
if (valid && Boolean(this.form.buildname)) {
|
let params = {
|
serialno: this.buildParams.serialNo,
|
objectno: this.objectno,
|
isTempSave: false
|
}
|
params = Object.assign({}, this.form, params)
|
// console.log(params)
|
// if(this.imagesNull){
|
saveNewBuild(params).then(res => {
|
if (res.code === '00') {
|
this.$store.state.risk.buildParams.serialNo = res.result.serialno
|
this.$store.state.risk.buildParams.objectType = res.result.objecttype
|
this.oldForm = Object.assign(this.oldForm, this.form)
|
this.$emit('bulidICommit')
|
}
|
})
|
// }else{
|
// this.$message.error('影像资料未上传')
|
// }
|
} else {
|
this.$message.warning('当前页面存在必填项未录入或数据录入错误,请检查!')
|
return false
|
}
|
})
|
},
|
handleSave() {
|
let isSave = true
|
// this.$confirm(`当前有数据未保存,是否保存当前数据`, '保存信息确认', {
|
// confirmButtonText: '保存',
|
// cancelButtonText: '取消',
|
// customClass: 'building_messages_box',
|
// confirmButtonClass: 'building_messages_box_confirm',
|
// cancelButtonClass: 'building_messages_box_cancel',
|
// center: true
|
// })
|
// .then(() => {
|
this.$refs['form'].validate((valid) => {
|
if (valid && Boolean(this.form.buildname)) {
|
let params = {
|
serialno: this.buildParams.serialNo,
|
objectno: this.buildParams.objectNo,
|
projectid: this.projectId,
|
isTempSave: true
|
}
|
params = Object.assign({}, this.form, params)
|
params.projectid = this.buildParams.projectid
|
// console.log(params)
|
saveNewBuild(params).then(res => {
|
if (res.code === '00') {
|
this.$message.success('保存成功!')
|
this.$store.state.risk.buildParams.serialNo = res.result.serialno
|
this.serialno = res.result.serialno
|
this.oldForm = Object.assign(this.oldForm, this.form)
|
}
|
})
|
} else {
|
this.$message.warning('当前页面存在必填项未录入或数据录入错误,请检查!')
|
isSave = false
|
return false
|
}
|
})
|
// })
|
// .catch(() => {});
|
return isSave
|
},
|
handelProductName(value) {
|
this.objectno = value.serialNo
|
if (this.form.productname !== value.productname) {
|
this.form.productname = value.productname
|
this.form.projectid = value.projectId
|
this.form.ispairkingfloor = ''
|
this.form.buildname = ''
|
this.form.buildid = ''
|
this.form.codemodel = ''
|
this.form.propertytype = ''
|
this.form.buildtransstatus = ''
|
this.form.propertyyear = value.propertyyear
|
this.form.shproduct = value.shproduct
|
this.form.housedate = ''
|
this.form.houseoutdate = ''
|
this.form.houseproice = ''
|
this.form.onehouse = ''
|
this.form.twohouse = ''
|
this.form.sum = ''
|
this.form.bank = ''
|
this.form.cloudloasize = ''
|
this.projectId = value.projectId
|
}
|
/* this.form.productname = value.productname
|
this.form.propertyyear = value.propertyyear
|
this.form.shproduct = value.shproduct
|
this.projectId = value.projectId */
|
},
|
handleBuildName(value) {
|
// console.log(value)
|
this.form.buildcode = value.buildcode
|
this.form.buildname = value.buildname
|
this.form.codemodel = value.codemodel
|
this.form.buildid = value.buildid
|
this.form.propertytype = value.propertytype
|
},
|
handelFloor(value) {
|
this.form.ispairkingfloor = value
|
},
|
// 临时保存楼栋基本信息
|
tempBuildMsg() {
|
let isSave = true
|
if (!this.serialno) {
|
if(this.isPost) return
|
this.isPost = true
|
this.$refs['form'].validate((valid) => {
|
if (valid && Boolean(this.form.buildname)) {
|
let params = {
|
serialno: this.buildParams.serialNo,
|
objectno: this.objectno,
|
projectid: this.projectId,
|
isTempSave: true
|
}
|
params = Object.assign({}, this.form, params)
|
try {
|
saveTempBuild(params).then(res => {
|
if (res.code === '00') {
|
this.serialno = res.result.serialno
|
this.$store.state.risk.buildParams.serialNo = res.result.serialno
|
}
|
this.isPost = false
|
})
|
} catch (error) {
|
this.isPost = false
|
|
}
|
|
} else {
|
// this.$message.warning('当前页面存在必填项未录入或数据录入错误,请检查!')
|
this.isPost = false
|
isSave = false
|
return false
|
}
|
})
|
return isSave
|
}
|
},
|
// 展开图片
|
show(row) {
|
row.isShow = true
|
},
|
// 收起图片
|
hide(row) {
|
row.isShow = false
|
},
|
},
|
beforeRouteLeave (to, from, next) {
|
// console.log(this.oldForm)
|
// console.log(this.form)
|
for (const key in this.oldForm) {
|
if (this.oldForm.hasOwnProperty(key)) {
|
if (this.oldForm[key] != this.form[key]) {
|
// console.log(this.oldForm[key])
|
// console.log(this.form[key])
|
this.$confirm(`当前页面存在未保存的数据,是否放弃保存数据?`, '提示', {
|
confirmButtonText: '是',
|
cancelButtonText: '否',
|
customClass: 'building_messages_box',
|
confirmButtonClass: 'building_messages_box_confirm',
|
cancelButtonClass: 'building_messages_box_cancel',
|
center: true
|
})
|
.then(() => {
|
next()
|
})
|
.catch(() => {
|
})
|
return
|
}
|
}
|
}
|
next()
|
}
|
}
|
</script>
|
|
<style lang="stylus" scoped>
|
.returnList
|
width 83px
|
height 24px
|
background-color #eee
|
border-radius 12px
|
border none
|
margin-top 14px
|
i
|
font-size 12px
|
.el-icon-back
|
position relative
|
left -3px
|
top -3px
|
.photoData
|
padding-bottom 70px
|
</style>
|