admin-web/src/views/stock/transfer/transferApplication/detail.vue
@@ -1,6 +1,6 @@
<template>
  <win-md class="stock-detail" :title="setting.title" @close="close" :width="'800px'" :loading="loading">
    <div v-loading="loading">
      <el-row :gutter="20">
        <el-col :span="8">
          <span>调拨单号:</span>
@@ -71,6 +71,17 @@
          </el-table-column>
        </el-table>
      </div>
    <div id="uploadPreviewImages" style="display: none">
      <span v-for="(src, index) in fileList" :key="index">
        <img
            v-if="checkImg(src.name)"
            class="v-img"
            :src="src.url"
            :alt="src.name"
            style="width: 100px; height: 100px"
        />
      </span>
    </div>
  </win-md>
</template>
@@ -79,6 +90,12 @@
import * as DateFormatter from '@/utils/DateFormatter';
import winMd from '@/components/win/win-md';
import transfer from '../../../mixins/transfer';
import {getDownUrl} from "@/utils/base";
import Viewer from 'viewerjs';
import 'viewerjs/dist/viewer.css';
let viewer = null;
export default {
  mixins: [transfer],
@@ -86,7 +103,8 @@
  props: {
    setting: {
      type: Object,
      default: () => {},
      default: () => {
      },
    },
  },
  data() {
@@ -107,9 +125,50 @@
      this.detail = res;
      this.fileList = this.detail.procureDoc ? JSON.parse(this.detail.procureDoc) : [];
      this.loading = false;
      this.$nextTick(() => {
        this.initPreviewImg();
      });
    });
  },
  methods: {
    initPreviewImg() {
      if (viewer != null) {
        viewer.destroy();
      }
      const ViewerDom = document.querySelector('#uploadPreviewImages');
      viewer = new Viewer(ViewerDom, {});
    },
    handlePreview(file) {
      if (!this.checkImg(file.name)) {
        return false;
      }
      let index = 0;
      for (let i = 0; i < this.fileList.length; i++) {
        const f = this.fileList[i];
        if (this.checkImg(f.name)) {
          if (file.id == f.id) {
            break;
          }
          index++;
        }
      }
      viewer.view(index);
    },
    checkImg(name) {
      const suffix = name.substring(name.lastIndexOf('.'), name.length);
      const imgArray = ['.jpg', '.jpeg', '.png', '.bmp'];
      if (imgArray.indexOf(suffix) < 0) {
        return false;
      }
      return true;
    },
    getUrl(path) {
      if (path.substr(0, 7).toLowerCase() == 'http://' || path.substr(0, 8).toLowerCase() == 'https://') {
        return path;
      } else {
        return getDownUrl() + path;
      }
    },
    close() {
      this.$emit('close');
    },