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
<!--
 * @Author: your name
 * @Date: 2019-10-21 15:40:58
 * @LastEditTime: 2019-12-10 10:00:18
 * @LastEditors: PengJianTian
 * @Description: In User Settings Edit
 * @FilePath: /e:\Demo\cts-web\src\views\area\partner\update\ImageInfo.vue
 -->
<template>
  <div class="imageData">
    <el-row>
      <p class="title">影像资料信息</p>
    </el-row>
        <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" :class="!item.required ? 'not-require':''"><!-- 标题 -->
          <i v-if="item.transFormBeanDto.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>showImageNumber?false:true">
            <span class="el-icon-error" @click="handleDelete(image.docno,image.attachmentno)" v-if=" !eighty && item.transFormBeanDto.writeAble "></span>
            <!-- <span class="el-icon-error" @click="handleDelete(image.docno,image.attachmentno)" v-if=" item.transFormBeanDto.writeAble"></span> -->
            <img
              src="@/assets/PDF.svg"
              v-if="image.imagetype=='PDF'"
              alt
                            @click="handleImageClick(image,item.objectNo,item.docType)"
            />
            <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="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 > showImageIcon"
            @click="hide(item,index)"
          /><!-- 多张图右下角的显示图标 -->
          <img
            src="../../../../assets/images/show.png"
            alt=""
                        v-show="!item.isShow&&item.images.length > showImageIcon"
            @click="show(item)"
          /><!-- 多张图右下角的显示图标 -->
                    <!-- 图片上传 -->
          <div @click="setIndex(index)" style="display: inline-block" v-if="item.transFormBeanDto.writeAble">
                        <el-upload
                            action=""
                            :multiple="true"
                            list-type="picture-card"
                            :headers="uploadHeader"
                            :http-request="handleUpload"
                            :file-list="fileList"
                            :show-file-list="false"
                        >
                            <i class="el-icon-plus"></i>
                        </el-upload>
                    </div>
        </div>
      </div>
    </el-card>
    </div>
</template>
 
<script>
import '@/views/area/style/images.styl'
import { queryChannelImageInfo, addChannelImage, delChannelImage } from '@/api/area/partner'
import { mapState } from 'vuex'
import { communal } from '@/views/area/mixins'
export default {
  mixins: [ communal ],
  data: function() {
    return {
      loading: true,
      // url: process.env.VUE_APP_API_HOST + 'server/addProjectImage',
      items: '',
      // ChannelThreePartiesImage:'',
      // ChannelThreePartiesImageLength:'',
      index: '',
      dialogImageUrl: '',
      dialogVisible: false,
      fileData: '',
      fileList: [],
      newWindow: null,
      uploadHeader: {
        'Content-Type': 'multipart/form-data; boundary=ReaquestHeader'
            },
      state: false, // 图片请求是否请求回来的状态
    }
  },
  computed: {
    ...mapState({
      partnerParams: state => state.risk.partnerParams
    }),
    eighty() {
      const { partnerParams } = this
      const { phaseno } = partnerParams
      if (phaseno === '0080') {
        return true
      } else {
        return false
      }
    }
  },
  created() {
    this.getForm()
  },
  methods: {
    // async getForm(i,isDelete = false) {
    async getForm(i) {
      let params = {
        serialno: this.partnerParams.serialno,
        objectType: this.partnerParams.objectType
      }
      const { exhibitionAllImages } = this
            let res = await queryChannelImageInfo(params)
            res.result.forEach((value, index) => {
                if (value.images.length <= exhibitionAllImages) {
                    value.isShow = true
                } else {
                    value.isShow = false
        }
        if (value.images.length >= exhibitionAllImages) {
          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()
        })
        // 初始化时对当前阶段的图片进行缓存
        // if (!i && value.key === 'ChannelThreeParties') {
        //   this.ChannelThreePartiesImage = [...value.images]
        //   this.ChannelThreePartiesImageLength = value.images.length
        // }
      })
      // if (isDelete) {
      //   const { ChannelThreePartiesImageLength } = this
      //   const imagesIndex = res.result.findIndex(({key}) => key === 'ChannelThreeParties')
      //   if (imagesIndex > -1) {
      //     const { images } = res.result[imagesIndex]
      //     for (let i = ChannelThreePartiesImageLength;i<=ChannelThreePartiesImageLength; i++) {
      //       images[i].isDelete = isDelete
      //     }
      //     res.result[imagesIndex].images = [...images]
      //   }
      // }
      // console.log(this.ChannelThreePartiesImage,'---',res.result[4].images)
      // res.result[4].transFormBeanDto.writeAble = true
      this.items = res.result
            this.state = true
      this.loading = false
    },
    setIndex(index) {
      this.index = index
    },
    handleDelete(docno, attachmentno) {
      // this.$confirm(`请确认是否删除该图片!`, '删除图片确认', {
      //   confirmButtonText: '确定',
            //     cancelButtonText: '取消',
            //     customClass: 'par_messages_box',
            //     confirmButtonClass: 'par_messages_box_confirm',
            //     cancelButtonClass: 'par_messages_box_cancel',
      //   center: true
      // })
      //   .then(() => {
          let params = {
            attachmentno,
            docno
          }
          delChannelImage(params).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('description', this.items[this.index].description)
      formData.append('docType', this.items[this.index].docType)
      formData.append('serialNo', this.partnerParams.serialno)
      formData.append('objectType', this.partnerParams.objectType)
      if (this.fileData !== undefined) {
        addChannelImage(formData).then(res => {
          if (res.code === '00') {
            // if (this.partnerParams.phaseno === '0080') {
            //   this.getForm(this.index,true)
            // } else {
            this.getForm(this.index)
            // }
          }
        })
      }
    },
    handleSubmit() {
            // 检查必填项
            let verifyItem = this.items.filter(item => item.transFormBeanDto.required)
            let imageNull = verifyItem.some(item => this._.isEmpty(item.images))
            if (!imageNull) {
          this.$emit('handleNextPage', true)            
      } else {
        this.$message.warning('请检查必填项!')
      }
    },
    // 保存
    async handleSave(submitSave) {
      let params = {
        serialno: this.partnerParams.serialno,
        objectType: this.partnerParams.objectType
      }
      let res = await queryChannelImageInfo(params)
      // 统计影像资料必填的数目
      let index = 0
      for (let i = 0; i<res.result.length; i++) {
        if (res.result[i].transFormBeanDto.required) {
          index++
        }
      }
      // 检查必填图片列表长度是否为0
      for (let i = 0; i<res.result.length; i++) {
        if (res.result[i].transFormBeanDto.required) {
          if (res.result[i].count === 0) {
            if (!submitSave) {
              this.$message.warning('请检查必填项!')
            }
            break
          } else {
            // 只有当影像资料最后一项也上传了才提示保存成功
            if ( i === index - 1) {
              if (!submitSave) {
                this.$message.success('保存成功')
              }
              break
            }
          }
        }
      }
    },
    // 保存成功
    handleSaveDarft (submitSave) {
                this.$message.success('保存成功!')
        },
        handleImageClick(image, objectno, typeno) {
      // 根据路由模式判断路径分割方式
      const routeStr = location.href.includes('#') ? '#/' : ''
            // 图片点击事件
            let serialno = image.docno
            let attachmentno = image.attachmentno
      let objecttype = this.partnerParams.objectType
            let type = '3' // 1-项目 2-企业 3-合作方
            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'
            )
        },
        // 展开图片
        show(row) {
      row.isShow = true
    },
    // 收起图片
    hide(row) {
      row.isShow = false
    },
  }
}
</script>
 
<style scoped lang="stylus"></style>