<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>
|