scorpio пре 2 година
родитељ
комит
5fb5c3f220

+ 12 - 1
src/api/project/index.js

@@ -407,13 +407,24 @@ export default {
   /**
    * 项目照片
    */
-  photoProject(params) {
+  addPhotoProject(params) {
     return fetch(
       '/blade-project-manage-v2/project-dispatch/v2/save-project-address-pic',
       params,
       'post',
       'json'
     )
+  },
+  /**
+   * 获取项目地址相关照片
+   * @param params
+   * @returns {Promise | Promise<unknown>}
+   */
+  photoProject(params) {
+    return fetch(
+      '/blade-project-manage-v2/project-dispatch/v2/project-address-pic-list',
+      params
+    )
   }
 }
 

+ 1 - 1
src/views/project/componens/info1.vue

@@ -195,7 +195,7 @@ export default {
   methods: {
     save() {
       if (this.photoList.length > 0) {
-        this.$api.project.photoProject(this.photoList).then(res => {
+        this.$api.project.addPhotoProject(this.photoList).then(res => {
           if (res.code === 200) {
             console.log(res)
           }

+ 45 - 5
src/views/project/componens/map-picker.vue

@@ -38,7 +38,12 @@
           <span class="ml-20 font-12 grey-6">*请选择图片类型的文件</span>
         </div>
         <div class="img-content flex flex-justify-start hide-scrollbar mt-20">
-          <img :src="item.url" v-for="item in photoList" :key="item.url" />
+          <img
+            :src="item.url"
+            v-for="(item, index) in photoList"
+            :key="item.url"
+            @click="showImg(index)"
+          />
         </div>
         <div class="full-width flex flex-center flex-justify-end">
           <el-button type="primary" plain @click="show = false"
@@ -48,6 +53,12 @@
         </div>
       </div>
     </el-dialog>
+    <el-image-viewer
+      v-if="showImage"
+      :url-list="preList"
+      :initial-index="initial"
+      @close="showImage = false"
+    />
   </div>
 </template>
 
@@ -60,9 +71,14 @@ export default {
     filepicker
   },
   watch: {
+    projectId: {
+      type: String,
+      default: ''
+    },
     show: {
       handler(val) {
         if (val) {
+          this.getPhoto()
           setTimeout(() => {
             this.initMap()
           }, 1000)
@@ -92,12 +108,17 @@ export default {
     },
     latLng: {
       type: Array,
-      default: []
+      default: () => {
+        return []
+      }
     }
   },
   data() {
     return {
       show: false,
+      showImage: false,
+      initial: 0,
+      preList: [],
       map: null,
       geocoder: '',
       keyword: '相国',
@@ -113,10 +134,24 @@ export default {
         longitude: '',
         latitude: ''
       },
-      photoList: []
+      photoList: [],
+      editPhoto: false
     }
   },
   methods: {
+    getPhoto() {
+      this.$api.project
+        .photoProject({ projectId: this.projectId })
+        .then(res => {
+          if (res.code === 200) {
+            this.photoList = res.data.map(ele => {
+              ele.fileVO.url = ele.fileVO.filePath
+              return ele.fileVO
+            })
+            this.preList = this.photoList.map(ele => ele.url)
+          }
+        })
+    },
     initMap() {
       window._AMapSecurityConfig = {
         securityJsCode: 'b7c07b56f6647ae56ff3d926a42d9565'
@@ -201,7 +236,6 @@ export default {
           e.value = e.name + '(' + e.district + ')'
           return e
         })
-        console.log(tmp)
         cb(tmp)
       })
     },
@@ -210,9 +244,10 @@ export default {
       this.form.latitude = this.latitude
       this.form.longitude = this.longitude
       this.show = false
-      this.$emit('success', this.form, this.photoList)
+      this.$emit('success', this.form, this.editPhoto ? this.photoList : [])
     },
     filePicker(list) {
+      this.editPhoto = true
       const tmps = list
         .filter(ele => !api.offices.includes(ele.suffix))
         .map(ele => {
@@ -227,6 +262,11 @@ export default {
           }
         })
       this.photoList = this.photoList.concat(tmps)
+      this.preList = this.photoList.map(ele => ele.url)
+    },
+    showImg(index) {
+      this.initial = index
+      this.showImage = true
     },
     close() {
       // this.photoList.length = 0