press-next
Version:
Vue3 组件库,支持 Composition API
122 lines (109 loc) • 2.89 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;
hasStarted?: boolean;
canSetTime?: boolean;
canSetBo?: boolean;
bo_type?: number;
}
// 表格列配置 - 与 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,
},
];
export function getMockData() {
// 轮次设置项数据
const roundSetItemData: RoundSetItemData = {
roundName: '32进16',
timeText: '3月18日 12:00',
formatText: '三局两胜',
actionText: '整轮开赛',
selected: false,
disabled: false,
editable: true,
showTimeIcon: true,
showFormatIcon: true,
hasStarted: false,
canSetTime: true,
canSetBo: true,
bo_type: 3,
};
// 组件属性配置
const componentProps = {
...roundSetItemData,
columns: getTableColumns(),
};
return componentProps;
}
// 生成多个轮次数据的函数
export const generateRoundSetItems = (count = 5): RoundSetItemData[] => {
const roundNames = ['256进128', '128进64', '64进32', '32进16', '16进8', '8进4', '4进2', '决赛'];
const formatOptions = ['一局胜负', '三局两胜', '五局三胜', '七局四胜'];
const actionOptions = ['整轮开赛', '单场开赛', '已开赛'];
const items: RoundSetItemData[] = [];
for (let i = 0; i < count && i < roundNames.length; i += 1) {
const isCompleted = Math.random() > 0.7;
const isSelected = i === 1; // 默认选中第二项
items.push({
roundName: roundNames[i],
timeText: `3月${18 + Math.floor(i / 2)}日 ${10 + i}:00`,
formatText: formatOptions[i % formatOptions.length],
actionText: isCompleted ? '已开赛' : actionOptions[i % actionOptions.length],
selected: isSelected,
disabled: isCompleted,
editable: !isCompleted,
showTimeIcon: !isCompleted,
showFormatIcon: !isCompleted,
hasStarted: isCompleted,
canSetTime: !isCompleted,
canSetBo: !isCompleted,
bo_type: [1, 3, 5, 7][i % 4],
});
}
return items;
};
const DEMO_DATA = {
...getMockData(),
};
export default DEMO_DATA;