修改
This commit is contained in:
@@ -84,51 +84,15 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import type { TbWorkcaseDTO } from '@/types/workcase'
|
||||
import { workcaseAPI } from '@/api/workcase/workcase'
|
||||
|
||||
// 响应式数据
|
||||
const headerPaddingTop = ref<number>(44)
|
||||
const headerTotalHeight = ref<number>(88)
|
||||
const activeTab = ref<string>('all')
|
||||
|
||||
// 模拟工单数据
|
||||
const orders = ref<TbWorkcaseDTO[]>([
|
||||
{
|
||||
workcaseId: 'TH20241217001',
|
||||
userId: '1',
|
||||
username: '李经理',
|
||||
phone: '13800138001',
|
||||
type: '控制系统故障',
|
||||
device: 'TH-500GF',
|
||||
deviceCode: 'TH20230501001',
|
||||
emergency: 'emergency',
|
||||
status: 'processing',
|
||||
createTime: '2024-12-17 15:30:00'
|
||||
},
|
||||
{
|
||||
workcaseId: 'TH20241217002',
|
||||
userId: '2',
|
||||
username: '王工',
|
||||
phone: '13800138002',
|
||||
type: '发动机故障',
|
||||
device: 'TH-300GF',
|
||||
deviceCode: 'TH20230502001',
|
||||
emergency: 'normal',
|
||||
status: 'pending',
|
||||
createTime: '2024-12-17 14:20:00'
|
||||
},
|
||||
{
|
||||
workcaseId: 'TH20241216001',
|
||||
userId: '3',
|
||||
username: '张总',
|
||||
phone: '13800138003',
|
||||
type: '电气系统故障',
|
||||
device: 'TH-800GF',
|
||||
deviceCode: 'TH20230503001',
|
||||
emergency: 'normal',
|
||||
status: 'done',
|
||||
createTime: '2024-12-16 09:15:00'
|
||||
}
|
||||
])
|
||||
const orders = ref<TbWorkcaseDTO[]>([])
|
||||
const loading = ref<boolean>(false)
|
||||
const error = ref<string>('')
|
||||
|
||||
// 计算属性:根据tab筛选工单
|
||||
const filteredOrders = computed(() => {
|
||||
@@ -158,19 +122,44 @@ onMounted(() => {
|
||||
headerTotalHeight.value = statusBarHeight + 44
|
||||
// #endif
|
||||
|
||||
// TODO: 实际调用API获取工单列表
|
||||
// 调用API获取工单列表
|
||||
loadWorkcaseList()
|
||||
})
|
||||
|
||||
// 加载工单列表
|
||||
function loadWorkcaseList() {
|
||||
// TODO: 调用 workcaseAPI.getWorkcaseList() 获取数据
|
||||
console.log('加载工单列表')
|
||||
async function loadWorkcaseList() {
|
||||
loading.value = true
|
||||
error.value = ''
|
||||
try {
|
||||
const filter: TbWorkcaseDTO = {}
|
||||
if (activeTab.value !== 'all') {
|
||||
filter.status = activeTab.value as TbWorkcaseDTO['status']
|
||||
}
|
||||
const res = await workcaseAPI.getWorkcaseList(filter)
|
||||
if (res.success && res.dataList) {
|
||||
orders.value = res.dataList || []
|
||||
} else {
|
||||
error.value = res.message || '加载失败'
|
||||
uni.showToast({
|
||||
title: res.message || '加载失败',
|
||||
icon: 'error'
|
||||
})
|
||||
}
|
||||
} catch (e) {
|
||||
error.value = '网络错误,请稍后重试'
|
||||
uni.showToast({
|
||||
title: '网络错误,请稍后重试',
|
||||
icon: 'error'
|
||||
})
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 切换Tab
|
||||
function changeTab(tab: string) {
|
||||
activeTab.value = tab
|
||||
loadWorkcaseList()
|
||||
}
|
||||
|
||||
// 获取状态样式类
|
||||
|
||||
Reference in New Issue
Block a user