<template>
|
<div class="app-container">
|
<el-card class="box-card">
|
<template #header>
|
<div class="card-header">
|
<span>办公物资申请管理</span>
|
<el-button type="primary" @click="showApplyDialog = true">
|
<el-icon><Plus /></el-icon>
|
新建申请
|
</el-button>
|
</div>
|
</template>
|
|
<!-- 搜索区域 -->
|
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch">
|
<el-form-item label="申请编号" prop="applyNo">
|
<el-input
|
v-model="queryParams.applyNo"
|
placeholder="请输入申请编号"
|
clearable
|
style="width: 200px"
|
@keyup.enter="handleQuery"
|
/>
|
</el-form-item>
|
<el-form-item label="申请人" prop="applicant">
|
<el-input
|
v-model="queryParams.applicant"
|
placeholder="请输入申请人"
|
clearable
|
style="width: 200px"
|
@keyup.enter="handleQuery"
|
/>
|
</el-form-item>
|
<el-form-item label="申请状态" prop="status">
|
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable style="width: 200px">
|
<el-option label="待审批" value="pending" />
|
<el-option label="已通过" value="approved" />
|
<el-option label="已拒绝" value="rejected" />
|
<el-option label="已发放" value="issued" />
|
</el-select>
|
</el-form-item>
|
<el-form-item>
|
<el-button type="primary" @click="handleQuery">
|
<el-icon><Search /></el-icon>
|
搜索
|
</el-button>
|
<el-button @click="resetQuery">
|
<el-icon><Refresh /></el-icon>
|
重置
|
</el-button>
|
</el-form-item>
|
<el-form-item>
|
<el-button type="primary" @click="handleExport">
|
<el-icon><Download /></el-icon>
|
导出
|
</el-button>
|
<el-button type="success" @click="handleBatchApprove" :disabled="multipleSelection.length === 0">
|
<el-icon><Check /></el-icon>
|
批量审批
|
</el-button>
|
</el-form-item>
|
</el-form>
|
|
<!-- 表格区域 -->
|
<el-table
|
v-loading="loading"
|
:data="suppliesList"
|
@selection-change="handleSelectionChange"
|
style="width: 100%"
|
>
|
<el-table-column type="selection" width="55" align="center" />
|
<el-table-column label="申请编号" align="center" prop="applyNo" width="180" />
|
<el-table-column label="申请人" align="center" prop="applicant" width="120" />
|
<el-table-column label="部门" align="center" prop="department" width="120" />
|
<el-table-column label="物资类型" align="center" prop="supplyType" width="120" />
|
<el-table-column label="申请数量" align="center" prop="quantity" width="100" />
|
<el-table-column label="申请原因" align="center" prop="reason" min-width="200" show-overflow-tooltip />
|
<el-table-column label="申请状态" align="center" prop="status" width="100">
|
<template #default="scope">
|
<el-tag :type="getStatusType(scope.row.status)">
|
{{ getStatusText(scope.row.status) }}
|
</el-tag>
|
</template>
|
</el-table-column>
|
<el-table-column label="申请时间" align="center" prop="applyTime" width="180" />
|
<el-table-column label="审批人" align="center" prop="approver" width="120" />
|
<el-table-column label="审批时间" align="center" prop="approveTime" width="180" />
|
<el-table-column label="发放时间" align="center" prop="issueTime" width="180" />
|
<el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width" width="200">
|
<template #default="scope">
|
<el-button
|
v-if="scope.row.status === 'pending'"
|
type="primary"
|
link
|
@click="handleApprove(scope.row)"
|
>
|
审批
|
</el-button>
|
<el-button
|
v-if="scope.row.status === 'approved'"
|
type="success"
|
link
|
@click="handleIssue(scope.row)"
|
>
|
发放
|
</el-button>
|
<el-button
|
type="info"
|
link
|
@click="handleDetail(scope.row)"
|
>
|
详情
|
</el-button>
|
<el-button
|
v-if="scope.row.status === 'pending'"
|
type="danger"
|
link
|
@click="handleDelete(scope.row)"
|
>
|
删除
|
</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
|
<!-- 分页 -->
|
<pagination
|
v-show="total > 0"
|
:total="total"
|
v-model:page="queryParams.pageNum"
|
v-model:limit="queryParams.pageSize"
|
@pagination="getList"
|
/>
|
</el-card>
|
|
<!-- 申请对话框 -->
|
<el-dialog
|
v-model="showApplyDialog"
|
title="办公物资申请"
|
width="600px"
|
append-to-body
|
>
|
<el-form ref="applyFormRef" :model="applyForm" :rules="applyRules" label-width="100px">
|
<el-form-item label="物资类型" prop="supplyType">
|
<el-select v-model="applyForm.supplyType" placeholder="请选择物资类型" style="width: 100%">
|
<el-option label="办公用品" value="office" />
|
<el-option label="电子设备" value="electronic" />
|
<el-option label="清洁用品" value="cleaning" />
|
<el-option label="其他" value="other" />
|
</el-select>
|
</el-form-item>
|
<el-form-item label="具体物品" prop="itemName">
|
<el-input v-model="applyForm.itemName" placeholder="请输入具体物品名称" />
|
</el-form-item>
|
<el-form-item label="申请数量" prop="quantity">
|
<el-input-number v-model="applyForm.quantity" :min="1" :max="999" style="width: 100%" />
|
</el-form-item>
|
<el-form-item label="申请原因" prop="reason">
|
<el-input
|
v-model="applyForm.reason"
|
type="textarea"
|
:rows="3"
|
placeholder="请输入申请原因"
|
/>
|
</el-form-item>
|
<el-form-item label="紧急程度" prop="urgency">
|
<el-radio-group v-model="applyForm.urgency">
|
<el-radio label="normal">普通</el-radio>
|
<el-radio label="urgent">紧急</el-radio>
|
<el-radio label="very_urgent">非常紧急</el-radio>
|
</el-radio-group>
|
</el-form-item>
|
</el-form>
|
<template #footer>
|
<div class="dialog-footer">
|
<el-button @click="showApplyDialog = false">取 消</el-button>
|
<el-button type="primary" @click="submitApply">确 定</el-button>
|
</div>
|
</template>
|
</el-dialog>
|
|
<!-- 审批对话框 -->
|
<el-dialog
|
v-model="showApproveDialog"
|
title="审批申请"
|
width="500px"
|
append-to-body
|
>
|
<el-form ref="approveFormRef" :model="approveForm" :rules="approveRules" label-width="100px">
|
<el-form-item label="审批结果" prop="approveResult">
|
<el-radio-group v-model="approveForm.approveResult">
|
<el-radio label="approved">通过</el-radio>
|
<el-radio label="rejected">拒绝</el-radio>
|
</el-radio-group>
|
</el-form-item>
|
<el-form-item label="审批意见" prop="approveComment">
|
<el-input
|
v-model="approveForm.approveComment"
|
type="textarea"
|
:rows="3"
|
placeholder="请输入审批意见"
|
/>
|
</el-form-item>
|
</el-form>
|
<template #footer>
|
<div class="dialog-footer">
|
<el-button @click="showApproveDialog = false">取 消</el-button>
|
<el-button type="primary" @click="submitApprove">确 定</el-button>
|
</div>
|
</template>
|
</el-dialog>
|
|
<!-- 详情对话框 -->
|
<el-dialog
|
v-model="showDetailDialog"
|
title="申请详情"
|
width="700px"
|
append-to-body
|
>
|
<el-descriptions :column="2" border>
|
<el-descriptions-item label="申请编号">{{ currentDetail.applyNo }}</el-descriptions-item>
|
<el-descriptions-item label="申请人">{{ currentDetail.applicant }}</el-descriptions-item>
|
<el-descriptions-item label="部门">{{ currentDetail.department }}</el-descriptions-item>
|
<el-descriptions-item label="物资类型">{{ currentDetail.supplyType }}</el-descriptions-item>
|
<el-descriptions-item label="具体物品">{{ currentDetail.itemName }}</el-descriptions-item>
|
<el-descriptions-item label="申请数量">{{ currentDetail.quantity }}</el-descriptions-item>
|
<el-descriptions-item label="申请原因" :span="2">{{ currentDetail.reason }}</el-descriptions-item>
|
<el-descriptions-item label="申请状态">
|
<el-tag :type="getStatusType(currentDetail.status)">
|
{{ getStatusText(currentDetail.status) }}
|
</el-tag>
|
</el-descriptions-item>
|
<el-descriptions-item label="申请时间">{{ currentDetail.applyTime }}</el-descriptions-item>
|
<el-descriptions-item label="审批人">{{ currentDetail.approver || '-' }}</el-descriptions-item>
|
<el-descriptions-item label="审批时间">{{ currentDetail.approveTime || '-' }}</el-descriptions-item>
|
<el-descriptions-item label="审批意见" :span="2">{{ currentDetail.approveComment || '-' }}</el-descriptions-item>
|
<el-descriptions-item label="发放时间">{{ currentDetail.issueTime || '-' }}</el-descriptions-item>
|
<el-descriptions-item label="发放人">{{ currentDetail.issuer || '-' }}</el-descriptions-item>
|
</el-descriptions>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script setup>
|
import { ref, reactive, onMounted } from 'vue'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { Plus, Search, Refresh, Download, Check } from '@element-plus/icons-vue'
|
|
// 响应式数据
|
const loading = ref(false)
|
const showSearch = ref(true)
|
const showApplyDialog = ref(false)
|
const showApproveDialog = ref(false)
|
const showDetailDialog = ref(false)
|
const multipleSelection = ref([])
|
const total = ref(0)
|
const suppliesList = ref([])
|
const currentDetail = ref({})
|
|
// 查询参数
|
const queryParams = reactive({
|
pageNum: 1,
|
pageSize: 10,
|
applyNo: '',
|
applicant: '',
|
status: ''
|
})
|
|
// 申请表单
|
const applyForm = reactive({
|
supplyType: '',
|
itemName: '',
|
quantity: 1,
|
reason: '',
|
urgency: 'normal'
|
})
|
|
// 审批表单
|
const approveForm = reactive({
|
approveResult: 'approved',
|
approveComment: ''
|
})
|
|
// 表单校验规则
|
const applyRules = {
|
supplyType: [{ required: true, message: '请选择物资类型', trigger: 'change' }],
|
itemName: [{ required: true, message: '请输入具体物品名称', trigger: 'blur' }],
|
quantity: [{ required: true, message: '请输入申请数量', trigger: 'blur' }],
|
reason: [{ required: true, message: '请输入申请原因', trigger: 'blur' }]
|
}
|
|
const approveRules = {
|
approveResult: [{ required: true, message: '请选择审批结果', trigger: 'change' }],
|
approveComment: [{ required: true, message: '请输入审批意见', trigger: 'blur' }]
|
}
|
|
// 假数据
|
const mockData = [
|
{
|
id: 1,
|
applyNo: 'WS20241201001',
|
applicant: '陈志强',
|
department: '技术部',
|
supplyType: '办公用品',
|
itemName: 'A4打印纸',
|
quantity: 10,
|
reason: '日常办公打印需要',
|
status: 'pending',
|
applyTime: '2024-12-01 09:30:00',
|
approver: '',
|
approveTime: '',
|
approveComment: '',
|
issueTime: '',
|
issuer: ''
|
},
|
{
|
id: 2,
|
applyNo: 'WS20241201002',
|
applicant: '刘雅婷',
|
department: '人事部',
|
supplyType: '电子设备',
|
itemName: '无线鼠标',
|
quantity: 2,
|
reason: '新员工入职配备',
|
status: 'approved',
|
applyTime: '2024-12-01 10:15:00',
|
approver: '王建国',
|
approveTime: '2024-12-01 14:20:00',
|
approveComment: '同意申请,请及时发放',
|
issueTime: '',
|
issuer: ''
|
},
|
{
|
id: 3,
|
applyNo: 'WS20241201003',
|
applicant: '王建国',
|
department: '财务部',
|
supplyType: '清洁用品',
|
itemName: '洗手液',
|
quantity: 5,
|
reason: '办公室清洁用品补充',
|
status: 'issued',
|
applyTime: '2024-12-01 11:00:00',
|
approver: '刘雅婷',
|
approveTime: '2024-12-01 15:30:00',
|
approveComment: '同意申请',
|
issueTime: '2024-12-01 16:00:00',
|
issuer: '钱伟明'
|
},
|
{
|
id: 4,
|
applyNo: 'WS20241201004',
|
applicant: '赵丽华',
|
department: '市场部',
|
supplyType: '其他',
|
itemName: '文件夹',
|
quantity: 20,
|
reason: '项目资料整理需要',
|
status: 'rejected',
|
applyTime: '2024-12-01 13:45:00',
|
approver: '陈志强',
|
approveTime: '2024-12-01 17:00:00',
|
approveComment: '数量过多,建议减少到10个',
|
issueTime: '',
|
issuer: ''
|
},
|
{
|
id: 5,
|
applyNo: 'WS20241202001',
|
applicant: '钱伟明',
|
department: '运营部',
|
supplyType: '办公用品',
|
itemName: '签字笔',
|
quantity: 50,
|
reason: '部门日常办公用品补充',
|
status: 'pending',
|
applyTime: '2024-12-02 08:30:00',
|
approver: '',
|
approveTime: '',
|
approveComment: '',
|
issueTime: '',
|
issuer: ''
|
},
|
{
|
id: 6,
|
applyNo: 'WS20241202002',
|
applicant: '孙明华',
|
department: '技术部',
|
supplyType: '电子设备',
|
itemName: '键盘',
|
quantity: 3,
|
reason: '新员工设备配备',
|
status: 'approved',
|
applyTime: '2024-12-02 14:20:00',
|
approver: '陈志强',
|
approveTime: '2024-12-02 16:00:00',
|
approveComment: '同意申请',
|
issueTime: '',
|
issuer: ''
|
},
|
{
|
id: 7,
|
applyNo: 'WS20241203001',
|
applicant: '周美玲',
|
department: '人事部',
|
supplyType: '清洁用品',
|
itemName: '纸巾',
|
quantity: 30,
|
reason: '办公区域清洁用品补充',
|
status: 'issued',
|
applyTime: '2024-12-03 09:15:00',
|
approver: '赵丽华',
|
approveTime: '2024-12-03 10:30:00',
|
approveComment: '同意申请',
|
issueTime: '2024-12-03 11:00:00',
|
issuer: '孙明华'
|
},
|
{
|
id: 8,
|
applyNo: 'WS20241203002',
|
applicant: '吴志强',
|
department: '财务部',
|
supplyType: '其他',
|
itemName: '计算器',
|
quantity: 2,
|
reason: '财务核算工作需要',
|
status: 'rejected',
|
applyTime: '2024-12-03 15:45:00',
|
approver: '王建国',
|
approveTime: '2024-12-03 17:20:00',
|
approveComment: '已有计算器,暂不需要',
|
issueTime: '',
|
issuer: ''
|
}
|
]
|
|
// 获取列表数据
|
const getList = () => {
|
loading.value = true
|
// 模拟异步请求
|
setTimeout(() => {
|
let filteredData = [...mockData]
|
|
// 根据查询条件过滤
|
if (queryParams.applyNo) {
|
filteredData = filteredData.filter(item =>
|
item.applyNo.toLowerCase().includes(queryParams.applyNo.toLowerCase())
|
)
|
}
|
if (queryParams.applicant) {
|
filteredData = filteredData.filter(item =>
|
item.applicant.toLowerCase().includes(queryParams.applicant.toLowerCase())
|
)
|
}
|
if (queryParams.status) {
|
filteredData = filteredData.filter(item =>
|
item.status === queryParams.status
|
)
|
}
|
|
// 按申请时间倒序排列
|
filteredData.sort((a, b) => new Date(b.applyTime) - new Date(a.applyTime))
|
|
total.value = filteredData.length
|
suppliesList.value = filteredData.slice(
|
(queryParams.pageNum - 1) * queryParams.pageSize,
|
queryParams.pageNum * queryParams.pageSize
|
)
|
loading.value = false
|
}, 500)
|
}
|
|
// 查询
|
const handleQuery = () => {
|
queryParams.pageNum = 1
|
getList()
|
}
|
|
// 重置查询
|
const resetQuery = () => {
|
queryParams.applyNo = ''
|
queryParams.applicant = ''
|
queryParams.status = ''
|
handleQuery()
|
}
|
|
// 多选
|
const handleSelectionChange = (selection) => {
|
multipleSelection.value = selection
|
}
|
|
// 获取状态类型
|
const getStatusType = (status) => {
|
const statusMap = {
|
pending: 'warning',
|
approved: 'success',
|
rejected: 'danger',
|
issued: 'info'
|
}
|
return statusMap[status] || 'info'
|
}
|
|
// 获取状态文本
|
const getStatusText = (status) => {
|
const statusMap = {
|
pending: '待审批',
|
approved: '已通过',
|
rejected: '已拒绝',
|
issued: '已发放'
|
}
|
return statusMap[status] || status
|
}
|
|
// 提交申请
|
const submitApply = () => {
|
const newApply = {
|
id: mockData.length + 1,
|
applyNo: `WS${new Date().getTime()}`,
|
applicant: '当前用户',
|
department: '技术部',
|
supplyType: applyForm.supplyType,
|
itemName: applyForm.itemName,
|
quantity: applyForm.quantity,
|
reason: applyForm.reason,
|
status: 'pending',
|
applyTime: new Date().toLocaleString(),
|
approver: '',
|
approveTime: '',
|
approveComment: '',
|
issueTime: '',
|
issuer: ''
|
}
|
|
mockData.unshift(newApply)
|
showApplyDialog.value = false
|
ElMessage.success('申请提交成功')
|
getList()
|
|
// 重置表单
|
Object.assign(applyForm, {
|
supplyType: '',
|
itemName: '',
|
quantity: 1,
|
reason: '',
|
urgency: 'normal'
|
})
|
}
|
|
// 审批
|
const handleApprove = (row) => {
|
currentDetail.value = row
|
showApproveDialog.value = true
|
}
|
|
// 提交审批
|
const submitApprove = () => {
|
const index = mockData.findIndex(item => item.id === currentDetail.value.id)
|
if (index !== -1) {
|
mockData[index].status = approveForm.approveResult
|
mockData[index].approver = '当前审批人'
|
mockData[index].approveTime = new Date().toLocaleString()
|
mockData[index].approveComment = approveForm.approveComment
|
}
|
|
showApproveDialog.value = false
|
ElMessage.success('审批完成')
|
getList()
|
|
// 重置表单
|
Object.assign(approveForm, {
|
approveResult: 'approved',
|
approveComment: ''
|
})
|
}
|
|
// 发放
|
const handleIssue = (row) => {
|
const index = mockData.findIndex(item => item.id === row.id)
|
if (index !== -1) {
|
mockData[index].status = 'issued'
|
mockData[index].issueTime = new Date().toLocaleString()
|
mockData[index].issuer = '当前发放人'
|
}
|
|
ElMessage.success('发放完成')
|
getList()
|
}
|
|
// 查看详情
|
const handleDetail = (row) => {
|
currentDetail.value = row
|
showDetailDialog.value = true
|
}
|
|
// 删除
|
const handleDelete = (row) => {
|
ElMessageBox.confirm('确认删除该申请吗?', '提示', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning'
|
}).then(() => {
|
const index = mockData.findIndex(item => item.id === row.id)
|
if (index !== -1) {
|
mockData.splice(index, 1)
|
}
|
ElMessage.success('删除成功')
|
getList()
|
})
|
}
|
|
// 批量审批
|
const handleBatchApprove = () => {
|
if (multipleSelection.value.length === 0) {
|
ElMessage.warning('请选择要审批的记录')
|
return
|
}
|
|
ElMessageBox.confirm(`确认批量审批选中的 ${multipleSelection.value.length} 条记录吗?`, '提示', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning'
|
}).then(() => {
|
multipleSelection.value.forEach(row => {
|
const index = mockData.findIndex(item => item.id === row.id)
|
if (index !== -1) {
|
mockData[index].status = 'approved'
|
mockData[index].approver = '当前审批人'
|
mockData[index].approveTime = new Date().toLocaleString()
|
mockData[index].approveComment = '批量审批通过'
|
}
|
})
|
ElMessage.success('批量审批完成')
|
getList()
|
})
|
}
|
|
// 导出
|
const handleExport = () => {
|
ElMessage.success('导出功能开发中...')
|
}
|
|
// 页面加载时获取数据
|
onMounted(() => {
|
getList()
|
})
|
</script>
|
|
<style scoped>
|
.app-container {
|
padding: 20px;
|
}
|
|
.card-header {
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
}
|
|
.mb8 {
|
margin-bottom: 8px;
|
}
|
|
.dialog-footer {
|
text-align: right;
|
}
|
|
:deep(.el-descriptions__label) {
|
width: 120px;
|
}
|
</style>
|