modify clockin & leave

This commit is contained in:
2026-03-04 23:45:26 +08:00
parent ce706694ef
commit 0516db1690
7 changed files with 163 additions and 77 deletions
+43
View File
@@ -71,6 +71,11 @@ class LeaveApiService {
"flow_status": "1", // 提交即進入審核中
"create_user": currentUid,
"create_date": DateFormat('yyyy-MM-dd HH:mm:ss').format(DateTime.now()),
// Sync calc
"start_date": DateFormat('yyyy-MM-dd').format(leave.startTime!),
"end_date": DateFormat('yyyy-MM-dd').format(leave.endTime!),
"start_time": DateFormat('HH:mm').format(leave.startTime!),
"end_time": DateFormat('HH:mm').format(leave.endTime!),
};
return await _apiService.fetchList<Leave>(
@@ -82,4 +87,42 @@ class LeaveApiService {
fromJson: (json) => Leave.fromJson(json), // 這裡填入模型的解析工廠
);
}
// 修正 5: 實作撤回請假單 API
Future<bool> withdrawLeave(String billNo) async {
try {
await _apiService.fetchList<dynamic>(
tableName: "hrs_leave",
pk: "billno",
queryFilter: "billno^$billNo", // 指定該單號
action: "U", // U 代表 Update
data: {
"flow_status": "0", // 0: 退回草稿/已撤回
"update_user": AuthManager().currentUserId,
"update_date": DateFormat('yyyy-MM-dd HH:mm:ss').format(DateTime.now()),
},
fromJson: (json) => json,
);
return true;
} catch (e) {
print("撤回失敗: $e");
return false;
}
}
// 修正 3: 查詢簽核進度 (FlowLog)
Future<List<FlowLog>> fetchFlowLogs(String billNo) async {
// 假設有一張表 flow_log 記錄簽核歷程
return await _apiService.fetchList<FlowLog>(
tableName: "flow_log",
pk: "log_id",
queryFilter: "1^50^create_date^*^^^billno^$billNo",
fromJson: (json) => FlowLog(
stepName: json['step_name'] ?? '簽核節點',
approverName: json['approver_name'] ?? '系統/主管',
status: json['status'] ?? '0',
time: json['create_date'] != null ? DateTime.tryParse(json['create_date']) : null,
),
);
}
}