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
<template>
  <FYImageSelectDialog
    title="场景图片"
    :typeList="typesList"
    :typeImgMap="typesMap"
  ></FYImageSelectDialog>
</template>
<script>
import mediafileApi from '@/api/fysp/mediafileApi.js';
import { $fysp } from '@/api/index.js';
export default {
  props: {
    subtask: {
      type: Object,
      efault: {}
    }
  },
  data() {
    return {
      // 无数据
      typesList: [],
      typesMap: new Map(),
    };
  },
  mounted() {
    this.getGroupImgs();
  },
  methods: {
    // 图片分类
    getGroupImgs() {
      mediafileApi.getRoutineByStGuid(this.subtask.stGuid).then((res) => {
        let typeList = [];
        let typeMap = new Map();
        function hasThisTypeName(typeName) {
          return typeList.map((item) => item.typeName).indexOf(typeName) != -1;
        }
        function addNewType(typeId, typeName, img) {
          typeList.push({
            typeId: typeId,
            typeName: typeName
          });
          typeMap.set(typeId, [img]);
        }
        function addToThisType(typeId, img) {
          typeMap.get(typeId).push(img);
        }
        const data = res.data;
        for (const e of data) {
          let img = {
            url: $fysp.imgUrl + e.extension1 + e.guid + '.jpg'
          };
          const businesstype = e.businesstype;
          const businesstypeid = e.businesstypeid;
          if (hasThisTypeName(businesstype)) {
            addToThisType(businesstypeid, img);
          } else {
            addNewType(businesstypeid, businesstype, img);
          }
        }
 
        this.typesList = typeList;
        this.typesMap = typeMap;
      });
    }
  }
};
</script>
<style scoped></style>