bonus-ui/src/views/material/stquery/deviceUsingRecord.vue

404 lines
15 KiB
Vue
Raw Normal View History

2024-12-16 17:59:18 +08:00
<template>
<div class="app-container" id="">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="80px">
<el-form-item prop="time">
2024-12-16 17:59:18 +08:00
<el-date-picker
v-model="queryParams.time"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
type="daterange"
value-format="yyyy-MM-dd"
style="width: 240px"
></el-date-picker>
</el-form-item>
<el-form-item prop="keyWord">
2024-12-16 17:59:18 +08:00
<el-input
v-model="queryParams.keyWord"
placeholder="请输入关键字"
clearable :maxlength="20"
style="width: 240px"
/>
</el-form-item>
<el-form-item prop="unitId">
2024-12-30 11:32:23 +08:00
<treeselect
v-model="queryParams.unitId"
:options="unitList" :normalizer="normalizer"
:show-count="true" style="width: 240px" :disable-branch-nodes="true"
noChildrenText="没有数据了" noOptionsText="没有数据" noResultsText="没有搜索结果"
placeholder="请选择往来单位" @select="unitChange"
2025-06-09 17:36:15 +08:00
/>
2024-12-30 11:32:23 +08:00
<!-- <el-cascader v-model="unitId"
2024-12-16 17:59:18 +08:00
:show-all-levels="false"
:options="unitList"
:props="selectTreeProps"
filterable
clearable
collapse-tags
@change="unitChange"
placeholder="请选择往来单位"
2024-12-30 11:32:23 +08:00
></el-cascader> -->
2024-12-16 17:59:18 +08:00
</el-form-item>
<el-form-item prop="proId">
2024-12-30 11:32:23 +08:00
<treeselect
v-model="queryParams.proId"
:options="proList" :normalizer="normalizer"
:show-count="true" style="width: 240px" :disable-branch-nodes="true"
noChildrenText="没有数据了" noOptionsText="没有数据" noResultsText="没有搜索结果"
placeholder="请选择工程名称" @select="proChange"
/>
<!-- <el-cascader v-model="projectId"
2024-12-16 17:59:18 +08:00
:show-all-levels="false"
:options="proList"
:props="selectTreeProps"
filterable clearable
collapse-tags
@change="proChange"
placeholder="请选择工程名称"
2024-12-30 11:32:23 +08:00
></el-cascader> -->
2024-12-16 17:59:18 +08:00
</el-form-item>
<el-form-item prop="typeName">
2024-12-16 17:59:18 +08:00
<el-input
v-model="queryParams.typeName"
placeholder="请输入物资名称"
clearable :maxlength="20"
style="width: 240px"
/>
</el-form-item>
<el-form-item prop="isSlt">
2024-12-16 17:59:18 +08:00
<el-select
v-model="queryParams.isSlt"
filterable clearable
style="width: 240px"
placeholder="请选择结算状态"
2024-12-16 17:59:18 +08:00
>
<el-option
v-for="item in sltList"
:key="item.id"
:label="item.name"
:value="item.id"
>
</el-option>
</el-select>
</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-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
>导出</el-button
2025-06-09 17:36:15 +08:00
>
2024-12-16 17:59:18 +08:00
</el-form-item>
</el-form>
2025-06-09 17:36:15 +08:00
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
2025-08-21 11:24:07 +08:00
<el-table v-loading="loading" :data="tableList" border :span-method="objectSpanMethod" :max-height="650">
2024-12-16 17:59:18 +08:00
<!-- houseName type typeName typeModelName unitName storeNum manageType useNum repairNum inputNum repairInputNum allNum-->
2025-07-24 14:23:57 +08:00
<el-table-column label="序号" align="center" type="index">
2024-12-16 17:59:18 +08:00
<template scope="scope">
<span v-if="scope.$index==0">合计</span>
2025-09-11 14:19:04 +08:00
<span v-else>{{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index }}</span>
2025-06-09 17:36:15 +08:00
</template>
</el-table-column>
2025-07-24 14:23:57 +08:00
<el-table-column label="协议号" align="center" prop="agreementCode" width="140"/>
<el-table-column label="工程名称" align="center" prop="proName" width="180"/>
<el-table-column label="往来单位" align="center" prop="unitName" width="180"/>
<el-table-column label="实施单位" align="center" prop="impUnitName" width="150px" :show-overflow-tooltip="true"/>
2025-07-24 14:23:57 +08:00
<!-- <el-table-column label="合同主体" align="center" prop="contractPart" width="150px" :show-overflow-tooltip="true"/> -->
2024-12-16 17:59:18 +08:00
<el-table-column label="物资名称" align="center" prop="typeName" :show-overflow-tooltip="true"/>
<el-table-column label="规格型号" align="center" prop="typeModelName" :show-overflow-tooltip="true"/>
2025-06-09 17:36:15 +08:00
<el-table-column label="计量单位" align="center" prop="unit" :show-overflow-tooltip="true"/>
2025-07-24 14:23:57 +08:00
<el-table-column label="领用数量" align="center" prop="leaseNum"></el-table-column>
<el-table-column label="归还数量" align="center" prop="backNum"></el-table-column>
<el-table-column label="在用数量" align="center" prop="usNum"></el-table-column>
<el-table-column label="在用总价值(元)" align="center" prop="usPrice"></el-table-column>
2025-10-23 17:41:43 +08:00
<!-- <el-table-column label="投入总价值(元)" align="center" prop="totalPrice" />-->
2025-06-09 17:36:15 +08:00
<el-table-column label="协议状态" align="center" prop="isSltName" :show-overflow-tooltip="true"/>
</el-table>
2024-12-16 17:59:18 +08:00
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
2025-08-29 17:23:47 +08:00
:page-sizes="[10, 20, 50, 100]"
2024-12-16 17:59:18 +08:00
@pagination="getList"
2025-06-09 17:36:15 +08:00
/>
2024-12-16 17:59:18 +08:00
</div>
</template>
<script>
import {
getProjUsingRecordListApi,getProjUsingRecordListNoPage
} from '@/api/stquery/stquery';
2025-06-09 17:36:15 +08:00
import {
2024-12-16 17:59:18 +08:00
getProjectList,
2025-06-09 17:36:15 +08:00
getUnitList,
2024-12-16 17:59:18 +08:00
} from '@/api/back/index.js'
2024-12-30 11:32:23 +08:00
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
2024-12-16 17:59:18 +08:00
export default {
2025-05-14 09:31:18 +08:00
name: 'DeviceUsingRecord',
2024-12-16 17:59:18 +08:00
dicts: [],
2024-12-30 11:32:23 +08:00
components: { Treeselect },
2024-12-16 17:59:18 +08:00
data() {
return {
// 遮罩层
loading: false,
// 选中数组
ids: [],
// 弹出层标题
title: '查看',
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
selectTreeProps: {
children: 'children',
label: 'name',
// multiple: false,
value: 'id',
// multiple: true,
},
unitId: null,
projectId: null,
unitList: [],
proList: [],
sltList:[{id:'0',name:'未结算'},{id:'1',name:'已结算'}],
// 总条数
total: 0,
// 主表格数据
2025-06-09 17:36:15 +08:00
tableList: [],
2024-12-16 17:59:18 +08:00
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
time: null,
2024-12-30 11:32:23 +08:00
unitId: null,
proId: null,
2024-12-16 17:59:18 +08:00
keyWord: null,
2025-06-09 17:36:15 +08:00
typeName: null, //物资名称
2024-12-16 17:59:18 +08:00
isSlt: null //结算状态
2025-06-09 17:36:15 +08:00
},
2024-12-16 17:59:18 +08:00
}
},
created() {
2025-07-15 18:01:52 +08:00
const end = new Date()
let start = new Date()
2025-07-18 16:53:11 +08:00
start.setFullYear(start.getFullYear() - 1); // 设置为去年的今天
2025-07-15 18:01:52 +08:00
this.queryParams.time = [this.format(start), this.format(end)]
2024-12-16 17:59:18 +08:00
this.initSelectData()
this.getList()
},
methods: {
2025-07-15 18:01:52 +08:00
format(date) {
const y = date.getFullYear()
const m = String(date.getMonth() + 1).padStart(2, '0')
const day = String(date.getDate()).padStart(2, '0')
return `${y}-${m}-${day}`
},
2024-12-16 17:59:18 +08:00
initSelectData() {
this.GetUnitData()
this.GetProData()
},
2024-12-30 11:32:23 +08:00
/** 转换菜单数据结构 */
normalizer(node) {
if (node.children && !node.children.length) {
delete node.children;
}
return {
id: node.id,
label: node.name,
children: node.children,
};
2025-06-09 17:36:15 +08:00
},
2024-12-16 17:59:18 +08:00
// 获取 来往单位 列表数据
async GetUnitData() {
const params = {
2024-12-30 11:32:23 +08:00
// projectId: this.queryParams.proId /* */,
2024-12-16 17:59:18 +08:00
}
const res = await getUnitList(params)
this.unitList = res.data
},
unitChange(val){
2024-12-30 11:32:23 +08:00
// if(val&&val.length>0){
// this.queryParams.unitId=this.unitId[this.unitId.length - 1]
// }else if(val&&val.length==0){
// this.queryParams.unitId=""
// }
// this.GetProData()
setTimeout(()=>{
this.GetProData()
2025-06-09 17:36:15 +08:00
},500)
},
2024-12-16 17:59:18 +08:00
// 获取 工程名称 列表数据
async GetProData() {
const params = { unitId: this.queryParams.unitId}
const res = await getProjectList(params)
this.proList = res.data
2024-12-30 11:32:23 +08:00
this.queryParams.proId=null
2024-12-16 17:59:18 +08:00
},
proChange(val){
2024-12-30 11:32:23 +08:00
// if(val&&val.length>0){
// this.queryParams.proId=this.projectId[this.projectId.length - 1]
// }else if(val&&val.length==0){
// this.queryParams.proId=""
// }
// this.GetUnitData()
setTimeout(()=>{
this.GetUnitData()
},500)
2024-12-16 17:59:18 +08:00
},
// 获取列表
async getList() {
this.loading = true
const params = {
unitId: this.queryParams.unitId,
proId: this.queryParams.proId,
keyWord: this.queryParams.keyWord,
typeName: this.queryParams.typeName,
isSlt: this.queryParams.isSlt,
startTime: this.queryParams.time && this.queryParams.time[0],
endTime: this.queryParams.time && this.queryParams.time[1],
pageSize: this.queryParams.pageSize,
pageNum: this.queryParams.pageNum
}
const res = await getProjUsingRecordListApi(params)
if(res.data.rows.length>0){
2025-06-09 17:36:15 +08:00
this.tableList = res.data.rows;
2024-12-16 17:59:18 +08:00
}else{
this.tableList=[]
}
this.total = res.data.total;
let param = {
unitId: this.queryParams.unitId,
proId: this.queryParams.proId,
keyWord: this.queryParams.keyWord,
typeName: this.queryParams.typeName,
isSlt: this.queryParams.isSlt,
startTime: this.queryParams.time && this.queryParams.time[0],
endTime: this.queryParams.time && this.queryParams.time[1]
}
const response = await getProjUsingRecordListNoPage(param)
let obj = {
leaseNum: response.data.totalLeaseNum||0,
backNum: response.data.totalBackNum||0,
usNum: response.data.totalUsNum||0,
usPrice: response.data.totalUsPrice||0,
totalPrice: response.data.totalTotalPrice||0,
isSltName:''
}
this.tableList.unshift(obj)
console.log(this.tableList)
this.loading = false
2025-06-09 17:36:15 +08:00
2024-12-16 17:59:18 +08:00
},
indexContinuationForTable(num, size) {
let number = (num - 1) * size
console.log(number)
if(number==0){
return "合计"
}else{
return number
2025-06-09 17:36:15 +08:00
}
2024-12-16 17:59:18 +08:00
},
2025-06-09 17:36:15 +08:00
// 合并单元格 rowIndex=行数 columnIndex=列数
// 这里是合并table的除表头外的第一行的第二列 + 除表头外的第二行的第二列
2024-12-16 17:59:18 +08:00
// 注意列数和行数从 0 开始
objectSpanMethod ({ row, column, rowIndex, columnIndex }) {
if (rowIndex === 0 && columnIndex == 0) {
let rowspan = 1
let colspan = 7
return { rowspan, colspan }
}
// 解决偏移的重要代码
// 重点在 else if 判断必须加因为合并单元格数据会出现偏移、
// 否则如果是 第二行 的 第二列 那么隐藏原有第二行 的 第二列的数据使他隐藏
else if (rowIndex === 0 && columnIndex < 7) {
return {
2025-06-09 17:36:15 +08:00
rowspan: 0,
colspan: 0
2024-12-16 17:59:18 +08:00
}
}
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
2025-06-09 17:36:15 +08:00
},
2024-12-16 17:59:18 +08:00
/** 重置按钮操作 */
2025-06-09 17:36:15 +08:00
resetQuery() {
2025-07-15 18:04:17 +08:00
const end = new Date()
let start = new Date()
start.setFullYear(start.getFullYear() - 1);
this.queryParams.time = [this.format(start), this.format(end)]
2024-12-16 17:59:18 +08:00
this.queryParams.time=[]
2024-12-27 10:15:11 +08:00
this.unitId=[]
this.projectId=[]
2024-12-16 17:59:18 +08:00
this.resetForm('queryForm')
this.handleQuery()
2025-06-09 17:36:15 +08:00
},
2024-12-16 17:59:18 +08:00
/** 导出按钮操作 */
handleExport() {
2025-06-09 17:36:15 +08:00
const formatTime = (date) => {
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');
const seconds = String(date.getSeconds()).padStart(2, '0');
return `${year}${month}${day}_${hours}${minutes}${seconds}`;
};
2025-07-18 11:17:54 +08:00
const params = {
unitId: this.queryParams.unitId,
proId: this.queryParams.proId,
keyWord: this.queryParams.keyWord,
typeName: this.queryParams.typeName,
isSlt: this.queryParams.isSlt,
startTime: this.queryParams.time && this.queryParams.time[0],
endTime: this.queryParams.time && this.queryParams.time[1],
pageSize: this.queryParams.pageSize,
pageNum: this.queryParams.pageNum
}
2025-06-09 17:36:15 +08:00
const currentTime = formatTime(new Date());
2024-12-16 17:59:18 +08:00
this.download(
'material/complex_query/exportProjUsingRecord',
{
2025-07-18 11:17:54 +08:00
...params,
2024-12-16 17:59:18 +08:00
},
2025-06-09 17:36:15 +08:00
`综合查询_工程机具使用_${currentTime}.xlsx`,
2024-12-16 17:59:18 +08:00
)
2025-06-09 17:36:15 +08:00
},
2024-12-16 17:59:18 +08:00
},
}
</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;
}
</style>