wanshenmean
2026-02-09 ae9517420d848e215a9eb807270d5ef6fbe92ae9
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
<template>
  <div class="task-info-page">
    <a-card>
      <a-space style="margin-bottom: 16px">
        <a-input-search
          v-model:value="searchText"
          placeholder="搜索任务号"
          style="width: 200px"
          @search="handleSearch"
        />
        <a-select
          v-model:value="statusFilter"
          placeholder="任务状态"
          style="width: 120px"
          @change="handleSearch"
          allowClear
        >
          <a-select-option :value="0">待处理</a-select-option>
          <a-select-option :value="1">处理中</a-select-option>
          <a-select-option :value="2">已完成</a-select-option>
          <a-select-option :value="3">已取消</a-select-option>
        </a-select>
      </a-space>
 
      <a-table
        :columns="columns"
        :data-source="dataSource"
        :loading="loading"
        :pagination="pagination"
        @change="handleTableChange"
        row-key="Id"
      >
        <template #bodyCell="{ column, record }">
          <template v-if="column.key === 'TaskStatus'">
            <a-tag :color="getStatusColor(record.TaskStatus)">
              {{ getStatusText(record.TaskStatus) }}
            </a-tag>
          </template>
          <template v-else-if="column.key === 'action'">
            <a @click="handleView(record)">查看详情</a>
          </template>
        </template>
      </a-table>
    </a-card>
  </div>
</template>
 
<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue';
import { message } from 'ant-design-vue';
import type { TaskInfo } from '../../../types/common';
 
const columns = [
  { title: '任务号', dataIndex: 'TaskNo', key: 'TaskNo' },
  { title: '任务类型', dataIndex: 'TaskType', key: 'TaskType' },
  { title: '任务状态', dataIndex: 'TaskStatus', key: 'TaskStatus' },
  { title: '仓库编码', dataIndex: 'WarehouseCode', key: 'WarehouseCode' },
  { title: '创建时间', dataIndex: 'CreateDate', key: 'CreateDate' },
  { title: '创建人', dataIndex: 'Creator', key: 'Creator' },
  { title: '操作', key: 'action', width: 120 },
];
 
const dataSource = ref<TaskInfo[]>([]);
const loading = ref(false);
const searchText = ref('');
const statusFilter = ref<number>();
const pagination = reactive({
  current: 1,
  pageSize: 20,
  total: 0,
  showSizeChanger: true,
  showTotal: (total: number) => `共 ${total} 条`,
});
 
onMounted(() => {
  fetchData();
});
 
async function fetchData() {
  loading.value = true;
  try {
    // 这里调用实际的 API
    setTimeout(() => {
      dataSource.value = [];
      pagination.total = 0;
      loading.value = false;
    }, 500);
  } catch (error) {
    console.error('Fetch data error:', error);
    loading.value = false;
  }
}
 
function handleTableChange(pag: any) {
  pagination.current = pag.current;
  pagination.pageSize = pag.pageSize;
  fetchData();
}
 
function handleSearch() {
  pagination.current = 1;
  fetchData();
}
 
function handleView(record: TaskInfo) {
  message.info(`查看任务详情: ${record.TaskNo}`);
}
 
function getStatusColor(status?: number) {
  const colorMap: Record<number, string> = {
    0: 'default',
    1: 'processing',
    2: 'success',
    3: 'error',
  };
  return colorMap[status || 0] || 'default';
}
 
function getStatusText(status?: number) {
  const textMap: Record<number, string> = {
    0: '待处理',
    1: '处理中',
    2: '已完成',
    3: '已取消',
  };
  return textMap[status || 0] || '未知';
}
</script>
 
<style scoped>
.task-info-page {
  padding: 0;
}
</style>