bonus-ui/src/views/EquipmentEntryApply/EquipmentMainList.vue

357 lines
9.5 KiB
Vue
Raw Normal View History

2025-10-13 09:27:53 +08:00
<template>
<div class="app-container-con">
2025-10-29 11:05:22 +08:00
<el-form :model="queryParams" ref="queryFormRef" inline label-width="auto" size="small">
2025-10-13 09:27:53 +08:00
<!-- 表单搜索 -->
2025-10-29 11:05:22 +08:00
<el-card class="search-box">
<el-row>
<el-col :span="18">
2025-12-01 09:43:58 +08:00
<el-form-item prop="createUser" label="申请人">
2025-10-29 11:05:22 +08:00
<el-input clearable style="width: 240px" placeholder="请输入关键字" v-model.trim="queryParams.createUser" />
</el-form-item>
2025-10-13 09:27:53 +08:00
<el-form-item label="申请时间" prop="createTime">
2025-10-29 11:05:22 +08:00
<el-date-picker type="daterange" style="width: 100%" unlink-panels range-separator=""
start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd"
v-model="queryParams.createTime" />
2025-10-13 09:27:53 +08:00
</el-form-item>
<el-form-item label="审批状态" prop="status">
2025-10-29 11:05:22 +08:00
<el-select clearable style="width: 100%" placeholder="请选择审批状态" v-model="queryParams.status">
<el-option label="待审批" value="0" />
<el-option label="已审批" value="1" />
<el-option label="草稿" value="3" />
2025-10-13 09:27:53 +08:00
</el-select>
</el-form-item>
2025-10-29 11:05:22 +08:00
</el-col>
<el-col :span="6" style="text-align: right;">
2025-10-29 13:42:42 +08:00
2025-10-29 17:56:05 +08:00
<el-button class="primary-lease" size="mini" icon="el-icon-search" style="margin-right: 0;" type="primary" @click="getEquipmentApplyList">
2025-10-29 11:05:22 +08:00
查询
2025-10-13 09:27:53 +08:00
</el-button>
2025-10-29 17:56:05 +08:00
<el-button class="primary-lease" size="mini" icon="el-icon-refresh" @click="resetForm">
2025-10-29 13:42:42 +08:00
重置
</el-button>
2025-10-29 11:05:22 +08:00
</el-col>
</el-row>
</el-card>
2025-10-13 09:27:53 +08:00
2025-10-29 11:05:22 +08:00
<el-card class="content-box">
<el-row>
<el-col>
2025-10-29 17:56:05 +08:00
<el-button class="primary-lease" size="mini" type="primary" @click="addEquipment()" style="margin-right: 0px">
2025-10-29 11:05:22 +08:00
装备录入
2025-10-13 09:27:53 +08:00
</el-button>
2025-10-29 11:05:22 +08:00
2025-10-29 17:56:05 +08:00
<el-button class="primary-lease" size="mini" type="primary" @click="showDetails('1')" style="margin-right: 0px">
2025-10-29 11:05:22 +08:00
展开明细
2025-10-13 09:27:53 +08:00
</el-button>
2025-10-29 11:05:22 +08:00
</el-col>
</el-row>
<!-- 表格区域 -->
<div class="table-container">
<el-table :data="tableData" border stripe height="100%">
<el-table-column label="序号" align="center" width="55" type="index" />
<el-table-column prop="orderNumber" label="录入单号" align="center" />
<el-table-column prop="devCount" label="申请录入数量" align="center" />
<el-table-column prop="createUser" label="申请人" align="center" />
<el-table-column prop="createTime" label="申请时间" align="center" />
<el-table-column prop="status" align="center" label="审批状态">
<template slot-scope="{ row }">
<el-tag v-if="row.status == 0" size="small" type="warning">审批中</el-tag>
<el-tag v-if="row.status == 1" size="small" type="success">已审批</el-tag>
<el-tag v-if="row.status == 3" size="small" type="info">草稿</el-tag>
</template>
</el-table-column>
<el-table-column prop="agree" label="已通过数量" align="center" />
<el-table-column prop="reject" label="已驳回数量" align="center" />
<el-table-column label="操作" align="center" min-width="100">
<template slot-scope="{ row }">
<el-button type="text" size="mini" @click="viewEquipment(row.id)">
<i class="el-icon-view"></i> 查看
</el-button>
<el-button type="text" size="mini" @click="editEquipment(row.id)" v-if="row.status === '3'">
<i class="el-icon-edit"></i> 编辑
</el-button>
<el-button type="text" size="mini" @click="deleteItem(row)" v-if="row.status === '3'">
<i class="el-icon-delete"></i> 删除
</el-button>
</template>
</el-table-column>
</el-table>
</div>
2025-10-13 09:27:53 +08:00
2025-10-29 11:05:22 +08:00
<!-- 分页 -->
<div class="pagination-wrapper">
<pagination :total="total" @pagination="handlePageChange" :page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize" />
</div>
</el-card>
2025-10-13 09:27:53 +08:00
</el-form>
</div>
</template>
<script>
import { getEquipmentApplyListApi, equipmentDelApiNew } from '@/api/EquipmentEntryApply/index'
export default {
name: 'EquipmentMainList',
data() {
return {
total: 0,
orderId: '',
isVisible: false,
isAddVisible: false,
queryParams: {
2025-10-29 11:05:22 +08:00
createUser: '',
2025-10-13 09:27:53 +08:00
createTime: '',
status: '',
pageNum: 1,
2025-10-29 11:05:22 +08:00
pageSize: 10,
2025-10-13 09:27:53 +08:00
},
tableData: [],
totalDetails: 0,
orderIdDetails: '',
isVisibleDetails: false,
isAddVisibleDetails: false,
queryParamsDetails: {
status: '',
applyTime: '',
pageNum: 1,
2025-10-29 11:05:22 +08:00
pageSize: 10,
2025-10-13 09:27:53 +08:00
},
tableDataDetails: [],
2025-10-29 11:05:22 +08:00
isDetails: '0',
2025-10-13 09:27:53 +08:00
}
},
mounted() {
this.getEquipmentApplyList()
},
methods: {
/**
* 获取装备申请列表
*/
getEquipmentApplyList() {
2025-10-14 17:23:57 +08:00
this.queryParams.startCreateTime = this.queryParams.createTime ? this.queryParams.createTime[0] : ''
this.queryParams.endCreateTime = this.queryParams.createTime ? this.queryParams.createTime[1] : ''
const params = { ...this.queryParams }
delete params.createTime
getEquipmentApplyListApi(params)
2025-10-29 11:05:22 +08:00
.then((res) => {
2025-10-13 09:27:53 +08:00
this.tableData = res.data.rows
this.total = res.data.total
})
2025-10-29 11:05:22 +08:00
.catch((error) => {
2025-10-13 09:27:53 +08:00
console.error('获取装备申请列表失败:', error)
})
},
/**
* 分页变化处理
*/
handlePageChange() {
this.getEquipmentApplyList()
},
/**
* 重置表单
*/
resetForm() {
this.$refs.queryFormRef.resetFields()
this.queryParams.pageNum = 1
this.getEquipmentApplyList()
},
/**
* 删除项目
*/
deleteItem(row) {
this.$confirm('是否确定删除?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
2025-10-29 11:05:22 +08:00
type: 'warning',
2025-10-13 09:27:53 +08:00
})
.then(() => equipmentDelApiNew({ id: row.id }))
2025-10-29 11:05:22 +08:00
.then((res) => {
2025-10-13 09:27:53 +08:00
if (res.code === 200) {
this.$message.success('删除成功')
this.getEquipmentApplyList()
} else {
this.$message.error('删除失败')
}
})
2025-10-29 11:05:22 +08:00
.catch((error) => {
if (error !== 'cancel') {
// 排除取消操作的错误
2025-10-13 09:27:53 +08:00
console.error('删除失败:', error)
this.$message.error('删除失败,请重试')
}
})
},
//展示明细
showDetails(num) {
this.$emit('switch-view', num)
},
// 查看模式
viewEquipment(orderId) {
this.$router.push({
name: 'equipmentInput',
2025-10-14 17:23:57 +08:00
query: {
2025-10-13 09:27:53 +08:00
orderId: orderId,
isAddVisible: true,
2025-10-29 11:05:22 +08:00
isApprovalVisible: false,
},
2025-10-13 09:27:53 +08:00
})
},
// 编辑模式
editEquipment(orderId) {
this.$router.push({
name: 'equipmentInput',
2025-10-14 17:23:57 +08:00
query: {
2025-10-13 09:27:53 +08:00
orderId: orderId,
isAddVisible: false,
2025-10-29 11:05:22 +08:00
isApprovalVisible: false,
},
2025-10-13 09:27:53 +08:00
})
},
// 新增模式
addEquipment() {
this.$router.push({
name: 'equipmentInput',
2025-10-14 17:23:57 +08:00
query: {
2025-10-13 09:27:53 +08:00
orderId: '',
isAddVisible: false,
2025-10-29 11:05:22 +08:00
isApprovalVisible: false,
},
2025-10-13 09:27:53 +08:00
})
2025-10-29 11:05:22 +08:00
},
},
2025-10-13 09:27:53 +08:00
}
</script>
<style scoped lang="scss">
.view-btn {
color: #409eff;
font-size: 14px;
font-weight: bold;
}
.edit-btn {
color: #67c23a;
font-size: 12px;
font-weight: bold;
}
.delete-btn {
color: #f56c6c;
font-size: 16px;
font-weight: bold;
}
.app-container-con {
height: calc(100vh - 84px);
2025-10-29 11:05:22 +08:00
// padding: 20px;
2025-10-13 09:27:53 +08:00
-webkit-box-sizing: border-box;
box-sizing: border-box;
overflow-y: hidden;
}
::v-deep .el-pagination {
margin-top: 15px;
text-align: right;
}
::v-deep .el-button {
margin-right: 8px;
}
2025-10-29 11:05:22 +08:00
.search-box {
margin-bottom: 20px;
border-radius: 8px;
2025-10-29 18:26:13 +08:00
::v-deep .el-card__body {
padding: 20px !important;
}
2025-10-29 11:05:22 +08:00
}
.content-box {
border-radius: 8px;
2025-10-29 18:26:13 +08:00
height: calc(100vh - 210px);
2025-10-29 11:05:22 +08:00
display: flex;
flex-direction: column;
overflow: hidden;
::v-deep .el-card__body {
display: flex !important;
flex-direction: column !important;
height: 100% !important;
padding: 20px;
}
.el-row:first-child {
margin-bottom: 16px;
flex-shrink: 0;
.el-col {
display: flex;
justify-content: flex-end;
align-items: center;
gap: 12px;
}
}
.table-container {
flex: 1;
overflow: hidden;
margin-bottom: 0;
min-height: 0;
display: flex;
flex-direction: column;
}
.pagination-wrapper {
flex-shrink: 0;
padding-top: 6px;
margin-top: auto;
::v-deep .pagination-container {
padding: 0px 20px !important;
margin-bottom: 30px;
}
}
::v-deep .el-table {
// 启用斑马纹
&.el-table--striped .el-table__body {
tr.el-table__row--striped td {
background-color: #F6FBFA !important; // 浅紫色
}
}
.el-table__header {
background: #E9F0EE;
th {
background: #E9F0EE !important;
color: #606266;
font-weight: 600;
height: 50px;
}
}
2025-10-29 13:31:49 +08:00
&.el-table--striped .el-table__body tr.el-table__row:hover>td.el-table__cell {
background-color: #CCF1E9 !important;
2025-10-29 11:05:22 +08:00
}
}
}
2025-10-29 18:26:13 +08:00
.el-form-item--small.el-form-item {
margin-bottom: 0px;
}
2025-10-13 09:27:53 +08:00
</style>