|
@@ -61,7 +61,11 @@ class _CrowdSelectLabelState extends State<CrowdSelectLabelView> {
|
|
|
isChecked: controller.state.isAllSelect
|
|
|
? controller.state.isAllSelect
|
|
|
: controller.state.selectedCodes.contains(dto.code),
|
|
|
+ isAllChecked: controller.state.isAllSelect,
|
|
|
onChanged: (value) {
|
|
|
+ if (controller.state.isAllSelect && dto.code != "0") {
|
|
|
+ return;
|
|
|
+ }
|
|
|
controller.onItemCheckChanged(dto.code!);
|
|
|
if (controller.state.selectedCodes.length == 7) {
|
|
|
controller.state.isAllSelect = true;
|
|
@@ -81,6 +85,9 @@ class VCheckBoxButton extends StatefulWidget {
|
|
|
/// 是否默认选中
|
|
|
final bool? isChecked;
|
|
|
|
|
|
+ /// 是否默认选中
|
|
|
+ final bool? isAllChecked;
|
|
|
+
|
|
|
/// 选中状态变更
|
|
|
final ValueChanged<bool>? onChanged;
|
|
|
|
|
@@ -89,6 +96,7 @@ class VCheckBoxButton extends StatefulWidget {
|
|
|
required this.label,
|
|
|
this.isChecked,
|
|
|
this.onChanged,
|
|
|
+ this.isAllChecked,
|
|
|
});
|
|
|
@override
|
|
|
State<StatefulWidget> createState() => _VCheckBoxState();
|
|
@@ -96,12 +104,16 @@ class VCheckBoxButton extends StatefulWidget {
|
|
|
|
|
|
class _VCheckBoxState extends State<VCheckBoxButton> {
|
|
|
bool _isChecked = false;
|
|
|
+ bool _isAllChecked = false;
|
|
|
|
|
|
@override
|
|
|
void initState() {
|
|
|
if (widget.isChecked != null) {
|
|
|
_isChecked = widget.isChecked!;
|
|
|
}
|
|
|
+ if (widget.isAllChecked != null) {
|
|
|
+ _isAllChecked = widget.isAllChecked!;
|
|
|
+ }
|
|
|
super.initState();
|
|
|
}
|
|
|
|
|
@@ -127,9 +139,15 @@ class _VCheckBoxState extends State<VCheckBoxButton> {
|
|
|
alignment: Alignment.center,
|
|
|
height: height,
|
|
|
decoration: BoxDecoration(
|
|
|
- color: _isChecked ? primaryColor : Colors.white,
|
|
|
+ color: (_isAllChecked && widget.label != "全选")
|
|
|
+ ? Colors.grey
|
|
|
+ : _isChecked
|
|
|
+ ? primaryColor
|
|
|
+ : Colors.white,
|
|
|
borderRadius: BorderRadius.circular(borderRadius),
|
|
|
- border: _isChecked ? null : Border.all(color: primaryColor),
|
|
|
+ border: ((_isAllChecked && widget.label != "全选") || _isChecked)
|
|
|
+ ? null
|
|
|
+ : Border.all(color: primaryColor),
|
|
|
),
|
|
|
child: Row(
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
@@ -138,7 +156,11 @@ class _VCheckBoxState extends State<VCheckBoxButton> {
|
|
|
Text(
|
|
|
widget.label,
|
|
|
style: TextStyle(
|
|
|
- color: _isChecked ? Colors.white : primaryColor,
|
|
|
+ color: (_isAllChecked && widget.label != "全选")
|
|
|
+ ? Colors.black
|
|
|
+ : _isChecked
|
|
|
+ ? Colors.white
|
|
|
+ : primaryColor,
|
|
|
fontSize: 16,
|
|
|
),
|
|
|
),
|
|
@@ -151,3 +173,76 @@ class _VCheckBoxState extends State<VCheckBoxButton> {
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+class ContractStateSelectLabelView extends StatefulWidget {
|
|
|
+ final List<ContractStateEnum> ContractStateEnums;
|
|
|
+ final Function selectRaidoChange;
|
|
|
+ final ContractStateEnum? selectContractState;
|
|
|
+
|
|
|
+ const ContractStateSelectLabelView(
|
|
|
+ {super.key,
|
|
|
+ required this.ContractStateEnums,
|
|
|
+ required this.selectRaidoChange,
|
|
|
+ this.selectContractState});
|
|
|
+ @override
|
|
|
+ State<StatefulWidget> createState() => _ContractStateSelectLabelState();
|
|
|
+}
|
|
|
+
|
|
|
+class _ContractStateSelectLabelState
|
|
|
+ extends State<ContractStateSelectLabelView> {
|
|
|
+ late List<ContractStateEnum> ContractStateEnums;
|
|
|
+ String selectContractState = "0";
|
|
|
+
|
|
|
+ final Map<String, String> ContractStateMap = {
|
|
|
+ "All": "未选择",
|
|
|
+ "Unsigned": "未签约",
|
|
|
+ "Cancelled": "已取消",
|
|
|
+ "Expired": "已过期",
|
|
|
+ "Signed": "已签约",
|
|
|
+ "Voided": "已解约",
|
|
|
+ "Refused": "已拒绝",
|
|
|
+ };
|
|
|
+ @override
|
|
|
+ void initState() {
|
|
|
+ super.initState();
|
|
|
+ ContractStateEnums = widget.ContractStateEnums;
|
|
|
+ if (widget.selectContractState != null) {
|
|
|
+ selectContractState = widget.selectContractState!.name;
|
|
|
+ } else {
|
|
|
+ selectContractState = "0";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @override
|
|
|
+ Widget build(BuildContext context) {
|
|
|
+ return Wrap(
|
|
|
+ spacing: 16,
|
|
|
+ runSpacing: 12,
|
|
|
+ children: [
|
|
|
+ buildItem(LabelDTO(code: "0", labelName: "全选"), context),
|
|
|
+ ...ContractStateEnums.map((ContractStateEnum e) => buildItem(
|
|
|
+ LabelDTO(code: e.name, labelName: ContractStateMap[e.name]),
|
|
|
+ context)).toList(),
|
|
|
+ ],
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ Widget buildItem(LabelDTO dto, BuildContext context) {
|
|
|
+ return InkWell(
|
|
|
+ child: VCheckBoxButton(
|
|
|
+ key: GlobalKey(),
|
|
|
+ label: dto.labelName ?? '',
|
|
|
+ isChecked: selectContractState == dto.code,
|
|
|
+ // isAllChecked: selectContractState == "0",
|
|
|
+ onChanged: (value) {
|
|
|
+ // if (selectContractState == "0" && dto.code != "0") {
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ selectContractState = dto.code ?? '0';
|
|
|
+ widget.selectRaidoChange(dto.code);
|
|
|
+ setState(() {});
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ }
|
|
|
+}
|