04953b22dc
- 新增通用审批列表页面(我发起的/待我审批/我已审批) - 新增通用审批详情页面(支持审批通过/拒绝操作) - 修复审批列表过滤逻辑("我已审批"只显示已完成订单) - 修复登录页面未设置 Zustand store 的问题 - 修复 User 类型定义(id 改为 number 类型) - 修复草稿恢复时的日期转换问题 - 创建测试数据脚本(test_data.php) - 安装 webman 官方依赖包(database, redis, pagination 等) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
264 lines
8.4 KiB
PHP
264 lines
8.4 KiB
PHP
<?php
|
|
|
|
require_once __DIR__ . '/vendor/autoload.php';
|
|
require_once __DIR__ . '/support/bootstrap.php';
|
|
|
|
use support\Db;
|
|
|
|
$userId1 = 1; // 李佳博
|
|
$userId2 = 2; // 闫继光
|
|
$userId3 = 3; // 孟启
|
|
|
|
// 获取出差审批流程
|
|
$flow = Db::table('approval_flow')->where('business_type', 'business_trip')->where('status', 1)->first();
|
|
|
|
if (!$flow) {
|
|
echo "Error: No approval flow found\n";
|
|
exit;
|
|
}
|
|
|
|
echo "Creating test data...\n";
|
|
|
|
// 1. 创建用户2提交的申请(让用户1审批)
|
|
$trip1 = Db::table('business_trip')->insertGetId([
|
|
'user_id' => $userId2,
|
|
'reason' => '北京技术交流',
|
|
'start_date' => '2026-03-15',
|
|
'end_date' => '2026-03-17',
|
|
'destination' => '北京',
|
|
'estimated_cost' => 5000,
|
|
'status' => 'pending',
|
|
'created_at' => date('Y-m-d H:i:s'),
|
|
'updated_at' => date('Y-m-d H:i:s'),
|
|
]);
|
|
|
|
Db::table('business_trip_itinerary')->insert([
|
|
'business_trip_id' => $trip1,
|
|
'start_time' => '2026-03-15 08:00:00',
|
|
'end_time' => '2026-03-17 18:00:00',
|
|
'departure' => '郑州',
|
|
'destination' => '北京',
|
|
'transport' => '高铁',
|
|
'trip_type' => 'roundtrip',
|
|
'remark' => '参加技术交流会议',
|
|
'created_at' => date('Y-m-d H:i:s'),
|
|
'updated_at' => date('Y-m-d H:i:s'),
|
|
]);
|
|
|
|
$order1 = Db::table('approval_order')->insertGetId([
|
|
'business_type' => 'business_trip',
|
|
'business_id' => $trip1,
|
|
'title' => '出差申请 - 闫继光',
|
|
'applicant_id' => $userId2,
|
|
'status' => 'pending',
|
|
'current_nodes' => json_encode([1]),
|
|
'flow_id' => $flow->id,
|
|
'form_data' => json_encode(['reason' => '北京技术交流', 'approvers' => [$userId1]]),
|
|
'created_at' => date('Y-m-d H:i:s'),
|
|
'updated_at' => date('Y-m-d H:i:s'),
|
|
]);
|
|
|
|
Db::table('business_trip')->where('id', $trip1)->update(['approval_order_id' => $order1]);
|
|
|
|
Db::table('approval_record')->insert([
|
|
'order_id' => $order1,
|
|
'node_id' => 1,
|
|
'node_type' => 'single_approve',
|
|
'approver_id' => $userId2,
|
|
'action' => 'submit',
|
|
'created_at' => date('Y-m-d H:i:s'),
|
|
'updated_at' => date('Y-m-d H:i:s'),
|
|
]);
|
|
|
|
echo "Created trip for user 2 (闫继光), order_id: $order1\n";
|
|
|
|
// 2. 创建用户3提交的申请(让用户1审批)
|
|
$trip2 = Db::table('business_trip')->insertGetId([
|
|
'user_id' => $userId3,
|
|
'reason' => '上海客户拜访',
|
|
'start_date' => '2026-03-20',
|
|
'end_date' => '2026-03-21',
|
|
'destination' => '上海',
|
|
'estimated_cost' => 3000,
|
|
'status' => 'pending',
|
|
'created_at' => date('Y-m-d H:i:s'),
|
|
'updated_at' => date('Y-m-d H:i:s'),
|
|
]);
|
|
|
|
Db::table('business_trip_itinerary')->insert([
|
|
'business_trip_id' => $trip2,
|
|
'start_time' => '2026-03-20 08:00:00',
|
|
'end_time' => '2026-03-21 18:00:00',
|
|
'departure' => '郑州',
|
|
'destination' => '上海',
|
|
'transport' => '高铁',
|
|
'trip_type' => 'roundtrip',
|
|
'remark' => '拜访重要客户',
|
|
'created_at' => date('Y-m-d H:i:s'),
|
|
'updated_at' => date('Y-m-d H:i:s'),
|
|
]);
|
|
|
|
$order2 = Db::table('approval_order')->insertGetId([
|
|
'business_type' => 'business_trip',
|
|
'business_id' => $trip2,
|
|
'title' => '出差申请 - 孟启',
|
|
'applicant_id' => $userId3,
|
|
'status' => 'pending',
|
|
'current_nodes' => json_encode([1]),
|
|
'flow_id' => $flow->id,
|
|
'form_data' => json_encode(['reason' => '上海客户拜访', 'approvers' => [$userId1]]),
|
|
'created_at' => date('Y-m-d H:i:s'),
|
|
'updated_at' => date('Y-m-d H:i:s'),
|
|
]);
|
|
|
|
Db::table('business_trip')->where('id', $trip2)->update(['approval_order_id' => $order2]);
|
|
|
|
Db::table('approval_record')->insert([
|
|
'order_id' => $order2,
|
|
'node_id' => 1,
|
|
'node_type' => 'single_approve',
|
|
'approver_id' => $userId3,
|
|
'action' => 'submit',
|
|
'created_at' => date('Y-m-d H:i:s'),
|
|
'updated_at' => date('Y-m-d H:i:s'),
|
|
]);
|
|
|
|
echo "Created trip for user 3 (孟启), order_id: $order2\n";
|
|
|
|
// 3. 创建一个已通过的申请(用户1审批的)
|
|
$trip3 = Db::table('business_trip')->insertGetId([
|
|
'user_id' => $userId2,
|
|
'reason' => '广州展会',
|
|
'start_date' => '2026-03-10',
|
|
'end_date' => '2026-03-12',
|
|
'destination' => '广州',
|
|
'estimated_cost' => 8000,
|
|
'status' => 'approved',
|
|
'created_at' => date('Y-m-d H:i:s', strtotime('-2 days')),
|
|
'updated_at' => date('Y-m-d H:i:s', strtotime('-1 day')),
|
|
]);
|
|
|
|
Db::table('business_trip_itinerary')->insert([
|
|
'business_trip_id' => $trip3,
|
|
'start_time' => '2026-03-10 08:00:00',
|
|
'end_time' => '2026-03-12 18:00:00',
|
|
'departure' => '郑州',
|
|
'destination' => '广州',
|
|
'transport' => '飞机',
|
|
'trip_type' => 'roundtrip',
|
|
'remark' => '参加行业展会',
|
|
'created_at' => date('Y-m-d H:i:s', strtotime('-2 days')),
|
|
'updated_at' => date('Y-m-d H:i:s', strtotime('-2 days')),
|
|
]);
|
|
|
|
$order3 = Db::table('approval_order')->insertGetId([
|
|
'business_type' => 'business_trip',
|
|
'business_id' => $trip3,
|
|
'title' => '出差申请 - 闫继光',
|
|
'applicant_id' => $userId2,
|
|
'status' => 'approved',
|
|
'current_nodes' => json_encode([]),
|
|
'flow_id' => $flow->id,
|
|
'form_data' => json_encode(['reason' => '广州展会', 'approvers' => [$userId1]]),
|
|
'created_at' => date('Y-m-d H:i:s', strtotime('-2 days')),
|
|
'updated_at' => date('Y-m-d H:i:s', strtotime('-1 day')),
|
|
]);
|
|
|
|
Db::table('business_trip')->where('id', $trip3)->update(['approval_order_id' => $order3]);
|
|
|
|
Db::table('approval_record')->insert([
|
|
'order_id' => $order3,
|
|
'node_id' => 1,
|
|
'node_type' => 'single_approve',
|
|
'approver_id' => $userId2,
|
|
'action' => 'submit',
|
|
'created_at' => date('Y-m-d H:i:s', strtotime('-2 days')),
|
|
'updated_at' => date('Y-m-d H:i:s', strtotime('-2 days')),
|
|
]);
|
|
|
|
Db::table('approval_record')->insert([
|
|
'order_id' => $order3,
|
|
'node_id' => 1,
|
|
'node_type' => 'single_approve',
|
|
'approver_id' => $userId1,
|
|
'action' => 'approve',
|
|
'comment' => '同意',
|
|
'created_at' => date('Y-m-d H:i:s', strtotime('-1 day')),
|
|
'updated_at' => date('Y-m-d H:i:s', strtotime('-1 day')),
|
|
]);
|
|
|
|
echo "Created approved trip, order_id: $order3\n";
|
|
|
|
// 4. 创建一个已拒绝的申请
|
|
$trip4 = Db::table('business_trip')->insertGetId([
|
|
'user_id' => $userId3,
|
|
'reason' => '深圳培训',
|
|
'start_date' => '2026-03-05',
|
|
'end_date' => '2026-03-06',
|
|
'destination' => '深圳',
|
|
'estimated_cost' => 2000,
|
|
'status' => 'rejected',
|
|
'created_at' => date('Y-m-d H:i:s', strtotime('-3 days')),
|
|
'updated_at' => date('Y-m-d H:i:s', strtotime('-2 days')),
|
|
]);
|
|
|
|
Db::table('business_trip_itinerary')->insert([
|
|
'business_trip_id' => $trip4,
|
|
'start_time' => '2026-03-05 08:00:00',
|
|
'end_time' => '2026-03-06 18:00:00',
|
|
'departure' => '郑州',
|
|
'destination' => '深圳',
|
|
'transport' => '高铁',
|
|
'trip_type' => 'roundtrip',
|
|
'remark' => '参加产品培训',
|
|
'created_at' => date('Y-m-d H:i:s', strtotime('-3 days')),
|
|
'updated_at' => date('Y-m-d H:i:s', strtotime('-3 days')),
|
|
]);
|
|
|
|
$order4 = Db::table('approval_order')->insertGetId([
|
|
'business_type' => 'business_trip',
|
|
'business_id' => $trip4,
|
|
'title' => '出差申请 - 孟启',
|
|
'applicant_id' => $userId3,
|
|
'status' => 'rejected',
|
|
'current_nodes' => json_encode([]),
|
|
'flow_id' => $flow->id,
|
|
'form_data' => json_encode(['reason' => '深圳培训', 'approvers' => [$userId1]]),
|
|
'created_at' => date('Y-m-d H:i:s', strtotime('-3 days')),
|
|
'updated_at' => date('Y-m-d H:i:s', strtotime('-2 days')),
|
|
]);
|
|
|
|
Db::table('business_trip')->where('id', $trip4)->update(['approval_order_id' => $order4]);
|
|
|
|
Db::table('approval_record')->insert([
|
|
'order_id' => $order4,
|
|
'node_id' => 1,
|
|
'node_type' => 'single_approve',
|
|
'approver_id' => $userId3,
|
|
'action' => 'submit',
|
|
'created_at' => date('Y-m-d H:i:s', strtotime('-3 days')),
|
|
'updated_at' => date('Y-m-d H:i:s', strtotime('-3 days')),
|
|
]);
|
|
|
|
Db::table('approval_record')->insert([
|
|
'order_id' => $order4,
|
|
'node_id' => 1,
|
|
'node_type' => 'single_approve',
|
|
'approver_id' => $userId1,
|
|
'action' => 'reject',
|
|
'comment' => '预算不足,暂不批准',
|
|
'created_at' => date('Y-m-d H:i:s', strtotime('-2 days')),
|
|
'updated_at' => date('Y-m-d H:i:s', strtotime('-2 days')),
|
|
]);
|
|
|
|
echo "Created rejected trip, order_id: $order4\n";
|
|
|
|
// 5. 更新现有订单4的审批节点,让用户1成为审批人
|
|
Db::table('approval_order')->where('id', 4)->update([
|
|
'form_data' => json_encode(['reason' => '11', 'approvers' => [$userId1]]),
|
|
]);
|
|
|
|
echo "Updated order 4 to make user 1 the approver\n";
|
|
|
|
echo "\n=== Test data created successfully ===\n";
|