63 lines
2.0 KiB
Dart
63 lines
2.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:intl/intl.dart';
|
|
|
|
// --- 新增類別模型 ---
|
|
class ExpenseClass {
|
|
final String expId;
|
|
final String? expCName;
|
|
final String? expDesc;
|
|
|
|
ExpenseClass({required this.expId, this.expCName, this.expDesc});
|
|
|
|
factory ExpenseClass.fromJson(Map<String, dynamic> json) {
|
|
return ExpenseClass(
|
|
expId: json['ExpId'] ?? '',
|
|
expCName: json['ExpCName'],
|
|
expDesc: json['Exp_Desc'],
|
|
);
|
|
}
|
|
}
|
|
|
|
class ExpenseApply {
|
|
final int? applyId;
|
|
final DateTime applyDate;
|
|
final String empNo;
|
|
final String? rowData; // 費用說明
|
|
final String? picPath; // 圖片檔名/路徑
|
|
final String? expId; // [新增] 類別 ID
|
|
final String? expCName; // [新增] 類別名稱 (供查詢顯示用)
|
|
final int? expAmt; // [新增] 費用金額
|
|
final String? creatorId;
|
|
final DateTime? createDateTime;
|
|
|
|
ExpenseApply({
|
|
this.applyId,
|
|
required this.applyDate,
|
|
required this.empNo,
|
|
this.rowData,
|
|
this.picPath,
|
|
this.expId,
|
|
this.expCName,
|
|
this.expAmt,
|
|
this.creatorId,
|
|
this.createDateTime,
|
|
});
|
|
|
|
factory ExpenseApply.fromJson(Map<String, dynamic> json) {
|
|
return ExpenseApply(
|
|
applyId: int.tryParse(json['ApplyId']?.toString() ?? ''),
|
|
applyDate: json['ApplyDate'] != null ? DateTime.parse(json['ApplyDate']) : DateTime.now(),
|
|
empNo: json['EmpNo'] as String? ?? '',
|
|
rowData: json['RowData'] as String?,
|
|
picPath: json['PicPath'] as String?,
|
|
expId: json['ExpId'] as String? ?? '', // [新增]
|
|
expCName: json['ExpCName'] as String? ?? '', // [新增] 假設後端透過 View 聯集查詢
|
|
expAmt: int.tryParse(json['ExpAmt']?.toString() ?? '0') ?? 0,
|
|
creatorId: json['CreatorId'] as String?,
|
|
createDateTime: json['CreateDateTime'] != null ? DateTime.parse(json['CreateDateTime']) : null,
|
|
);
|
|
}
|
|
|
|
// 輔助屬性:取得完整圖片路徑 (假設後端基礎 URL)
|
|
String get fullPicUrl => "https://api.gex.com.tw:8033/uploads/$picPath";
|
|
} |