riku
2024-11-20 83ac952bb66518e7ce190b08741fdef28edcfd4f
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
<template>
  <div class="main">
    <div class="filters" v-if="false">
      <el-select
        v-for="(key_select, index_select) of filters.keys()"
        :placeholder="key_select.text"
      >
        <el-option
          v-for="(key_option, index_option) in filters.get(key_select.key)"
          :key="key_option.key"
          :value="key_option.value"
          :label="key_option.label"
        >
        </el-option>
      </el-select>
    </div>
    <div class="btns" v-if="!readonly">
      <el-button size="small" type="primary" @click="sendSelectedImg(true)">确定</el-button>
      <el-button size="small" type="primary" @click="sendSelectedImg(false)">取消</el-button>
    </div>
 
    <div class="center">
      <el-descriptions>
        <el-descriptions-item label="总数">
          <span>{{ this.imgPathsDataSourceCopy.length }}</span>
        </el-descriptions-item>
      </el-descriptions>
      <el-tabs v-model="activeId" type="card">
        <el-tab-pane v-for="item in typeList" :label="item.label" :name="item.id"> </el-tab-pane>
      </el-tabs>
      <el-empty v-if="imgObjList.length == 0" description="暂无记录" />
      <el-scrollbar v-else class="imgs">
        <el-image
          v-for="(img, i) in imgObjList"
          :class="[Boolean(img.isSelect) ? 'selected' : 'noActive', 'image']"
          fit="cover"
          :src="img._picUrl"
          lazy
          @click="onSelect(img, i)"
        />
      </el-scrollbar>
    </div>
  </div>
</template>
<script>
import problemApi from '@/api/fysp/problemApi.js';
import mediafileApi from '@/api/fysp/mediafileApi.js';
import { $fysp } from '@/api/index.js';
import { useCloned } from '@vueuse/core';
export default {
  props: {
    filters: Map,
    // 是否以只读的形式查看当前页面
    readonly: {
      type: Boolean,
      default: false
    },
    imgPathsDataSource: {
      type: Array,
      default: () => []
    },
    defaultFile: {
      type: Array,
      default: () => []
    }
  },
  data() {
    return {
      // 无数据
      isEmpty: false,
      isClose: false,
      isAll: false,
      activeId: 0,
      typeList: [
        { id: 0, label: '监控设备' },
        { id: 1, label: '治理设备' },
        { id: 2, label: '生产设备' }
      ],
      typeImgMap: new Map(),
      imgPathsDataSourceCopy: [],
      imgObjList: []
    };
  },
  watch: {
    activeId: {
      handler(newId, oldId) {
        this.filterImgList()
      },
      immediate: true
    }
  },
  mounted() {
    this.initImgUrlList();
  },
  methods: {
    filterImgList() {
      this.imgObjList = this.imgPathsDataSourceCopy.filter((item) => {
        return item.topTypeId == this.activeId;
      });
    },
    initDefaultFile() {
      for (let item of this.imgPathsDataSourceCopy) {
        for (let defaultItem of this.defaultFile) {
          if (item._picUrl == defaultItem.url) {
            item.isSelect = true;
          }
        }
      }
    },
    // 获取图片资源
    initImgUrlList() {
      this.imgPathsDataSourceCopy = useCloned(this.imgPathsDataSource).cloned.value;
      this.imgObjList = this.imgPathsDataSourceCopy;
      this.initDefaultFile();
 
      this.initSelectedTab();
    },
    // 初始化刚开始选中的标签
    initSelectedTab() {
      if (this.typeList.length > 0) {
        this.activeId = this.typeList[0].id;
      }
      this.filterImgList()
    },
    onSelect(img, i) {
      // if (i == 2 && !this.isAll) {
      //   this.getAllImgList();
      //   this.isAll = true;
      // } else {
      //   if (this.readonly) {
      //     return;
      //   }
      //   img.isSelect = !Boolean(img.isSelect);
      // }
 
      if (this.readonly) {
        return;
      }
      img.isSelect = !img.isSelect;
    },
    sendSelectedImg(isOk) {
      let result = [];
      if (!isOk) {
        this.$emit('selectPhonoEvent', result);
      }
      for (const item of this.imgPathsDataSourceCopy) {
        if (item.isSelect == true) {
          result.push(item);
        }
      }
      this.isClose = true;
      this.$emit('selectPhonoEvent', result);
    }
  }
};
</script>
<style scoped>
.center {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.text {
  padding: 20px;
}
 
.main {
  margin: 0 auto; /* 使父元素居中 */
  height: 100%;
  width: 100%;
}
 
.btns {
  /* height: 10%; */
}
/* 
  .img_types {
    margin: 0 auto;
    height: 440px;
    width: 900px;
    flex-grow: 1;
    overflow-y: hidden ;
    padding: 3%;
    flex-wrap: wrap;
    overflow: hidden;
  } */
 
.imgs {
  height: 50vh;
  width: 90%;
  min-height: 100px !important;
  /* border-style:solid;
      border-radius: 1px; */
  /* height: 100%; */
  flex-grow: 1 !important;
  overflow-y: auto !important;
  /* 内容的内边距 */
  display: flex !important;
  flex-wrap: wrap !important;
  /* overflow: hidden; */
}
 
.image {
  height: 210px;
  width: 200px;
  border-radius: 4px;
}
 
.active {
  padding: 5px;
  width: 20%;
  height: 200px;
  border: 0.5rem outset rgb(52, 155, 4);
}
 
.selected {
  padding: 5px;
  color: #4abe84;
  box-shadow: 0 2px 7px 0 rgba(85, 110, 97, 0.35);
  border: 1px solid rgba(74, 190, 132, 1);
}
 
.selected:before {
  content: '';
  position: absolute;
  right: 0;
  bottom: 0;
  border: 17px solid #4abe84;
  border-top-color: transparent;
  border-left-color: transparent;
}
 
.selected:after {
  content: '';
  width: 5px;
  height: 12px;
  position: absolute;
  right: 6px;
  bottom: 6px;
  border: 2px solid #fff;
  border-top-color: transparent;
  border-left-color: transparent;
  transform: rotate(45deg);
}
 
.noActive {
  padding: 5px;
}
 
.blurry {
  filter: blur(3px);
}
.filters {
  display: flex;
  padding: 5px;
}
 
::v-deep .el-dialog__body {
  height: 60vh;
  padding: 10px calc(var(--el-dialog-padding-primary) + 10px) !important;
}
</style>