bill_file_rights.dart 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /// 单据附件操作权限
  2. ///
  3. /// 来源: GET /OA/GetBillFileRights?billId=AE
  4. /// SPC_ID 格式: AE:1,1,1,1,1 (新增,下载,删除,查看,终审)
  5. class BillFileRights {
  6. final bool canAdd;
  7. final bool canDownload;
  8. final bool canDelete;
  9. final bool canView;
  10. final bool canFinalApprove;
  11. const BillFileRights({
  12. required this.canAdd,
  13. required this.canDownload,
  14. required this.canDelete,
  15. required this.canView,
  16. required this.canFinalApprove,
  17. });
  18. factory BillFileRights.fromJson(Map<String, dynamic> json) => BillFileRights(
  19. canAdd: json['canAdd'] == true,
  20. canDownload: json['canDownload'] == true,
  21. canDelete: json['canDelete'] == true,
  22. canView: json['canView'] == true,
  23. canFinalApprove: json['canFinalApprove'] == true,
  24. );
  25. /// 所有权限都为 false 的初始值
  26. static const none = BillFileRights(
  27. canAdd: false,
  28. canDownload: false,
  29. canDelete: false,
  30. canView: false,
  31. canFinalApprove: false,
  32. );
  33. /// 创建页:需要新增 + 查看权限
  34. bool get canManageAttachments => canAdd && canView;
  35. /// 详情页:需要查看 + 下载权限
  36. bool get canBrowseAttachments => canView && canDownload;
  37. }