add chart code
This commit is contained in:
@@ -6,6 +6,39 @@ import '../auth_manager.dart'; // 確保引入 AuthManager
|
||||
class LeaveApiService {
|
||||
final GenericApiService _apiService = GenericApiService();
|
||||
|
||||
// 新增:獲取所有啟用的假別清單
|
||||
Future<List<LeaveType>> fetchLeaveTypes() async {
|
||||
// 這裡通常不需要特別的 filter,或可根據公司邏輯過濾性別等
|
||||
return await _apiService.fetchList<LeaveType>(
|
||||
tableName: "hrs_leavetype",
|
||||
pk: "leavetype_id",
|
||||
queryFilter: "1^100^leavetype_id^*^^^", // 取得前100筆
|
||||
fromJson: (json) => LeaveType.fromJson(json),
|
||||
);
|
||||
}
|
||||
|
||||
// 查詢員工清單 (代理人)
|
||||
Future<List<Map<String, dynamic>>> fetchEmployees(String keyword) async {
|
||||
// 1. 設定查詢過濾器 (依據 Generic API 規範)
|
||||
// 格式:當前頁^每頁筆數^排序欄位^關鍵字欄位^關鍵字內容
|
||||
// 我們同時搜尋姓名(personcname)或工號(personid)
|
||||
String queryFilter = "1^50^personid^*^^^personcname^$keyword";
|
||||
|
||||
final List<dynamic> result = await _apiService.fetchList<dynamic>(
|
||||
tableName: "basperson", // 指向員工主檔
|
||||
pk: "personid",
|
||||
queryFilter: queryFilter,
|
||||
fromJson: (json) => json,
|
||||
);
|
||||
|
||||
// 2. 轉換並確保回傳正確的欄位映射
|
||||
return result.map((e) => {
|
||||
'id': e['personid'] ?? '',
|
||||
'name': e['personcname'] ?? '',
|
||||
'dept': e['departmentid'] ?? '',
|
||||
}).toList();
|
||||
}
|
||||
|
||||
// 獲取個人請假紀錄
|
||||
Future<List<Leave>> fetchLeaves(String personId) async {
|
||||
// 排序:按單據日期降冪
|
||||
|
||||
Reference in New Issue
Block a user