石广澎
2023-12-02 f7163108fef21286a2b447f1958ee3204d7854d0
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
<template>
  <win-md class="stock-detail" title="部门物品退回单详情" @close="close" :loading="loading">
    <el-row :gutter="20">
      <el-col :span="8">
        <span>退回单号:</span>
        <span>{{detail.businessFormCode}}</span>
      </el-col>
      <el-col :span="8">
        <span>所属机构:</span>
        <span>{{detail.agencyName}}</span>
      </el-col>
      <el-col :span="8">
        <span>部门:</span>
        <span>{{detail.departmentName}}</span>
      </el-col>
    </el-row>
    <el-row :gutter="20" style="margin-top: 20px">
      <el-col :span="8">
        <span>退回人:</span>
        <span>{{detail.operatorName}}</span>
      </el-col>
      <el-col :span="8">
        <span>退回时间:</span>
        <span>{{detail.dealTime|formatTime}}</span>
      </el-col>
    </el-row>
    <el-row :gutter="20" style="margin-top: 20px">
      <el-col class="img-row" :span="24">
        <span>退回手续:</span>
        <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.goods" :key="goodsIndex">
      <el-row :gutter="20">
        <el-col :span="7">
          <span>物品分类:</span>
          <span>{{ goodsItem.categoryName }}</span>
        </el-col>
        <el-col :span="8">
          <span>物品名称:</span>
          <span>{{ goodsItem.baseGoodsTemplateName }}</span>
        </el-col>
        <el-col :span="3">
          <span>类别:</span>
          <span>{{ goodsItem.classification }}类</span>
        </el-col>
        <el-col :span="6">
          <span>分发单号:</span>
          <span>{{ goodsItem.businessFormCode }}</span>
        </el-col>
      </el-row>
      <div class="card3" v-for="(mItem,k) in mItem" :key="k">
        <el-row v-if="mItem[0].goodsUserName" :gutter="24" type="flex" align="middle">
          <el-col :span="8">
            <span>规格型号:</span>
            <span>{{ mItem[0].baseGoodsModelsName }}</span>
          </el-col>
          <el-col :span="4">
            <span>单位:</span>
            <span>{{ mItem[0].unit }}</span>
          </el-col>
        </el-row>
        <el-table :data="mItem" style="margin-top: 15px">
          <el-table-column prop="baseGoodsModelsName" label="规格型号" align="left" v-if="!mItem[0].goodsUserName"/>
          <el-table-column prop="unit" label="单位" align="center" v-if="!mItem[0].goodsUserName"/>
          <el-table-column prop="goodsUserName" label="使用人" align="left" v-if="mItem[0].goodsUserName"/>
          <el-table-column prop="useCount" label="在用数量" align="center"/>
          <el-table-column prop="counts" label="报废数量" align="center"/>
          <el-table-column prop="scrappedName" label="报废原因" align="left"/>
        </el-table>
      </div>
    </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 {scrappedDetail} from '@/api/deptGoods/scrap';
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 },
  props: {
    setting: {
      type: Object,
      default: () => {},
    },
  },
  data() {
    return {
      loading: true,
      fileList: [],
      detail: {
        baseCategoryName: '',
        businessFormCode: '',
        goodsTemplateName: '',
        procureDoc: '',
        agencyId: '',
        agencyName: '',
        states: '',
        createName: '',
        time: '',
        procureGoods: [{}, {}],
        fileKey: Math.random(),
      },
    };
  },
  filters: {
    formatTime(time) {
      if (!time) return '-';
      return DateFormatter.LongToDateTime(time);
    },
    formatPrice(price) {
      return price / 100
    }
  },
  created() {
    scrappedDetail({ id: this.setting.id }).then((res) => {
      this.detail = res;
      this.loading = false
      this.fileList = this.detail.procureDoc ? JSON.parse(this.detail.procureDoc) : [];
      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++;
        }
      }
      // this.fileList.forEach((f, i) => {
      //   if (file.uid == f.uid) {
      //     index = i
      //   }
      // })
      // document.querySelector('#uploadPreviewImages').children[0].click()
      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');
    },
  },
};
</script>
<style lang="scss" scoped>
//@import url(../../../../styles/store.scss);
.card3 {
  padding: 15px;
  margin-top: 20px;
  border-radius: 2px;
  background: #ffffff;
}
</style>