49 lines
1.1 KiB
TypeScript
49 lines
1.1 KiB
TypeScript
export const calcTypeName = (type: number) => {
|
|
const style = {
|
|
2: {
|
|
text: "冲",
|
|
color: "#EB5241",
|
|
bgColor: "rgba(235,82,65,0.15)",
|
|
roundedBgColor: "#E75859",
|
|
},
|
|
1: {
|
|
text: "稳",
|
|
color: "#FA8E23",
|
|
bgColor: "rgba(250,142,35,0.15)",
|
|
roundedBgColor: "#FF8800",
|
|
},
|
|
0: {
|
|
text: "保",
|
|
color: "#15C496",
|
|
bgColor: "rgba(21,196,150,0.15)",
|
|
roundedBgColor: "#34C724",
|
|
},
|
|
}[type] || { text: "保", color: "#15C496", bgColor: "rgba(21,196,150,0.15)" };
|
|
|
|
return {
|
|
text: style.text,
|
|
style: {
|
|
color: style.color,
|
|
backgroundColor: style.bgColor,
|
|
},
|
|
roundedBgColor: style.roundedBgColor,
|
|
};
|
|
};
|
|
|
|
export const countModel = (list: any[]) => {
|
|
const tModel = [
|
|
{ type: 2, count: 0 },
|
|
{ type: 1, count: 0 },
|
|
{ type: 0, count: 0 },
|
|
];
|
|
|
|
list.forEach((item) => {
|
|
item.vItems.forEach((vItem:{type:number}) => {
|
|
const target = tModel.find((t) => t.type === vItem.type);
|
|
if (target) target.count++;
|
|
});
|
|
});
|
|
|
|
return { tModel };
|
|
};
|