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