press-next
Version:
Vue3 组件库,支持 Composition API
154 lines (144 loc) • 3.67 kB
text/typescript
// 表格列配置接口
export interface Column {
key: string;
title: string;
width?: string;
minWidth?: string;
align?: 'left' | 'center' | 'right';
sortable?: boolean;
}
// 轮次设置项接口
export interface RoundSetItemData {
roundName: string;
timeText: string;
formatText: string;
actionText: string;
selected?: boolean;
disabled?: boolean;
editable?: boolean;
showTimeIcon?: boolean;
showFormatIcon?: boolean;
}
// 表格列配置 - 与 press-match-table-header demo-data 保持一致
export const getTableColumns = (): Column[] => [
{
key: 'rounds',
title: '轮次',
width: '1.2rem',
align: 'left',
sortable: false,
},
{
key: 'settings',
title: '开赛设置',
width: '2rem',
align: 'center',
sortable: false,
},
{
key: 'ways',
title: '决胜方式',
width: '1.4rem',
align: 'center',
sortable: false,
},
{
key: 'operate',
title: '操作',
width: '1.6rem',
align: 'center',
sortable: false,
},
];
// BO映射配置
export const BO_MAP = {
1: '一局胜负',
3: '三局两胜',
5: '五局三胜',
7: '七局四胜',
} as const;
// 生成mock数据的函数
export const getMockData = () => {
const initialRoundSetList: RoundSetItemData[] = [
{
roundName: '256进128',
timeText: '3月18日 10:00',
formatText: '两局三胜',
actionText: '已开赛',
selected: false,
disabled: true,
editable: false,
showTimeIcon: false,
showFormatIcon: false,
},
{
roundName: '64进32',
timeText: '3月18日 10:00',
formatText: '一局胜负',
actionText: '已开赛',
selected: true,
disabled: true,
editable: false,
showTimeIcon: false,
showFormatIcon: false,
},
{
roundName: '32进16',
timeText: '3月18日 12:00',
formatText: '一局胜负',
actionText: '整轮开赛',
selected: false,
disabled: false,
editable: true,
showTimeIcon: true,
showFormatIcon: true,
},
{
roundName: '16进8',
timeText: '3月18日 12:00',
formatText: '一局胜负',
actionText: '整轮开赛',
selected: false,
disabled: false,
editable: true,
showTimeIcon: true,
showFormatIcon: true,
},
{
roundName: '8进4',
timeText: '3月18日 12:00',
formatText: '一局胜负',
actionText: '整轮开赛',
selected: false,
disabled: false,
editable: true,
showTimeIcon: true,
showFormatIcon: true,
},
];
return {
initialRoundSetList,
tableColumns: getTableColumns(),
generateMoreRoundData: (_startIndex = 0, count = 5): RoundSetItemData[] => {
const roundNames = ['4进2', '决赛', '三四名决赛'];
const formatOptions = ['一局胜负', '三局两胜', '五局三胜'];
const actionOptions = ['整轮开赛', '单场开赛', '已开赛'];
const newData: RoundSetItemData[] = [];
for (let i = 0; i < count && i < roundNames.length; i += 1) {
const isCompleted = Math.random() > 0.7;
newData.push({
roundName: roundNames[i],
timeText: `3月${18 + Math.floor(i / 2)}日 ${12 + i}:00`,
formatText: formatOptions[i % formatOptions.length],
actionText: isCompleted ? '已开赛' : actionOptions[i % actionOptions.length],
selected: false,
disabled: isCompleted,
editable: !isCompleted,
showTimeIcon: !isCompleted,
showFormatIcon: !isCompleted,
});
}
return newData;
},
};
};