wlzboy
2025-09-26 97db9d11ff425583d2dece82a842a7766bb5e7e4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
<template>
  <view class="task-container">
    <!-- 任务列表头部 -->
    <view class="task-list-section">
      <view class="task-header">
        <view class="header-title">任务列表</view>
        <view class="header-actions">
          <button class="search-toggle-btn" @click="toggleSearch">
            <uni-icons :type="showSearch ? 'close' : 'search'" size="20"></uni-icons>
          </button>
          <button class="refresh-btn" @click="refreshList">
            <uni-icons type="refresh" size="20"></uni-icons>
          </button>
        </view>
      </view>
      
      <!-- 查询条件区域 -->
      <view class="search-section" v-show="showSearch">
        <view class="search-form">
          <view class="form-item">
            <view class="form-label">任务状态</view>
            <picker mode="selector" :range="statusOptions" @change="onStatusChange">
              <view class="form-input picker-input">
                {{ selectedStatusText || '全部状态' }}
                <uni-icons type="arrowright" size="16" color="#999"></uni-icons>
              </view>
            </picker>
          </view>
          
          <view class="form-item">
            <view class="form-label">任务时间</view>
            <view class="date-range">
              <!-- 使用uni-datetime-picker组件 -->
              <uni-datetime-picker 
                v-model="startDate" 
                type="date" 
                :placeholder="'开始时间'"
                class="date-input"
              />
              <text class="divider">至</text>
              <!-- 使用uni-datetime-picker组件 -->
              <uni-datetime-picker 
                v-model="endDate" 
                type="date" 
                :placeholder="'结束时间'"
                class="date-input"
              />
            </view>
          </view>
          
          <view class="form-item">
            <view class="form-label">车牌号</view>
            <input 
              class="form-input" 
              placeholder="请输入车牌号" 
              v-model="searchForm.vehicle"
            />
          </view>
          
          <view class="form-item">
            <view class="form-label">任务编号</view>
            <input 
              class="form-input" 
              placeholder="请输入任务编号" 
              v-model="searchForm.taskNo"
            />
          </view>
          
          <view class="form-actions">
            <button class="search-btn" @click="handleSearch">查询</button>
            <button class="reset-btn" @click="resetSearch">重置</button>
          </view>
        </view>
      </view>
      
      <view class="task-filter">
        <scroll-view class="filter-tabs" scroll-x="true">
          <view 
            class="filter-item" 
            :class="{ active: currentFilter === 'all' }"
            @click="changeFilter('all')"
          >
            全部
          </view>
          <view 
            class="filter-item" 
            :class="{ active: currentFilter === 'pending' }"
            @click="changeFilter('pending')"
          >
            待处理
          </view>
          <view 
            class="filter-item" 
            :class="{ active: currentFilter === 'processing' }"
            @click="changeFilter('processing')"
          >
            处理中
          </view>
          <view 
            class="filter-item" 
            :class="{ active: currentFilter === 'completed' }"
            @click="changeFilter('completed')"
          >
            已完成
          </view>
        </scroll-view>
      </view>
      
      <scroll-view class="task-list-scroll" scroll-y="true">
        <view class="task-list">
          <view class="task-item" v-for="task in filteredTaskList" :key="task.id">
            <view class="task-main" @click="viewTaskDetail(task)">
              <view class="task-title">{{ getTaskTypeText(task.type) }} - {{ task.vehicle }}</view>
              <view class="task-info">
                <view class="info-row">
                  <view class="info-item">
                    <view class="label">任务编号:</view>
                    <view class="value">{{ task.taskNo }}</view>
                  </view>
                  <view class="info-item">
                    <view class="label">任务状态:</view>
                    <view class="value">{{ getStatusText(task.status) }}</view>
                  </view>
                </view>
                <view class="info-row">
                  <view class="info-item">
                    <view class="label">出发地:</view>
                    <view class="value">{{ task.startLocation }}</view>
                  </view>
                  <view class="info-item">
                    <view class="label">目的地:</view>
                    <view class="value">{{ task.endLocation }}</view>
                  </view>
                </view>
                <view class="info-row">
                  <view class="info-item">
                    <view class="label">出发时间:</view>
                    <view class="value">{{ task.startTime }}</view>
                  </view>
                  <view class="info-item">
                    <view class="label">执行人员:</view>
                    <view class="value">{{ task.assignee }}</view>
                  </view>
                </view>
              </view>
            </view>
            
            <!-- 操作按钮 -->
            <view class="task-actions">
              <button 
                class="action-btn" 
                :class="{ disabled: isActionDisabled(task, 'depart') }"
                @click="handleTaskAction(task, 'depart')"
                v-if="task.status !== 'completed'"
              >
                出发
              </button>
              <button 
                class="action-btn" 
                :class="{ disabled: isActionDisabled(task, 'arrive') }"
                @click="handleTaskAction(task, 'arrive')"
                v-if="task.status !== 'completed'"
              >
                已到达
              </button>
              <button 
                class="action-btn" 
                :class="{ disabled: isActionDisabled(task, 'return') }"
                @click="handleTaskAction(task, 'return')"
                v-if="task.status !== 'completed'"
              >
                返程
              </button>
              <button 
                class="action-btn" 
                :class="{ disabled: isActionDisabled(task, 'settle') }"
                @click="handleTaskAction(task, 'settle')"
                v-if="task.status !== 'completed'"
              >
                结算
              </button>
              <button 
                class="action-btn primary" 
                :class="{ disabled: isActionDisabled(task, 'complete') }"
                @click="handleTaskAction(task, 'complete')"
                v-if="task.status !== 'completed'"
              >
                已完成
              </button>
            </view>
          </view>
          
          <view class="no-data" v-if="filteredTaskList.length === 0">
            <uni-icons type="info" size="40" color="#ccc"></uni-icons>
            <text>暂无任务数据</text>
          </view>
        </view>
      </scroll-view>
    </view>
  </view>
</template>
 
<script>
  import uniDatetimePicker from '@/uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue'
  
  export default {
    components: {
      uniDatetimePicker
    },
    data() {
      return {
        // 控制查询界面显示/隐藏
        showSearch: false,
        
        // 查询条件
        searchForm: {
          vehicle: '',
          taskNo: ''
        },
        statusOptions: ['全部状态', '待处理', '处理中', '已完成'],
        statusValues: ['', 'pending', 'processing', 'completed'],
        selectedStatus: '',
        selectedStatusText: '',
        startDate: '',
        endDate: '',
        currentFilter: 'all',
        
        // 任务列表
        taskList: [
          {
            id: 1,
            title: '紧急维修任务',
            type: 'maintenance', // 维修保养
            startLocation: '广州市天河区XX路123号',
            endLocation: '广州市白云区YY路456号',
            startTime: '2023-05-15 15:00',
            assignee: '张三',
            status: 'pending',
            vehicle: '粤A12345',
            taskNo: 'RW20230515001'
          },
          {
            id: 2,
            title: '定期保养任务',
            type: 'maintenance', // 维修保养
            startLocation: '深圳市南山区XX路789号',
            endLocation: '深圳市福田区YY路999号',
            startTime: '2023-05-14 10:00',
            assignee: '李四',
            status: 'processing',
            vehicle: '粤B67890',
            taskNo: 'RW20230514002'
          },
          {
            id: 3,
            title: '设备巡检任务',
            type: 'inspection', // 巡检任务
            startLocation: '珠海市香洲区XX路321号',
            endLocation: '珠海市金湾区YY路654号',
            startTime: '2023-05-13 17:00',
            assignee: '王五',
            status: 'completed',
            vehicle: '粤C11111',
            taskNo: 'RW20230513003'
          },
          {
            id: 4,
            title: '加油任务',
            type: 'refuel', // 加油
            startLocation: '佛山市禅城区AA路555号',
            endLocation: '佛山市南海区BB路888号',
            startTime: '2023-05-12 09:00',
            assignee: '赵六',
            status: 'completed',
            vehicle: '粤D22222',
            taskNo: 'RW20230512004'
          },
          {
            id: 5,
            title: '急救转运任务',
            type: 'emergency', // 急救转运
            startLocation: '广州市越秀区医院路1号',
            endLocation: '广州市海珠区医院路2号',
            startTime: '2023-05-16 14:00',
            assignee: '张医生,李护士',
            status: 'pending',
            vehicle: '粤E33333',
            taskNo: 'RW20230516005'
          },
          {
            id: 6,
            title: '福祉车任务',
            type: 'welfare', // 福祉车
            startLocation: '广州市荔湾区社区路10号',
            endLocation: '广州市天河区养老院路20号',
            startTime: '2023-05-17 08:00',
            assignee: '王司机',
            status: 'processing',
            vehicle: '粤F44444',
            taskNo: 'RW20230517006'
          }
        ]
      }
    },
    computed: {
      filteredTaskList() {
        let filtered = this.taskList;
        
        // 应用筛选器
        if (this.currentFilter !== 'all') {
          filtered = filtered.filter(task => {
            if (this.currentFilter === 'pending') return task.status === 'pending';
            if (this.currentFilter === 'processing') return task.status === 'processing';
            if (this.currentFilter === 'completed') return task.status === 'completed';
            return true;
          });
        }
        
        // 应用状态筛选
        if (this.selectedStatus) {
          filtered = filtered.filter(task => task.status === this.selectedStatus);
        }
        
        // 应用车牌号筛选
        if (this.searchForm.vehicle) {
          filtered = filtered.filter(task => 
            task.vehicle.includes(this.searchForm.vehicle)
          );
        }
        
        // 应用任务编号筛选
        if (this.searchForm.taskNo) {
          filtered = filtered.filter(task => 
            task.taskNo.includes(this.searchForm.taskNo)
          );
        }
        
        // 应用时间范围筛选
        if (this.startDate) {
          filtered = filtered.filter(task => 
            task.startTime >= this.startDate
          );
        }
        
        if (this.endDate) {
          // 结束日期加一天,以便包含当天的数据
          const end = new Date(this.endDate);
          end.setDate(end.getDate() + 1);
          const endDateStr = end.toISOString().split('T')[0];
          
          filtered = filtered.filter(task => 
            task.startTime < endDateStr
          );
        }
        
        return filtered;
      }
    },
    methods: {
      // 切换查询界面显示/隐藏
      toggleSearch() {
        this.showSearch = !this.showSearch;
      },
      
      // 状态选择
      onStatusChange(e) {
        this.selectedStatus = this.statusValues[e.detail.value];
        this.selectedStatusText = this.statusOptions[e.detail.value];
      },
      
      // 查询
      handleSearch() {
        this.$modal.showToast('查询成功');
        console.log('查询条件:', {
          status: this.selectedStatus,
          startDate: this.startDate,
          endDate: this.endDate,
          vehicle: this.searchForm.vehicle,
          taskNo: this.searchForm.taskNo
        });
        // 查询完成后隐藏查询界面
        this.showSearch = false;
        // 这里可以调用API进行查询
      },
      
      // 重置查询条件
      resetSearch() {
        this.selectedStatus = '';
        this.selectedStatusText = '';
        this.startDate = '';
        this.endDate = '';
        this.searchForm.vehicle = '';
        this.searchForm.taskNo = '';
      },
      
      // 刷新列表
      refreshList() {
        this.$modal.showToast('列表已刷新');
        // 这里可以重新加载数据
      },
      
      // 筛选
      changeFilter(filter) {
        this.currentFilter = filter;
      },
      
      // 查看任务详情
      viewTaskDetail(task) {
        // 跳转到任务详情页面
        this.$tab.navigateTo(`/pages/task/detail?id=${task.id}`);
      },
      
      // 判断操作按钮是否禁用
      isActionDisabled(task, action) {
        // 根据任务状态和操作类型判断是否禁用
        switch (action) {
          case 'depart':
            return task.status !== 'pending';
          case 'arrive':
            return task.status !== 'processing';
          case 'return':
            return task.status !== 'processing';
          case 'settle':
            return task.status !== 'processing';
          case 'complete':
            return task.status !== 'processing';
          default:
            return false;
        }
      },
      
      // 处理任务操作
      handleTaskAction(task, action) {
        if (this.isActionDisabled(task, action)) {
          return;
        }
        
        switch (action) {
          case 'depart':
            // 出发操作,根据任务类型显示不同的确认信息
            let departMessage = '确定要标记为已出发吗?';
            if (task.type !== 'maintenance' && task.type !== 'refuel' && task.type !== 'inspection') {
              departMessage = '发出去目的地,确认?';
            }
            this.$modal.confirm(departMessage).then(() => {
              task.status = 'processing';
              this.$modal.showToast('已出发');
              // 这里可以调用API更新任务状态
            }).catch(() => {});
            break;
          case 'arrive':
            // 已到达操作
            this.$modal.confirm('已经到达目的地,确认?').then(() => {
              this.$modal.showToast('已到达');
              // 这里可以调用API更新任务状态
            }).catch(() => {});
            break;
          case 'return':
            // 返程操作
            this.$modal.confirm('现在已经返程中,确认?').then(() => {
              this.$modal.showToast('返程中');
              // 这里可以调用API更新任务状态
            }).catch(() => {});
            break;
          case 'settle':
            // 结算操作,跳转到结算页面
            this.$tab.navigateTo(`/pages/task/settlement?id=${task.id}`);
            break;
          case 'complete':
            // 已完成操作
            this.$modal.confirm('任务是否已经全部完成,确认?').then(() => {
              task.status = 'completed';
              this.$modal.showToast('任务已完成');
              // 这里可以调用API更新任务状态
            }).catch(() => {});
            break;
        }
      },
      
      getStatusText(status) {
        const statusMap = {
          'pending': '待处理',
          'processing': '处理中',
          'completed': '已完成'
        }
        return statusMap[status] || '未知'
      },
      
      getTaskTypeText(type) {
        const typeMap = {
          'maintenance': '维修保养',
          'refuel': '加油',
          'inspection': '巡检',
          'emergency': '急救转运',
          'welfare': '福祉车'
        }
        return typeMap[type] || '未知类型'
      }
    }
  }
</script>
 
<style lang="scss">
  .task-container {
    padding: 20rpx;
    background-color: #f5f5f5;
    height: 100vh;
    display: flex;
    flex-direction: column;
    // 隐藏滚动条但保持滚动功能
    ::-webkit-scrollbar {
      display: none;
      width: 0 !important;
      height: 0 !important;
      background: transparent;
    }
    
    // Firefox滚动条隐藏
    * {
      scrollbar-width: none; /* Firefox */
    }
    
    // IE/Edge滚动条隐藏
    * {
      -ms-overflow-style: none; /* IE 10+ */
    }
  }
  
  // 任务列表区域
  .task-list-section {
    flex: 1;
    background-color: white;
    border-radius: 15rpx;
    padding: 30rpx;
    box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
  }
  
  .task-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20rpx 0;
    flex-shrink: 0; // 防止收缩
    
    .header-title {
      font-size: 36rpx;
      font-weight: bold;
    }
    
    .header-actions {
      display: flex;
      
      .search-toggle-btn, .refresh-btn {
        width: 60rpx;
        height: 60rpx;
        border-radius: 50%;
        background-color: #f0f0f0;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-left: 20rpx;
      }
    }
  }
  
  // 查询条件区域
  .search-section {
    background-color: #f9f9f9;
    border-radius: 15rpx;
    padding: 30rpx;
    margin: 20rpx 0;
    box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
    flex-shrink: 0; // 防止收缩
    
    .form-item {
      margin-bottom: 30rpx;
      
      &:last-child {
        margin-bottom: 0;
      }
      
      .form-label {
        font-size: 28rpx;
        margin-bottom: 15rpx;
        color: #333;
      }
      
      .form-input {
        height: 70rpx;
        padding: 0 20rpx;
        border: 1rpx solid #eee;
        border-radius: 10rpx;
        font-size: 28rpx;
        
        &.picker-input {
          display: flex;
          align-items: center;
          justify-content: space-between;
        }
      }
      
      .date-range {
        display: flex;
        align-items: center;
        
        .date-input {
          flex: 1;
          height: 70rpx;
          padding: 0 20rpx;
          border: 1rpx solid #eee;
          border-radius: 10rpx;
          font-size: 28rpx;
          display: flex;
          align-items: center;
        }
        
        .divider {
          margin: 0 20rpx;
          color: #999;
        }
      }
    }
    
    .form-actions {
      display: flex;
      margin-top: 20rpx;
      
      .search-btn, .reset-btn {
        flex: 1;
        height: 70rpx;
        border-radius: 10rpx;
        font-size: 28rpx;
        margin: 0 10rpx;
      }
      
      .search-btn {
        background-color: #007AFF;
        color: white;
      }
    }
  }
  
  .task-filter {
    margin-bottom: 30rpx;
    flex-shrink: 0; // 防止收缩
    
    .filter-tabs {
      white-space: nowrap;
      padding: 10rpx 0;
      // 隐藏滚动条但保持滚动功能
      ::-webkit-scrollbar {
        display: none;
        width: 0 !important;
        height: 0 !important;
        background: transparent;
      }
      
      // Firefox滚动条隐藏
      * {
        scrollbar-width: none; /* Firefox */
      }
      
      // IE/Edge滚动条隐藏
      * {
        -ms-overflow-style: none; /* IE 10+ */
      }
      
      .filter-item {
        display: inline-block;
        padding: 15rpx 30rpx;
        margin-right: 20rpx;
        background-color: #f5f5f5;
        border-radius: 30rpx;
        font-size: 28rpx;
        
        &.active {
          background-color: #007AFF;
          color: white;
        }
      }
    }
  }
  
  .task-list-scroll {
    flex: 1;
    // 隐藏滚动条但保持滚动功能
    ::-webkit-scrollbar {
      display: none;
      width: 0 !important;
      height: 0 !important;
      background: transparent;
    }
    
    // Firefox滚动条隐藏
    * {
      scrollbar-width: none; /* Firefox */
    }
    
    // IE/Edge滚动条隐藏
    * {
      -ms-overflow-style: none; /* IE 10+ */
    }
  }
  
  .task-list {
    .task-item {
      background-color: #fafafa;
      border-radius: 15rpx;
      margin-bottom: 30rpx;
      overflow: hidden;
      
      .task-main {
        padding: 30rpx;
        border-bottom: 1rpx solid #f0f0f0;
        
        .task-title {
          font-size: 32rpx;
          font-weight: bold;
          margin-bottom: 20rpx;
        }
        
        .task-info {
          .info-row {
            display: flex;
            margin-bottom: 15rpx;
            
            &:last-child {
              margin-bottom: 0;
            }
            
            .info-item {
              flex: 1;
              display: flex;
              
              .label {
                font-size: 26rpx;
                color: #666;
                margin-right: 10rpx;
                white-space: nowrap;
              }
              
              .value {
                font-size: 26rpx;
                flex: 1;
                word-break: break-all;
              }
            }
          }
        }
      }
      
      .task-actions {
        display: flex;
        padding: 20rpx;
        
        .action-btn {
          flex: 1;
          height: 70rpx;
          border-radius: 10rpx;
          font-size: 26rpx;
          margin: 0 5rpx;
          background-color: #f0f0f0;
          color: #333;
          
          &.primary {
            background-color: #007AFF;
            color: white;
          }
          
          &.disabled {
            opacity: 0.5;
          }
          
          &:first-child {
            margin-left: 0;
          }
          
          &:last-child {
            margin-right: 0;
          }
        }
      }
    }
    
    .no-data {
      text-align: center;
      padding: 100rpx 0;
      color: #999;
      
      text {
        display: block;
        margin-top: 20rpx;
      }
    }
  }
</style>