From 87f07e589fb1c8103513a5fcc8febe3b14f5535f Mon Sep 17 00:00:00 2001
From: 石广澎 <shiguangpeng@163.com>
Date: 星期五, 01 十二月 2023 17:30:46 +0800
Subject: [PATCH] feat: 1、图片预览使用半路径 2、部门物品退回详情

---
 admin-web/src/views/stock/accessStock/outbound/detail.vue |   97 ++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 81 insertions(+), 16 deletions(-)

diff --git a/admin-web/src/views/stock/accessStock/outbound/detail.vue b/admin-web/src/views/stock/accessStock/outbound/detail.vue
index c973e30..ff58e36 100644
--- a/admin-web/src/views/stock/accessStock/outbound/detail.vue
+++ b/admin-web/src/views/stock/accessStock/outbound/detail.vue
@@ -1,5 +1,5 @@
 <template>
-  <win-md class="stock-detail" :title="setting.title" @close="close" :width="'800px'">
+  <win-md class="stock-detail" :title="setting.title" @close="close" :width="'800px'" :loading="loading">
     <el-row :gutter="20">
       <el-col :span="8">
         <span>鍑哄簱鍗曞彿锛�</span>
@@ -17,28 +17,30 @@
     <el-row :gutter="20" style="margin-top: 20px">
       <el-col :span="8">
         <span>鍒涘缓浜猴細</span>
-        <span>{{ detail.buyerName }}</span>
+        <span>{{ detail.operatorName }}</span>
       </el-col>
       <el-col :span="8">
         <span>鍑哄簱鏃堕棿锛�</span>
-        <span>{{ detail.incomeTime | formatTime }}</span>
+        <span>{{ detail.dealTime | formatTime }}</span>
       </el-col>
     </el-row>
-    <el-row :gutter="20" style="margin-top: 20px">
+    <el-row v-if="fileList && fileList.length" :gutter="20" style="margin-top: 20px">
       <el-col class="img-row" :span="24">
         <span>鍑哄簱鎵嬬画锛�</span>
-        <div class="img-box"></div>
+        <div class="img-box" v-for="(item, index) in fileList" :key="index" @click="handlePreview(item)">
+          <img class="img" :src="getUrl(item.path)" alt=""/>
+        </div>
       </el-col>
     </el-row>
-    <div class="goods-card" v-for="(goodsItem, goodsIndex) in detail.procureGoods" :key="goodsIndex">
+    <div class="goods-card" v-for="(goodsItem, goodsIndex) in detail.fromOutputGoods" :key="goodsIndex">
       <el-row :gutter="20">
         <el-col :span="8">
           <span>鐗╁搧鍒嗙被锛�</span>
-          <span>{{ goodsItem.baseCategoryName }}</span>
+          <span>{{ goodsItem.categoryName }}</span>
         </el-col>
         <el-col :span="8">
           <span>鐗╁搧鍚嶇О锛�</span>
-          <span>{{ goodsItem.goodsTemplateName }}</span>
+          <span>{{ goodsItem.goodsName }}</span>
         </el-col>
       </el-row>
       <el-table :data="goodsItem.models" :stripe="true" style="margin-top: 20px">
@@ -59,18 +61,34 @@
         </el-table-column>
         <el-table-column prop="counts" label="閲戦" align="center">
           <template slot-scope="scope">
-            {{ (scope.row.price * scope.row.counts).toFixed(2) }}
+            {{ scope.row.price * scope.row.counts | formatPrice}}
           </template>
         </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="getUrl(src.path)"
+            :alt="src.name"
+            style="width: 100px; height: 100px"
+        />
+      </span>
+    </div>
   </win-md>
 </template>
 <script>
-import { procureDetail } from '@/api/stock/procure/purchaseOrder';
+import {outputDetail} from '@/api/stock/accessStock';
 import winMd from '@/components/win/win-md';
 import * as DateFormatter from '@/utils/DateFormatter';
 
+import {getDownUrl} from "@/utils/base";
+import Viewer from 'viewerjs';
+import 'viewerjs/dist/viewer.css';
+
+let viewer = null;
 export default {
   components: { winMd },
 
@@ -82,16 +100,17 @@
   },
   data() {
     return {
+      loading:true,
+      fileList: [],
       detail: {
-        baseCategoryName: '',
+        categoryName: '',
         businessFormCode: '',
-        goodsTemplateName: '',
+        goodsName: '',
         agencyId: '',
         agencyName: '',
         states: '',
         createName: '',
-        time: '',
-        procureGoods: [{}, {}],
+        fromOutputGoods: [],
       },
     };
   },
@@ -100,14 +119,60 @@
       if (!time) return;
       return DateFormatter.LongToDateTime(time);
     },
+    formatPrice(price) {
+      return price / 100
+    }
   },
   created() {
-    procureDetail({ id: this.setting.id }).then((res) => {
+    outputDetail({ id: this.setting.id }).then((res) => {
       this.detail = res;
+      this.fileList = this.detail.doc ? JSON.parse(this.detail.doc) : [];
+      this.loading = false;
+      this.$nextTick(() => {
+        this.initPreviewImg();
+      });
     });
   },
   methods: {
-    close() {},
+    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'];
+      return imgArray.indexOf(suffix) >= 0;
+
+    },
+    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')
+    },
   },
 };
 </script>

--
Gitblit v1.9.1