bonus-ui/src/views/business/warehouse/index.vue

307 lines
10 KiB
Vue
Raw Normal View History

2025-11-16 18:10:19 +08:00
<template>
<!-- 基础页面 -->
<div class="app-container">
<el-card v-show="showSearch" style="margin-bottom: 20px">
2025-12-02 17:54:15 +08:00
<el-form :model="queryParams" ref="queryForm" inline label-width="auto">
2025-11-16 18:10:19 +08:00
<el-form-item label="需求单位" prop="useUnit">
<el-select
v-model="queryParams.useUnit"
placeholder="请选择需求单位"
clearable
filterable
2025-12-02 17:54:15 +08:00
style="width: 240px"
2025-11-16 18:10:19 +08:00
>
<el-option
v-for="item in propertyUnitList"
:key="item.id"
:label="item.label"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item label="项目名称" prop="proCode">
<el-select
2025-12-02 17:54:15 +08:00
style="width: 240px"
2025-11-16 18:10:19 +08:00
clearable
2025-12-04 13:51:50 +08:00
filterable
2025-11-16 18:10:19 +08:00
placeholder="请选择项目名称"
2025-12-04 13:51:50 +08:00
popper-class="my-select-dropdown"
2025-11-16 18:10:19 +08:00
v-model="queryParams.proCode"
>
<el-option
:key="item.proCode"
:label="item.proName"
:value="item.proCode"
v-for="item in useProjectList"
2025-12-04 13:51:50 +08:00
>
<el-tooltip
effect="dark"
:content="item.proName"
placement="right"
>
<span class="option-text">{{ item.proName }}</span>
</el-tooltip>
</el-option>
2025-11-16 18:10:19 +08:00
</el-select>
</el-form-item>
<el-form-item label="任务状态" prop="taskStatus">
<el-select
v-model="queryParams.taskStatus"
placeholder="请选择任务状态"
clearable
filterable
2025-12-02 17:54:15 +08:00
style="width: 240px"
2025-11-16 18:10:19 +08:00
>
<el-option v-for="item in statusList" :key="item.value" :label="item.label" :value="item.value"/>
</el-select>
</el-form-item>
<!-- 日期范围 -->
<el-form-item label="申请日期">
<el-date-picker
v-model="timeRange"
type="daterange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
clearable
unlink-panels
value-format="yyyy-MM-dd"
format="yyyy-MM-dd"
2025-12-02 17:54:15 +08:00
style="width: 240px"
2025-11-16 18:10:19 +08:00
/>
</el-form-item>
<!-- 表单按钮 -->
<el-form-item style="float: right">
2025-11-20 18:02:34 +08:00
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">查询</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="handleReset">重置</el-button>
2025-11-16 18:10:19 +08:00
</el-form-item>
</el-form>
</el-card>
<el-card>
<el-row :gutter="10" class="mb8" justify="end">
<el-col :span="4">
2025-11-24 18:47:53 +08:00
<span style="font-size: 20px; font-weight: 800">退库申请列表</span>
2025-11-16 18:10:19 +08:00
</el-col>
<el-col :span="20" style="display: flex; justify-content: flex-end">
2025-11-20 18:02:34 +08:00
<el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd">新建申请</el-button>
2025-11-16 18:10:19 +08:00
</el-col>
<!-- <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" /> -->
</el-row>
<el-table
v-loading="isLoading"
:data="tableList"
highlight-current-row
border
stripe
2025-12-04 11:29:53 +08:00
height="546"
2025-11-16 18:10:19 +08:00
style="width: 100%"
>
<el-table-column
type="index"
width="55"
label="序号"
align="center"
:index="(index) => (queryParams.pageNum - 1) * queryParams.pageSize + index + 1"
/>
<el-table-column label="退库单号" align="center" prop="code" :show-overflow-tooltip="true"/>
<el-table-column label="需求单位" align="center" prop="useUnit" :show-overflow-tooltip="true"/>
<el-table-column label="项目名称" align="center" prop="proName" :show-overflow-tooltip="true"/>
<el-table-column label="退库装备数" align="center" prop="devNum" :show-overflow-tooltip="true" width="120px"/>
<el-table-column label="退库工具数" align="center" prop="toolNum" :show-overflow-tooltip="true"/>
<el-table-column label="任务状态" align="center" prop="taskStatus" :show-overflow-tooltip="true">
<template slot-scope="scope">
2025-12-08 15:28:33 +08:00
<el-tag v-if="scope.row.taskStatus == '0'" type="info" @click="openDialog(scope.row)" style="cursor: pointer">待审批</el-tag>
<el-tag v-if="scope.row.taskStatus == '1'" type="warning" @click="openDialog(scope.row)" style="cursor: pointer">审批中</el-tag>
<el-tag v-if="scope.row.taskStatus == '2'" type="success" @click="openDialog(scope.row)" style="cursor: pointer">已审批</el-tag>
<el-tag v-if="scope.row.taskStatus == '3'" type="danger" @click="openDialog(scope.row)" style="cursor: pointer">审批驳回</el-tag>
2025-11-16 18:10:19 +08:00
</template>
</el-table-column>
<el-table-column label="申请人" align="center" prop="createBy" :show-overflow-tooltip="true" width="140px"/>
<el-table-column label="申请时间" align="center" prop="createTime" width="160px"/>
<el-table-column label="操作" align="center">
<template slot-scope="{ row }">
<el-button size="mini" type="text" icon="el-icon-zoom-in" @click="handleView(row)">查看</el-button>
<el-button v-if="row.taskStatus != 1" size="mini" type="text" icon="el-icon-edit" @click="handleEdit(row)">
编辑
</el-button>
<el-button v-if="row.taskStatus != 1" size="mini" type="text" icon="el-icon-delete"
@click="handleDelete(row)" style="color: red"
>删除
</el-button
>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<pagination
2025-12-04 11:29:53 +08:00
2025-11-16 18:10:19 +08:00
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</el-card>
2025-12-08 15:28:33 +08:00
<ApproveDialog ref="approveDialog" />
2025-11-16 18:10:19 +08:00
</div>
</template>
<script>
import { getList } from '@/api/business/warehouse'
import {
getUseProjectListAPI
} from '@/api/EquipmentLedger/equ-out'
import { deptTreeSelect } from '@/api/system/user'
2025-11-16 19:41:15 +08:00
import { deleteApplyApi } from '@/api/business'
2025-12-08 15:28:33 +08:00
import ApproveDialog from '@/views/business/components/ApproveDialog'
2025-11-16 18:10:19 +08:00
export default {
name: 'ApplyList',
2025-12-08 15:28:33 +08:00
components: {
ApproveDialog
},
2025-11-16 18:10:19 +08:00
data() {
return {
propertyUnitList: [],
isLoading: false,
showSearch: true,
timeRange: [],
queryParams: {
pageNum: 1,
pageSize: 10,
taskStatus: null,
createBy: null,
startTime: null,
endTime: null,
useUnit: null
},
statusList: [
2025-12-02 16:35:39 +08:00
{ label: '待审批', value: '0' },
{ label: '审批中', value: '1' },
{ label: '已审批', value: '2' },
{ label: '审批驳回', value: '3' },
2025-11-16 18:10:19 +08:00
],
total: 0, // 总条数
// 表格数据
tableList: [],
useProjectList: [] // 使用项目下拉选
}
},
created() {
this.getUseProjectList()
this.getList()
this.getDeptTreeSelect()
},
methods: {
getDeptTreeSelect() {
deptTreeSelect().then((res) => {
this.propertyUnitList = this.filterTree(res.data)
console.log('🚀 ~ getDeptTreeSelect ~ this.propertyUnitList:', this.propertyUnitList)
})
},
filterTree(nodes) {
return nodes
.map(node => {
if (node.children) {
node.children = this.filterTree(node.children)
}
return node
})
.filter(node => node.status !== '1')
},
// 获取使用项目的下拉选
async getUseProjectList() {
const res = await getUseProjectListAPI()
this.useProjectList = res.data
},
// 查询
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
// 重置
handleReset() {
this.queryParams.pageNum = 1
this.queryParams.pageSize = 10
this.queryParams.parentId = '0'
this.queryParams.level = '1'
this.queryParams.taskStatus = null
this.timeRange = []
this.$refs.queryForm.resetFields()
this.getList()
},
// 获取列表
async getList() {
console.log('列表-查询', this.queryParams)
this.isLoading = true
this.queryParams.startTime = this.timeRange && this.timeRange[0] ? this.timeRange[0] : null
this.queryParams.endTime = this.timeRange && this.timeRange[1] ? this.timeRange[1] : null
try {
const params = { ...this.queryParams }
const res = await getList(params)
this.tableList = res.data.rows || []
this.total = res.data.total || 0
} catch (error) {
this.tableList = []
this.total = 0
} finally {
this.isLoading = false
}
},
// 新增
handleAdd() {
2025-11-16 19:41:15 +08:00
this.$router.push({ path: '/business/warehouse/details',query: {isEdit: true } })
2025-11-16 18:10:19 +08:00
},
// 查看
handleView(row) {
this.$router.push({ path: '/business/warehouse/details', query: { id: row.id, isView: true } })
},
// 编辑
handleEdit(row) {
this.$router.push({ path: '/business/warehouse/details', query: { id: row.id, isEdit: true } })
},
// 删除
handleDelete(row) {
this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(async() => {
this.isLoading = true
try {
await deleteApplyApi({ id: row.id })
// 提示
this.$message({
type: 'success',
message: '删除成功!'
})
this.getList()
} catch (error) {
console.log('🚀 ~ error:', error)
} finally {
this.isLoading = false
}
})
2025-12-08 15:28:33 +08:00
},
openDialog(row) {
this.$refs.approveDialog.openDialog(row.id, 'EQUIPMENT_RETURN')
2025-11-16 18:10:19 +08:00
}
}
}
</script>
2025-11-20 18:02:34 +08:00
<style lang="scss" scoped>
.el-form-item {
margin-bottom: 0; /* 取消form-item的默认下边距 */
}
</style>