增加外层导出Excel及时间筛选
This commit is contained in:
parent
4dabad5713
commit
10fcfcb1d4
|
|
@ -9,7 +9,7 @@ export function getSltAgreementInfo(query) {
|
|||
})
|
||||
}
|
||||
|
||||
// 查询费用结算申请列表
|
||||
// 查询未结算费用报表---list列表
|
||||
export function getSltReportList(query) {
|
||||
return request({
|
||||
url: '/material/slt_agreement_info/getSltReportList',
|
||||
|
|
|
|||
|
|
@ -324,7 +324,7 @@ export default {
|
|||
const params = {
|
||||
// projectId: this.queryParams.projectId /* */,
|
||||
}
|
||||
const res = await getUnitList(params)
|
||||
const res = await getUnitListFilterTeam(params)
|
||||
this.unitList = res.data;
|
||||
|
||||
if (this.queryParams.projectId) {
|
||||
|
|
@ -333,15 +333,8 @@ export default {
|
|||
},
|
||||
unitChange(val){
|
||||
console.log('Selected values:', val); // 检查选中的值
|
||||
// this.unitIds.push(Number(val.id));
|
||||
// if(val&&val.length>0){
|
||||
// this.queryParams.unitId=this.unitIds[this.unitIds.length - 1]
|
||||
// }else if(val&&val.length==0){
|
||||
// this.queryParams.unitId=""
|
||||
// }
|
||||
console.log("xxxxxxxxx",this.queryParams.unitId)
|
||||
console.log("yyyyyyyyy",this.unitIds)
|
||||
// this.GetProData()
|
||||
setTimeout(()=>{
|
||||
this.queryParams.projectId=null
|
||||
this.queryParams.agreementId = null
|
||||
|
|
@ -361,12 +354,6 @@ export default {
|
|||
this.getAgreementInfo()
|
||||
},
|
||||
proChange(val){
|
||||
// if(val&&val.length>0){
|
||||
// this.queryParams.projectId=this.projectIds[this.projectIds.length - 1]
|
||||
// }else if(val&&val.length==0){
|
||||
// this.queryParams.projectId=""
|
||||
// }
|
||||
// this.GetUnitData()
|
||||
setTimeout(()=>{
|
||||
this.GetUnitData()
|
||||
},500)
|
||||
|
|
@ -481,13 +468,6 @@ export default {
|
|||
//维修任务单打印
|
||||
print() {
|
||||
this.$refs.remarksPrintRef.print();
|
||||
// printJS({
|
||||
// printable: 'checkId',
|
||||
// type: 'html',
|
||||
// targetStyles: ['*'],
|
||||
// maxWidth:'1400'
|
||||
// // 其他配置选项
|
||||
// });
|
||||
},
|
||||
|
||||
/** 删除按钮操作 */
|
||||
|
|
|
|||
|
|
@ -236,9 +236,9 @@
|
|||
|
||||
<script>
|
||||
import {
|
||||
getProjectList,
|
||||
getUnitList,
|
||||
getAgreementInfoById,
|
||||
getProjectList,
|
||||
getUnitList,
|
||||
getAgreementInfoById, getUnitListFilterTeam,
|
||||
} from '@/api/back/index.js'
|
||||
import { getSltList,costExamine, getSltInfo } from '@/api/cost/cost'
|
||||
import { toChineseAmount } from '@/utils/bonus.js'
|
||||
|
|
@ -338,7 +338,7 @@ export default {
|
|||
const params = {
|
||||
// projectId: this.queryParams.projectId /* */,
|
||||
}
|
||||
const res = await getUnitList(params)
|
||||
const res = await getUnitListFilterTeam(params)
|
||||
this.unitList = res.data;
|
||||
|
||||
this.getAgreementInfo()
|
||||
|
|
|
|||
|
|
@ -22,19 +22,23 @@
|
|||
<el-form-item prop="agreementCode">
|
||||
<el-input v-model="queryParams.agreementCode" placeholder="请输入协议号" clearable disabled/>
|
||||
</el-form-item>
|
||||
<el-form-item prop="sltStatus">
|
||||
<el-select v-model="queryParams.sltStatus" placeholder="请选择结算状态" clearable filterable>
|
||||
<el-option
|
||||
v-for="dict in statusList"
|
||||
:key="dict.id"
|
||||
:label="dict.name"
|
||||
:value="dict.id"
|
||||
></el-option>
|
||||
</el-select>
|
||||
<el-form-item prop="dateRange">
|
||||
<el-date-picker
|
||||
v-model="queryParams.dateRange"
|
||||
type="daterange"
|
||||
range-separator="至"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
format="yyyy-MM-dd"
|
||||
value-format="yyyy-MM-dd"
|
||||
style="width: 240px"
|
||||
@change="handleDateRangeChange">
|
||||
</el-date-picker>
|
||||
</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="success" icon="el-icon-download" size="mini" @click="exportExcel" :disabled="tableList.length === 0">导出Excel</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
|
|
@ -120,13 +124,13 @@
|
|||
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total > 0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
<!-- <pagination-->
|
||||
<!-- v-show="total > 0"-->
|
||||
<!-- :total="total"-->
|
||||
<!-- :page.sync="queryParams.pageNum"-->
|
||||
<!-- :limit.sync="queryParams.pageSize"-->
|
||||
<!-- @pagination="getList"-->
|
||||
<!-- />-->
|
||||
|
||||
<!-- 费用详情弹窗 -->
|
||||
<el-dialog
|
||||
|
|
@ -263,9 +267,9 @@
|
|||
|
||||
<script>
|
||||
import {
|
||||
getProjectList,
|
||||
getUnitList,
|
||||
getAgreementInfoById,
|
||||
getProjectList,
|
||||
getUnitList,
|
||||
getAgreementInfoById, getUnitListFilterTeam,
|
||||
} from '@/api/back/index.js'
|
||||
import {getSltList, costExamine, getSltInfo, getSltReportedList} from '@/api/cost/cost'
|
||||
import { toChineseAmount } from '@/utils/bonus.js'
|
||||
|
|
@ -322,6 +326,9 @@ export default {
|
|||
projectId: null,
|
||||
agreementId: null,
|
||||
agreementCode: null,
|
||||
dateRange: null,
|
||||
startTime: null,
|
||||
endTime: null,
|
||||
},
|
||||
openPrint: false,
|
||||
// 审批弹窗
|
||||
|
|
@ -352,11 +359,50 @@ export default {
|
|||
}
|
||||
},
|
||||
created() {
|
||||
this.initDefaultDateRange()
|
||||
this.GetUnitData()
|
||||
this.GetProData()
|
||||
this.getList()
|
||||
},
|
||||
methods: {
|
||||
// 初始化默认日期范围(当月第一天到最后一天)
|
||||
initDefaultDateRange() {
|
||||
const now = new Date()
|
||||
const year = now.getFullYear()
|
||||
const month = now.getMonth()
|
||||
|
||||
// 当月第一天
|
||||
const firstDay = new Date(year, month, 1)
|
||||
const firstDayStr = this.formatDate(firstDay)
|
||||
|
||||
// 当月最后一天
|
||||
const lastDay = new Date(year, month + 1, 0)
|
||||
const lastDayStr = this.formatDate(lastDay)
|
||||
|
||||
this.queryParams.dateRange = [firstDayStr, lastDayStr]
|
||||
this.queryParams.startTime = firstDayStr
|
||||
this.queryParams.endTime = lastDayStr
|
||||
},
|
||||
|
||||
// 格式化日期为 yyyy-MM-dd 格式
|
||||
formatDate(date) {
|
||||
const year = date.getFullYear()
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(date.getDate()).padStart(2, '0')
|
||||
return `${year}-${month}-${day}`
|
||||
},
|
||||
|
||||
// 处理日期范围变化
|
||||
handleDateRangeChange(dateRange) {
|
||||
if (dateRange && dateRange.length === 2) {
|
||||
this.queryParams.startTime = dateRange[0]
|
||||
this.queryParams.endTime = dateRange[1]
|
||||
} else {
|
||||
this.queryParams.startTime = null
|
||||
this.queryParams.endTime = null
|
||||
}
|
||||
},
|
||||
|
||||
/** 转换菜单数据结构 */
|
||||
normalizer(node) {
|
||||
if (node.children && !node.children.length) {
|
||||
|
|
@ -373,7 +419,7 @@ export default {
|
|||
const params = {
|
||||
// projectId: this.queryParams.projectId /* */,
|
||||
}
|
||||
const res = await getUnitList(params)
|
||||
const res = await getUnitListFilterTeam(params)
|
||||
this.unitList = res.data;
|
||||
|
||||
this.getAgreementInfo()
|
||||
|
|
@ -449,7 +495,12 @@ export default {
|
|||
projectId: null,
|
||||
agreementId: '',
|
||||
agreementCode: '',
|
||||
dateRange: null,
|
||||
startTime: null,
|
||||
endTime: null,
|
||||
}
|
||||
// 重新初始化默认日期范围
|
||||
this.initDefaultDateRange()
|
||||
this.resetForm('queryForm')
|
||||
this.handleQuery()
|
||||
},
|
||||
|
|
@ -775,6 +826,113 @@ export default {
|
|||
}
|
||||
},
|
||||
|
||||
// 导出主表格Excel
|
||||
exportExcel() {
|
||||
if (!this.tableList || this.tableList.length === 0) {
|
||||
this.$modal.msgWarning('没有可导出的数据');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// 定义Excel列配置
|
||||
const columns = [
|
||||
{ key: 'index', title: '序号' },
|
||||
{ key: 'agreementCode', title: '协议号' },
|
||||
{ key: 'unitName', title: '结算单位' },
|
||||
{ key: 'projectName', title: '结算工程' },
|
||||
{ key: 'createTime', title: '结算时间' },
|
||||
{ key: 'settlementType', title: '结算类型' },
|
||||
{ key: 'leaseCost', title: '租赁费用' },
|
||||
{ key: 'repairCost', title: '维修费用' },
|
||||
{ key: 'loseCost', title: '丢失费用' },
|
||||
{ key: 'scrapCost', title: '报废费用' },
|
||||
{ key: 'costs', title: '合计费用(元)' }
|
||||
];
|
||||
|
||||
// 准备Excel数据
|
||||
const excelData = [];
|
||||
|
||||
// 添加表头
|
||||
const headerRow = columns.map(col => col.title);
|
||||
excelData.push(headerRow);
|
||||
|
||||
// 添加数据行
|
||||
this.tableList.forEach((row, index) => {
|
||||
const dataRow = columns.map(col => {
|
||||
if (col.key === 'index') {
|
||||
return (this.queryParams.pageNum - 1) * 10 + index + 1;
|
||||
} else if (col.key === 'settlementType') {
|
||||
// 处理结算类型显示
|
||||
if (row.settlementType === 1) return '工器具';
|
||||
if (row.settlementType === 2) return '安全工器具';
|
||||
return '总费用';
|
||||
} else if (col.key === 'costs') {
|
||||
// 处理合计费用格式
|
||||
return row.costs != null && row.costs !== '' ? parseFloat(row.costs.toFixed(2)) : 0.00;
|
||||
} else if (col.key === 'leaseCost' || col.key === 'repairCost' || col.key === 'loseCost' || col.key === 'scrapCost') {
|
||||
// 处理费用字段格式
|
||||
return row[col.key] || 0;
|
||||
} else {
|
||||
return row[col.key] || '';
|
||||
}
|
||||
});
|
||||
excelData.push(dataRow);
|
||||
});
|
||||
|
||||
// 创建工作簿和工作表
|
||||
const workbook = XLSX.utils.book_new();
|
||||
const worksheet = XLSX.utils.aoa_to_sheet(excelData);
|
||||
|
||||
// 设置列宽
|
||||
const columnWidths = [
|
||||
{ wch: 8 }, // 序号
|
||||
{ wch: 20 }, // 协议号
|
||||
{ wch: 15 }, // 结算单位
|
||||
{ wch: 20 }, // 结算工程
|
||||
{ wch: 12 }, // 结算时间
|
||||
{ wch: 12 }, // 结算类型
|
||||
{ wch: 12 }, // 租赁费用
|
||||
{ wch: 12 }, // 维修费用
|
||||
{ wch: 12 }, // 丢失费用
|
||||
{ wch: 12 }, // 报废费用
|
||||
{ wch: 15 } // 合计费用
|
||||
];
|
||||
worksheet['!cols'] = columnWidths;
|
||||
|
||||
// 添加工作表到工作簿
|
||||
XLSX.utils.book_append_sheet(workbook, worksheet, '结算记录');
|
||||
|
||||
// 生成文件名(包含日期范围)
|
||||
let fileName = '结算记录';
|
||||
if (this.queryParams.startTime && this.queryParams.endTime) {
|
||||
fileName += `_${this.queryParams.startTime}_至_${this.queryParams.endTime}`;
|
||||
}
|
||||
fileName += `_${new Date().toISOString().slice(0, 10)}.xlsx`;
|
||||
|
||||
// 生成Excel文件并下载
|
||||
const excelBuffer = XLSX.write(workbook, { bookType: 'xlsx', type: 'array' });
|
||||
const blob = new Blob([excelBuffer], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
|
||||
|
||||
// 创建下载链接
|
||||
const link = document.createElement('a');
|
||||
const url = URL.createObjectURL(blob);
|
||||
link.setAttribute('href', url);
|
||||
link.setAttribute('download', fileName);
|
||||
link.style.visibility = 'hidden';
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
|
||||
// 清理URL对象
|
||||
URL.revokeObjectURL(url);
|
||||
|
||||
this.$modal.msgSuccess('Excel导出成功');
|
||||
} catch (error) {
|
||||
console.error('导出Excel失败:', error);
|
||||
this.$modal.msgError('导出Excel失败,请稍后重试');
|
||||
}
|
||||
},
|
||||
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
<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="success" icon="el-icon-download" size="mini" @click="exportExcel" :disabled="tableList.length === 0">导出Excel</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
|
|
@ -37,8 +38,8 @@
|
|||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="协议号" align="center" prop="agreementCode" :show-overflow-tooltip="true"/>
|
||||
<el-table-column label="协议签订单位" align="center" prop="unitName" />
|
||||
<el-table-column label="协议签订工程" align="center" prop="projectName" />
|
||||
<el-table-column label="结算单位" align="center" prop="unitName" />
|
||||
<el-table-column label="结算工程" align="center" prop="projectName" />
|
||||
|
||||
<el-table-column label="结算类型" align="center" prop="sltStatus" :show-overflow-tooltip="true">
|
||||
<template slot-scope="scope">
|
||||
|
|
@ -109,13 +110,13 @@
|
|||
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total > 0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
<!-- <pagination-->
|
||||
<!-- v-show="total > 0"-->
|
||||
<!-- :total="total"-->
|
||||
<!-- :page.sync="queryParams.pageNum"-->
|
||||
<!-- :limit.sync="queryParams.pageSize"-->
|
||||
<!-- @pagination="getList"-->
|
||||
<!-- />-->
|
||||
|
||||
<!-- 费用详情弹窗 -->
|
||||
<el-dialog
|
||||
|
|
@ -252,9 +253,9 @@
|
|||
|
||||
<script>
|
||||
import {
|
||||
getProjectList,
|
||||
getUnitList,
|
||||
getAgreementInfoById,
|
||||
getProjectList,
|
||||
getUnitList,
|
||||
getAgreementInfoById, getUnitListFilterTeam,
|
||||
} from '@/api/back/index.js'
|
||||
import {getSltList, costExamine, getSltReportedList, getSltReportList} from '@/api/cost/cost'
|
||||
import { toChineseAmount } from '@/utils/bonus.js'
|
||||
|
|
@ -362,7 +363,7 @@ export default {
|
|||
const params = {
|
||||
// projectId: this.queryParams.projectId /* */,
|
||||
}
|
||||
const res = await getUnitList(params)
|
||||
const res = await getUnitListFilterTeam(params)
|
||||
this.unitList = res.data;
|
||||
|
||||
this.getAgreementInfo()
|
||||
|
|
@ -595,6 +596,107 @@ export default {
|
|||
});
|
||||
},
|
||||
|
||||
// 导出主表格Excel
|
||||
exportExcel() {
|
||||
if (!this.tableList || this.tableList.length === 0) {
|
||||
this.$modal.msgWarning('没有可导出的数据');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// 定义Excel列配置
|
||||
const columns = [
|
||||
{ key: 'index', title: '序号' },
|
||||
{ key: 'agreementCode', title: '协议号' },
|
||||
{ key: 'unitName', title: '结算单位' },
|
||||
{ key: 'projectName', title: '结算工程' },
|
||||
{ key: 'settlementType', title: '结算类型' },
|
||||
{ key: 'leaseCost', title: '租赁费用' },
|
||||
{ key: 'repairCost', title: '维修费用' },
|
||||
{ key: 'loseCost', title: '丢失费用' },
|
||||
{ key: 'scrapCost', title: '报废费用' },
|
||||
{ key: 'costs', title: '合计费用(元)' }
|
||||
];
|
||||
|
||||
// 准备Excel数据
|
||||
const excelData = [];
|
||||
|
||||
// 添加表头
|
||||
const headerRow = columns.map(col => col.title);
|
||||
excelData.push(headerRow);
|
||||
|
||||
// 添加数据行
|
||||
this.tableList.forEach((row, index) => {
|
||||
const dataRow = columns.map(col => {
|
||||
if (col.key === 'index') {
|
||||
return (this.queryParams.pageNum - 1) * 10 + index + 1;
|
||||
} else if (col.key === 'settlementType') {
|
||||
// 处理结算类型显示
|
||||
if (row.settlementType === 1) return '工器具';
|
||||
if (row.settlementType === 2) return '安全工器具';
|
||||
return '总费用';
|
||||
} else if (col.key === 'costs') {
|
||||
// 处理合计费用格式
|
||||
return row.costs != null && row.costs !== '' ? parseFloat(row.costs.toFixed(2)) : 0.00;
|
||||
} else if (col.key === 'leaseCost' || col.key === 'repairCost' || col.key === 'loseCost' || col.key === 'scrapCost') {
|
||||
// 处理费用字段格式
|
||||
return row[col.key] || 0;
|
||||
} else {
|
||||
return row[col.key] || '';
|
||||
}
|
||||
});
|
||||
excelData.push(dataRow);
|
||||
});
|
||||
|
||||
// 创建工作簿和工作表
|
||||
const workbook = XLSX.utils.book_new();
|
||||
const worksheet = XLSX.utils.aoa_to_sheet(excelData);
|
||||
|
||||
// 设置列宽
|
||||
const columnWidths = [
|
||||
{ wch: 8 }, // 序号
|
||||
{ wch: 20 }, // 协议号
|
||||
{ wch: 15 }, // 结算单位
|
||||
{ wch: 20 }, // 结算工程
|
||||
{ wch: 12 }, // 结算类型
|
||||
{ wch: 12 }, // 租赁费用
|
||||
{ wch: 12 }, // 维修费用
|
||||
{ wch: 12 }, // 丢失费用
|
||||
{ wch: 12 }, // 报废费用
|
||||
{ wch: 15 } // 合计费用
|
||||
];
|
||||
worksheet['!cols'] = columnWidths;
|
||||
|
||||
// 添加工作表到工作簿
|
||||
XLSX.utils.book_append_sheet(workbook, worksheet, '未结算记录');
|
||||
|
||||
// 生成文件名
|
||||
const fileName = `未结算记录_${new Date().toISOString().slice(0, 10)}.xlsx`;
|
||||
|
||||
// 生成Excel文件并下载
|
||||
const excelBuffer = XLSX.write(workbook, { bookType: 'xlsx', type: 'array' });
|
||||
const blob = new Blob([excelBuffer], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
|
||||
|
||||
// 创建下载链接
|
||||
const link = document.createElement('a');
|
||||
const url = URL.createObjectURL(blob);
|
||||
link.setAttribute('href', url);
|
||||
link.setAttribute('download', fileName);
|
||||
link.style.visibility = 'hidden';
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
|
||||
// 清理URL对象
|
||||
URL.revokeObjectURL(url);
|
||||
|
||||
this.$modal.msgSuccess('Excel导出成功');
|
||||
} catch (error) {
|
||||
console.error('导出Excel失败:', error);
|
||||
this.$modal.msgError('导出Excel失败,请稍后重试');
|
||||
}
|
||||
},
|
||||
|
||||
// 导出费用详情为Excel
|
||||
exportCostDetail() {
|
||||
if (!this.costDetailList || this.costDetailList.length === 0) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue