// 审批管理主页面
|
<template>
|
<view class="sales-account">
|
<!-- 使用通用页面头部组件 -->
|
<PageHeader :title="pageTitle"
|
@back="goBack" />
|
<!-- 审批类型切换(从菜单直接进入时可切换;经 index1~8 进入时不展示) -->
|
<view v-if="showTypeTabs"
|
class="type-tabs-wrap">
|
<up-tabs :list="typeTabList"
|
:current="activeTypeIndex"
|
line-color="#ed8d05"
|
@click="onTypeTabClick" />
|
</view>
|
<!-- 搜索和筛选区域 -->
|
<view class="search-section">
|
<view class="search-bar">
|
<view class="search-input">
|
<up-input class="search-text"
|
placeholder="请输入流程编号"
|
v-model="searchForm.approveId"
|
clearable />
|
</view>
|
<view class="filter-chip"
|
:class="{ 'filter-chip--active': searchForm.approveStatus !== '' }"
|
@click="openStatusSheet">
|
<text class="filter-chip-text">{{ approveStatusText }}</text>
|
<up-icon name="arrow-down"
|
size="14"
|
color="#999"></up-icon>
|
</view>
|
<view class="search-button"
|
@click="getList">
|
<up-icon name="search"
|
size="24"
|
color="#999"></up-icon>
|
</view>
|
</view>
|
</view>
|
<up-action-sheet :show="showStatusSheet"
|
title="审批状态"
|
:actions="statusActions"
|
@select="onSelectStatus"
|
@close="showStatusSheet = false" />
|
<!-- 审批列表 -->
|
<view class="ledger-list"
|
v-if="ledgerList.length > 0">
|
<view v-for="(item, index) in ledgerList"
|
:key="index">
|
<view class="ledger-item">
|
<view class="item-header">
|
<view class="item-left">
|
<view class="document-icon">
|
<up-icon name="file-text"
|
size="16"
|
color="#ffffff"></up-icon>
|
</view>
|
<text class="item-id">{{ item.approveId }}</text>
|
</view>
|
<view class="item-tag">
|
<u-tag :type="getTagClass(item.approveStatus)">{{ formatReceiptType(item.approveStatus) }}</u-tag>
|
</view>
|
</view>
|
<up-divider></up-divider>
|
<view class="item-details">
|
<view class="detail-row">
|
<text class="detail-label">申请人</text>
|
<text class="detail-value">{{ item.approveUserName }}</text>
|
</view>
|
<view class="detail-row">
|
<text class="detail-label">申请部门</text>
|
<text class="detail-value">{{ item.approveDeptName }}</text>
|
</view>
|
<view class="detail-row-approveReason">
|
<text class="detail-label">审批事由</text>
|
<text class="detail-value highlightBlue">{{ item.approveReason }}</text>
|
</view>
|
<view class="detail-row">
|
<text class="detail-label">申请日期</text>
|
<text class="detail-value">{{ item.approveTime }}</text>
|
</view>
|
<!-- approveType=2 请假相关字段 -->
|
<template v-if="item.approveType === 2">
|
<view class="detail-row">
|
<text class="detail-label">请假开始时间</text>
|
<text class="detail-value">{{ item.startDate || '-' }}</text>
|
</view>
|
<view class="detail-row">
|
<text class="detail-label">请假结束时间</text>
|
<text class="detail-value">{{ item.endDate || '-' }}</text>
|
</view>
|
</template>
|
<!-- approveType=3 出差相关字段 -->
|
<view v-if="item.approveType === 3"
|
class="detail-row">
|
<text class="detail-label">出差地点</text>
|
<text class="detail-value">{{ item.location || '-' }}</text>
|
</view>
|
<!-- approveType=4 报销相关字段 -->
|
<view v-if="item.approveType === 4"
|
class="detail-row">
|
<text class="detail-label">报销金额</text>
|
<text class="detail-value highlightYellow">{{ item.price ? `¥${item.price}` : '-' }}</text>
|
</view>
|
<view class="detail-row">
|
<text class="detail-label">结束日期</text>
|
<text class="detail-value">{{ item.approveOverTime }}</text>
|
</view>
|
<up-divider></up-divider>
|
<view class="detail-info">
|
<view class="detail-row-user">
|
<text class="detail-label">当前审批人</text>
|
<view class="detail-value approver-value">
|
<view class="approver-chip">
|
<text class="approver-name">{{ item.approveUserCurrentName || '未分配' }}</text>
|
</view>
|
</view>
|
</view>
|
<view class="detail-row">
|
<view class="actions">
|
<u-button type="primary"
|
size="small"
|
class="action-btn edit"
|
v-if="!(item.approveStatus == 2 || item.approveStatus == 1 || item.approveStatus == 4 || item.approveStatus == 8 || item.approveType == 5 || item.approveType == 6 || item.approveType == 7)"
|
@click="handleItemClick(item)">
|
编辑
|
</u-button>
|
<u-button type="info"
|
size="small"
|
class="action-btn detail"
|
@click="handleDetailClick(item)">
|
详情
|
</u-button>
|
<u-button type="success"
|
size="small"
|
class="action-btn approve"
|
:disabled="item.approveUserCurrentId == null || item.approveStatus == 2 || item.approveStatus == 3 || item.approveStatus == 4 || item.approveStatus == 8 || item.approveUserCurrentId !== userStore.id"
|
@click="approve(item)">
|
审核
|
</u-button>
|
</view>
|
</view>
|
</view>
|
</view>
|
</view>
|
</view>
|
</view>
|
<view v-else
|
class="no-data">
|
<text>暂无审批数据</text>
|
</view>
|
<!-- 浮动操作按钮 -->
|
<view class="fab-button"
|
v-if="activeApproveType != 5 && activeApproveType != 6 && activeApproveType != 7"
|
@click="handleAdd">
|
<up-icon name="plus"
|
size="24"
|
color="#ffffff"></up-icon>
|
</view>
|
</view>
|
</template>
|
|
<script setup>
|
import { ref, toRefs, reactive, computed } from "vue";
|
import PageHeader from "@/components/PageHeader.vue";
|
import { approveProcessListPage } from "@/api/collaborativeApproval/approvalProcess";
|
import { onLoad, onShow } from "@dcloudio/uni-app";
|
import useUserStore from "@/store/modules/user";
|
|
/** 审批状态筛选(与 Web approvalProcess 列表一致) */
|
const APPROVE_STATUS_OPTIONS = [
|
{ value: "", label: "全部状态" },
|
{ value: 0, label: "待审核" },
|
{ value: 1, label: "审核中" },
|
{ value: 2, label: "审核完成" },
|
{ value: 3, label: "审核未通过" },
|
{ value: 4, label: "已重新提交" },
|
];
|
|
// 接收父组件传递的 approveType 参数(index1~8 固定类型;0 表示未指定)
|
const props = defineProps({
|
approveType: {
|
type: Number,
|
default: 0,
|
},
|
});
|
|
// 审批类型标题
|
const APPROVE_TYPE_LABELS = {
|
1: "公出管理",
|
2: "请假管理",
|
3: "出差管理",
|
4: "报销管理",
|
5: "采购审批",
|
6: "报价审批",
|
7: "发货审批",
|
8: "危险作业审批",
|
};
|
|
/** 可切换的协同审批类型(与 Web approvalProcess Tab 一致) */
|
const TYPE_TAB_VALUES = [1, 2, 3, 4, 5, 6, 7];
|
|
/** 父级传入的固定类型;0 表示未指定,可由页内 Tab 切换 */
|
const fixedApproveType = computed(() => Number(props.approveType) || 0);
|
const activeApproveType = ref(fixedApproveType.value || 1);
|
|
const showTypeTabs = computed(() => fixedApproveType.value === 0);
|
|
const typeTabList = computed(() =>
|
TYPE_TAB_VALUES.map(value => ({ name: APPROVE_TYPE_LABELS[value] }))
|
);
|
|
const activeTypeIndex = computed(() => {
|
const idx = TYPE_TAB_VALUES.indexOf(activeApproveType.value);
|
return idx >= 0 ? idx : 0;
|
});
|
|
const pageTitle = computed(
|
() => APPROVE_TYPE_LABELS[activeApproveType.value] || "协同审批"
|
);
|
|
const onTypeTabClick = item => {
|
activeApproveType.value = TYPE_TAB_VALUES[item?.index ?? 0] || 1;
|
searchForm.value.approveId = "";
|
searchForm.value.approveStatus = "";
|
getList();
|
};
|
|
/** 列表行自带 approveType,缺失时回退当前 Tab */
|
const currentItemApproveType = item =>
|
Number(item?.approveType) || activeApproveType.value;
|
|
const userStore = useUserStore();
|
// 数据
|
const ledgerList = ref([]);
|
const data = reactive({
|
searchForm: {
|
approveId: "",
|
approveStatus: "",
|
},
|
});
|
const { searchForm } = toRefs(data);
|
|
const showStatusSheet = ref(false);
|
|
const statusActions = computed(() =>
|
APPROVE_STATUS_OPTIONS.map(opt => ({ name: opt.label, value: opt.value }))
|
);
|
|
const approveStatusText = computed(() => {
|
const hit = APPROVE_STATUS_OPTIONS.find(
|
opt => String(opt.value) === String(searchForm.value.approveStatus)
|
);
|
return hit?.label || "全部状态";
|
});
|
|
const openStatusSheet = () => {
|
showStatusSheet.value = true;
|
};
|
|
const onSelectStatus = action => {
|
searchForm.value.approveStatus = action?.value ?? "";
|
showStatusSheet.value = false;
|
getList();
|
};
|
|
// 返回上一页
|
const goBack = () => {
|
uni.navigateBack();
|
};
|
// 查询列表
|
const getList = () => {
|
showLoadingToast("加载中...");
|
const page = {
|
current: -1,
|
size: -1,
|
};
|
approveProcessListPage({
|
...page,
|
approveType: activeApproveType.value,
|
...searchForm.value,
|
})
|
.then(res => {
|
ledgerList.value = res.data.records;
|
closeToast();
|
})
|
.catch(() => {
|
closeToast();
|
});
|
};
|
// 显示加载提示
|
const showLoadingToast = message => {
|
uni.showLoading({
|
title: message,
|
mask: true,
|
});
|
};
|
|
// 关闭提示
|
const closeToast = () => {
|
uni.hideLoading();
|
};
|
|
// 显示筛选选项
|
const showFilterOptions = () => {
|
uni.showActionSheet({
|
itemList: ["按日期筛选", "按状态筛选", "按金额筛选"],
|
success: res => {
|
console.log("选择了筛选选项:", res.tapIndex);
|
},
|
});
|
};
|
// 格式化回款方式
|
const formatReceiptType = params => {
|
if (params == 0) {
|
return "待审核";
|
} else if (params == 1) {
|
return "审核中";
|
} else if (params == 2) {
|
return "审核完成";
|
} else if (params == 4) {
|
return "已重新提交";
|
} else {
|
return "不通过";
|
}
|
};
|
// 获取标签样式类
|
const getTagClass = type => {
|
if (type == 0) {
|
return "warning";
|
} else if (type == 1) {
|
return "primary";
|
} else if (type == 2) {
|
return "success";
|
} else if (type == 4) {
|
return "primary";
|
} else {
|
return "error";
|
}
|
};
|
|
// 点击列表项
|
const handleItemClick = item => {
|
// 使用本地存储传递数据
|
uni.setStorageSync("invoiceLedgerEditRow", JSON.stringify(item));
|
uni.setStorageSync("operationType", "edit");
|
uni.setStorageSync("approveId", item.approveId);
|
uni.setStorageSync("approveType", currentItemApproveType(item));
|
uni.navigateTo({
|
url: "/pages/cooperativeOffice/collaborativeApproval/detail",
|
});
|
};
|
|
// 查看详情
|
const handleDetailClick = item => {
|
uni.setStorageSync("invoiceLedgerEditRow", JSON.stringify(item));
|
uni.setStorageSync("operationType", "detail");
|
uni.setStorageSync("approveId", item.approveId);
|
uni.setStorageSync("approveType", currentItemApproveType(item));
|
uni.navigateTo({
|
url: "/pages/cooperativeOffice/collaborativeApproval/detail",
|
});
|
};
|
|
// 添加新记录
|
const handleAdd = () => {
|
uni.setStorageSync("operationType", "add");
|
uni.setStorageSync("approveType", activeApproveType.value);
|
uni.navigateTo({
|
url: `/pages/cooperativeOffice/collaborativeApproval/detail?approveType=${activeApproveType.value}`,
|
});
|
};
|
// 点击审核
|
const approve = item => {
|
const type = currentItemApproveType(item);
|
uni.setStorageSync("approveId", item.approveId);
|
uni.setStorageSync("approveType", type);
|
uni.navigateTo({
|
url:
|
"/pages/cooperativeOffice/collaborativeApproval/approve?approveType=" +
|
type,
|
});
|
};
|
|
onLoad(options => {
|
// index1~8 传固定类型;菜单直接进入时可用 ?approveType= 指定,默认公出管理
|
activeApproveType.value =
|
Number(options?.approveType) || fixedApproveType.value || 1;
|
// 解析approveId
|
if (options.approveId) {
|
searchForm.value.approveId = options.approveId;
|
}
|
});
|
|
onShow(() => {
|
// 页面加载完成后的初始化逻辑
|
getList();
|
});
|
</script>
|
|
<style scoped lang="scss">
|
@import "../../../styles/sales-common.scss";
|
|
.u-divider {
|
margin: 0 !important;
|
}
|
|
// 审批类型切换
|
.type-tabs-wrap {
|
background: #fff;
|
border-bottom: 1px solid #f0f0f0;
|
padding: 0 8px;
|
}
|
|
// 文档图标样式 - 覆盖公共样式中的背景色
|
.document-icon {
|
background: #ed8d05;
|
}
|
|
// 状态筛选 chip
|
.filter-chip {
|
display: flex;
|
align-items: center;
|
gap: 4px;
|
flex-shrink: 0;
|
margin-left: 8px;
|
padding: 6px 10px;
|
background: #fff;
|
border: 1px solid #e5e7eb;
|
border-radius: 16px;
|
|
&--active {
|
border-color: #2979ff;
|
background: #f0f6ff;
|
}
|
}
|
|
.filter-chip-text {
|
font-size: 12px;
|
color: #606266;
|
max-width: 88px;
|
overflow: hidden;
|
text-overflow: ellipsis;
|
white-space: nowrap;
|
}
|
|
.filter-chip--active .filter-chip-text {
|
color: #2979ff;
|
}
|
|
// 浮动按钮样式 - 覆盖公共样式中的背景色
|
.fab-button {
|
background: #ed8d05;
|
}
|
|
// 特有样式
|
.detail-row-user {
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
}
|
|
.detail-row-approveReason {
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
margin-bottom: 8px;
|
}
|
|
.detail-value.highlightBlue {
|
color: #2979ff;
|
font-weight: 500;
|
}
|
|
.detail-value.highlightYellow {
|
color: #ed8d05;
|
font-weight: 500;
|
}
|
|
.approver-value {
|
display: flex;
|
justify-content: flex-end;
|
}
|
|
.approver-chip {
|
display: inline-flex;
|
align-items: center;
|
gap: 6px;
|
background: #f0f6ff;
|
color: #2b7cff;
|
border: 1px solid #e0efff;
|
border-radius: 999px;
|
padding: 4px 10px;
|
max-width: 100%;
|
}
|
|
.approver-name {
|
font-size: 12px;
|
color: #2b7cff;
|
overflow: hidden;
|
text-overflow: ellipsis;
|
white-space: nowrap;
|
}
|
|
.actions {
|
display: flex;
|
gap: 10px;
|
align-items: center;
|
justify-content: flex-end;
|
}
|
|
.action-btn {
|
border-radius: 16px;
|
height: 28px;
|
line-height: 28px;
|
padding: 0 12px;
|
}
|
</style>
|