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
<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>