bonus-ui/src/views/materialsStation/equipment/equipmentRecord/index.vue

374 lines
12 KiB
Vue

<template>
<div class="app-container" id="">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="90px">
<el-form-item label="分公司" prop="impUnitName">
<el-input
v-model="queryParams.impUnitName"
placeholder="请输入分公司"
clearable
:maxlength="50"
style="width: 240px"
/>
</el-form-item>
<el-form-item label="项目部" prop="departName">
<el-input
v-model="queryParams.departName"
placeholder="请输入项目部"
clearable
:maxlength="50"
style="width: 240px"
/>
</el-form-item>
<el-form-item label="工程" prop="proName">
<el-input
v-model="queryParams.proName"
placeholder="请输入工程"
clearable
:maxlength="50"
style="width: 240px"
/>
</el-form-item>
<el-form-item label="分包单位" prop="subUnitName">
<el-input
v-model="queryParams.subUnitName"
placeholder="请输入分包单位"
clearable
:maxlength="50"
style="width: 240px"
/>
</el-form-item>
<el-form-item label="班组名称" prop="teamName">
<el-input
v-model="queryParams.teamName"
placeholder="请输入班组名称"
clearable
:maxlength="50"
style="width: 240px"
/>
</el-form-item>
<el-form-item label="物资名称" prop="typeName">
<el-input
v-model="queryParams.typeName"
placeholder="请输入物资名称"
clearable
:maxlength="50"
style="width: 240px"
/>
</el-form-item>
<el-form-item label="规格型号" prop="typeModelName">
<el-input
v-model="queryParams.typeModelName"
placeholder="请输入规格型号"
clearable
:maxlength="50"
style="width: 240px"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">查询</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<div class="tip-box-wrap">
<div class="tip-box">
<div class="tip-num">{{ tipForm.departNum || 0 }}</div>
<div class="tip-text">项目部总数</div>
</div>
<div class="tip-box">
<div class="tip-num">{{ tipForm.proNum || 0 }}</div>
<div class="tip-text">工程总数</div>
</div>
<div class="tip-box">
<div class="tip-num">{{ tipForm.teamNum || 0 }}</div>
<div class="tip-text">班组总数</div>
</div>
<div class="tip-box">
<div class="tip-num">{{ tipForm.allNum || 0 }}</div>
<div class="tip-text">总保有量</div>
</div>
<div class="tip-box">
<div class="tip-num">{{ tipForm.inNum || 0 }}</div>
<div class="tip-text">站内数量</div>
</div>
<div class="tip-box">
<div class="tip-num">{{ tipForm.useNum || 0 }}</div>
<div class="tip-text">在用数量</div>
</div>
</div>
</el-row>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport">导出数据</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="tableList" :max-height="650">
<el-table-column
label="序号"
align="center"
type="index"
width="55"
:index="index => (queryParams.pageNum - 1) * queryParams.pageSize + index + 1"
/>
<el-table-column label="分公司" align="center" prop="impUnitName" width="200" />
<el-table-column label="项目部" align="center" prop="departName" width="200" />
<el-table-column label="工程名称" align="center" prop="proName" width="200" />
<el-table-column label="分包单位" align="center" prop="subUnitName" width="200">
<template slot-scope="{ row }">
<span v-if="row.subUnitName">{{ row.subUnitName }}</span>
<span v-else>{{ '/' }}</span>
</template>
</el-table-column>
<el-table-column label="班组名称" align="center" prop="teamName">
<template slot-scope="{ row }">
<span v-if="row.teamName">{{ row.teamName }}</span>
<span v-else>{{ '站内库存' }}</span>
</template>
</el-table-column>
<el-table-column label="物资名称" align="center" prop="typeName" :show-overflow-tooltip="true" />
<el-table-column label="规格型号" align="center" prop="typeModelName" :show-overflow-tooltip="true" />
<el-table-column label="计量单位" align="center" prop="unit" :show-overflow-tooltip="true" />
<el-table-column label="数量" align="center" prop="allNum" :show-overflow-tooltip="true">
<template slot-scope="scope">
<!-- 当 manageType 为 '编码' 时,使用可点击的 span -->
<span class="clickText" v-if="scope.row.manageType == '编码'" @click="openRecords(scope.row)">
{{ scope.row.allNum }}
</span>
<!-- 否则,直接显示数字 -->
<span v-else>
{{ scope.row.allNum }}
</span>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
:page-sizes="[10, 20, 50, 100]"
@pagination="getList"
/>
<!-- 在库编码设备弹窗-->
<el-dialog :title="title" :visible.sync="openRecord" width="1200px" append-to-body>
<el-form :model="dialogQuery" ref="dialogQuery" size="small" :inline="true" label-width="80px">
<el-form-item label="关键字" prop="keyWord">
<el-input
v-model="dialogQuery.keyWord"
placeholder="请输入关键字"
clearable
:maxlength="30"
style="width: 240px"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleDialogQuery">查询</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetDialogQuery">重置</el-button>
</el-form-item>
<el-form-item>
<el-button icon="el-icon-download" size="mini" @click="handleDialogStoreExport">导出</el-button>
</el-form-item>
</el-form>
<el-table v-loading="loading" :data="dialogList">
<el-table-column
label="序号"
align="center"
width="80"
type="index"
:index="indexContinuation(dialogQuery.pageNum, dialogQuery.pageSize)"
></el-table-column>
<el-table-column label="机具名称" align="center" prop="typeName" :show-overflow-tooltip="true" />
<el-table-column label="规格型号" align="center" prop="typeModelName" :show-overflow-tooltip="true" />
<el-table-column label="设备编码" align="center" prop="maCode" :show-overflow-tooltip="true" />
</el-table>
<pagination
v-show="dialogTotal > 0"
:total="dialogTotal"
:page.sync="dialogQuery.pageNum"
:limit.sync="dialogQuery.pageSize"
@pagination="getStoreCodeList"
/>
</el-dialog>
</div>
</template>
<script>
import { getProTotalListApi, getStorageInfoListApi, getRetainedEquipmentListApi } from '@/api/materialsStation'
export default {
name: '',
dicts: [],
data() {
return {
// 遮罩层
loading: false,
// 选中数组
ids: [],
// 弹出层标题
title: '查看',
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 主表格数据
tableList: [],
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
impUnitName: null,
departName: null,
proName: null,
subUnitName: null,
teamName: null,
typeName: null, //物资名称
typeModelName: null //规格型号
},
tipForm: {
departNum: 0, // 项目部总数
proNum: 0, // 工程总数
teamNum: 0, // 班组总数
allNum: 0, // 总保有量
inNum: 0, // 站内数量
useNum: 0 // 在用数量
},
//在库弹窗
openRecord: false,
dialogList: [], //在库编码设备列表
dialogQuery: {
pageNum: 1,
pageSize: 10,
keyWord: undefined
},
dialogTotal: 0
}
},
created() {
this.getList()
},
methods: {
// 获取列表
async getList() {
this.loading = true
const params = {
...this.queryParams
}
try {
const res = await getRetainedEquipmentListApi(params)
this.tableList = res.data.rows || []
console.log('🚀 ~ getList ~ this.tableList:', this.tableList)
this.total = res.data.total || 0
const totalInfo = await getProTotalListApi(params)
this.tipForm = totalInfo.data
console.log('🚀 ~ getList ~ this.tableList:', this.tableList)
this.loading = false
} catch (error) {
this.loading = false
}
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm('queryForm')
this.handleQuery()
},
/** 导出按钮操作 */
handleExport() {
this.download(
'material/material_maMachine/exportRetainedEquipmentList',
{
...this.queryParams
},
`工器具台账_${new Date().getTime()}.xlsx`
)
},
//查看在库编码数据
openRecords(row) {
this.dialogList = []
this.dialogTotal = 0
this.dialogQuery.pageNum = 1
this.dialogQuery.pageSize = 10
this.dialogQuery.keyWord = ''
this.dialogQuery.typeId = row.typeId
this.dialogQuery.proId = row.proId
this.dialogQuery.teamId = row.teamId || ''
this.openRecord = true
this.getStoreCodeList()
},
/** 查询在库编码列表 */
async getStoreCodeList() {
try {
this.loading = true
const res = await getStorageInfoListApi(this.dialogQuery)
this.dialogList = res.data.rows || []
this.dialogTotal = res.data.total || 0
} catch (error) {
console.log('🚀 ~ getStoreCodeList ~ error:', error)
} finally {
this.loading = false
}
},
/** 搜索在库按钮操作 */
handleDialogQuery() {
this.dialogQuery.pageNum = 1
this.dialogQuery.pageSize = 10
this.getStoreCodeList()
},
resetDialogQuery() {
this.dialogQuery.pageNum = 1
this.dialogQuery.pageSize = 10
this.dialogQuery.keyWord = ''
this.getStoreCodeList()
},
handleDialogStoreExport() {
this.download(
'material/material_maMachine/exportStorageInfoList',
{ ...this.dialogQuery },
`设备编码详情_${new Date().getTime()}.xlsx`
)
}
// ------------------
}
}
</script>
<style lang="scss" scoped>
::v-deep.el-table .fixed-width .el-button--mini {
width: 60px !important;
margin-bottom: 10px;
}
.clickText {
color: #02a7f0;
cursor: pointer;
}
.tip-box-wrap {
display: flex;
justify-content: space-between;
.tip-box {
padding: 10px 30px;
background: #4cb1f9;
border-radius: 5px;
color: #fff;
text-align: center;
.tip-num {
font-size: 28px;
}
}
}
</style>