/*
 * @Author: XianKaiQun
 * @Date: 2020-07-07 09:00:08
 * @LastEditors: wuwei
 * @LastEditTime: 2024-04-29 10:54:07
 * @Description: 
 */

import 'dart:async';
import 'package:get/get.dart';
import 'package:app_package/app_package.dart';
import 'package:app_package/src/assets.gen.dart';
import 'package:app_package/src/models/task_list.dart';
import 'package:app_package/src/view_models/work_store.dart';
import 'package:dotted_border/dotted_border.dart';
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:wisdom_cli/wisdom_cli.dart';
import 'package:video_player/video_player.dart';
import '../../api/message.dart';
import '../../models/msg_count.dart';
import '../../stores/push.dart';

part 'components/fast_grid.dart';
part 'components/all_grid.dart';
part 'components/notice.dart';
part 'components/top.dart';
part 'components/top_menu.dart';
part 'components/task.dart';
part 'components/line_card.dart';
part 'components/dot_line.dart';
part 'components/work_card.dart';
part 'components/fee.dart';
part 'components/engineer.dart';
part 'components/tab_card.dart';

class WorkPage extends StatelessWidget {
  const WorkPage({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return ChangeNotifierProvider(
      create: (_) => WorkStore(context),
      child: _PageView(),
      lazy: false,
    );
  }
}

class _PageView extends StatefulWidget {
  _PageView({Key? key}) : super(key: key);
  @override
  _PageViewState createState() => _PageViewState();
}

class _PageViewState extends State<_PageView> {
  @override
  void initState() {
    super.initState();
  }

  @override
  void didChangeDependencies() {
    super.didChangeDependencies();
  }

  @override
  Widget build(BuildContext context) {
    final store = Provider.of<WorkStore>(context, listen: true);

    return Scaffold(
      appBar: WAppBar(
        brightness: Brightness.light,
        backgroundColor: Color(0xffDDEEFE),
        toolbarHeight: 0,
      ),
      body: Stack(
        children: [
          Image.asset(
            'lib/assets/main/bg.png',
            package: 'app_package',
            width: MediaQuery.of(context).size.width,
          ),
          Column(
            children: [
              /// 顶部栏
              _TopBar(),

              ///公告消息
              _NoticeComponent(),

              WisScrollView(
                controller: store.mainController,
                key: store.scrollViewKey,
                onInit: () => store.onInit(),
                onRefresh: () => store.onInit(),
                slivers: <Widget>[
                  SizedBox(height: 10.pt).asSliver(),
                  _TopMenu().asSliver(),
                  if (store.currentCommunity?.id == null) ...[
                    NoDragList(),
                  ] else ...[
                    DragList(),
                  ],
                  if (store.currentCommunity?.id == null &&
                      store.isShowTask == false) ...[
                    SliverToBoxAdapter(
                      child: WEmptyWidget(
                        text: WisText('空空如也~请先选择小区哦'),
                      ),
                    )
                  ],
                  SizedBox(height: 30.pt).asSliver(),
                ],
              ).asFlexible(flex: 1),
              Opacity(
                opacity: 1,
                child: Container(
                  color: Colors.transparent,
                  height: 60.pt,
                ),
              ),
            ],
          ),
        ],
      ),
    );
  }
}

class DragList extends StatefulWidget {
  const DragList({Key? key});
  @override
  State<DragList> createState() => _DragListState();
}

class _DragListState extends State<DragList> {
  Widget _buildAlertDialog() {
    return AlertDialog(
      title: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          WisText(
            '系统说明',
            size: 16.pt,
            weight: FontWeight.w600,
          ),
          Wisdom(
            onTap: () => Get.back(),
            child: Icon(
              Icons.close,
              size: 22.pt,
            ),
          )
        ],
      ),
      titleTextStyle: const TextStyle(fontSize: 20, color: Colors.black),
      titlePadding: EdgeInsets.all(
        15.pt,
      ),
      contentPadding: const EdgeInsets.symmetric(horizontal: 5),
      backgroundColor: Colors.white,
      content: _buildContent(),
      actions: const [],
      elevation: 4,
      shape: const RoundedRectangleBorder(
        borderRadius: BorderRadius.all(
          Radius.circular(20),
        ),
      ),
    );
  }

  Widget _buildContent() {
    return Container(
      width: MediaQuery.of(context).size.width * 0.8,
      child: Wisdom.column(
        padding: EdgeInsets.fromLTRB(
          15.pt,
          5.pt,
          15.pt,
          15.pt,
        ),
        mainAxisSize: MainAxisSize.min,
        children: [
          Row(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              WisText(
                '收费率：',
                size: 14.pt,
                weight: FontWeight.w600,
              ),
              WisText('统计今年及本月的收费率。(收费率 = 本期实收/本期应收。)').asExpanded(),
            ],
          ),
          SizedBox(height: 5.pt),
          Row(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              WisText(
                '应收：',
                size: 14.pt,
                weight: FontWeight.w600,
              ),
              WisText('当月应收总额。').asExpanded(),
            ],
          ),
          SizedBox(height: 5.pt),
          Row(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              WisText(
                '欠费：',
                size: 14.pt,
                weight: FontWeight.w600,
              ),
              WisText('当月欠费总额。').asExpanded(),
            ],
          ),
          SizedBox(height: 5.pt),
          Row(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              WisText(
                '实收：',
                size: 14.pt,
                weight: FontWeight.w600,
              ),
              WisText('当月实收总额。').asExpanded(),
            ],
          ),
          SizedBox(height: 5.pt),
          Row(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              WisText(
                '今日已收：',
                size: 14.pt,
                weight: FontWeight.w600,
              ),
              WisText('按照当日统计收款金额。').asExpanded(),
            ],
          ),
        ],
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    final store = Provider.of<WorkStore>(context, listen: true);
    final colorScheme = WTheme.of(context).colorScheme;
    return ReorderableColumn(
      onReorder: (int oldIndex, int newIndex) =>
          store.orderList(oldIndex, newIndex),
      dataList: store.widgetList
          .map((item) =>
              item == 'TaskTabs' || item == 'NoticeTabs' ? true : false)
          .toList(),
      children: [
        for (int i = 0; i < store.widgetList.length; i++)
          Container(
            key: (store.widgetList[i] == 'TaskTabs' ||
                    store.widgetList[i] == 'NoticeTabs')
                ? null
                : Key(store.widgetList[i]),
            child: Column(mainAxisSize: MainAxisSize.min, children: [
              if (store.widgetList[i] == 'TaskTabs' &&
                  store.taskCardList.length > 0) ...[
                Provider<WorkStore>(
                  create: (_) => WorkStore(context),
                  builder: (context, child) {
                    return TabCard(
                      height: store.taskCardList.length > 3 ? 376.pt : 313.pt,
                      isIconed: store.taskCardList.length > 3,
                      tabs: store.taskCardList.length > 3
                          ? [
                              for (int i = 0;
                                  i < store.taskCardList.length;
                                  i++)
                                Wisdom.column(
                                    mainAxisAlignment: MainAxisAlignment.center,
                                    children: [
                                      Image.asset(
                                        store.taskIconList[i]['select'],
                                        package: 'app_package',
                                        width: 27.pt,
                                        height: 27.pt,
                                      ),
                                    ]),
                            ]
                          : store.taskCardList
                              .map((item) => item.inventoryName)
                              .toList(),
                      unSelectedTabs: [
                        for (int i = 0; i < store.taskCardList.length; i++)
                          Wisdom.column(
                              mainAxisAlignment: MainAxisAlignment.center,
                              children: [
                                Image.asset(
                                  store.taskIconList[i]['unSelect'],
                                  package: 'app_package',
                                  width: 27.pt,
                                  height: 27.pt,
                                ),
                              ]),
                      ],
                      selectIndex: store.taskCardIndex,
                      onSelectCard: (index) => store.onSelectWorkTab(index),
                      child: [
                        for (var item in store.taskCardList)
                          Wisdom.column(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            crossAxisAlignment: CrossAxisAlignment.start,
                            padding: EdgeInsets.all(15.pt),
                            children: [
                              Wisdom.column(
                                  mainAxisAlignment: MainAxisAlignment.start,
                                  crossAxisAlignment: CrossAxisAlignment.start,
                                  children: [
                                    if (store.taskCardList.length > 3) ...[
                                      WisText(
                                        '${item.inventoryName}',
                                        size: 18.pt,
                                        color: colorScheme.mainTitle,
                                        weight: FontWeight.w600,
                                      ),
                                    ],
                                    Wisdom.column(
                                      padding: EdgeInsets.only(
                                          top: store.taskCardList.length > 3
                                              ? 20.pt
                                              : 0),
                                      children: [
                                        for (var cardItem
                                            in item.excutivePlatformList)
                                          _RouteItem(
                                            toRoutes: () =>
                                                store.toTaskDetail(cardItem),
                                            name: '${cardItem.title}',
                                            item: cardItem,
                                            dotline: DotLine(
                                              color: Color(0XFF0F67F8),
                                              fadeColor: Color(0XFFCCDBFF),
                                              isPrimary: true,
                                            ),
                                          ),
                                      ],
                                    ),
                                  ]),
                              Wisdom.row(
                                mainAxisAlignment:
                                    MainAxisAlignment.spaceBetween,
                                children: [
                                  Row(
                                    children: [
                                      WisText(
                                        '未完成数',
                                        size: 13.pt,
                                        color: colorScheme.grey,
                                      ),
                                      SizedBox(width: 10.pt),
                                      WisText(
                                        '${item.undoneCount > 99 ? '99+' : item?.undoneCount ?? 0}',
                                        size: 24.pt,
                                        color: colorScheme.primary,
                                      ),
                                    ],
                                  ),
                                  Wisdom.row(
                                    onTap: () => store.toTask(item),
                                    children: [
                                      WisText(
                                        '查看更多',
                                        size: 13.pt,
                                        color: colorScheme.grey,
                                      ),
                                      SizedBox(width: 4.pt),
                                      Image.asset(
                                        'lib/assets/main/enter2.png',
                                        package: 'app_package',
                                        width: 14.pt,
                                        height: 14.pt,
                                      ),
                                    ],
                                  ),
                                ],
                              ),
                            ],
                          ),
                      ],
                    );
                  },
                ),
              ],
              if (store.widgetList[i] == 'WorkCard' &&
                  store.taskCardList.length > 0) ...[
                WorkCard(
                  name: store.taskCardList[0].inventoryName,
                  data: store.taskCardList[0],
                  toRoutes: () => store.toTask(store.taskCardList[0]),
                ),
              ],
              if (store.widgetList[i] == 'TaskCard') ...[
                Provider(
                  create: (_) => WorkStore(context),
                  builder: (context, child) {
                    return Wisdom(
                      padding: EdgeInsets.only(
                        left: 15.pt,
                        right: 15.pt,
                        top: 15.pt,
                      ),
                      child: WisCard(
                        child: Wisdom.column(
                          padding: EdgeInsets.all(15.pt),
                          borderRadius: BorderRadius.circular(12.pt),
                          children: [
                            Wisdom.row(
                              onTap: () => store.toWaitTask(),
                              padding: EdgeInsets.all(15.pt),
                              borderRadius: BorderRadius.circular(12.pt),
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              color: colorScheme.background,
                              children: [
                                WisText(
                                  '待领取任务数（个）',
                                  size: 15.pt,
                                  weight: FontWeight.w600,
                                ),
                                Wisdom.row(children: [
                                  WisText(
                                    '${store.taskStatistics?.waitReceive != null && store.taskStatistics!.waitReceive! > 99 ? '99+' : store.taskStatistics?.waitReceive ?? 0}',
                                    color: colorScheme.primary,
                                    size: 34.pt,
                                    weight: FontWeight.bold,
                                  ),
                                  SizedBox(width: 5.pt),
                                  Image.asset(
                                    'lib/assets/main/enter.png',
                                    package: 'app_package',
                                    width: 14.pt,
                                    height: 14.pt,
                                  ),
                                ]),
                              ],
                            ),
                            Wisdom.row(
                              padding: EdgeInsets.only(
                                top: 15.pt,
                              ),
                              children: [
                                Row(
                                  children: [
                                    _Number(
                                      toRoute: () => store.toNoOpenTask(),
                                      number:
                                          store.taskStatistics?.noOpenCount ??
                                              0,
                                      text: '未开始',
                                      color: colorScheme.orange,
                                    ).asFlexible(flex: 1),
                                    _Number(
                                      toRoute: () => store.toDoingTask(),
                                      number:
                                          store.taskStatistics?.doingCount ?? 0,
                                      text: '进行中',
                                      color: colorScheme.green,
                                    ).asFlexible(flex: 1),
                                  ],
                                ).asFlexible(flex: 1),
                                Wisdom(
                                  margin: EdgeInsets.symmetric(
                                    horizontal: 15.pt,
                                  ),
                                  width: 0.5.pt,
                                  height: 34.pt,
                                  color: Color(0XFFDCDDE1),
                                ),
                                Row(
                                  children: [
                                    Image.asset(
                                      'lib/assets/main/icon_rwtj.png',
                                      package: 'app_package',
                                      width: 18.pt,
                                      height: 18.pt,
                                    ),
                                    SizedBox(
                                      width: 5.pt,
                                    ),
                                    Wisdom(
                                      onTap: () => store.toTaskStatistics(),
                                      child: WisText(
                                        '任务统计',
                                        size: 16.pt,
                                        color: colorScheme.mainTitle,
                                        weight: FontWeight.bold,
                                      ),
                                    )
                                  ],
                                )
                              ],
                            ),
                            if (store.taskFee?.isShow == true) ...[
                              Wisdom.row(
                                border: Border(
                                  top: BorderSide(
                                    color: colorScheme.divider,
                                    width: .5.pt,
                                  ),
                                ),
                                margin: EdgeInsets.only(
                                  top: 15.pt,
                                ),
                                padding: EdgeInsets.only(
                                  top: 15.pt,
                                ),
                                mainAxisAlignment:
                                    MainAxisAlignment.spaceBetween,
                                children: [
                                  Row(
                                    children: [
                                      Image.asset(
                                        'lib/assets/main/faj.png',
                                        package: 'app_package',
                                        width: 19.pt,
                                        height: 19.pt,
                                      ),
                                      WisText(
                                        '罚金总额',
                                        color: colorScheme.mainTitle,
                                        size: 15.pt,
                                        weight: FontWeight.bold,
                                      ),
                                    ],
                                  ),
                                  WisText(
                                    '${store.taskFee?.penaltyFee ?? 0}',
                                    color: colorScheme.red,
                                    size: 19.pt,
                                    weight: FontWeight.bold,
                                  ),
                                ],
                              )
                            ]
                          ],
                        ),
                      ),
                    );
                  },
                )
              ],
              if (store.widgetList[i] == 'FeeWidget' &&
                  store.feeStatistics != null) ...[
                Provider<WorkStore>(
                  create: (_) => WorkStore(context),
                  builder: (context, child) {
                    return Wisdom.column(
                        onTap: () => store.toFee(),
                        margin: EdgeInsets.only(
                          left: 15.pt,
                          right: 15.pt,
                          top: 25.pt,
                        ),
                        children: [
                          Stack(clipBehavior: Clip.none, children: [
                            if ((store.feeStatistics?.receivableFee != null &&
                                    store.feeStatistics?.receivableFee > 0) ||
                                (store.feeStatistics?.arrearsFee != null &&
                                    store.feeStatistics?.arrearsFee > 0) ||
                                (store.feeStatistics?.receivableFee != null &&
                                    store.feeStatistics?.receivableFee >
                                        0)) ...[
                              WisCard(
                                padding: EdgeInsets.all(15.pt),
                                child: Column(
                                  children: [
                                    SizedBox(height: 70.pt),
                                    if (store.feeStatistics?.receivableFee !=
                                            null &&
                                        store.feeStatistics?.receivableFee >
                                            0) ...[
                                      Row(
                                        mainAxisAlignment:
                                            MainAxisAlignment.spaceBetween,
                                        children: [
                                          Row(children: [
                                            Image.asset(
                                              'lib/assets/main/yingshou.png',
                                              package: 'app_package',
                                              width: 34.pt,
                                              height: 34.pt,
                                            ),
                                            SizedBox(width: 12.pt),
                                            WisText(
                                              '应收（${store.billStatisticIsMonthText}）',
                                              color: colorScheme.minor,
                                              size: 14.pt,
                                            ),
                                          ]),
                                          Row(
                                            children: [
                                              WisText(
                                                '${store.feeStatistics?.receivableFee ?? '--'}',
                                                color: colorScheme.mainTitle,
                                                size: 15.pt,
                                                weight: FontWeight.bold,
                                              ),
                                            ],
                                          ),
                                        ],
                                      ),
                                    ],
                                    if (store.feeStatistics?.receivedFee !=
                                            null &&
                                        store.feeStatistics?.receivedFee >
                                            0) ...[
                                      SizedBox(
                                        height: 10.pt,
                                      ),
                                      Row(
                                        mainAxisAlignment:
                                            MainAxisAlignment.spaceBetween,
                                        children: [
                                          Row(children: [
                                            Image.asset(
                                              'lib/assets/main/shishou.png',
                                              package: 'app_package',
                                              width: 34.pt,
                                              height: 34.pt,
                                            ),
                                            SizedBox(width: 12.pt),
                                            WisText(
                                              '实收（${store.billStatisticIsMonthText}）',
                                              color: colorScheme.minor,
                                              size: 14.pt,
                                            ),
                                          ]),
                                          Row(
                                            children: [
                                              WisText(
                                                '${store.feeStatistics?.receivedFee ?? '--'}',
                                                color: colorScheme.mainTitle,
                                                size: 15.pt,
                                                weight: FontWeight.bold,
                                              ),
                                            ],
                                          ),
                                        ],
                                      ),
                                    ],
                                    if (store.feeStatistics?.arrearsFee !=
                                            null &&
                                        store.feeStatistics?.arrearsFee >
                                            0) ...[
                                      SizedBox(
                                        height: 10.pt,
                                      ),
                                      Row(
                                        mainAxisAlignment:
                                            MainAxisAlignment.spaceBetween,
                                        children: [
                                          Row(children: [
                                            Image.asset(
                                              'lib/assets/main/qianfei.png',
                                              package: 'app_package',
                                              width: 34.pt,
                                              height: 34.pt,
                                            ),
                                            SizedBox(width: 12.pt),
                                            WisText(
                                              '欠费（${store.billStatisticIsMonthText}）',
                                              color: colorScheme.minor,
                                              size: 14.pt,
                                            ),
                                          ]),
                                          Row(
                                            children: [
                                              WisText(
                                                '${store.feeStatistics?.arrearsFee ?? '--'}',
                                                color: colorScheme.mainTitle,
                                                size: 15.pt,
                                                weight: FontWeight.bold,
                                              ),
                                            ],
                                          ),
                                        ],
                                      ),
                                    ],
                                  ],
                                ),
                              ),
                              Positioned(
                                top: -10.pt,
                                left: 0,
                                right: 0,
                                child: Wisdom(
                                  padding: EdgeInsets.all(15.pt),
                                  color: colorScheme.primary,
                                  gradient: LinearGradient(
                                    colors: [
                                      const Color(0xFF4D80FF),
                                      Color(0xFF0F67F8)
                                    ],
                                    stops: [1.0, 1.0],
                                  ),
                                  boxShadow: [
                                    BoxShadow(
                                      color: Color(0x332F78FA),
                                      blurRadius: 5.pt,
                                      offset: Offset(0, 2.5.pt),
                                    )
                                  ],
                                  borderRadius: BorderRadius.circular(12.pt),
                                  child: Row(
                                      mainAxisAlignment:
                                          MainAxisAlignment.spaceBetween,
                                      children: [
                                        Wisdom.row(
                                          margin: EdgeInsets.only(right: 10.pt),
                                          onTap: () => {
                                            showDialog(
                                              context: context,
                                              builder: (ctx) =>
                                                  _buildAlertDialog(),
                                            ),
                                          },
                                          children: [
                                            Image.asset(
                                              'lib/assets/main/shoufeilv.png',
                                              package: 'app_package',
                                              width: 34.pt,
                                              height: 34.pt,
                                            ),
                                            SizedBox(width: 12.pt),
                                            WisText(
                                              '收费率',
                                              color: Colors.white,
                                              size: 15.pt,
                                              weight: FontWeight.w600,
                                              overflow: TextOverflow.ellipsis,
                                            ),
                                            SizedBox(width: 2.pt),
                                            Icon(
                                              Icons.info_outlined,
                                              size: 13.pt,
                                              color: Colors.white,
                                            ),
                                          ],
                                        ),
                                        Wisdom.row(
                                          mainAxisAlignment:
                                              MainAxisAlignment.end,
                                          children: [
                                            Wisdom.column(
                                              margin:
                                                  EdgeInsets.only(right: 10.pt),
                                              crossAxisAlignment:
                                                  CrossAxisAlignment.end,
                                              children: [
                                                WisText(
                                                  '今年',
                                                  size: 14.pt,
                                                  color: Colors.white,
                                                ),
                                                SizedBox(width: 5.pt),
                                                Wisdom.row(children: [
                                                  WisText(
                                                    '${store.feeStatistics?.collectionRate ?? '--'}',
                                                    size: 22.pt,
                                                    weight: FontWeight.bold,
                                                    color: Colors.white,
                                                    overflow:
                                                        TextOverflow.ellipsis,
                                                  ),
                                                  WisText(
                                                    '%',
                                                    size: 16.pt,
                                                    weight: FontWeight.bold,
                                                    color: Colors.white,
                                                    overflow:
                                                        TextOverflow.ellipsis,
                                                  ),
                                                ])
                                              ],
                                            ),
                                            Wisdom.column(
                                              crossAxisAlignment:
                                                  CrossAxisAlignment.end,
                                              children: [
                                                WisText(
                                                  '${store.billStatisticIsMonthText}',
                                                  size: 14.pt,
                                                  color: Colors.white,
                                                ),
                                                SizedBox(width: 5.pt),
                                                Wisdom.row(children: [
                                                  WisText(
                                                    '${store.feeStatistics?.monthCollectionRate ?? '--'}',
                                                    size: 22.pt,
                                                    weight: FontWeight.bold,
                                                    color: Colors.white,
                                                    overflow:
                                                        TextOverflow.ellipsis,
                                                  ),
                                                  WisText(
                                                    '%',
                                                    size: 16.pt,
                                                    weight: FontWeight.bold,
                                                    color: Colors.white,
                                                    overflow:
                                                        TextOverflow.ellipsis,
                                                  ),
                                                ])
                                              ],
                                            ),
                                          ],
                                        ),
                                      ]),
                                ),
                              ),
                            ] else ...[
                              Wisdom(
                                padding: EdgeInsets.all(15.pt),
                                color: colorScheme.primary,
                                gradient: LinearGradient(
                                  colors: [
                                    const Color(0xFF4D80FF),
                                    Color(0xFF0F67F8)
                                  ],
                                  stops: [1.0, 1.0],
                                ),
                                boxShadow: [
                                  BoxShadow(
                                    color: Color(0x332F78FA),
                                    blurRadius: 5.pt,
                                    offset: Offset(0, 2.5.pt),
                                  )
                                ],
                                borderRadius: BorderRadius.circular(12.pt),
                                child: Row(
                                    mainAxisAlignment:
                                        MainAxisAlignment.spaceBetween,
                                    children: [
                                      Wisdom.row(
                                        margin: EdgeInsets.only(right: 10.pt),
                                        onTap: () => {
                                          showDialog(
                                            context: context,
                                            builder: (ctx) =>
                                                _buildAlertDialog(),
                                          ),
                                        },
                                        children: [
                                          Image.asset(
                                            'lib/assets/main/shoufeilv.png',
                                            package: 'app_package',
                                            width: 34.pt,
                                            height: 34.pt,
                                          ),
                                          SizedBox(width: 12.pt),
                                          WisText(
                                            '收费率',
                                            color: Colors.white,
                                            size: 15.pt,
                                            weight: FontWeight.w600,
                                            overflow: TextOverflow.ellipsis,
                                          ),
                                          SizedBox(width: 2.pt),
                                          Icon(
                                            Icons.info_outlined,
                                            size: 13.pt,
                                            color: Colors.white,
                                          ),
                                        ],
                                      ),
                                      Wisdom.row(
                                        mainAxisAlignment:
                                            MainAxisAlignment.end,
                                        children: [
                                          Wisdom.column(
                                            margin:
                                                EdgeInsets.only(right: 10.pt),
                                            crossAxisAlignment:
                                                CrossAxisAlignment.end,
                                            children: [
                                              WisText(
                                                '今年',
                                                size: 13.pt,
                                                color: Colors.white,
                                              ),
                                              SizedBox(width: 5.pt),
                                              Wisdom.row(children: [
                                                WisText(
                                                  '${store.feeStatistics?.collectionRate ?? '--'}',
                                                  size: 22.pt,
                                                  weight: FontWeight.bold,
                                                  color: Colors.white,
                                                  overflow:
                                                      TextOverflow.ellipsis,
                                                ),
                                                WisText(
                                                  '%',
                                                  size: 16.pt,
                                                  weight: FontWeight.bold,
                                                  color: Colors.white,
                                                  overflow:
                                                      TextOverflow.ellipsis,
                                                ),
                                              ])
                                            ],
                                          ),
                                          Wisdom.column(
                                            crossAxisAlignment:
                                                CrossAxisAlignment.end,
                                            children: [
                                              WisText(
                                                '${store.billStatisticIsMonthText}',
                                                size: 13.pt,
                                                color: Colors.white,
                                              ),
                                              SizedBox(width: 5.pt),
                                              Wisdom.row(children: [
                                                WisText(
                                                  '${store.feeStatistics?.monthCollectionRate ?? '--'}',
                                                  size: 22.pt,
                                                  weight: FontWeight.bold,
                                                  color: Colors.white,
                                                  overflow:
                                                      TextOverflow.ellipsis,
                                                ),
                                                WisText(
                                                  '%',
                                                  size: 16.pt,
                                                  weight: FontWeight.bold,
                                                  color: Colors.white,
                                                  overflow:
                                                      TextOverflow.ellipsis,
                                                ),
                                              ])
                                            ],
                                          ),
                                        ],
                                      ),
                                    ]),
                              ),
                            ],
                          ]),
                          SizedBox(
                            height: 10.pt,
                          ),
                          WisCard(
                            child: Wisdom.row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              padding: EdgeInsets.all(15.pt),
                              // color: Colors.white,
                              children: [
                                Row(
                                  children: [
                                    Image.asset(
                                      'lib/assets/main/fee_total.png',
                                      package: 'app_package',
                                      width: 34.pt,
                                      height: 34.pt,
                                    ),
                                    SizedBox(width: 12.pt),
                                    Column(
                                      crossAxisAlignment:
                                          CrossAxisAlignment.start,
                                      children: [
                                        WisText(
                                          '今日已收（${store.billStatisticIsMonthText}）',
                                          size: 14.pt,
                                          color: colorScheme.minor,
                                        ),
                                        SizedBox(width: 5.pt),
                                        WisText(
                                          '${store.feeStatistics?.dayReceivedFee ?? '--'}',
                                          color: colorScheme.mainTitle,
                                          size: 15.pt,
                                          weight: FontWeight.bold,
                                        ),
                                      ],
                                    ),
                                  ],
                                ),
                                Wisdom(
                                  onTap: () => store.toFee(),
                                  padding: EdgeInsets.symmetric(
                                    horizontal: 15.pt,
                                    vertical: 7.pt,
                                  ),
                                  gradient: LinearGradient(
                                    colors: [
                                      const Color(0xFF4D80FF),
                                      Color(0xFF0F67F8)
                                    ],
                                    stops: [1.0, 1.0],
                                  ),
                                  borderRadius: BorderRadius.circular(20.pt),
                                  child: WisText(
                                    '收费',
                                    color: Colors.white,
                                    size: 15.pt,
                                    weight: FontWeight.w600,
                                  ),
                                )
                              ],
                            ),
                          ),
                        ]);
                  },
                ),
              ],
              if (store.widgetList[i] == 'NoticeTabs' &&
                  store.dynamicCardList.length > 0) ...[
                Provider<WorkStore>(
                  create: (_) => WorkStore(context),
                  builder: (context, child) {
                    return TabCard(
                      tabs: store.dynamicCardList
                          .map((item) => item['name'])
                          .toList(),
                      selectIndex: store.dynamicCardIndex,
                      onSelectCard: (index) => store.onSelectTab(index),
                      child: [
                        if (store.isShowRepair) ...[
                          TabCardBody(
                            list: [
                              TabRowItem(
                                onTap: () => store.toRepairIndex(),
                                num: WisText(
                                  '${store.repairStatistics?.repair ?? 0}',
                                  color: colorScheme.primary,
                                  size: 32.pt,
                                  weight: FontWeight.bold,
                                ),
                                text: WisText(
                                  '报修需处理数',
                                  color: colorScheme.minor,
                                  size: 14.pt,
                                ),
                              ).asExpanded(),
                              TabRowItem(
                                onTap: () => store.toReportIndex(),
                                num: WisText(
                                  '${store.repairStatistics?.report ?? 0}',
                                  color: colorScheme.orange,
                                  size: 32.pt,
                                  weight: FontWeight.bold,
                                ),
                                text: WisText(
                                  '报事需处理数',
                                  color: colorScheme.minor,
                                  size: 14.pt,
                                ),
                              ).asExpanded(),
                            ],
                            toRoutes: () => store.toRepair(),
                          ),
                        ],
                        if (store.isShowNotice) ...[
                          TabCardBody(
                            list: [
                              TabRowItem(
                                num: WisText(
                                  '${store.noticeStatistics?.published ?? 0}',
                                  color: colorScheme.primary,
                                  size: 32.pt,
                                  weight: FontWeight.bold,
                                ),
                                text: WisText(
                                  '已发布(条)',
                                  color: colorScheme.minor,
                                  size: 14.pt,
                                ),
                              ).asExpanded(),
                              TabRowItem(
                                num: WisText(
                                  '${store.noticeStatistics?.draft ?? 0}',
                                  color: colorScheme.orange,
                                  size: 32.pt,
                                  weight: FontWeight.bold,
                                ),
                                text: WisText(
                                  '草稿箱(条)',
                                  color: colorScheme.minor,
                                  size: 14.pt,
                                ),
                              ).asExpanded(),
                            ],
                            toRoutes: () => store.toNotice(),
                          ),
                        ],
                        if (store.isShowDynamic) ...[
                          TabCardBody(
                            list: [
                              TabRowItem(
                                num: WisText(
                                  '${store.dynamicStatistics?.month ?? 0}',
                                  color: colorScheme.green,
                                  size: 32.pt,
                                  weight: FontWeight.bold,
                                ),
                                text: WisText(
                                  '${store.billStatisticIsMonthText}(条)',
                                  color: colorScheme.minor,
                                  size: 14.pt,
                                ),
                              ).asExpanded(),
                              TabRowItem(
                                num: WisText(
                                  '${store.dynamicStatistics?.week ?? 0}',
                                  color: colorScheme.orange,
                                  size: 32.pt,
                                  weight: FontWeight.bold,
                                ),
                                text: WisText(
                                  '本周(条)',
                                  color: colorScheme.minor,
                                  size: 14.pt,
                                ),
                              ).asExpanded(),
                              TabRowItem(
                                num: WisText(
                                  '${store.dynamicStatistics?.year ?? 0}',
                                  color: colorScheme.primary,
                                  size: 32.pt,
                                  weight: FontWeight.bold,
                                ),
                                text: WisText(
                                  '年(条)',
                                  color: colorScheme.minor,
                                  size: 14.pt,
                                ),
                              ).asExpanded(),
                            ],
                            toRoutes: () => store.toDynamic(),
                          ),
                        ],
                      ],
                    );
                  },
                ),
              ],
              if (store.widgetList[i] == 'EngineerWidget') ...[
                Provider<WorkStore>(
                  create: (_) => WorkStore(context),
                  builder: (context, child) {
                    return Wisdom.column(
                      // margin: EdgeInsets.only(top: 15.pt),
                      children: [
                        if (store.isShowMeter) ...[
                          WisCard(
                            margin: EdgeInsets.only(
                              left: 15.pt,
                              right: 15.pt,
                              top: 15.pt,
                            ),
                            padding: EdgeInsets.all(15.pt),
                            child: Row(
                              children: [
                                Row(
                                  children: [
                                    Image.asset(
                                      'lib/assets/main/chaobiao.png',
                                      package: 'app_package',
                                      width: 21.pt,
                                      height: 21.pt,
                                    ),
                                    SizedBox(width: 10.pt),
                                    WisText(
                                      '抄表',
                                      color: colorScheme.mainTitle,
                                      size: 16.pt,
                                    ),
                                  ],
                                ).asFlexible(flex: 1),
                                Row(
                                  mainAxisAlignment: MainAxisAlignment.end,
                                  children: [
                                    Wisdom.column(
                                      onTap: () => store.toMeters(),
                                      margin: EdgeInsets.only(right: 36.pt),
                                      // crossAxisAlignment: CrossAxisAlignment.end,
                                      children: [
                                        WisText(
                                          '${store.meterStatistics?.read ?? '0'}',
                                          size: 24.pt,
                                          color: colorScheme.primary,
                                          weight: FontWeight.bold,
                                        ),
                                        SizedBox(height: 5.pt),
                                        Row(
                                          children: [
                                            WisText(
                                              '已抄表',
                                              color: colorScheme.minor,
                                              size: 13.pt,
                                            ),
                                            Image.asset(
                                              'lib/assets/main/enter.png',
                                              package: 'app_package',
                                              width: 14.pt,
                                              height: 14.pt,
                                            ),
                                          ],
                                        ),
                                      ],
                                    ),
                                    Wisdom.column(
                                      onTap: () => store.toMeters(),
                                      children: [
                                        WisText(
                                          '${store.meterStatistics?.unread ?? '0'}',
                                          size: 24.pt,
                                          color: colorScheme.orange,
                                          weight: FontWeight.bold,
                                        ),
                                        SizedBox(height: 5.pt),
                                        Row(
                                          children: [
                                            WisText(
                                              '未抄表',
                                              color: colorScheme.minor,
                                              size: 13.pt,
                                            ),
                                            Image.asset(
                                              'lib/assets/main/enter.png',
                                              package: 'app_package',
                                              width: 14.pt,
                                              height: 14.pt,
                                            ),
                                          ],
                                        ),
                                      ],
                                    ),
                                  ],
                                ),
                              ],
                            ),
                          ),
                        ],
                        if (store.isShowDevices &&
                            store.deviceStatistics.length > 0) ...[
                          WisCard(
                            margin: EdgeInsets.only(
                              top: 15.pt,
                              left: 15.pt,
                              right: 15.pt,
                            ),
                            padding: EdgeInsets.only(
                                top: 0.pt,
                                left: 15.pt,
                                right: 15.pt,
                                bottom: 15.pt),
                            child: Column(
                              children: [
                                for (var i = 0;
                                    i < store.deviceStatistics.length;
                                    i++)
                                  Wisdom.row(
                                    margin: EdgeInsets.only(top: 10.pt),
                                    children: [
                                      Row(
                                        children: [
                                          Image.asset(
                                            'lib/assets/main/ludeng.png',
                                            package: 'app_package',
                                            width: 21.pt,
                                            height: 21.pt,
                                          ),
                                          SizedBox(width: 10.pt),
                                          WisText(
                                            '${store.deviceStatistics[i]?.name ?? '--'}',
                                            color: colorScheme.mainTitle,
                                            size: 16.pt,
                                          ),
                                        ],
                                      ).asFlexible(flex: 1),
                                      Row(
                                        mainAxisAlignment:
                                            MainAxisAlignment.end,
                                        children: [
                                          Wisdom.column(
                                            onTap: () => store.toDevices(),
                                            margin:
                                                EdgeInsets.only(right: 36.pt),
                                            children: [
                                              WisText(
                                                '${store.deviceStatistics[i]?.open ?? '0'}',
                                                size: 24.pt,
                                                color: colorScheme.primary,
                                                weight: FontWeight.bold,
                                              ),
                                              SizedBox(height: 5.pt),
                                              Row(
                                                children: [
                                                  WisText(
                                                    '已开启',
                                                    color: colorScheme.minor,
                                                    size: 13.pt,
                                                  ),
                                                  Image.asset(
                                                    'lib/assets/main/enter.png',
                                                    package: 'app_package',
                                                    width: 14.pt,
                                                    height: 14.pt,
                                                  ),
                                                ],
                                              ),
                                            ],
                                          ),
                                          Wisdom.column(
                                            onTap: () => store.toDevices(),
                                            children: [
                                              WisText(
                                                '${store.deviceStatistics[i]?.close ?? '0'}',
                                                size: 24.pt,
                                                color: colorScheme.orange,
                                                weight: FontWeight.bold,
                                              ),
                                              SizedBox(height: 5.pt),
                                              Row(
                                                children: [
                                                  WisText(
                                                    '已关闭',
                                                    color: colorScheme.minor,
                                                    size: 13.pt,
                                                  ),
                                                  Image.asset(
                                                    'lib/assets/main/enter.png',
                                                    package: 'app_package',
                                                    width: 14.pt,
                                                    height: 14.pt,
                                                  ),
                                                ],
                                              ),
                                            ],
                                          ),
                                        ],
                                      ),
                                    ],
                                  ),
                              ],
                            ),
                          ),
                        ]
                      ],
                    ).asFlexible(flex: 1);
                  },
                ),
              ],
            ]),
          ),
      ],
    ).asSliver();
  }
}

class NoDragList extends StatelessWidget {
  const NoDragList({Key? key});

  @override
  Widget build(BuildContext context) {
    final store = Provider.of<WorkStore>(context, listen: true);

    return Column(children: [
      for (int i = 0; i < store.widgetList.length; i++)
        Container(
          child: Column(children: [
            if (store.widgetList[i] == 'TaskTabs' &&
                store.taskCardList.length > 0) ...[
              TaskCardWidget(),
            ],
            if (store.widgetList[i] == 'WorkCard' &&
                store.taskCardList.length > 0) ...[
              WorkCard(
                name: store.taskCardList[0].inventoryName,
                data: store.taskCardList[0],
                toRoutes: () => store.toTask(store.taskCardList[0]),
              ),
            ],
            if (store.widgetList[i] == 'TaskCard') ...[
              TaskCard(),
            ],
          ]),
        )
    ]).asSliver();
  }
}

class TaskCardWidget extends StatelessWidget {
  const TaskCardWidget({Key? key});

  @override
  Widget build(BuildContext context) {
    final colorScheme = WTheme.of(context).colorScheme;
    final store = Provider.of<WorkStore>(context, listen: true);
    return TabCard(
      height: store.taskCardList.length > 3 ? 376.pt : 313.pt,
      isIconed: store.taskCardList.length > 3,
      tabs: store.taskCardList.length > 3
          ? [
              for (int i = 0; i < store.taskCardList.length; i++)
                Wisdom.column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      Image.asset(
                        store.taskIconList[i]['select'],
                        package: 'app_package',
                        width: 27.pt,
                        height: 27.pt,
                      ),
                    ]),
            ]
          : store.taskCardList.map((item) => item.inventoryName).toList(),
      unSelectedTabs: [
        for (int i = 0; i < store.taskCardList.length; i++)
          Wisdom.column(mainAxisAlignment: MainAxisAlignment.center, children: [
            Image.asset(
              store.taskIconList[i]['unSelect'],
              package: 'app_package',
              width: 27.pt,
              height: 27.pt,
            ),
          ]),
      ],
      selectIndex: store.taskCardIndex,
      onSelectCard: (index) => store.onSelectWorkTab(index),
      child: [
        for (var item in store.taskCardList)
          Wisdom.column(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            crossAxisAlignment: CrossAxisAlignment.start,
            padding: EdgeInsets.all(15.pt),
            children: [
              Wisdom.column(
                  mainAxisAlignment: MainAxisAlignment.start,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    if (store.taskCardList.length > 3) ...[
                      WisText(
                        '${item.inventoryName}',
                        size: 18.pt,
                        color: colorScheme.mainTitle,
                        weight: FontWeight.w600,
                      ),
                    ],
                    Wisdom.column(
                      padding: EdgeInsets.only(
                          top: store.taskCardList.length > 3 ? 20.pt : 0),
                      children: [
                        for (var cardItem in item.excutivePlatformList)
                          _RouteItem(
                            toRoutes: () => store.toTaskDetail(cardItem),
                            name: '${cardItem.title}',
                            item: cardItem,
                            dotline: DotLine(
                              color: Color(0XFF0F67F8),
                              fadeColor: Color(0XFFCCDBFF),
                              isPrimary: true,
                            ),
                          ),
                      ],
                    ),
                  ]),
              Wisdom.row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Row(
                    children: [
                      WisText(
                        '未完成数',
                        size: 13.pt,
                        color: colorScheme.grey,
                      ),
                      SizedBox(width: 10.pt),
                      WisText(
                        '${item.undoneCount > 99 ? '99+' : item?.undoneCount ?? 0}',
                        size: 24.pt,
                        color: colorScheme.primary,
                      ),
                    ],
                  ),
                  Wisdom.row(
                    onTap: () => store.toTask(item),
                    children: [
                      WisText(
                        '查看更多',
                        size: 13.pt,
                        color: colorScheme.grey,
                      ),
                      SizedBox(width: 4.pt),
                      Image.asset(
                        'lib/assets/main/enter2.png',
                        package: 'app_package',
                        width: 14.pt,
                        height: 14.pt,
                      ),
                    ],
                  ),
                ],
              ),
            ],
          ),
      ],
    );
  }
}

class NoticeWidget extends StatelessWidget {
  const NoticeWidget({Key? key});

  @override
  Widget build(BuildContext context) {
    final store = Provider.of<WorkStore>(context, listen: true);
    final colorScheme = WTheme.of(context).colorScheme;

    return TabCard(
      tabs: store.dynamicCardList.map((item) => item['name']).toList(),
      selectIndex: store.dynamicCardIndex,
      onSelectCard: (index) => store.onSelectTab(index),
      child: [
        if (store.isShowRepair) ...[
          TabCardBody(
            list: [
              TabRowItem(
                onTap: () => store.toRepairIndex(),
                num: WisText(
                  '${store.repairStatistics?.repair ?? 0}',
                  color: colorScheme.primary,
                  size: 32.pt,
                  weight: FontWeight.bold,
                ),
                text: WisText(
                  '报修需处理数',
                  color: colorScheme.minor,
                  size: 14.pt,
                ),
              ).asExpanded(),
              TabRowItem(
                onTap: () => store.toReportIndex(),
                num: WisText(
                  '${store.repairStatistics?.report ?? 0}',
                  color: colorScheme.orange,
                  size: 32.pt,
                  weight: FontWeight.bold,
                ),
                text: WisText(
                  '报事需处理数',
                  color: colorScheme.minor,
                  size: 14.pt,
                ),
              ).asExpanded(),
            ],
            toRoutes: () => store.toRepair(),
          ),
        ],
        if (store.isShowNotice) ...[
          TabCardBody(
            list: [
              TabRowItem(
                num: WisText(
                  '${store.noticeStatistics?.published ?? 0}',
                  color: colorScheme.primary,
                  size: 32.pt,
                  weight: FontWeight.bold,
                ),
                text: WisText(
                  '已发布(条)',
                  color: colorScheme.minor,
                  size: 14.pt,
                ),
              ).asExpanded(),
              TabRowItem(
                num: WisText(
                  '${store.noticeStatistics?.draft ?? 0}',
                  color: colorScheme.orange,
                  size: 32.pt,
                  weight: FontWeight.bold,
                ),
                text: WisText(
                  '草稿箱(条)',
                  color: colorScheme.minor,
                  size: 14.pt,
                ),
              ).asExpanded(),
            ],
            toRoutes: () => store.toNotice(),
          ),
        ],
        if (store.isShowDynamic) ...[
          TabCardBody(
            list: [
              TabRowItem(
                num: WisText(
                  '${store.dynamicStatistics?.month ?? 0}',
                  color: colorScheme.green,
                  size: 32.pt,
                  weight: FontWeight.bold,
                ),
                text: WisText(
                  '${store.billStatisticIsMonthText}(条)',
                  color: colorScheme.minor,
                  size: 14.pt,
                ),
              ).asExpanded(),
              TabRowItem(
                num: WisText(
                  '${store.dynamicStatistics?.week ?? 0}',
                  color: colorScheme.orange,
                  size: 32.pt,
                  weight: FontWeight.bold,
                ),
                text: WisText(
                  '本周(条)',
                  color: colorScheme.minor,
                  size: 14.pt,
                ),
              ).asExpanded(),
              TabRowItem(
                num: WisText(
                  '${store.dynamicStatistics?.year ?? 0}',
                  color: colorScheme.primary,
                  size: 32.pt,
                  weight: FontWeight.bold,
                ),
                text: WisText(
                  '年(条)',
                  color: colorScheme.minor,
                  size: 14.pt,
                ),
              ).asExpanded(),
            ],
            toRoutes: () => store.toDynamic(),
          ),
        ],
      ],
    );
  }
}
