zhaoxiaoqiang1
2026-01-04 f1d30d03186c79ca2cbcfe60d6d2ce7d73fba97b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
<!--
 * @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>