| | |
| | | return { |
| | | // 无数据 |
| | | typesList: [], |
| | | typesMap: new Map(), |
| | | typesMap: new Map() |
| | | }; |
| | | }, |
| | | mounted() { |
| | |
| | | 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 = { |
| | |
| | | }; |
| | | const businesstype = e.businesstype; |
| | | const businesstypeid = e.businesstypeid; |
| | | if (hasThisTypeName(businesstype)) { |
| | | addToThisType(businesstypeid, img); |
| | | if ( |
| | | typeList.find((item) => item.typeName == businesstype) != undefined |
| | | ) { |
| | | typeMap.get(businesstypeid).push(img); |
| | | } else { |
| | | addNewType(businesstypeid, businesstype, img); |
| | | typeList.push({ |
| | | typeId: businesstypeid, |
| | | typeName: businesstype |
| | | }); |
| | | typeMap.set(businesstypeid, [img]); |
| | | } |
| | | } |
| | | |
| | | this.typesList = typeList; |
| | | this.typesMap = typeMap; |
| | | }); |