增添優化功能
This commit is contained in:
@@ -1,2 +1,5 @@
|
|||||||
org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError
|
org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError
|
||||||
android.useAndroidX=true
|
android.useAndroidX=true
|
||||||
|
|
||||||
|
kotlin.incremental=false
|
||||||
|
kotlin.incremental.android=false
|
||||||
@@ -25,7 +25,7 @@ class ClockInApiService {
|
|||||||
return await _apiService.fetchList<ClockInRecord>(
|
return await _apiService.fetchList<ClockInRecord>(
|
||||||
tableName: "hrs_ClockInRecord",
|
tableName: "hrs_ClockInRecord",
|
||||||
pk: "ClockInId",
|
pk: "ClockInId",
|
||||||
queryFilter: "1^100^ClockInDateTime^*^ClockInDateTime >= DATE_SUB(CURDATE(), INTERVAL 7 DAY)^^ClockInUserId^$userId",
|
queryFilter: "1^100^ClockInDateTime^*^ClockInDateTime >= DATE_SUB(CURDATE(), INTERVAL 7 DAY)^hrs_ClockInRecord^ClockInUserId^$userId",
|
||||||
fromJson: (json) => ClockInRecord.fromJson(json),
|
fromJson: (json) => ClockInRecord.fromJson(json),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -241,7 +241,7 @@ class _ClockInManagerState extends State<ClockInManager> {
|
|||||||
return ListTile(
|
return ListTile(
|
||||||
leading: Icon(Icons.access_time, color: record.typeColor),
|
leading: Icon(Icons.access_time, color: record.typeColor),
|
||||||
title: Text("${record.type} - ${record.formattedDateTime}"),
|
title: Text("${record.type} - ${record.formattedDateTime}"),
|
||||||
subtitle: Text(record.storeId ?? ""),
|
subtitle: Text(record.StoreName ?? ""),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,6 +9,7 @@ class ClockInRecord {
|
|||||||
final double? longitude;
|
final double? longitude;
|
||||||
final String? type;
|
final String? type;
|
||||||
final String? storeId;
|
final String? storeId;
|
||||||
|
final String? StoreName;
|
||||||
|
|
||||||
ClockInRecord({
|
ClockInRecord({
|
||||||
this.clockInId,
|
this.clockInId,
|
||||||
@@ -18,6 +19,7 @@ class ClockInRecord {
|
|||||||
this.longitude,
|
this.longitude,
|
||||||
this.type,
|
this.type,
|
||||||
this.storeId,
|
this.storeId,
|
||||||
|
this.StoreName,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory ClockInRecord.fromJson(Map<String, dynamic> json) {
|
factory ClockInRecord.fromJson(Map<String, dynamic> json) {
|
||||||
@@ -29,6 +31,7 @@ class ClockInRecord {
|
|||||||
longitude: double.tryParse(json['ClockInLongitude']?.toString() ?? '0'),
|
longitude: double.tryParse(json['ClockInLongitude']?.toString() ?? '0'),
|
||||||
type: json['ClockInType'] as String?,
|
type: json['ClockInType'] as String?,
|
||||||
storeId: json['ClockInStoreId'] as String?,
|
storeId: json['ClockInStoreId'] as String?,
|
||||||
|
StoreName: json['StoreName'] as String?,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class ExpenseApiService {
|
|||||||
// 1. 獲取費用申請清單
|
// 1. 獲取費用申請清單
|
||||||
Future<List<ExpenseApply>> fetchExpenses(String empNo) async {
|
Future<List<ExpenseApply>> fetchExpenses(String empNo) async {
|
||||||
// 根據 index.js 邏輯,queryFilter 應符合後端 split('^') 的期待
|
// 根據 index.js 邏輯,queryFilter 應符合後端 split('^') 的期待
|
||||||
String queryFilter = "1^100^ApplyDate^*^EmpNo^$empNo";
|
String queryFilter = "1^100^ApplyDate^*^^eipm24^EmpNo^$empNo^^";
|
||||||
return await _apiService.fetchList<ExpenseApply>(
|
return await _apiService.fetchList<ExpenseApply>(
|
||||||
tableName: "acc_ExpsApply",
|
tableName: "acc_ExpsApply",
|
||||||
pk: "ApplyId",
|
pk: "ApplyId",
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ class ExpenseDetail extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
_buildDetailRow(Icons.event, '費用日期', DateFormat('yyyy-MM-dd').format(expense.applyDate)),
|
_buildDetailRow(Icons.event, '費用日期', DateFormat('yyyy-MM-dd').format(expense.applyDate)),
|
||||||
const Divider(height: 30),
|
const Divider(height: 30),
|
||||||
_buildDetailRow(Icons.badge_outlined, '申請人工號', expense.empNo),
|
_buildDetailRow(Icons.badge_outlined, '申請人工號', '${expense.empNo} ${expense.personCName}'),
|
||||||
const Divider(height: 30),
|
const Divider(height: 30),
|
||||||
_buildDetailRow(Icons.category, '費用類別', expense.expCName ?? expense.expId ?? '未分類'),
|
_buildDetailRow(Icons.category, '費用類別', expense.expCName ?? expense.expId ?? '未分類'),
|
||||||
const Divider(height: 30),
|
const Divider(height: 30),
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ class ExpenseApply {
|
|||||||
final int? applyId;
|
final int? applyId;
|
||||||
final DateTime applyDate;
|
final DateTime applyDate;
|
||||||
final String empNo;
|
final String empNo;
|
||||||
|
final String? personCName; // new
|
||||||
final String? rowData; // 費用說明
|
final String? rowData; // 費用說明
|
||||||
final String? picPath; // 圖片檔名/路徑
|
final String? picPath; // 圖片檔名/路徑
|
||||||
final String? expId; // [新增] 類別 ID
|
final String? expId; // [新增] 類別 ID
|
||||||
@@ -62,6 +63,7 @@ class ExpenseApply {
|
|||||||
this.applyId,
|
this.applyId,
|
||||||
required this.applyDate,
|
required this.applyDate,
|
||||||
required this.empNo,
|
required this.empNo,
|
||||||
|
this.personCName, //關聯擴充欄位
|
||||||
this.rowData,
|
this.rowData,
|
||||||
this.picPath,
|
this.picPath,
|
||||||
this.expId,
|
this.expId,
|
||||||
@@ -76,6 +78,7 @@ class ExpenseApply {
|
|||||||
applyId: int.tryParse(json['ApplyId']?.toString() ?? ''),
|
applyId: int.tryParse(json['ApplyId']?.toString() ?? ''),
|
||||||
applyDate: json['ApplyDate'] != null ? DateTime.parse(json['ApplyDate']) : DateTime.now(),
|
applyDate: json['ApplyDate'] != null ? DateTime.parse(json['ApplyDate']) : DateTime.now(),
|
||||||
empNo: json['EmpNo'] as String? ?? '',
|
empNo: json['EmpNo'] as String? ?? '',
|
||||||
|
personCName: json['personCName'] as String? ?? '', // new
|
||||||
rowData: json['RowData'] as String?,
|
rowData: json['RowData'] as String?,
|
||||||
picPath: json['PicPath'] as String?,
|
picPath: json['PicPath'] as String?,
|
||||||
expId: json['ExpId'] as String? ?? '', // [新增]
|
expId: json['ExpId'] as String? ?? '', // [新增]
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class LeaveApiService {
|
|||||||
// *** 關聯取得假別名稱,存到 Cache
|
// *** 關聯取得假別名稱,存到 Cache
|
||||||
|
|
||||||
// 排序:按單據日期降冪
|
// 排序:按單據日期降冪
|
||||||
String queryFilter = "1^100^billdate^*^start_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND DATE_ADD(CURDATE(), INTERVAL 7 DAY)^^personid^$personId";
|
String queryFilter = "1^100^billdate^*^start_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 21 DAY) AND DATE_ADD(CURDATE(), INTERVAL 7 DAY)^hrsm11^personid^$personId";
|
||||||
|
|
||||||
return await _apiService.fetchList<Leave>(
|
return await _apiService.fetchList<Leave>(
|
||||||
tableName: "hrs_leave",
|
tableName: "hrs_leave",
|
||||||
@@ -147,4 +147,55 @@ class LeaveApiService {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 上呈請假單
|
||||||
|
/// 上呈請假單
|
||||||
|
/// 對應 API 規格: bpmm02_spread
|
||||||
|
Future<bool> promoteLeave(String personId, String billNo) async {
|
||||||
|
// 依據標準規範,參數一律使用 para0x
|
||||||
|
final Map<String, String> params = {
|
||||||
|
"para01": "eipm21",
|
||||||
|
"para02": personId,
|
||||||
|
"para03": billNo,
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 使用與 sign_todo_api.dart 相同的 fetchProcedure 結構
|
||||||
|
// 依據您提供的 url: ".../bpmm02_spread/1/",這裡將 endpoint 設為 "bpmm02_spread/1/"
|
||||||
|
// (若底層機制會自動補齊後方的 /1/,可自行改為 "bpmm02_spread")
|
||||||
|
await _apiService.fetchProcedure<dynamic>(
|
||||||
|
procedureEndpoint: "bpmm02_spread",
|
||||||
|
params: params,
|
||||||
|
fromJson: (json) => json, // 僅需確認執行成功,回傳值暫不處理
|
||||||
|
);
|
||||||
|
|
||||||
|
// 只要 fetchProcedure 沒有拋出異常 (且底層已處理 code == 0),即視為成功
|
||||||
|
return true;
|
||||||
|
} catch (e) {
|
||||||
|
// 統一的錯誤捕獲與日誌
|
||||||
|
print("LeaveApiService.promoteLeave 異常: $e");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 取得簽核進度歷程
|
||||||
|
/// 對應 API: bpm_sign_history/2/
|
||||||
|
Future<List<Map<String, dynamic>>> fetchSignHistory(String billNo) async {
|
||||||
|
final Map<String, String> params = {
|
||||||
|
"para01": "eipm21", // 來源單別 functiontag
|
||||||
|
"para02": billNo, // 原單單號 query_id
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 呼叫 SP,並將回傳的每一筆資料解析為 Map
|
||||||
|
return await _apiService.fetchProcedure<Map<String, dynamic>>(
|
||||||
|
procedureEndpoint: "bpm_sign_history",
|
||||||
|
params: params,
|
||||||
|
fromJson: (json) => json as Map<String, dynamic>,
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
print("LeaveApiService.fetchSignHistory 異常: $e");
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+138
-50
@@ -13,30 +13,46 @@ class LeaveDetail extends StatefulWidget {
|
|||||||
|
|
||||||
class _LeaveDetailState extends State<LeaveDetail> {
|
class _LeaveDetailState extends State<LeaveDetail> {
|
||||||
final LeaveApiService _apiService = LeaveApiService();
|
final LeaveApiService _apiService = LeaveApiService();
|
||||||
bool _isWithdrawing = false;
|
bool _isPromoting = false;
|
||||||
|
|
||||||
// 實作撤回邏輯
|
// 實作上呈邏輯
|
||||||
Future<void> _handleWithdraw() async {
|
Future<void> _handlePromote() async {
|
||||||
final confirm = await showDialog<bool>(
|
final confirm = await showDialog<bool>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (ctx) => AlertDialog(
|
builder: (ctx) => AlertDialog(
|
||||||
title: const Text('確認撤回'),
|
title: const Text('確認上呈'),
|
||||||
content: const Text('您確定要撤回此張請假單嗎?'),
|
content: const Text('您確定要將此張請假單上呈簽核嗎?'),
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(onPressed: () => Navigator.pop(ctx, false), child: const Text('取消')),
|
TextButton(
|
||||||
TextButton(onPressed: () => Navigator.pop(ctx, true), child: const Text('確定', style: TextStyle(color: Colors.red))),
|
onPressed: () => Navigator.pop(ctx, false),
|
||||||
|
child: const Text('取消', style: TextStyle(color: Colors.grey))
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.pop(ctx, true),
|
||||||
|
child: const Text('確定上呈', style: TextStyle(color: Colors.blue, fontWeight: FontWeight.bold))
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (confirm == true) {
|
if (confirm == true) {
|
||||||
setState(() => _isWithdrawing = true);
|
setState(() => _isPromoting = true);
|
||||||
final success = await _apiService.withdrawLeave(widget.leave.billNo);
|
|
||||||
setState(() => _isWithdrawing = false);
|
final success = await _apiService.promoteLeave(
|
||||||
|
widget.leave.personId,
|
||||||
|
widget.leave.billNo
|
||||||
|
);
|
||||||
|
|
||||||
|
setState(() => _isPromoting = false);
|
||||||
|
|
||||||
if (success && mounted) {
|
if (success && mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('已成功撤回')));
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
Navigator.pop(context, true); // 回傳 true 讓前一頁 (Manager) 重新整理列表
|
const SnackBar(
|
||||||
|
content: Text('已成功上呈單據'),
|
||||||
|
backgroundColor: Colors.green,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
Navigator.pop(context, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -56,24 +72,31 @@ class _LeaveDetailState extends State<LeaveDetail> {
|
|||||||
_buildInfoCard(context),
|
_buildInfoCard(context),
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
|
|
||||||
// 修正 3: 新增簽核進度區塊
|
// 簽核進度區塊
|
||||||
const Text('簽核進度', style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color: Colors.blueGrey)),
|
const Text('簽核進度', style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color: Colors.blueGrey)),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
_buildFlowTimeline(),
|
_buildSignHistoryTable(),
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
|
|
||||||
// 修正 5: 實作撤回按鈕邏輯
|
|
||||||
if (leave.flowStatus == '0' || leave.flowStatus == '1')
|
if (leave.flowStatus == '0' || leave.flowStatus == '1')
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
child: OutlinedButton.icon(
|
child: ElevatedButton.icon(
|
||||||
onPressed: _isWithdrawing ? null : _handleWithdraw,
|
onPressed: _isPromoting ? null : _handlePromote,
|
||||||
icon: _isWithdrawing ? const CircularProgressIndicator(strokeWidth: 2) : const Icon(Icons.history_outlined),
|
icon: _isPromoting
|
||||||
label: Text(_isWithdrawing ? '處理中...' : '撤回申請'),
|
? const SizedBox(
|
||||||
style: OutlinedButton.styleFrom(
|
width: 20, height: 20,
|
||||||
foregroundColor: Colors.red,
|
child: CircularProgressIndicator(strokeWidth: 2, color: Colors.white)
|
||||||
side: const BorderSide(color: Colors.red),
|
)
|
||||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
: const Icon(Icons.send_rounded),
|
||||||
|
label: Text(_isPromoting ? '上呈處理中...' : '上呈申請'),
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
backgroundColor: Colors.blue,
|
||||||
|
foregroundColor: Colors.white,
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -92,7 +115,6 @@ class _LeaveDetailState extends State<LeaveDetail> {
|
|||||||
children: [
|
children: [
|
||||||
Text('單號: ${widget.leave.billNo}', style: const TextStyle(fontSize: 14, color: Colors.grey)),
|
Text('單號: ${widget.leave.billNo}', style: const TextStyle(fontSize: 14, color: Colors.grey)),
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
// 修正 4: 顯示 leaveTypeName
|
|
||||||
Text(widget.leave.leaveTypeName, style: const TextStyle(fontSize: 28, fontWeight: FontWeight.bold)),
|
Text(widget.leave.leaveTypeName, style: const TextStyle(fontSize: 28, fontWeight: FontWeight.bold)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -106,10 +128,7 @@ class _LeaveDetailState extends State<LeaveDetail> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildInfoCard(BuildContext context) {
|
Widget _buildInfoCard(BuildContext context) {
|
||||||
// 處理代理人顯示文字 (防呆處理)
|
String displayAgent = '${widget.leave.agentId} ${widget.leave.agentName}';
|
||||||
String displayAgent = widget.leave.agentName.isNotEmpty
|
|
||||||
? '${widget.leave.agentName} (${widget.leave.agentId})'
|
|
||||||
: widget.leave.agentId;
|
|
||||||
|
|
||||||
return Card(
|
return Card(
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
@@ -122,7 +141,6 @@ class _LeaveDetailState extends State<LeaveDetail> {
|
|||||||
const Divider(height: 30),
|
const Divider(height: 30),
|
||||||
_buildDetailRow(Icons.timer_outlined, '請假時數', '${widget.leave.days} 天 ${widget.leave.hours} 小時'),
|
_buildDetailRow(Icons.timer_outlined, '請假時數', '${widget.leave.days} 天 ${widget.leave.hours} 小時'),
|
||||||
const Divider(height: 30),
|
const Divider(height: 30),
|
||||||
// 修正 6: 顯示帶有姓名的代理人資訊
|
|
||||||
_buildDetailRow(Icons.person_outline, '代理人', displayAgent),
|
_buildDetailRow(Icons.person_outline, '代理人', displayAgent),
|
||||||
const Divider(height: 30),
|
const Divider(height: 30),
|
||||||
_buildDetailRow(Icons.edit_note, '事由', widget.leave.leaveNote ?? '未填寫'),
|
_buildDetailRow(Icons.edit_note, '事由', widget.leave.leaveNote ?? '未填寫'),
|
||||||
@@ -148,33 +166,103 @@ class _LeaveDetailState extends State<LeaveDetail> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 實作簽核時間軸 (搭配 FutureBuilder)
|
// ===== 簽核進度 Table (精準對接 SP 欄位) =====
|
||||||
Widget _buildFlowTimeline() {
|
Widget _buildSignHistoryTable() {
|
||||||
return FutureBuilder<List<FlowLog>>(
|
return FutureBuilder<List<Map<String, dynamic>>>(
|
||||||
future: _apiService.fetchFlowLogs(widget.leave.billNo),
|
future: _apiService.fetchSignHistory(widget.leave.billNo),
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
if (snapshot.connectionState == ConnectionState.waiting) return const Center(child: CircularProgressIndicator());
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||||
if (!snapshot.hasData || snapshot.data!.isEmpty) return const Text('尚無簽核歷程', style: TextStyle(color: Colors.grey));
|
return const Center(child: Padding(
|
||||||
|
padding: EdgeInsets.all(20.0),
|
||||||
|
child: CircularProgressIndicator(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
if (!snapshot.hasData || snapshot.data!.isEmpty) {
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
width: double.infinity,
|
||||||
|
decoration: BoxDecoration(color: Colors.grey.shade50, borderRadius: BorderRadius.circular(10)),
|
||||||
|
child: const Text('尚無簽核歷程', style: TextStyle(color: Colors.grey), textAlign: TextAlign.center),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
final logs = snapshot.data!;
|
final logs = snapshot.data!;
|
||||||
return Container(
|
|
||||||
padding: const EdgeInsets.all(16),
|
return ClipRRect(
|
||||||
decoration: BoxDecoration(color: Colors.grey.shade50, borderRadius: BorderRadius.circular(10), border: Border.all(color: Colors.grey.shade200)),
|
borderRadius: BorderRadius.circular(8),
|
||||||
child: Column(
|
child: Table(
|
||||||
children: logs.map((log) {
|
border: TableBorder.all(color: Colors.grey.shade300, width: 1),
|
||||||
return ListTile(
|
// 設定各欄位的寬度比例:意見欄位給予最大空間
|
||||||
contentPadding: EdgeInsets.zero,
|
columnWidths: const {
|
||||||
leading: Icon(
|
0: FlexColumnWidth(2.0), // 簽核人
|
||||||
log.status == '1' ? Icons.check_circle : (log.status == 'X' ? Icons.cancel : Icons.pending),
|
1: FlexColumnWidth(2.0), // 狀態
|
||||||
color: log.status == '1' ? Colors.green : (log.status == 'X' ? Colors.red : Colors.orange),
|
2: FlexColumnWidth(3.0), // 意見
|
||||||
),
|
3: FlexColumnWidth(2.5), // 時間
|
||||||
title: Text('${log.stepName} - ${log.approverName}'),
|
},
|
||||||
subtitle: Text(log.time != null ? DateFormat('MM/dd HH:mm').format(log.time!) : ''),
|
children: [
|
||||||
);
|
// 表頭列
|
||||||
}).toList(),
|
TableRow(
|
||||||
|
decoration: BoxDecoration(color: Colors.blueGrey.shade50),
|
||||||
|
children: [
|
||||||
|
_buildTableCell('簽核人', isHeader: true),
|
||||||
|
_buildTableCell('狀態', isHeader: true),
|
||||||
|
_buildTableCell('意見', isHeader: true),
|
||||||
|
_buildTableCell('時間', isHeader: true),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
// 動態產生資料列,對接 SP 欄位
|
||||||
|
...logs.map((log) {
|
||||||
|
final approver = log['personcname']?.toString() ?? '-';
|
||||||
|
final statusName = log['sign_status_name']?.toString() ?? '-';
|
||||||
|
final note = log['sign_note']?.toString() ?? '';
|
||||||
|
final timeStr = log['create_date']?.toString() ?? '';
|
||||||
|
|
||||||
|
// 簡單判斷狀態文字來給予顏色提示 (依照中文涵義)
|
||||||
|
Color statusColor = Colors.black87;
|
||||||
|
if (statusName.contains('同意') || statusName.contains('核准')) {
|
||||||
|
statusColor = Colors.green;
|
||||||
|
} else if (statusName.contains('駁回') || statusName.contains('拒絕')) {
|
||||||
|
statusColor = Colors.red;
|
||||||
|
} else if (statusName.contains('待簽')) {
|
||||||
|
statusColor = Colors.orange;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 處理時間格式,如果為 yyyy-MM-dd HH:mm:ss 則截取 MM-dd HH:mm 以節省空間
|
||||||
|
String displayTime = timeStr;
|
||||||
|
if (displayTime.length >= 16) {
|
||||||
|
// 如果前面有年份(例如: 2026-03-04),可視需求決定要不要擷取 substring(5, 16)
|
||||||
|
displayTime = displayTime.substring(5, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TableRow(
|
||||||
|
children: [
|
||||||
|
_buildTableCell(approver),
|
||||||
|
_buildTableCell(statusName, textColor: statusColor),
|
||||||
|
_buildTableCell(note.isEmpty ? '-' : note),
|
||||||
|
_buildTableCell(displayTime),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 表格單元格的小元件
|
||||||
|
Widget _buildTableCell(String text, {bool isHeader = false, Color? textColor}) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 4),
|
||||||
|
child: Text(
|
||||||
|
text,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: isHeader ? FontWeight.bold : FontWeight.normal,
|
||||||
|
color: textColor ?? (isHeader ? Colors.blueGrey.shade700 : Colors.black87),
|
||||||
|
fontSize: 13,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -76,7 +76,9 @@ class _LeaveFormState extends State<LeaveForm> {
|
|||||||
billNo: '', // API 端生成
|
billNo: '', // API 端生成
|
||||||
personId: widget.userId,
|
personId: widget.userId,
|
||||||
agentId: _selectedAgent!['id'].toString(), // 確保轉為 String
|
agentId: _selectedAgent!['id'].toString(), // 確保轉為 String
|
||||||
|
agentName: '',
|
||||||
leaveType: _selectedType!.id, // 傳送 ID 給後端
|
leaveType: _selectedType!.id, // 傳送 ID 給後端
|
||||||
|
leaveTypeName: '',
|
||||||
startTime: start,
|
startTime: start,
|
||||||
endTime: end,
|
endTime: end,
|
||||||
days: calcDays, // 寫入計算後的天數
|
days: calcDays, // 寫入計算後的天數
|
||||||
|
|||||||
@@ -47,9 +47,9 @@ class Leave {
|
|||||||
this.billDate,
|
this.billDate,
|
||||||
required this.personId,
|
required this.personId,
|
||||||
required this.agentId,
|
required this.agentId,
|
||||||
this.agentName = '',
|
required this.agentName,
|
||||||
required this.leaveType,
|
required this.leaveType,
|
||||||
this.leaveTypeName = '',
|
required this.leaveTypeName,
|
||||||
this.startTime,
|
this.startTime,
|
||||||
this.endTime,
|
this.endTime,
|
||||||
this.days = 0,
|
this.days = 0,
|
||||||
@@ -70,7 +70,7 @@ class Leave {
|
|||||||
billDate: json['billdate'] != null ? DateTime.tryParse(json['billdate']) : null,
|
billDate: json['billdate'] != null ? DateTime.tryParse(json['billdate']) : null,
|
||||||
personId: json['personid'] as String? ?? '',
|
personId: json['personid'] as String? ?? '',
|
||||||
agentId: json['agentid'] as String? ?? '',
|
agentId: json['agentid'] as String? ?? '',
|
||||||
agentName: json['agentname'] ?? '', /// 假設 API 會 Join 姓名
|
agentName: json['agentName'] ?? '', /// 假設 API 會 Join 姓名
|
||||||
leaveType: json['leavetype'] as String? ?? '',
|
leaveType: json['leavetype'] as String? ?? '',
|
||||||
// leaveTypeName: json['leavetype_name'] ?? json['leavetype'] ?? '',
|
// leaveTypeName: json['leavetype_name'] ?? json['leavetype'] ?? '',
|
||||||
leaveTypeName: typeName, // 這裡現在保證有值
|
leaveTypeName: typeName, // 這裡現在保證有值
|
||||||
|
|||||||
+15
-86
@@ -98,92 +98,21 @@ class MainMenu extends StatelessWidget {
|
|||||||
|
|
||||||
// 所有選單項目的列表
|
// 所有選單項目的列表
|
||||||
final List<MenuItem> menuItems = [
|
final List<MenuItem> menuItems = [
|
||||||
// 1. 新聞資訊 (使用您的 NewsManager)
|
MenuItem(title: '公告事項', icon: Icons.article, targetScreen: AnnouncementManager()),
|
||||||
MenuItem(
|
MenuItem(title: '員工打卡',icon: Icons.access_time_filled,targetScreen: ClockInManager(userId: uid)),
|
||||||
title: '公告事項',
|
MenuItem(title: '請假作業', icon: Icons.event_available, targetScreen: LeaveManager(currentUserId: uid)),
|
||||||
icon: Icons.article,
|
MenuItem(title: '待簽核事項', icon: Icons.pending_actions, targetScreen: SignTodoManager()),
|
||||||
//targetScreen: NewsManager(),
|
MenuItem(title: '待辦事項', icon: Icons.checklist, targetScreen: TodoManager(currentUserId: uid)),
|
||||||
targetScreen: AnnouncementManager(),
|
MenuItem(title: '行事曆', icon: Icons.calendar_today, targetScreen: CalendarManager(userId: uid)),
|
||||||
),
|
MenuItem(title: '會議通知', icon: Icons.people_alt, targetScreen: MeetingManager()),
|
||||||
// 2. 員工打卡
|
MenuItem(title: '產品型錄', icon: Icons.local_mall, targetScreen: PlaceholderScreen(title: '產品型錄')),
|
||||||
MenuItem(
|
MenuItem(title: '通訊錄', icon: Icons.contact_phone, targetScreen: PersonManager()),
|
||||||
title: '員工打卡',
|
MenuItem(title: '業績查詢', icon: Icons.query_stats, targetScreen: ChannelSalesManager()),
|
||||||
icon: Icons.access_time_filled,
|
MenuItem(title: 'Issue List', icon: Icons.bug_report, targetScreen: IssueManager()),
|
||||||
targetScreen: ClockInManager(userId: uid),
|
MenuItem(title: '訊息通知', icon: Icons.notifications, targetScreen: MessageManager(currentUserId: uid)),
|
||||||
),
|
MenuItem(title: '費用申請', icon: Icons.article, targetScreen: ExpenseManager(currentUserId: uid)),
|
||||||
// 2. 員工打卡
|
MenuItem(title: '新聞(Demo)', icon: Icons.article, targetScreen: NewsManager()),
|
||||||
MenuItem(
|
MenuItem(title: '設定', icon: Icons.settings, targetScreen: SettingsPage()),
|
||||||
title: '請假作業',
|
|
||||||
icon: Icons.event_available,
|
|
||||||
targetScreen: LeaveManager(currentUserId: uid),
|
|
||||||
), // 3. 待簽核事項
|
|
||||||
MenuItem(
|
|
||||||
title: '待簽核事項',
|
|
||||||
icon: Icons.pending_actions,
|
|
||||||
targetScreen: SignTodoManager(),
|
|
||||||
),
|
|
||||||
// 4. 待辦事項
|
|
||||||
MenuItem(
|
|
||||||
title: '待辦事項',
|
|
||||||
icon: Icons.checklist,
|
|
||||||
targetScreen: TodoManager(currentUserId: uid),
|
|
||||||
),
|
|
||||||
// 5. 行事曆
|
|
||||||
MenuItem(
|
|
||||||
title: '行事曆',
|
|
||||||
icon: Icons.calendar_today,
|
|
||||||
targetScreen: CalendarManager(userId: uid),
|
|
||||||
),
|
|
||||||
// 6. 其他功能 (佔位)
|
|
||||||
MenuItem(
|
|
||||||
title: '會議通知',
|
|
||||||
icon: Icons.people_alt,
|
|
||||||
targetScreen: MeetingManager(),
|
|
||||||
),
|
|
||||||
// 6. 其他功能 (佔位)
|
|
||||||
MenuItem(
|
|
||||||
title: '產品型錄',
|
|
||||||
icon: Icons.local_mall,
|
|
||||||
targetScreen: PlaceholderScreen(title: '產品型錄'),
|
|
||||||
),
|
|
||||||
// 6. 其他功能 (佔位)
|
|
||||||
MenuItem(
|
|
||||||
title: '通訊錄',
|
|
||||||
icon: Icons.contact_phone,
|
|
||||||
targetScreen: PersonManager(),
|
|
||||||
),
|
|
||||||
MenuItem(
|
|
||||||
title: '業績查詢',
|
|
||||||
icon: Icons.query_stats,
|
|
||||||
targetScreen: ChannelSalesManager(),
|
|
||||||
),
|
|
||||||
MenuItem(
|
|
||||||
title: 'Issue List',
|
|
||||||
icon: Icons.bug_report,
|
|
||||||
targetScreen: IssueManager(),
|
|
||||||
),
|
|
||||||
MenuItem(
|
|
||||||
title: '訊息通知',
|
|
||||||
icon: Icons.notifications,
|
|
||||||
targetScreen: MessageManager(currentUserId: uid),
|
|
||||||
),
|
|
||||||
MenuItem(
|
|
||||||
title: '費用申請',
|
|
||||||
icon: Icons.article,
|
|
||||||
targetScreen: ExpenseManager(currentUserId: uid),
|
|
||||||
//targetScreen: AnnouncementManager(),
|
|
||||||
),
|
|
||||||
MenuItem(
|
|
||||||
title: '新聞(Demo)',
|
|
||||||
icon: Icons.article,
|
|
||||||
targetScreen: NewsManager(),
|
|
||||||
//targetScreen: AnnouncementManager(),
|
|
||||||
),
|
|
||||||
MenuItem(
|
|
||||||
title: '設定',
|
|
||||||
icon: Icons.settings,
|
|
||||||
targetScreen: SettingsPage(),
|
|
||||||
),
|
|
||||||
];
|
];
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
|
|||||||
Reference in New Issue
Block a user