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
<template>
  <FYImageSelectDialog
    v-loading="loading"
    title="台账图片"
    :typeList="typeList"
    :typeImgMap="typeImgMap"
  ></FYImageSelectDialog>
</template>
<script setup>
import { ref, computed, onMounted } from 'vue';
import problemApiFytz from '@/api/fytz/problemApi.js';
import userApi from '@/api/fysp/userApi.js';
import { svToTz } from '@/enum/scene';
import { $fytz } from '@/api/index';
const loading = ref(true)
const props = defineProps({
  // 展示模式
  mode: {
    type: Number,
    default: 0
  },
  subtask: {
    type: Array,
    default: () => []
  }
});
const typeList = ref([]);
const typeImgMap = ref(new Map());
function getList() {
  userApi.getTzId(props.subtask.sceneId).then((res) => {
    loading.value = true
    let tzUserId = res.tzUserId;
 
    problemApiFytz
      .getLedgerPic({
        tzUserId: tzUserId,
        sceneType: svToTz(props.subtask.sceneTypeId).value,
        time: getMonth()
      })
      .then((res) => {
        let data = res;
        if (data && data.length > 0) {
          data.forEach((item) => {
            let type;
            let typeIndex = typeList.value
              .map((typeItem) => typeItem.typeName)
              .indexOf(item.ledgerType);
            if (typeIndex != -1) {
              type = typeList.value[typeIndex];
            }
            if (
              typeList.value
                .map((typeItem) => typeItem.typeName)
                .indexOf(item.ledgerType) == -1
            ) {
              type = {
                typeId: typeList.value.length,
                typeName: item.ledgerType
              };
              typeList.value.push(type);
              typeImgMap.value.set(type.typeId, []);
            }
            item.url = $fytz.imgUrl + item.path1;
            typeImgMap.value.get(type.typeId).push(item);
          });
        }
      }).finally(() => loading.value = false);
  });
}
function getMonth() {
  // 使用Date对象解析日期字符串
  var date = new Date(props.subtask.subtask.planstarttime);
  // 获取月份信息,月份是从0开始的,所以需要加1
  let month = date.getMonth() + 1;
  if (String(month).length == 1) {
    month = `0${month}`;
  }
  var year = date.getFullYear();
  return `${year}-${month}`;
}
onMounted(() => {
  getList();
});
</script>