/*
 * @Author: XianKaiQun
 * @Date: 2020-07-14 08:58:59
 * @LastEditors: wjc
 * @LastEditTime: 2023-04-03 11:59:34
 * @Description: 
 */
part of '../index.dart';

class _TableComponent extends StatelessWidget {
  const _TableComponent({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    final store = Provider.of<PrivateDashBoardStore>(context);
    final style = WTheme.of(context);
    final colorScheme = style.colorScheme;
    final staffList = store.staffList;
    var heads = [
      '部门人员(${staffList.length})',
      '未开始',
      '进行中',
      '已完成',
      '超时完成',
    ];

    return WisCard(
      isSliver: true,
      margin:
          EdgeInsets.only(left: 15.pt, right: 15.pt, top: 5.pt, bottom: 5.pt),
      padding: EdgeInsets.all(15.pt),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.stretch,
        children: <Widget>[
          Table(
            defaultColumnWidth: IntrinsicColumnWidth(),
            children: [
              TableRow(
                decoration: BoxDecoration(
                  border: Border(
                    bottom: BorderSide(width: 0.5, color: colorScheme.divider),
                  ),
                ),
                children: [
                  for (var item in heads)
                    Text(
                      item,
                      textAlign: TextAlign.center,
                      style: TextStyle(
                        fontWeight: FontWeight.bold,
                        fontSize: 13.pt,
                      ),
                      strutStyle: StrutStyle(leading: 1.5),
                    )
                ],
              ),
              for (var items in staffList)
                TableRow(
                  decoration: BoxDecoration(
                    border: Border(
                      bottom:
                          BorderSide(width: 0.5, color: colorScheme.divider),
                    ),
                  ),
                  children: [
                    Text(
                      items.name ?? '',
                      textAlign: TextAlign.center,
                      style: TextStyle(fontSize: 13.pt),
                      strutStyle: StrutStyle(leading: 1.5),
                    ),
                    Text.rich(
                      TextSpan(
                        children: [
                          TextSpan(
                            text: '${items.noOpen ?? 0}',
                            style: TextStyle(
                              color: colorScheme.mainTitle,
                            ),
                          ),
                          if ((items.noOpenTimeOut ?? 0) != 0)
                            TextSpan(text: '(${items.noOpenTimeOut ?? 0})'),
                        ],
                      ),
                      textAlign: TextAlign.center,
                      style:
                          TextStyle(fontSize: 13.pt, color: colorScheme.danger),
                      strutStyle: StrutStyle(leading: 1.5),
                    ),
                    Text.rich(
                      TextSpan(
                        children: [
                          TextSpan(
                            text: '${items.doing ?? 0}',
                            style: TextStyle(
                              color: colorScheme.mainTitle,
                            ),
                          ),
                          if ((items.doingTimeOut ?? 0) != 0)
                            TextSpan(text: '(${items.doingTimeOut ?? 0})'),
                        ],
                      ),
                      textAlign: TextAlign.center,
                      style:
                          TextStyle(fontSize: 13.pt, color: colorScheme.danger),
                      strutStyle: StrutStyle(leading: 1.5),
                    ),
                    Text(
                      '${items.finished ?? '0'}',
                      textAlign: TextAlign.center,
                      style: TextStyle(
                        fontSize: 13.pt,
                        color: colorScheme.mainTitle,
                      ),
                      strutStyle: StrutStyle(leading: 1.5),
                    ),
                    Text(
                      '${items.finishedTimeOut ?? '0'}',
                      textAlign: TextAlign.center,
                      style: TextStyle(
                          fontSize: 13.pt, color: colorScheme.warning),
                      strutStyle: StrutStyle(leading: 1.5),
                    )
                  ],
                ),
            ],
          ),
          SizedBox(height: 15.pt),
          Text(
            '注：统计数据为本年创建任务',
            textAlign: TextAlign.right,
            style: TextStyle(
              color: colorScheme.grey,
              fontSize: 10.pt,
            ),
          ),
        ],
      ),
    );
  }
}
