feat(mobile): add auth-province and auth-city company display in profile page
- Add authProvinceCompany and authCityCompany to RoleType enum - Update UserAuthorizationSummary to support all role types - Update profile page to display all authorization types 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
4bf4efb1f4
commit
26427443fe
|
|
@ -5,8 +5,10 @@ import '../constants/api_endpoints.dart';
|
|||
/// 角色类型
|
||||
enum RoleType {
|
||||
community,
|
||||
provinceCompany,
|
||||
cityCompany,
|
||||
authProvinceCompany, // 省团队
|
||||
provinceCompany, // 省区域
|
||||
authCityCompany, // 市团队
|
||||
cityCompany, // 市区域
|
||||
}
|
||||
|
||||
extension RoleTypeExtension on RoleType {
|
||||
|
|
@ -14,8 +16,12 @@ extension RoleTypeExtension on RoleType {
|
|||
switch (this) {
|
||||
case RoleType.community:
|
||||
return 'COMMUNITY';
|
||||
case RoleType.authProvinceCompany:
|
||||
return 'AUTH_PROVINCE_COMPANY';
|
||||
case RoleType.provinceCompany:
|
||||
return 'PROVINCE_COMPANY';
|
||||
case RoleType.authCityCompany:
|
||||
return 'AUTH_CITY_COMPANY';
|
||||
case RoleType.cityCompany:
|
||||
return 'CITY_COMPANY';
|
||||
}
|
||||
|
|
@ -25,10 +31,14 @@ extension RoleTypeExtension on RoleType {
|
|||
switch (this) {
|
||||
case RoleType.community:
|
||||
return '社区';
|
||||
case RoleType.authProvinceCompany:
|
||||
return '省团队';
|
||||
case RoleType.provinceCompany:
|
||||
return '省公司';
|
||||
return '省区域';
|
||||
case RoleType.authCityCompany:
|
||||
return '市团队';
|
||||
case RoleType.cityCompany:
|
||||
return '市公司';
|
||||
return '市区域';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -37,8 +47,12 @@ extension RoleTypeExtension on RoleType {
|
|||
switch (value.toUpperCase()) {
|
||||
case 'COMMUNITY':
|
||||
return RoleType.community;
|
||||
case 'AUTH_PROVINCE_COMPANY':
|
||||
return RoleType.authProvinceCompany;
|
||||
case 'PROVINCE_COMPANY':
|
||||
return RoleType.provinceCompany;
|
||||
case 'AUTH_CITY_COMPANY':
|
||||
return RoleType.authCityCompany;
|
||||
case 'CITY_COMPANY':
|
||||
return RoleType.cityCompany;
|
||||
default:
|
||||
|
|
@ -154,16 +168,22 @@ class AuthorizationResponse {
|
|||
class UserAuthorizationSummary {
|
||||
/// 社区授权 (如果有)
|
||||
final AuthorizationResponse? community;
|
||||
/// 省公司授权 (如果有)
|
||||
/// 省团队授权 (如果有)
|
||||
final AuthorizationResponse? authProvinceCompany;
|
||||
/// 省区域授权 (如果有)
|
||||
final AuthorizationResponse? provinceCompany;
|
||||
/// 市公司授权 (如果有)
|
||||
/// 市团队授权 (如果有)
|
||||
final AuthorizationResponse? authCityCompany;
|
||||
/// 市区域授权 (如果有)
|
||||
final AuthorizationResponse? cityCompany;
|
||||
/// 所有授权列表
|
||||
final List<AuthorizationResponse> allAuthorizations;
|
||||
|
||||
UserAuthorizationSummary({
|
||||
this.community,
|
||||
this.authProvinceCompany,
|
||||
this.provinceCompany,
|
||||
this.authCityCompany,
|
||||
this.cityCompany,
|
||||
required this.allAuthorizations,
|
||||
});
|
||||
|
|
@ -174,15 +194,23 @@ class UserAuthorizationSummary {
|
|||
/// 社区名称
|
||||
String? get communityName => community?.displayTitle;
|
||||
|
||||
/// 省公司名称
|
||||
/// 省团队名称
|
||||
String? get authProvinceCompanyName => authProvinceCompany?.displayTitle;
|
||||
|
||||
/// 省区域名称
|
||||
String? get provinceCompanyName => provinceCompany?.displayTitle;
|
||||
|
||||
/// 市公司名称
|
||||
/// 市团队名称
|
||||
String? get authCityCompanyName => authCityCompany?.displayTitle;
|
||||
|
||||
/// 市区域名称
|
||||
String? get cityCompanyName => cityCompany?.displayTitle;
|
||||
|
||||
factory UserAuthorizationSummary.fromList(List<AuthorizationResponse> authorizations) {
|
||||
AuthorizationResponse? community;
|
||||
AuthorizationResponse? authProvinceCompany;
|
||||
AuthorizationResponse? provinceCompany;
|
||||
AuthorizationResponse? authCityCompany;
|
||||
AuthorizationResponse? cityCompany;
|
||||
|
||||
for (final auth in authorizations) {
|
||||
|
|
@ -190,9 +218,15 @@ class UserAuthorizationSummary {
|
|||
case RoleType.community:
|
||||
community = auth;
|
||||
break;
|
||||
case RoleType.authProvinceCompany:
|
||||
authProvinceCompany = auth;
|
||||
break;
|
||||
case RoleType.provinceCompany:
|
||||
provinceCompany = auth;
|
||||
break;
|
||||
case RoleType.authCityCompany:
|
||||
authCityCompany = auth;
|
||||
break;
|
||||
case RoleType.cityCompany:
|
||||
cityCompany = auth;
|
||||
break;
|
||||
|
|
@ -201,7 +235,9 @@ class UserAuthorizationSummary {
|
|||
|
||||
return UserAuthorizationSummary(
|
||||
community: community,
|
||||
authProvinceCompany: authProvinceCompany,
|
||||
provinceCompany: provinceCompany,
|
||||
authCityCompany: authCityCompany,
|
||||
cityCompany: cityCompany,
|
||||
allAuthorizations: authorizations,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -35,8 +35,10 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
|||
String _community = '--';
|
||||
String _parentCommunity = '--';
|
||||
String _childCommunity = '--';
|
||||
String _cityCompany = '--';
|
||||
String _provinceCompany = '--';
|
||||
String _authCityCompany = '--'; // 市团队
|
||||
String _cityCompany = '--'; // 市区域
|
||||
String _authProvinceCompany = '--'; // 省团队
|
||||
String _provinceCompany = '--'; // 省区域
|
||||
String _province = '--';
|
||||
|
||||
// 团队数据(从 referral-service 获取)
|
||||
|
|
@ -292,8 +294,10 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
|||
|
||||
debugPrint('[ProfilePage] 授权数据加载成功:');
|
||||
debugPrint('[ProfilePage] 社区授权: ${summary.community != null}');
|
||||
debugPrint('[ProfilePage] 市公司授权: ${summary.cityCompany != null}');
|
||||
debugPrint('[ProfilePage] 省公司授权: ${summary.provinceCompany != null}');
|
||||
debugPrint('[ProfilePage] 市团队授权: ${summary.authCityCompany != null}');
|
||||
debugPrint('[ProfilePage] 市区域授权: ${summary.cityCompany != null}');
|
||||
debugPrint('[ProfilePage] 省团队授权: ${summary.authProvinceCompany != null}');
|
||||
debugPrint('[ProfilePage] 省区域授权: ${summary.provinceCompany != null}');
|
||||
|
||||
// 获取社区层级数据
|
||||
try {
|
||||
|
|
@ -315,7 +319,9 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
|||
if (mounted) {
|
||||
setState(() {
|
||||
_community = summary.communityName ?? '--';
|
||||
_authCityCompany = summary.authCityCompanyName ?? '--';
|
||||
_cityCompany = summary.cityCompanyName ?? '--';
|
||||
_authProvinceCompany = summary.authProvinceCompanyName ?? '--';
|
||||
_provinceCompany = summary.provinceCompanyName ?? '--';
|
||||
|
||||
// 更新社区考核数据
|
||||
|
|
@ -882,26 +888,38 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
|||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
// 第二行:所属社区 | 授权市公司
|
||||
// 第二行:所属社区 | 市团队
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: _buildInfoItem('所属社区', _community),
|
||||
),
|
||||
Expanded(
|
||||
child: _buildInfoItem('授权市公司', _cityCompany),
|
||||
child: _buildInfoItem('市团队', _authCityCompany),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
// 第三行:上级社区 | 授权省公司
|
||||
// 第三行:上级社区 | 市区域
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: _buildInfoItem('上级社区', _parentCommunity),
|
||||
),
|
||||
Expanded(
|
||||
child: _buildInfoItem('授权省公司', _provinceCompany),
|
||||
child: _buildInfoItem('市区域', _cityCompany),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
// 第四行:省团队 | 省区域
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: _buildInfoItem('省团队', _authProvinceCompany),
|
||||
),
|
||||
Expanded(
|
||||
child: _buildInfoItem('省区域', _provinceCompany),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
|
|||
Loading…
Reference in New Issue