feat(web-admin): CC list read filter, mark-read, and batch read.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
9c589de6d7
commit
98423aad7b
1 file changed
+145
-8
@@ -5,8 +5,59 @@
|
||||
<div class="panel-top">
|
||||
<h2 class="title-bar-heading">抄送我的</h2>
|
||||
</div>
|
||||
|
||||
<div class="filter-block">
|
||||
<el-form :model="searchForm" class="filter-form" @submit.prevent>
|
||||
<div class="filter-grid">
|
||||
<el-form-item label="阅读状态">
|
||||
<el-select v-model="searchForm.readStatus" placeholder="请选择">
|
||||
<el-option label="未读" value="unread" />
|
||||
<el-option label="已读" value="read" />
|
||||
<el-option label="全部" value="all" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div class="filter-actions-row">
|
||||
<div class="filter-actions-end">
|
||||
<el-button class="btn-ghost" @click="handleReset">
|
||||
<el-icon><RefreshLeft /></el-icon>
|
||||
重置
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" @click="handleSearch">
|
||||
<el-icon><Search /></el-icon>
|
||||
搜索
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<div class="list-toolbar">
|
||||
<div class="list-toolbar-row">
|
||||
<div class="list-toolbar-selected">
|
||||
已选 <span class="sel-num">{{ selectedRows.length }}</span> 项
|
||||
</div>
|
||||
<el-button
|
||||
class="btn-ghost"
|
||||
:disabled="batchReadDisabled"
|
||||
@click="handleBatchRead"
|
||||
>
|
||||
<el-icon><Check /></el-icon>
|
||||
批量已读
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="list-body list-wrap">
|
||||
<el-table class="list-table" :data="rows" v-loading="loading" stripe>
|
||||
<el-table
|
||||
class="list-table"
|
||||
:data="rows"
|
||||
v-loading="loading"
|
||||
stripe
|
||||
row-key="id"
|
||||
@selection-change="onSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" min-width="55" align="center" header-align="center" />
|
||||
<el-table-column
|
||||
type="index"
|
||||
label="序号"
|
||||
@@ -22,7 +73,12 @@
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
>
|
||||
<template #default="{ row }">{{ row.appName || row.title || '-' }}</template>
|
||||
<template #default="{ row }">
|
||||
<span class="cc-flow-name">
|
||||
<span v-if="!row.isRead" class="cc-unread-dot" aria-hidden="true" />
|
||||
{{ row.appName || row.title || '-' }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="initiatorUserName"
|
||||
@@ -64,12 +120,23 @@
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" min-width="300" fixed="right" align="center">
|
||||
<el-table-column label="阅读状态" min-width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag size="small" :type="row.isRead ? 'info' : 'danger'">
|
||||
{{ row.isRead ? '已读' : '未读' }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" min-width="320" fixed="right" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button class="btn-op-item primary" @click="openDetail(row)">
|
||||
<el-icon><View /></el-icon>
|
||||
查看
|
||||
</el-button>
|
||||
<el-button class="btn-op-item" :disabled="!!row.isRead" @click="markOneRead(row)">
|
||||
<el-icon><Check /></el-icon>
|
||||
已读
|
||||
</el-button>
|
||||
<el-button
|
||||
class="btn-op-item"
|
||||
:loading="printingId === (row.instanceId || row.id)"
|
||||
@@ -87,13 +154,19 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onActivated, onMounted, ref } from 'vue'
|
||||
import { computed, onActivated, onMounted, reactive, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { Printer, View } from '@element-plus/icons-vue'
|
||||
import { fetchOaInstanceDetail, fetchOaTasks } from '@/api/oaApproval'
|
||||
import { Check, Printer, RefreshLeft, Search, View } from '@element-plus/icons-vue'
|
||||
import {
|
||||
fetchBatchMarkOaCcTasksRead,
|
||||
fetchMarkOaCcTaskRead,
|
||||
fetchOaInstanceDetail,
|
||||
fetchOaTasks
|
||||
} from '@/api/oaApproval'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import { exportOaApprovalPdf } from '@/utils/oa-approval-print'
|
||||
import { refreshOaMenuBadges } from '@/utils/oa-menu-badge'
|
||||
|
||||
defineOptions({ name: 'OaApprovalCc' })
|
||||
|
||||
@@ -102,6 +175,12 @@
|
||||
const loading = ref(false)
|
||||
const printingId = ref('')
|
||||
const rows = ref<any[]>([])
|
||||
const selectedRows = ref<any[]>([])
|
||||
const searchForm = reactive({
|
||||
readStatus: 'unread' as 'unread' | 'read' | 'all'
|
||||
})
|
||||
|
||||
const batchReadDisabled = computed(() => !selectedRows.value.some((r) => !r.isRead))
|
||||
|
||||
function currentPrinterName() {
|
||||
const info: any = userStore.info || userStore.getUserInfo || {}
|
||||
@@ -133,12 +212,51 @@
|
||||
return map[s] || s
|
||||
}
|
||||
|
||||
function openDetail(row: any) {
|
||||
function onSelectionChange(selection: any[]) {
|
||||
selectedRows.value = selection
|
||||
}
|
||||
|
||||
function handleSearch() {
|
||||
void load()
|
||||
}
|
||||
|
||||
function handleReset() {
|
||||
searchForm.readStatus = 'unread'
|
||||
void load()
|
||||
}
|
||||
|
||||
async function markOneRead(row: any) {
|
||||
const id = String(row?.id || '').trim()
|
||||
if (!id || row.isRead) return
|
||||
await fetchMarkOaCcTaskRead(id)
|
||||
await load()
|
||||
}
|
||||
|
||||
async function openDetail(row: any) {
|
||||
const id = row.instanceId
|
||||
const taskId = String(row?.id || '').trim()
|
||||
if (!id) return
|
||||
if (taskId && !row.isRead) {
|
||||
try {
|
||||
await fetchMarkOaCcTaskRead(taskId)
|
||||
} catch {
|
||||
/* 仍允许进入详情 */
|
||||
}
|
||||
void refreshOaMenuBadges()
|
||||
}
|
||||
router.push({ path: `/system-manage/oa-approval/instances/${id}` })
|
||||
}
|
||||
|
||||
async function handleBatchRead() {
|
||||
const ids = selectedRows.value
|
||||
.filter((r) => !r.isRead)
|
||||
.map((r) => String(r.id || '').trim())
|
||||
.filter(Boolean)
|
||||
if (!ids.length) return
|
||||
await fetchBatchMarkOaCcTasksRead(ids)
|
||||
await load()
|
||||
}
|
||||
|
||||
async function printRow(row: any) {
|
||||
const id = String(row?.instanceId || row?.id || '').trim()
|
||||
if (!id || printingId.value) return
|
||||
@@ -164,15 +282,34 @@
|
||||
async function load() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await fetchOaTasks('cc')
|
||||
const res = await fetchOaTasks('cc', { readStatus: searchForm.readStatus })
|
||||
rows.value = res?.list || []
|
||||
} catch {
|
||||
rows.value = []
|
||||
} finally {
|
||||
loading.value = false
|
||||
selectedRows.value = []
|
||||
void refreshOaMenuBadges()
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(load)
|
||||
onActivated(load)
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.cc-flow-name {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.cc-unread-dot {
|
||||
flex-shrink: 0;
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
border-radius: 50%;
|
||||
background: #fd4e4e;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user