Files
oa_app/pages/todo/list.vue
T
2026-09-23 16:52:48 +08:00

94 lines
3.1 KiB
Vue

<template>
<view class="page">
<fy-header title="待办审批" back />
<view v-if="!can" class="deny">当前账号没有审批或申请权限</view>
<view v-else>
<view class="tabs">
<text v-for="t in tabs" :key="t.id" class="tab" :class="{ on: tab === t.id }" @click="switchTab(t.id)">{{ t.title }}</text>
</view>
<view v-if="loading" class="empty">加载中</view>
<view v-else-if="!rows.length" class="empty">暂无记录</view>
<view v-for="r in rows" :key="r.no || r.id" class="card item" @click="open(r)">
<view>
<text class="t">{{ r.title || r.no }}</text>
<text class="s">{{ r.typeLabel || r.type }} · {{ r.submitter || r.assigneeName || '' }}</text>
</view>
<text class="chip">{{ r.status || '待处理' }}</text>
</view>
</view>
</view>
</template>
<script>
import FyHeader from '../../components/fy-header.vue'
import { store } from '../../utils/store.js'
import { asList } from '../../utils/format.js'
import { oaGet } from '../../utils/api.js'
export default {
components: { FyHeader },
data() {
return {
tab: 'pending',
tabs: [
{ id: 'pending', title: '待处理' },
{ id: 'review', title: '我发起的' },
{ id: 'handled', title: '已处理' },
{ id: 'reviewed', title: '已审阅' }
],
rows: [],
loading: false
}
},
computed: {
can() { return store.can('personal', 'approve') || store.can('personal', 'apply') }
},
onLoad(q) {
if (q.tab) this.tab = q.tab
},
onShow() { if (this.can) this.load() },
methods: {
switchTab(id) {
this.tab = id
this.load()
},
async load() {
this.loading = true
try {
const page = await oaGet(`/workflow/requests?tab=${this.tab}&page=1&size=50`, store.token)
this.rows = asList(page && page.records ? page.records : page)
if (this.tab === 'pending') {
try {
const work = asList(await oaGet('/work-tasks?tab=pending', store.token)).map((t) => ({
...t, typeLabel: '工作协同', title: t.title, source: 'work'
}))
this.rows = [...this.rows, ...work]
} catch (_) {}
}
} catch (_) {
this.rows = []
} finally {
this.loading = false
}
},
open(r) {
if (r.source === 'work' || r.taskId) {
uni.navigateTo({ url: '/pages/coop/detail?id=' + encodeURIComponent(r.id || r.taskId) })
return
}
uni.navigateTo({ url: '/pages/todo/detail?no=' + encodeURIComponent(r.no || r.id || '') })
}
}
}
</script>
<style scoped>
.tabs { display: flex; padding: 16rpx 16rpx 0; }
.tab { flex: 1; text-align: center; font-size: 24rpx; color: #737686; padding: 16rpx 0; }
.tab.on { color: #2563eb; font-weight: 700; border-bottom: 4rpx solid #2563eb; }
.item { margin: 16rpx 24rpx; padding: 24rpx; display: flex; justify-content: space-between; align-items: center; }
.t { display: block; font-size: 28rpx; font-weight: 600; }
.s { font-size: 22rpx; color: #737686; }
.empty, .deny { padding: 80rpx; text-align: center; color: #737686; }
</style>