a76724b385
新增 DatePickerField 日期选择器与 date_util;可搜索下拉 SearchableOptionField 支持内联新建选项;入库/出库录单表单、商品页、财务页、app_shell 导航相应调整。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
54 lines
1.7 KiB
Dart
54 lines
1.7 KiB
Dart
class ShopInfo {
|
|
final int id;
|
|
final String code;
|
|
final String name;
|
|
final String address;
|
|
final String phone;
|
|
final String managerName;
|
|
final String logoUrl;
|
|
final String wechatId;
|
|
// 店级动态配置(后端 shops.custom_fields JSON),存录入默认值等轻量配置
|
|
final Map<String, dynamic> customFields;
|
|
|
|
const ShopInfo({
|
|
required this.id,
|
|
required this.code,
|
|
required this.name,
|
|
required this.address,
|
|
required this.phone,
|
|
required this.managerName,
|
|
this.logoUrl = '',
|
|
this.wechatId = '',
|
|
this.customFields = const {},
|
|
});
|
|
|
|
/// 入库录入默认商品名称选项 id(未配置返回 null)。
|
|
int? get defaultNameId => _asInt(customFields['default_name_id']);
|
|
|
|
/// 入库录入默认系列选项 id(未配置返回 null)。
|
|
int? get defaultSeriesId => _asInt(customFields['default_series_id']);
|
|
|
|
/// 入库录入默认规格选项 id(未配置返回 null)。
|
|
int? get defaultSpecId => _asInt(customFields['default_spec_id']);
|
|
|
|
static int? _asInt(dynamic v) {
|
|
if (v == null) return null;
|
|
if (v is num) return v.toInt();
|
|
return int.tryParse(v.toString());
|
|
}
|
|
|
|
factory ShopInfo.fromJson(Map<String, dynamic> json) => ShopInfo(
|
|
id: (json['id'] as num).toInt(),
|
|
code: json['code'] as String? ?? '',
|
|
name: json['name'] as String? ?? '',
|
|
address: json['address'] as String? ?? '',
|
|
phone: json['phone'] as String? ?? '',
|
|
managerName: json['manager_name'] as String? ?? '',
|
|
logoUrl: json['logo_url'] as String? ?? '',
|
|
wechatId: json['wechat_id'] as String? ?? '',
|
|
customFields:
|
|
(json['custom_fields'] as Map?)?.cast<String, dynamic>() ??
|
|
const {},
|
|
);
|
|
}
|