1218 lines
37 KiB
Vue
1218 lines
37 KiB
Vue
<template>
|
||
<div class="page-container">
|
||
<!-- 统计卡片区域 -->
|
||
<el-row :gutter="20" class="stats-row">
|
||
<el-col :span="6">
|
||
<div class="stat-card stat-card-primary">
|
||
<div class="stat-content">
|
||
<div class="stat-icon">
|
||
<el-icon><Document /></el-icon>
|
||
</div>
|
||
<div class="stat-info">
|
||
<div class="stat-value">{{ totalCount }}</div>
|
||
<div class="stat-label">总流程数</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</el-col>
|
||
<el-col :span="6">
|
||
<div class="stat-card stat-card-success">
|
||
<div class="stat-content">
|
||
<div class="stat-icon">
|
||
<el-icon><Check /></el-icon>
|
||
</div>
|
||
<div class="stat-info">
|
||
<div class="stat-value">{{ completedCount }}</div>
|
||
<div class="stat-label">已完成</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</el-col>
|
||
<el-col :span="6">
|
||
<div class="stat-card stat-card-warning">
|
||
<div class="stat-content">
|
||
<div class="stat-icon">
|
||
<el-icon><Clock /></el-icon>
|
||
</div>
|
||
<div class="stat-info">
|
||
<div class="stat-value">{{ runningCount }}</div>
|
||
<div class="stat-label">审批中</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</el-col>
|
||
<el-col :span="6">
|
||
<div class="stat-card stat-card-info">
|
||
<div class="stat-content">
|
||
<div class="stat-icon">
|
||
<el-icon><Timer /></el-icon>
|
||
</div>
|
||
<div class="stat-info">
|
||
<div class="stat-value">{{ waitingCount }}</div>
|
||
<div class="stat-label">等待中</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</el-col>
|
||
</el-row>
|
||
|
||
<!-- 搜索区域 -->
|
||
<el-card class="button-card" v-show="showSearch">
|
||
<template #header>
|
||
<div class="card-header">
|
||
<span class="toolbar-title">项目审批查询</span>
|
||
</div>
|
||
</template>
|
||
<el-form ref="queryFormRef" :model="queryParams" label-width="100px">
|
||
<!-- 第一行:4个搜索条件 -->
|
||
<el-row :gutter="20">
|
||
<el-col :span="6">
|
||
<el-form-item label="申报编号" prop="applicationNo">
|
||
<el-input v-model="queryParams.applicationNo" placeholder="请输入申报编号" clearable @keyup.enter="handleQuery" />
|
||
</el-form-item>
|
||
</el-col>
|
||
<el-col :span="6">
|
||
<el-form-item label="项目名称" prop="projectName">
|
||
<el-input v-model="queryParams.projectName" placeholder="请输入项目名称" clearable @keyup.enter="handleQuery" />
|
||
</el-form-item>
|
||
</el-col>
|
||
<el-col :span="6">
|
||
<el-form-item label="流程状态" prop="processStatus">
|
||
<el-select v-model="queryParams.processStatus" placeholder="请选择流程状态" clearable style="width: 100%">
|
||
<el-option label="等待开始" value="waiting" />
|
||
<el-option label="进行中" value="running" />
|
||
<el-option label="已完成" value="completed" />
|
||
<el-option label="已终止" value="terminated" />
|
||
</el-select>
|
||
</el-form-item>
|
||
</el-col>
|
||
<el-col :span="6">
|
||
<el-form-item label="提交人" prop="submitterName">
|
||
<el-input v-model="queryParams.submitterName" placeholder="请输入提交人姓名" clearable @keyup.enter="handleQuery" />
|
||
</el-form-item>
|
||
</el-col>
|
||
</el-row>
|
||
|
||
<!-- 第二行:时间筛选 + 操作按钮 -->
|
||
<el-row :gutter="20">
|
||
<el-col :span="6">
|
||
<el-form-item label="提交时间">
|
||
<el-date-picker
|
||
v-model="daterangeStartTime"
|
||
value-format="YYYY-MM-DD"
|
||
type="daterange"
|
||
range-separator="-"
|
||
start-placeholder="开始日期"
|
||
end-placeholder="结束日期"
|
||
@change="handleQuery"
|
||
style="width: 100%"
|
||
/>
|
||
</el-form-item>
|
||
</el-col>
|
||
<el-col :span="18">
|
||
<!-- 留空,保持布局对齐 -->
|
||
</el-col>
|
||
</el-row>
|
||
|
||
<el-row>
|
||
<el-col :span="24" class="search-btn-container">
|
||
<el-form-item>
|
||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||
</el-form-item>
|
||
</el-col>
|
||
</el-row>
|
||
</el-form>
|
||
</el-card>
|
||
|
||
<el-card shadow="never" class="button-card table-card">
|
||
<template #header>
|
||
<el-row ref="toolbarRef" :gutter="10" class="mb8">
|
||
<el-col :span="1.5">
|
||
<el-button type="success" plain icon="Plus" @click="handleStartProcess" v-hasPermi="['cw:projectApproval:add']"> 启动新流程 </el-button>
|
||
</el-col>
|
||
<el-col :span="1.5">
|
||
<el-button type="primary" plain icon="View" @click="handleViewPending" v-hasPermi="['cw:projectApproval:pendingList']">
|
||
我的待审批
|
||
</el-button>
|
||
</el-col>
|
||
<el-col :span="1.5">
|
||
<el-button type="info" plain icon="Finished" @click="handleViewProcessed" v-hasPermi="['cw:projectApproval:processedList']">
|
||
我的已审批
|
||
</el-button>
|
||
</el-col>
|
||
<el-col :span="1.5">
|
||
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['cw:projectApproval:export']"> 导出 </el-button>
|
||
</el-col>
|
||
<right-toolbar :show-search="showSearch" @update:show-search="(val) => (showSearch = val)" @query-table="getList" />
|
||
</el-row>
|
||
</template>
|
||
|
||
<div class="table-container">
|
||
<el-table
|
||
v-loading="loading"
|
||
border
|
||
:data="processList"
|
||
@selection-change="handleSelectionChange"
|
||
@row-dblclick="handleView"
|
||
style="width: 100%"
|
||
:scroll-x="true"
|
||
class="scroll-table"
|
||
>
|
||
<el-table-column type="selection" width="55" align="center" fixed="left" />
|
||
<el-table-column label="申报编号" align="center" prop="applicationNo" min-width="140" />
|
||
<el-table-column label="流程名称" align="center" prop="processName" min-width="180" show-overflow-tooltip />
|
||
<el-table-column label="流程状态" align="center" prop="processStatus" width="120">
|
||
<template #default="scope">
|
||
<el-tag :type="getProcessStatusType(scope.row.processStatus)" effect="light">
|
||
{{ getProcessStatusText(scope.row.processStatus) }}
|
||
</el-tag>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="进度" align="center" width="120">
|
||
<template #default="scope">
|
||
<span class="progress-text">{{ scope.row.currentNode }}/{{ scope.row.totalNodes }}</span>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="提交人" align="center" prop="submitterName" min-width="100" />
|
||
<el-table-column label="开始时间" align="center" prop="startTime" min-width="160">
|
||
<template #default="scope">
|
||
<span>{{ parseTime(scope.row.startTime, '{y}-{m}-{d} {h}:{i}') }}</span>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="结束时间" align="center" prop="endTime" min-width="160">
|
||
<template #default="scope">
|
||
<span>{{ scope.row.endTime ? parseTime(scope.row.endTime, '{y}-{m}-{d} {h}:{i}') : '进行中' }}</span>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="操作" align="center" width="280" fixed="right" class-name="small-padding fixed-width">
|
||
<template #default="scope">
|
||
<div class="action-buttons">
|
||
<el-tooltip content="查看详情" placement="top">
|
||
<el-button link type="info" :icon="View" @click="handleView(scope.row)" v-hasPermi="['cw:projectApproval:query']" />
|
||
</el-tooltip>
|
||
<el-tooltip content="审批" placement="top" v-if="scope.row.processStatus === 'running'">
|
||
<el-button link type="success" :icon="Check" @click="handleApprove(scope.row)" v-hasPermi="['cw:projectApproval:approve']" />
|
||
</el-tooltip>
|
||
<el-tooltip content="终止" placement="top" v-if="scope.row.processStatus === 'running'">
|
||
<el-button link type="danger" :icon="Close" @click="handleTerminate(scope.row)" v-hasPermi="['cw:projectApproval:terminate']" />
|
||
</el-tooltip>
|
||
</div>
|
||
</template>
|
||
</el-table-column>
|
||
</el-table>
|
||
</div>
|
||
|
||
<!-- 分页 -->
|
||
<div class="pagination-container">
|
||
<pagination
|
||
v-show="total > 0"
|
||
:total="total"
|
||
:page="queryParams.pageNum"
|
||
:limit="queryParams.pageSize"
|
||
@update:page="queryParams.pageNum = $event"
|
||
@update:limit="queryParams.pageSize = $event"
|
||
@pagination="getList"
|
||
/>
|
||
</div>
|
||
</el-card>
|
||
|
||
<!-- 流程详情对话框 -->
|
||
<el-dialog title="流程详情" v-model="detailDialog.visible" width="90%" append-to-body>
|
||
<div v-if="detailDialog.data" class="process-detail">
|
||
<ApplicationSummary :application-id="detailDialog.data?.applicationId" />
|
||
<!-- 基本信息 -->
|
||
<el-card shadow="never" class="mb-4">
|
||
<template #header>
|
||
<div class="card-header">
|
||
<span>基本信息</span>
|
||
</div>
|
||
</template>
|
||
<el-descriptions :column="2" border>
|
||
<el-descriptions-item label="申报编号">{{ detailDialog.data.applicationNo }}</el-descriptions-item>
|
||
<el-descriptions-item label="流程名称">{{ detailDialog.data.processName }}</el-descriptions-item>
|
||
<el-descriptions-item label="流程状态">
|
||
<el-tag :type="getProcessStatusType(detailDialog.data.processStatus)">
|
||
{{ getProcessStatusText(detailDialog.data.processStatus) }}
|
||
</el-tag>
|
||
</el-descriptions-item>
|
||
<el-descriptions-item label="总节点数">{{ detailDialog.data.totalNodes }}</el-descriptions-item>
|
||
<el-descriptions-item label="当前节点">{{ detailDialog.data.currentNode }}</el-descriptions-item>
|
||
<el-descriptions-item label="提交人">{{ detailDialog.data.submitterName }}</el-descriptions-item>
|
||
<el-descriptions-item label="开始时间">{{ detailDialog.data.startTime }}</el-descriptions-item>
|
||
<el-descriptions-item label="结束时间">{{ detailDialog.data.endTime || '进行中' }}</el-descriptions-item>
|
||
</el-descriptions>
|
||
</el-card>
|
||
|
||
<!-- 审批记录 -->
|
||
<el-card shadow="never">
|
||
<template #header>
|
||
<div class="card-header">
|
||
<span>审批记录</span>
|
||
</div>
|
||
</template>
|
||
<el-timeline>
|
||
<el-timeline-item
|
||
v-for="record in approvalRecords"
|
||
:key="record.id"
|
||
:icon="getTimelineIcon(record.nodeStatus)"
|
||
:type="getTimelineType(record.nodeStatus)"
|
||
:timestamp="record.startTime"
|
||
placement="top"
|
||
>
|
||
<el-card>
|
||
<div class="timeline-content">
|
||
<div class="timeline-header">
|
||
<span class="node-name">{{ record.customNodeName || record.nodeName }}</span>
|
||
<el-tag :type="getApprovalStatusType(record.nodeStatus)" size="small">
|
||
{{ getApprovalStatusText(record.nodeStatus) }}
|
||
</el-tag>
|
||
</div>
|
||
<div class="timeline-body">
|
||
<p><strong>审批人:</strong>{{ record.approverName }}</p>
|
||
<p><strong>审批意见:</strong>{{ record.approveOpinion || '暂无' }}</p>
|
||
<p v-if="record.endTime"><strong>完成时间:</strong>{{ record.endTime }}</p>
|
||
</div>
|
||
</div>
|
||
</el-card>
|
||
</el-timeline-item>
|
||
</el-timeline>
|
||
</el-card>
|
||
</div>
|
||
|
||
<template #footer>
|
||
<el-button @click="detailDialog.visible = false">关闭</el-button>
|
||
</template>
|
||
</el-dialog>
|
||
|
||
<!-- 审批操作对话框 -->
|
||
<el-dialog title="审批操作" v-model="approvalDialog.visible" width="60%" append-to-body>
|
||
<div v-if="approvalDialog.data" class="approval-form">
|
||
<!-- 项目信息展示 -->
|
||
<el-card shadow="never" class="mb-4">
|
||
<template #header>
|
||
<div class="card-header">
|
||
<span>项目信息</span>
|
||
</div>
|
||
</template>
|
||
<el-descriptions :column="2" border>
|
||
<el-descriptions-item label="申报编号">{{ approvalDialog.data.applicationNo }}</el-descriptions-item>
|
||
<el-descriptions-item label="项目名称">{{ approvalDialog.data.processName }}</el-descriptions-item>
|
||
<el-descriptions-item label="提交人">{{ approvalDialog.data.submitterName }}</el-descriptions-item>
|
||
<el-descriptions-item label="当前节点">{{ approvalDialog.data.currentNode }}/{{ approvalDialog.data.totalNodes }}</el-descriptions-item>
|
||
</el-descriptions>
|
||
</el-card>
|
||
|
||
<!-- 审批表单 -->
|
||
<el-form ref="approvalFormRef" :model="approvalForm" :rules="approvalRules" label-width="120px">
|
||
<el-form-item label="审批操作" prop="approveAction" required>
|
||
<el-radio-group v-model="approvalForm.approveAction">
|
||
<el-radio value="approve">
|
||
<el-icon><CircleCheck /></el-icon>
|
||
审批通过
|
||
</el-radio>
|
||
<el-radio value="reject">
|
||
<el-icon><CircleClose /></el-icon>
|
||
打回申请
|
||
</el-radio>
|
||
</el-radio-group>
|
||
</el-form-item>
|
||
|
||
<el-form-item label="审批意见" prop="approveOpinion" required>
|
||
<el-input v-model="approvalForm.approveOpinion" type="textarea" :rows="4" placeholder="请输入审批意见" maxlength="500" show-word-limit />
|
||
</el-form-item>
|
||
</el-form>
|
||
</div>
|
||
|
||
<template #footer>
|
||
<el-button @click="approvalDialog.visible = false">取消</el-button>
|
||
<el-button type="primary" :loading="approvalLoading" @click="confirmApproval">确定</el-button>
|
||
</template>
|
||
</el-dialog>
|
||
</div>
|
||
</template>
|
||
|
||
<script setup lang="ts" name="CwProjectApproval">
|
||
import { ref, reactive, onMounted, getCurrentInstance } from 'vue';
|
||
import { ElMessage, ElMessageBox } from 'element-plus';
|
||
import type { FormInstance } from 'element-plus';
|
||
import RightToolbar from '@/components/RightToolbar/index.vue';
|
||
import Pagination from '@/components/Pagination/index.vue';
|
||
import { Clock, CircleCheck, Search, Refresh, Plus, View, Check, Close, CircleClose, Document, Timer } from '@element-plus/icons-vue';
|
||
|
||
// 这里需要创建对应的API文件
|
||
import {
|
||
listProjectApproval,
|
||
getProjectApproval,
|
||
startCustomApprovalProcess,
|
||
approveProcess,
|
||
terminateProcess,
|
||
getMyPendingApprovals,
|
||
getMyProcessedApprovals,
|
||
getApprovalRecords,
|
||
getApprovalStatistics,
|
||
exportProjectApproval
|
||
} from '@/api/cw/projectApproval';
|
||
import ApplicationSummary from '@/views/cw/application/summary.vue';
|
||
import { parseTime } from '@/utils/ruoyi';
|
||
|
||
const { proxy } = getCurrentInstance() as any;
|
||
|
||
// 表单引用
|
||
const queryFormRef = ref<FormInstance>();
|
||
const approvalFormRef = ref<FormInstance>();
|
||
|
||
// 显示搜索
|
||
const showSearch = ref(true);
|
||
|
||
// 查询参数
|
||
const queryParams = reactive({
|
||
pageNum: 1,
|
||
pageSize: 10,
|
||
applicationNo: '',
|
||
projectName: '',
|
||
processStatus: '',
|
||
submitterName: '',
|
||
startTime: undefined as string[] | undefined
|
||
});
|
||
|
||
// 日期范围
|
||
const daterangeStartTime = ref<string[]>([]);
|
||
|
||
// 表格数据
|
||
const processList = ref([]);
|
||
const loading = ref(false);
|
||
const total = ref(0);
|
||
|
||
// 统计数据
|
||
const totalCount = ref(0);
|
||
const completedCount = ref(0);
|
||
const runningCount = ref(0);
|
||
const waitingCount = ref(0);
|
||
|
||
// 选择状态
|
||
const ids = ref<Array<string | number>>([]);
|
||
const single = ref(true);
|
||
const multiple = ref(true);
|
||
|
||
// 详情对话框
|
||
const detailDialog = reactive({
|
||
visible: false,
|
||
data: null as any
|
||
});
|
||
|
||
// 审批对话框
|
||
const approvalDialog = reactive({
|
||
visible: false,
|
||
data: null as any
|
||
});
|
||
|
||
const approvalForm = reactive({
|
||
approveAction: 'approve',
|
||
approveOpinion: ''
|
||
});
|
||
|
||
const approvalRules = {
|
||
approveAction: [{ required: true, message: '请选择审批操作', trigger: 'change' }],
|
||
approveOpinion: [
|
||
{ required: true, message: '请输入审批意见', trigger: 'blur' },
|
||
{ min: 5, max: 500, message: '审批意见长度在 5 到 500 个字符', trigger: 'blur' }
|
||
]
|
||
};
|
||
|
||
const approvalLoading = ref(false);
|
||
const approvalRecords = ref([]);
|
||
|
||
// 查询流程列表
|
||
const getList = async () => {
|
||
loading.value = true;
|
||
try {
|
||
// 处理时间范围
|
||
if (daterangeStartTime.value && daterangeStartTime.value.length === 2) {
|
||
queryParams.startTime = daterangeStartTime.value;
|
||
} else {
|
||
queryParams.startTime = undefined;
|
||
}
|
||
|
||
console.log('查询参数:', queryParams);
|
||
|
||
// 调用流程列表API - 获取所有流程数据
|
||
const response = await listProjectApproval(queryParams);
|
||
console.log('API响应:', response);
|
||
|
||
// 处理响应数据 - 支持多种格式
|
||
let rawData: any[] = [];
|
||
let totalCount = 0;
|
||
|
||
if (response.code === 200 && response.data) {
|
||
// R<TableDataInfo>格式
|
||
if (response.data.rows && Array.isArray(response.data.rows)) {
|
||
rawData = response.data.rows;
|
||
totalCount = response.data.total || 0;
|
||
} else if (Array.isArray(response.data)) {
|
||
// R<List>格式
|
||
rawData = response.data;
|
||
totalCount = response.data.length;
|
||
} else {
|
||
rawData = [];
|
||
totalCount = 0;
|
||
}
|
||
} else if (response.rows && Array.isArray(response.rows)) {
|
||
// 直接TableDataInfo格式
|
||
rawData = response.rows;
|
||
totalCount = response.total || 0;
|
||
} else {
|
||
rawData = [];
|
||
totalCount = 0;
|
||
}
|
||
|
||
// 字段映射:处理不同数据源的字段统一
|
||
processList.value = rawData.map((item) => ({
|
||
...item,
|
||
// 流程数据可能已经有正确字段,做兼容处理
|
||
processName: item.processName || item.projectName || '未知项目',
|
||
processStatus: item.processStatus || item.nodeStatus || 'pending',
|
||
submitterName: item.submitterName || item.applicantName || '未知',
|
||
// 流程数据应该包含节点信息,设置默认值以防缺失
|
||
totalNodes: item.totalNodes || 1,
|
||
currentNode: item.currentNode || 1,
|
||
// 保持时间字段
|
||
startTime: item.startTime || item.submitTime || item.createTime,
|
||
endTime: item.endTime || item.approvalTime
|
||
}));
|
||
total.value = totalCount;
|
||
|
||
console.log('解析后数据:', {
|
||
count: processList.value.length,
|
||
total: total.value,
|
||
data: processList.value
|
||
});
|
||
|
||
// 更新统计数据
|
||
getStatistics();
|
||
} catch (error) {
|
||
console.error('获取流程列表失败:', error);
|
||
ElMessage.error('获取流程列表失败');
|
||
processList.value = [];
|
||
total.value = 0;
|
||
} finally {
|
||
loading.value = false;
|
||
}
|
||
};
|
||
|
||
// 获取统计数据
|
||
const getStatistics = () => {
|
||
try {
|
||
totalCount.value = processList.value.length;
|
||
completedCount.value = processList.value.filter((item: any) => item.processStatus === 'completed').length;
|
||
runningCount.value = processList.value.filter((item: any) => item.processStatus === 'running').length;
|
||
waitingCount.value = processList.value.filter((item: any) => item.processStatus === 'waiting').length;
|
||
} catch (error) {
|
||
console.error('获取统计数据失败:', error);
|
||
totalCount.value = 0;
|
||
completedCount.value = 0;
|
||
runningCount.value = 0;
|
||
waitingCount.value = 0;
|
||
}
|
||
};
|
||
|
||
// 搜索
|
||
const handleQuery = () => {
|
||
queryParams.pageNum = 1;
|
||
getList();
|
||
};
|
||
|
||
// 重置
|
||
const resetQuery = () => {
|
||
daterangeStartTime.value = [];
|
||
queryFormRef.value?.resetFields();
|
||
handleQuery();
|
||
};
|
||
|
||
// 多选框选中数据
|
||
const handleSelectionChange = (selection: any[]) => {
|
||
ids.value = selection.map((item) => item.id);
|
||
single.value = selection.length !== 1;
|
||
multiple.value = !selection.length;
|
||
};
|
||
|
||
// 查看详情
|
||
const handleView = async (row: any) => {
|
||
try {
|
||
console.log('查看详情,数据:', row);
|
||
|
||
// 获取流程详情
|
||
if (row.id) {
|
||
const response = await getProjectApproval(row.id);
|
||
console.log('流程详情响应:', response);
|
||
|
||
if (response.code === 200 && response.data) {
|
||
detailDialog.data = response.data;
|
||
} else {
|
||
detailDialog.data = row;
|
||
}
|
||
} else {
|
||
detailDialog.data = row;
|
||
}
|
||
|
||
// 获取审批记录
|
||
if (row.applicationId) {
|
||
try {
|
||
const recordsResponse = await getApprovalRecords(row.applicationId);
|
||
console.log('审批记录响应:', recordsResponse);
|
||
|
||
if (recordsResponse.code === 200 && recordsResponse.data) {
|
||
approvalRecords.value = recordsResponse.data;
|
||
} else if (Array.isArray(recordsResponse)) {
|
||
approvalRecords.value = recordsResponse;
|
||
} else {
|
||
approvalRecords.value = [];
|
||
}
|
||
} catch (recordError) {
|
||
console.error('获取审批记录失败:', recordError);
|
||
approvalRecords.value = [];
|
||
}
|
||
} else {
|
||
approvalRecords.value = [];
|
||
}
|
||
|
||
detailDialog.visible = true;
|
||
} catch (error) {
|
||
console.error('获取流程详情失败:', error);
|
||
ElMessage.error('获取流程详情失败');
|
||
}
|
||
};
|
||
|
||
// 启动新流程
|
||
const handleStartProcess = () => {
|
||
// 跳转到项目申报页面或显示流程启动对话框
|
||
ElMessage.info('跳转到项目申报页面');
|
||
};
|
||
|
||
// 查看我的待审批
|
||
const handleViewPending = async () => {
|
||
try {
|
||
loading.value = true;
|
||
|
||
// 清空其他查询条件,专门查询待审批
|
||
const pendingParams = {
|
||
pageNum: 1,
|
||
pageSize: 10,
|
||
applicationNo: '',
|
||
projectName: '',
|
||
processStatus: '',
|
||
submitterName: '',
|
||
startTime: undefined
|
||
};
|
||
|
||
console.log('查询我的待审批,参数:', pendingParams);
|
||
const response = await getMyPendingApprovals(pendingParams);
|
||
console.log('我的待审批数据:', response);
|
||
|
||
// 处理响应数据
|
||
let rawData: any[] = [];
|
||
let totalCount = 0;
|
||
|
||
if (response.code === 200 && response.data) {
|
||
if (response.data.rows && Array.isArray(response.data.rows)) {
|
||
rawData = response.data.rows;
|
||
totalCount = response.data.total || 0;
|
||
} else if (Array.isArray(response.data)) {
|
||
rawData = response.data;
|
||
totalCount = response.data.length;
|
||
} else {
|
||
rawData = [];
|
||
totalCount = 0;
|
||
}
|
||
} else if (response.rows && Array.isArray(response.rows)) {
|
||
rawData = response.rows;
|
||
totalCount = response.total || 0;
|
||
} else {
|
||
rawData = [];
|
||
totalCount = 0;
|
||
}
|
||
|
||
// 字段映射:将后端CwApprovalRecordVo字段映射为前端表格期望的字段
|
||
processList.value = rawData.map((item) => ({
|
||
...item,
|
||
// 核心字段映射
|
||
processName: item.projectName || item.processName || '未知项目',
|
||
// 待审批状态应该是running,这样审批按钮才会显示
|
||
processStatus: item.nodeStatus === 'waiting' ? 'running' : item.nodeStatus || item.processStatus || 'pending',
|
||
submitterName: item.applicantName || item.submitterName || '未知',
|
||
// 使用后端返回的正确值(不再设置默认值)
|
||
totalNodes: item.totalNodes,
|
||
currentNode: item.currentNode,
|
||
// 保持时间字段
|
||
startTime: item.submitTime || item.startTime || item.createTime,
|
||
endTime: item.approvalTime || item.endTime
|
||
}));
|
||
total.value = totalCount;
|
||
|
||
console.log('解析后数据:', { count: processList.value.length, total: total.value, data: processList.value });
|
||
ElMessage.success('我的待审批数据加载完成');
|
||
} catch (error) {
|
||
console.error('获取我的待审批数据失败:', error);
|
||
ElMessage.error('获取我的待审批数据失败');
|
||
} finally {
|
||
loading.value = false;
|
||
}
|
||
};
|
||
|
||
// 查看我的已审批
|
||
const handleViewProcessed = async () => {
|
||
try {
|
||
loading.value = true;
|
||
const response = await getMyProcessedApprovals(queryParams);
|
||
console.log('已审批数据:', response);
|
||
|
||
// 处理响应数据
|
||
let rawData: any[] = [];
|
||
let totalCount = 0;
|
||
|
||
if (response.code === 200 && response.data) {
|
||
if (response.data.rows && Array.isArray(response.data.rows)) {
|
||
rawData = response.data.rows;
|
||
totalCount = response.data.total || 0;
|
||
} else if (Array.isArray(response.data)) {
|
||
rawData = response.data;
|
||
totalCount = response.data.length;
|
||
} else {
|
||
rawData = [];
|
||
totalCount = 0;
|
||
}
|
||
} else if (response.rows && Array.isArray(response.rows)) {
|
||
rawData = response.rows;
|
||
totalCount = response.total || 0;
|
||
} else {
|
||
rawData = [];
|
||
totalCount = 0;
|
||
}
|
||
|
||
// 字段映射:将后端CwApprovalRecordVo字段映射为前端表格期望的字段
|
||
processList.value = rawData.map((item) => ({
|
||
...item,
|
||
// 核心字段映射
|
||
processName: item.projectName || item.processName || '未知项目',
|
||
processStatus: item.nodeStatus || item.processStatus || 'completed',
|
||
submitterName: item.applicantName || item.submitterName || '未知',
|
||
// 使用后端返回的正确值(不再设置默认值)
|
||
totalNodes: item.totalNodes,
|
||
currentNode: item.currentNode,
|
||
// 保持时间字段
|
||
startTime: item.submitTime || item.startTime || item.createTime,
|
||
endTime: item.approvalTime || item.endTime
|
||
}));
|
||
total.value = totalCount;
|
||
|
||
console.log('解析后数据:', { count: processList.value.length, total: total.value, data: processList.value });
|
||
ElMessage.success('已审批数据加载完成');
|
||
} catch (error) {
|
||
console.error('获取已审批数据失败:', error);
|
||
ElMessage.error('获取已审批数据失败');
|
||
processList.value = [];
|
||
total.value = 0;
|
||
} finally {
|
||
loading.value = false;
|
||
}
|
||
};
|
||
|
||
// 审批操作
|
||
const handleApprove = async (row: any) => {
|
||
console.log('打开审批对话框,数据:', row);
|
||
if (!row.applicationId) {
|
||
ElMessage.error('缺少申请ID信息,无法进行审批');
|
||
return;
|
||
}
|
||
|
||
try {
|
||
// 通过applicationId查询当前用户的待审批记录
|
||
console.log('查询待审批记录,applicationId:', row.applicationId);
|
||
|
||
const response = await getMyPendingApprovals({
|
||
pageNum: 1,
|
||
pageSize: 100 // 获取足够多的记录
|
||
});
|
||
|
||
console.log('待审批记录查询响应:', response);
|
||
|
||
// 处理响应数据
|
||
let pendingRecords: any[] = [];
|
||
if (response.code === 200 && response.data) {
|
||
pendingRecords = response.data || [];
|
||
} else if (Array.isArray(response)) {
|
||
pendingRecords = response;
|
||
} else if (response.rows) {
|
||
pendingRecords = response.rows || [];
|
||
}
|
||
|
||
// 查找当前申请的待审批记录
|
||
const currentRecord = pendingRecords.find((record) => record.applicationId === row.applicationId && record.nodeStatus === 'waiting');
|
||
|
||
if (!currentRecord) {
|
||
ElMessage.error('未找到您对此申请的待审批记录,可能已被处理或您没有审批权限');
|
||
return;
|
||
}
|
||
|
||
console.log('找到待审批记录:', currentRecord);
|
||
|
||
// 将审批记录信息添加到对话框数据中
|
||
approvalDialog.data = {
|
||
...row,
|
||
approvalRecord: currentRecord,
|
||
recordId: currentRecord.id // 使用审批记录ID
|
||
};
|
||
|
||
approvalForm.approveAction = 'approve';
|
||
approvalForm.approveOpinion = '';
|
||
approvalDialog.visible = true;
|
||
} catch (error) {
|
||
console.error('查询待审批记录失败:', error);
|
||
ElMessage.error('查询待审批记录失败,无法进行审批操作');
|
||
}
|
||
};
|
||
|
||
// 确认审批
|
||
const confirmApproval = async () => {
|
||
if (!approvalFormRef.value) return;
|
||
|
||
const valid = await approvalFormRef.value.validate();
|
||
if (!valid) return;
|
||
|
||
try {
|
||
approvalLoading.value = true;
|
||
|
||
console.log('执行审批操作:', {
|
||
data: approvalDialog.data,
|
||
form: approvalForm
|
||
});
|
||
|
||
// 构造审批数据 - 使用正确的审批记录ID
|
||
const approvalData = {
|
||
recordId: approvalDialog.data.recordId, // 使用查询到的审批记录ID
|
||
action: approvalForm.approveAction,
|
||
opinion: approvalForm.approveOpinion
|
||
};
|
||
|
||
// 数据校验
|
||
if (!approvalData.recordId) {
|
||
ElMessage.error('审批记录ID缺失,无法进行审批操作');
|
||
return;
|
||
}
|
||
|
||
console.log('审批请求数据:', approvalData);
|
||
|
||
// 调用审批API
|
||
const response = await approveProcess(approvalData);
|
||
console.log('审批响应:', response);
|
||
|
||
ElMessage.success('审批操作成功');
|
||
approvalDialog.visible = false;
|
||
|
||
// 重新加载列表
|
||
getList();
|
||
} catch (error) {
|
||
console.error('审批操作失败:', error);
|
||
ElMessage.error('审批操作失败: ' + ((error as any)?.message || '未知错误'));
|
||
} finally {
|
||
approvalLoading.value = false;
|
||
}
|
||
};
|
||
|
||
// 终止流程
|
||
const handleTerminate = async (row: any) => {
|
||
try {
|
||
await ElMessageBox.confirm(`确定要终止流程"${row.processName}"吗?`, '系统提示', {
|
||
confirmButtonText: '确定',
|
||
cancelButtonText: '取消',
|
||
type: 'warning'
|
||
});
|
||
|
||
console.log('终止流程:', row);
|
||
|
||
// 调用终止流程API
|
||
const response = await terminateProcess(row.id);
|
||
console.log('终止流程响应:', response);
|
||
|
||
ElMessage.success('流程已终止');
|
||
getList();
|
||
} catch (error) {
|
||
if (error !== 'cancel') {
|
||
console.error('终止流程失败:', error);
|
||
ElMessage.error('终止流程失败: ' + ((error as any)?.message || '未知错误'));
|
||
}
|
||
}
|
||
};
|
||
|
||
// 导出
|
||
const handleExport = () => {
|
||
// const exportParams = { ...queryParams };
|
||
// exportProjectApproval(exportParams);
|
||
ElMessage.info('导出功能开发中');
|
||
};
|
||
|
||
// 获取流程状态类型
|
||
const getProcessStatusType = (status: string): ElTagType => {
|
||
const typeMap: Record<string, ElTagType> = {
|
||
waiting: 'info',
|
||
running: 'warning',
|
||
completed: 'success',
|
||
terminated: 'danger'
|
||
};
|
||
return (typeMap[status] || 'info') as ElTagType;
|
||
};
|
||
|
||
// 获取流程状态文本
|
||
const getProcessStatusText = (status: string) => {
|
||
const textMap: Record<string, string> = {
|
||
waiting: '等待开始',
|
||
running: '进行中',
|
||
completed: '已完成',
|
||
terminated: '已终止'
|
||
};
|
||
return textMap[status] || '未知';
|
||
};
|
||
|
||
// 获取审批状态类型
|
||
const getApprovalStatusType = (status: string): ElTagType => {
|
||
const typeMap: Record<string, ElTagType> = {
|
||
waiting: 'warning',
|
||
approving: 'primary',
|
||
approved: 'success',
|
||
rejected: 'danger',
|
||
pending: 'info'
|
||
};
|
||
return (typeMap[status] || 'info') as ElTagType;
|
||
};
|
||
|
||
// 获取审批状态文本
|
||
const getApprovalStatusText = (status: string) => {
|
||
const textMap: Record<string, string> = {
|
||
waiting: '等待审批',
|
||
approving: '审批中',
|
||
approved: '已通过',
|
||
rejected: '已拒绝',
|
||
pending: '待处理'
|
||
};
|
||
return textMap[status] || '未知';
|
||
};
|
||
|
||
// 获取时间线图标
|
||
const getTimelineIcon = (status: string) => {
|
||
const iconMap: Record<string, any> = {
|
||
waiting: Clock,
|
||
approving: Clock,
|
||
approved: CircleCheck,
|
||
rejected: CircleClose,
|
||
pending: Clock
|
||
};
|
||
return iconMap[status] || Clock;
|
||
};
|
||
|
||
// 获取时间线类型
|
||
const getTimelineType = (status: string): ElTagType => {
|
||
const typeMap: Record<string, ElTagType> = {
|
||
waiting: 'warning',
|
||
approving: 'primary',
|
||
approved: 'success',
|
||
rejected: 'danger',
|
||
pending: 'info'
|
||
};
|
||
return (typeMap[status] || 'info') as ElTagType;
|
||
};
|
||
|
||
// 页面挂载
|
||
onMounted(() => {
|
||
getList();
|
||
});
|
||
</script>
|
||
|
||
<style scoped lang="scss">
|
||
/* 页面容器样式 */
|
||
.page-container {
|
||
background-color: #f5f5f5;
|
||
min-height: calc(100vh - 84px);
|
||
padding: 8px;
|
||
}
|
||
|
||
/* 统计卡片样式 */
|
||
.stats-row {
|
||
margin-bottom: 20px;
|
||
}
|
||
|
||
.stat-card {
|
||
border-radius: 12px;
|
||
transition: all 0.3s ease;
|
||
height: 90px;
|
||
cursor: pointer;
|
||
|
||
&:hover {
|
||
transform: translateY(-2px);
|
||
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
|
||
}
|
||
|
||
.stat-content {
|
||
display: flex;
|
||
align-items: center;
|
||
padding: 5px 16px;
|
||
height: 100%;
|
||
box-sizing: border-box;
|
||
|
||
.stat-icon {
|
||
font-size: 28px;
|
||
margin-right: 15px;
|
||
opacity: 0.9;
|
||
}
|
||
|
||
.stat-info {
|
||
flex: 1;
|
||
|
||
.stat-value {
|
||
font-size: 24px;
|
||
font-weight: bold;
|
||
line-height: 1;
|
||
margin-bottom: 4px;
|
||
}
|
||
|
||
.stat-label {
|
||
font-size: 14px;
|
||
opacity: 0.8;
|
||
line-height: 1;
|
||
}
|
||
}
|
||
}
|
||
|
||
&.stat-card-primary {
|
||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||
color: white;
|
||
}
|
||
|
||
&.stat-card-success {
|
||
background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
|
||
color: white;
|
||
}
|
||
|
||
&.stat-card-warning {
|
||
background: linear-gradient(135deg, #ff9a56 0%, #ffad56 100%);
|
||
color: white;
|
||
}
|
||
|
||
&.stat-card-info {
|
||
background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
|
||
color: #333;
|
||
}
|
||
}
|
||
|
||
/* 搜索按钮居中样式 */
|
||
.search-btn-container {
|
||
display: flex;
|
||
justify-content: flex-end;
|
||
margin-top: 10px;
|
||
|
||
.el-form-item {
|
||
margin-bottom: 0 !important;
|
||
}
|
||
}
|
||
|
||
/* 卡片样式 */
|
||
:deep(.el-card) {
|
||
border: 1px solid #e4e7ed;
|
||
box-shadow:
|
||
0 2px 4px rgba(0, 0, 0, 0.12),
|
||
0 0 6px rgba(0, 0, 0, 0.04);
|
||
}
|
||
|
||
/* 表格卡片头部样式 */
|
||
.table-card :deep(.el-card__header) {
|
||
background-color: #fafafa;
|
||
border-bottom: 1px solid #ebeef5;
|
||
padding: 18px 20px;
|
||
}
|
||
|
||
/* 表格卡片内容样式 */
|
||
.table-card :deep(.el-card__body) {
|
||
padding: 0px 20px 20px 20px !important;
|
||
}
|
||
|
||
/* 表格样式 */
|
||
.scroll-table {
|
||
width: 100%;
|
||
|
||
:deep(.el-table__header-wrapper) {
|
||
.el-table__header {
|
||
th {
|
||
background-color: #fafafa;
|
||
color: #333;
|
||
font-weight: 600;
|
||
}
|
||
}
|
||
}
|
||
|
||
:deep(.el-table__body-wrapper) {
|
||
.el-table__row {
|
||
&:hover {
|
||
background-color: #f5f7fa;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/* 表格横向滚动条样式优化 */
|
||
.scroll-table :deep(.el-table__body-wrapper) {
|
||
overflow-x: auto !important;
|
||
overflow-y: auto;
|
||
scrollbar-width: thin;
|
||
scrollbar-color: #409eff #f0f0f0;
|
||
}
|
||
|
||
.scroll-table :deep(.el-table__header-wrapper) {
|
||
overflow-x: hidden;
|
||
}
|
||
|
||
/* Webkit 浏览器的横向滚动条样式 */
|
||
.scroll-table :deep(.el-table__body-wrapper)::-webkit-scrollbar {
|
||
height: 12px !important;
|
||
width: 12px !important;
|
||
}
|
||
|
||
.scroll-table :deep(.el-table__body-wrapper)::-webkit-scrollbar-track {
|
||
background: #f0f0f0 !important;
|
||
border-radius: 6px !important;
|
||
border: 1px solid #e4e7ed !important;
|
||
}
|
||
|
||
.scroll-table :deep(.el-table__body-wrapper)::-webkit-scrollbar-thumb {
|
||
background: #409eff !important;
|
||
border-radius: 6px !important;
|
||
border: 2px solid #f0f0f0 !important;
|
||
min-height: 20px !important;
|
||
}
|
||
|
||
.scroll-table :deep(.el-table__body-wrapper)::-webkit-scrollbar-thumb:hover {
|
||
background: #337ecc !important;
|
||
}
|
||
|
||
.scroll-table :deep(.el-table__body-wrapper)::-webkit-scrollbar-thumb:active {
|
||
background: #2b6cb0 !important;
|
||
}
|
||
|
||
.scroll-table :deep(.el-table__body-wrapper)::-webkit-scrollbar-corner {
|
||
background: #f0f0f0;
|
||
}
|
||
|
||
/* 固定列样式优化 */
|
||
.scroll-table :deep(.el-table__fixed-right) {
|
||
box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
|
||
}
|
||
|
||
.scroll-table :deep(.el-table__fixed-left) {
|
||
box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
|
||
}
|
||
|
||
/* 确保固定列在滚动时有正确的背景色 */
|
||
.scroll-table :deep(.el-table__fixed-right .el-table__cell),
|
||
.scroll-table :deep(.el-table__fixed-left .el-table__cell) {
|
||
background-color: #fff;
|
||
}
|
||
|
||
/* 表格行悬停效果在固定列上的同步 */
|
||
.scroll-table :deep(.el-table__row:hover .el-table__cell) {
|
||
background-color: #f5f7fa !important;
|
||
}
|
||
|
||
/* 操作按钮样式 */
|
||
.action-buttons {
|
||
display: flex;
|
||
gap: 4px;
|
||
justify-content: center;
|
||
align-items: center;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
/* 进度文本样式 */
|
||
.progress-text {
|
||
font-weight: 600;
|
||
color: #409eff;
|
||
}
|
||
|
||
/* 分页容器样式 */
|
||
.pagination-container {
|
||
display: flex;
|
||
justify-content: flex-end;
|
||
padding: 16px 20px 0 0 !important;
|
||
background-color: #fff;
|
||
margin-top: 0px !important;
|
||
}
|
||
|
||
/* 流程详情样式 */
|
||
.process-detail {
|
||
max-height: 600px;
|
||
overflow-y: auto;
|
||
}
|
||
|
||
.card-header {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
}
|
||
|
||
.timeline-content {
|
||
padding: 10px 0;
|
||
}
|
||
|
||
.timeline-header {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
margin-bottom: 10px;
|
||
}
|
||
|
||
.node-name {
|
||
font-weight: 500;
|
||
font-size: 16px;
|
||
}
|
||
|
||
.timeline-body p {
|
||
margin: 8px 0;
|
||
color: #666;
|
||
}
|
||
|
||
/* 审批表单样式 */
|
||
.approval-form {
|
||
padding: 20px 0;
|
||
}
|
||
|
||
/* 对话框样式 */
|
||
.dialog-footer {
|
||
display: flex;
|
||
justify-content: flex-end;
|
||
gap: 10px;
|
||
}
|
||
|
||
/* 输入框样式 */
|
||
:deep(.el-input .el-input__wrapper) {
|
||
border-radius: 4px;
|
||
}
|
||
|
||
:deep(.el-select .el-input__wrapper) {
|
||
border-radius: 4px;
|
||
}
|
||
|
||
:deep(.el-date-editor .el-input__wrapper) {
|
||
border-radius: 4px;
|
||
}
|
||
|
||
/* 响应式设计 */
|
||
@media (max-width: 768px) {
|
||
.page-container {
|
||
padding: 10px;
|
||
|
||
.stats-row {
|
||
.stat-card {
|
||
margin-bottom: 10px;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
</style>
|