/*
 * @Author       : WuWei
 * @LastEditors: ChenYaJin
 * @Date         : 2021-05-13 10:53:15
 * @LastEditTime: 2023-08-10 15:55:19
 * @FilePath     : /wisdom-huiguanjia-app/task_package/lib/src/pages/edit/components/open.dart
 * @Description  : 任务添加、编辑-选择任务是否公开
 */
part of '../index.dart';

// import '../../../assets.gen.dart';

class _BuildTaskOpen extends StatelessWidget {
  const _BuildTaskOpen({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final store = Provider.of<EditStore>(context, listen: false);
    final style = WTheme.of(context);
    final colorScheme = style.colorScheme;
    return SliverToBoxAdapter(
      child: Wisdom.column(
          color: Colors.white,
          padding: EdgeInsets.symmetric(horizontal: 15.pt),
          margin: EdgeInsets.only(bottom: 10.pt),
          borderRadius: BorderRadius.circular(10.pt),
          boxShadow: [
            BoxShadow(
              offset: Offset(0, 2.pt),
              color: Color(0x08000000),
              blurRadius: 10.pt,
              spreadRadius: 2.5.pt,
            ),
          ],
          children: <Widget>[
            Observer(builder: (context) {
              return Wisdom(
                padding: EdgeInsets.symmetric(vertical: 10.pt),
                border: Border(bottom: Divider.createBorderSide(context)),
                color: Colors.white,
                child: WFSwitch(
                  isRequired: false,
                  initialValue: store.params['isPublic'],
                  title: Wisdom.row(
                    mainAxisSize: MainAxisSize.min,
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      Image(
                        image: AssetList.$renwugongkai_png_image,
                        height: 22.pt,
                      ),
                      SizedBox(width: 10.pt),
                      WisText('任务公开',
                          color: colorScheme.mainTitle, size: 15.pt),
                    ],
                  ),
                  onChanged: (v) => store.isPublicChange(v),
                ),
              );
            }),
            Wisdom(
              color: Colors.white,
              padding: EdgeInsets.symmetric(vertical: 10.pt),
              border: Border(bottom: Divider.createBorderSide(context)),
              child: Column(
                children: <Widget>[
                  Observer(builder: (_) {
                    return WFTreePicker(
                      title: Wisdom.row(
                        mainAxisSize: MainAxisSize.min,
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: [
                          Image(
                            image: AssetList.$chixingren_png_image,
                            height: 22.pt,
                          ),
                          SizedBox(width: 10.pt),
                          WisText(
                            '执行人',
                            size: 15.pt,
                            color: colorScheme.mainTitle,
                          ),
                        ],
                      ),
                      dataList: store.operatorList,
                      initialValue: store.operatorId,
                      isMulti: false,
                      // enableValue: store.childOperatorId,
                      label: 'employeeName',
                      value: 'employeeId',
                      child: 'employees',
                      firstName: 'companyShortName',
                      firstValue: 'companyId',
                      hintText: '请选择执行人（必选）',
                      isSearch: true,
                      onChanged: (v) => store.onSetOperatorPeople(v),
                    );
                  }),
                ],
              ),
            ),
            Wisdom(
              color: Colors.white,
              padding: EdgeInsets.symmetric(vertical: 10.pt),
              border: Border(bottom: Divider.createBorderSide(context)),
              child: Column(
                children: <Widget>[
                  Observer(builder: (_) {
                    return WFTreePicker(
                      title: Wisdom.row(
                        mainAxisSize: MainAxisSize.min,
                        mainAxisAlignment: MainAxisAlignment.center,
                        crossAxisAlignment: CrossAxisAlignment.center,
                        children: [
                          Image(
                            image: AssetList.$jianduren_png_image,
                            height: 22.pt,
                          ),
                          SizedBox(width: 10.pt),
                          WisText(
                            '监督人',
                            size: 15.pt,
                            color: colorScheme.mainTitle,
                          ),
                        ],
                      ),
                      dataList: store.operatorList,
                      initialValue: store.supervisorId,
                      isMulti: false,
                      // enableValue: store.childOperatorId,
                      label: 'employeeName',
                      value: 'employeeId',
                      child: 'employees',
                      firstName: 'companyShortName',
                      firstValue: 'companyId',
                      hintText: '选择监督人（必选）',
                      isSearch: true,
                      onChanged: (v) => store.onSetSupervisor(v),
                    );
                  }),
                ],
              ),
            ),
            if (store.isCreate == true &&
                store.isChild == false &&
                store.isChildAdd == false &&
                store.isAbnormalAdd == false) ...[
              Wisdom(
                color: Colors.white,
                padding: EdgeInsets.symmetric(vertical: 10.pt),
                border: Border(bottom: Divider.createBorderSide(context)),
                child: Column(
                  children: <Widget>[
                    Observer(builder: (_) {
                      return WFTreePicker(
                        title: Wisdom.row(
                          mainAxisSize: MainAxisSize.min,
                          mainAxisAlignment: MainAxisAlignment.center,
                          crossAxisAlignment: CrossAxisAlignment.center,
                          children: [
                            Image(
                              image: AssetList.$chixingren_png_image,
                              height: 22.pt,
                            ),
                            SizedBox(width: 10.pt),
                            WisText(
                              '子任务执行人',
                              size: 15.pt,
                              color: colorScheme.mainTitle,
                            ),
                          ],
                        ),
                        titleWidth: 150.pt,
                        isRequired: false,
                        dataList: store.operatorList,
                        initialValue: store.childOperatorId,
                        isMulti: true,
                        // enableValue: store.childOperatorId,
                        label: 'employeeName',
                        value: 'employeeId',
                        child: 'employees',
                        firstName: 'companyShortName',
                        firstValue: 'companyId',
                        hintText: '选择多人创建子任务',
                        isSearch: true,
                        onChanged: (v) => store.onSetChildOperator(v),
                      );
                    }),
                  ],
                ),
              ),
            ],
            Wisdom.column(
              color: Colors.white,
              padding: EdgeInsets.symmetric(vertical: 10.pt),
              border: Border(bottom: Divider.createBorderSide(context)),
              crossAxisAlignment: CrossAxisAlignment.stretch,
              children: <Widget>[
                Observer(builder: (_) {
                  return WFTreePicker(
                    title: Wisdom.row(
                      mainAxisSize: MainAxisSize.min,
                      mainAxisAlignment: MainAxisAlignment.center,
                      crossAxisAlignment: CrossAxisAlignment.center,
                      children: [
                        Image(
                          image: AssetList.$copy_png_image,
                          height: 22.pt,
                        ),
                        SizedBox(width: 10.pt),
                        WisText('抄送人',
                            color: colorScheme.mainTitle, size: 15.pt),
                      ],
                    ),
                    isRequired: false,
                    dataList: store.operatorList,
                    initialValue: store.mailToIds,
                    isMulti: true,
                    // enableValue: store.childOperatorId,
                    label: 'employeeName',
                    value: 'employeeId',
                    child: 'employees',
                    firstName: 'companyShortName',
                    firstValue: 'companyId',
                    hintText: '选择抄送人，支持选择多人',
                    isSearch: true,
                    onChanged: (v) => store.onSelectCopyPeople(v),
                  );
                }),
              ],
            ),
            Wisdom(
              color: Colors.white,
              padding: EdgeInsets.symmetric(vertical: 10.pt),
              child: WFTimePicker(
                title: Wisdom.row(
                  mainAxisSize: MainAxisSize.min,
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: [
                    Image(
                      image: AssetList.$time_png_image,
                      height: 22.pt,
                    ),
                    SizedBox(width: 10.pt),
                    WisText('完成时间', color: colorScheme.mainTitle, size: 15.pt)
                  ],
                ),
                isRequired: false,
                type: 'datetime',
                initialDate: store.params['closeTime'] ?? null,
                onChanged: (v) => store.onTimePicker(v),
                hintText: '选择完成日期，不填则不要求',
              ),
            ),
          ]),
    );
  }
}
