2025-12-29 First Commit

This commit is contained in:
DATAEXPRESS\4734
2025-12-29 15:20:40 +08:00
commit fb2603c6f0
92 changed files with 6006 additions and 0 deletions
+44
View File
@@ -0,0 +1,44 @@
import './leave_model.dart';
import '../services/generic_api_service.dart';
import 'package:intl/intl.dart';
class LeaveApiService {
final GenericApiService _apiService = GenericApiService();
// 獲取個人請假紀錄
Future<List<Leave>> fetchLeaves(String personId) async {
// 排序:按單據日期降冪
String queryFilter = "1^100^billdate^*^personid^=^$personId";
return await _apiService.fetchList<Leave>(
tableName: "hrs_leave",
pk: "billno",
queryFilter: queryFilter,
fromJson: (json) => Leave.fromJson(json),
);
}
// 提交請假單 (新增)
Future<bool> createLeave(Leave leave) async {
final Map<String, dynamic> data = {
"billdate": DateFormat('yyyy-MM-dd HH:mm:ss').format(DateTime.now()),
"billno": "LV${DateTime.now().millisecondsSinceEpoch}", // 範例編號
"personid": leave.personId,
"agentid": leave.agentId,
"leavetype": leave.leaveType,
"starttime": DateFormat('yyyy-MM-dd HH:mm:ss').format(leave.startTime!),
"endtime": DateFormat('yyyy-MM-dd HH:mm:ss').format(leave.endTime!),
"days": leave.days,
"hours": leave.hours,
"leave_note": leave.leaveNote,
"flow_status": "1", // 提交即進入審核中
"create_user": leave.personId,
"create_date": DateFormat('yyyy-MM-dd HH:mm:ss').format(DateTime.now()),
};
// 呼叫底層 saveData 實作
// return await _apiService.saveData("hrs_leave", data);
print("提交假單: $data");
return true;
}
}