结算全部导出,结算权限页面
This commit is contained in:
parent
9ba223fe1f
commit
998aeac196
|
|
@ -114,3 +114,45 @@ export function delConfig(id) {
|
|||
method: 'post'
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*****************************************************************************************************************************************************
|
||||
*
|
||||
*/
|
||||
|
||||
// 结算人员配置列表接口
|
||||
export function getCostConfigListApi(query) {
|
||||
return request({
|
||||
url: '/material/sysWorkflowType/costConfigList',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 人员信息列表接口
|
||||
export function getCostConfigUserListApi(query) {
|
||||
return request({
|
||||
url: '/material/sysWorkflowType/costConfigUserList',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 结算人员配置--修改
|
||||
export function editCostConfigApi(data) {
|
||||
return request({
|
||||
url: '/material/sysWorkflowType/updateCostConfig',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 结算人员配置--删除
|
||||
export function deleteCostConfigApi(data) {
|
||||
return request({
|
||||
url: '/material/sysWorkflowType/deleteCostConfig',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
|
@ -864,6 +864,7 @@ export default {
|
|||
findLeaf(this.lessUniteList)
|
||||
if (leafNodes.length === 1) {
|
||||
this.maForm.leaseUnitId = leafNodes[0].id || leafNodes[0].value
|
||||
console.log("kkkkkkkkkkkkkkkk",this.maForm.leaseUnitId)
|
||||
await this.getLeaseAgreementId()
|
||||
}
|
||||
} catch (e) {
|
||||
|
|
@ -1043,10 +1044,12 @@ export default {
|
|||
},
|
||||
async getLeaseAgreementId() {
|
||||
try {
|
||||
console.log("xxxxxxxxxxxxxxxx222yyyyyyyyyyyyyy",this.maForm)
|
||||
const params = {
|
||||
unitId: this.maForm.leaseUnitId,
|
||||
projectId: this.maForm.leaseProId
|
||||
}
|
||||
console.log("zzzzzzzzzyyyyyyyyyy",params)
|
||||
const res = await getAgreement(params)
|
||||
console.log('🚀 ~ getAgreementId ~ res:', res)
|
||||
this.maForm.leaseAgreementId = res.data.agreementId
|
||||
|
|
@ -1093,7 +1096,9 @@ export default {
|
|||
// this.maForm.backProId = null
|
||||
// })
|
||||
// }, 500)
|
||||
this.getAgreementId()
|
||||
setTimeout(() => {
|
||||
this.getAgreementId()
|
||||
}, 500);
|
||||
},
|
||||
projectChange(val) {
|
||||
setTimeout(() => {
|
||||
|
|
@ -1116,7 +1121,9 @@ export default {
|
|||
// getListUnite({}).then(res => {
|
||||
// this.leaseUniteList = res.data
|
||||
// })
|
||||
this.getLeaseAgreementId()
|
||||
setTimeout(() => {
|
||||
this.getLeaseAgreementId();
|
||||
}, 500);
|
||||
// }, 500)
|
||||
},
|
||||
//获取任务详情--- 编辑回显数据
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@
|
|||
</el-table-column>
|
||||
<el-table-column label="丢失费用(元)" align="center" prop="cost" width="120">
|
||||
<template slot-scope="scope">
|
||||
{{ (scope.row.buyPrice * scope.row.num).toFixed(3) }}
|
||||
{{ (scope.row.buyPrice * scope.row.num).toFixed(2) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
|
@ -276,98 +276,24 @@ export default {
|
|||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// 定义Excel列配置
|
||||
const columns = [
|
||||
{ key: 'index', title: '序号' },
|
||||
{ key: 'agreementCode', title: '协议号' },
|
||||
{ key: 'unitName', title: '结算单位' },
|
||||
{ key: 'projectName', title: '结算工程' },
|
||||
{ key: 'typeName', title: '机具名称' },
|
||||
{ key: 'modelName', title: '规格型号' },
|
||||
{ key: 'mtUnitName', title: '单位' },
|
||||
{ key: 'num', title: '丢失数量' },
|
||||
{ key: 'buyPrice', title: '单价(元)' },
|
||||
{ key: 'cost', title: '丢失费用(元)' }
|
||||
];
|
||||
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}`;
|
||||
};
|
||||
|
||||
// 准备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) * this.queryParams.pageSize + index + 1;
|
||||
} else if (col.key === 'buyPrice') {
|
||||
// 处理单价字段格式
|
||||
return row.buyPrice ? parseFloat(row.buyPrice.toFixed(2)) : 0.00;
|
||||
} else if (col.key === 'cost') {
|
||||
// 处理丢失费用字段格式,计算buyPrice * num
|
||||
const cost = (row.buyPrice || 0) * (row.num || 0);
|
||||
return parseFloat(cost.toFixed(3));
|
||||
} 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: 20 }, // 机具名称
|
||||
{ wch: 15 }, // 规格型号
|
||||
{ wch: 8 }, // 单位
|
||||
{ wch: 10 }, // 丢失数量
|
||||
{ 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失败,请稍后重试');
|
||||
}
|
||||
const currentTime = formatTime(new Date());
|
||||
this.download(
|
||||
'/material/slt_agreement_info/exportLostList',
|
||||
{
|
||||
...this.queryParams,
|
||||
},
|
||||
`丢失费用报表_${currentTime}.xlsx`
|
||||
)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,14 +57,13 @@
|
|||
<el-table-column label="规格型号" align="center" prop="modelName" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="单位" align="center" prop="mtUnitName" width="80" />
|
||||
<el-table-column label="维修数量" align="center" prop="num" width="100" />
|
||||
<el-table-column label="维修费用(元)" align="center" prop="cost" width="120">
|
||||
<el-table-column label="维修费用(元)" align="center" prop="costs" width="120">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.costs ? scope.row.costs.toFixed(2) : '0.00' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="维修方式" align="center" prop="repairType" width="120" />
|
||||
<el-table-column label="费用类型" align="center" prop="partType" width="120" />
|
||||
<el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" min-width="50" />
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
|
|
@ -273,99 +272,25 @@ export default {
|
|||
this.$modal.msgWarning('没有可导出的数据');
|
||||
return;
|
||||
}
|
||||
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}`;
|
||||
};
|
||||
|
||||
try {
|
||||
// 定义Excel列配置
|
||||
const columns = [
|
||||
{ key: 'index', title: '序号' },
|
||||
{ key: 'agreementCode', title: '协议号' },
|
||||
{ key: 'unitName', title: '结算单位' },
|
||||
{ key: 'projectName', title: '结算工程' },
|
||||
{ key: 'typeName', title: '机具名称' },
|
||||
{ key: 'modelName', title: '规格型号' },
|
||||
{ key: 'mtUnitName', title: '单位' },
|
||||
{ key: 'num', title: '维修数量' },
|
||||
{ key: 'costs', title: '维修费用(元)' },
|
||||
{ key: 'repairType', title: '维修方式' },
|
||||
{ key: 'partType', title: '费用类型' },
|
||||
{ key: 'remark', title: '备注' }
|
||||
];
|
||||
const currentTime = formatTime(new Date());
|
||||
this.download(
|
||||
'/material/slt_agreement_info/exportRepairList',
|
||||
{
|
||||
...this.queryParams,
|
||||
},
|
||||
`维修费用报表_${currentTime}.xlsx`
|
||||
)
|
||||
|
||||
// 准备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) * this.queryParams.pageSize + index + 1;
|
||||
} else if (col.key === 'costs') {
|
||||
// 处理费用字段格式
|
||||
return row.costs ? parseFloat(row.costs.toFixed(2)) : 0.00;
|
||||
} 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: 20 }, // 机具名称
|
||||
{ wch: 15 }, // 规格型号
|
||||
{ wch: 8 }, // 单位
|
||||
{ wch: 10 }, // 维修数量
|
||||
{ wch: 15 }, // 维修费用
|
||||
{ wch: 12 }, // 维修方式
|
||||
{ wch: 12 }, // 费用类型
|
||||
{ wch: 20 } // 备注
|
||||
];
|
||||
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失败,请稍后重试');
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,12 +57,11 @@
|
|||
<el-table-column label="机具规格" align="center" prop="modelName" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="单位" align="center" prop="mtUnitName" width="80" />
|
||||
<el-table-column label="报废数量" align="center" prop="num" width="100" />
|
||||
<el-table-column label="报废费用(元)" align="center" prop="cost" width="120">
|
||||
<el-table-column label="报废费用(元)" align="center" prop="costs" width="120">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.cost ? scope.row.cost.toFixed(2) : '0.00' }}
|
||||
{{ scope.row.costs ? scope.row.costs.toFixed(2) : '0.00' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" min-width="50" />
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
|
|
@ -271,95 +270,24 @@ export default {
|
|||
this.$modal.msgWarning('没有可导出的数据');
|
||||
return;
|
||||
}
|
||||
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}`;
|
||||
};
|
||||
|
||||
try {
|
||||
// 定义Excel列配置
|
||||
const columns = [
|
||||
{ key: 'index', title: '序号' },
|
||||
{ key: 'agreementCode', title: '协议号' },
|
||||
{ key: 'unitName', title: '结算单位' },
|
||||
{ key: 'projectName', title: '结算工程' },
|
||||
{ key: 'typeName', title: '机具名称' },
|
||||
{ key: 'modelName', title: '机具规格' },
|
||||
{ key: 'mtUnitName', title: '单位' },
|
||||
{ key: 'num', title: '报废数量' },
|
||||
{ key: 'cost', title: '报废费用(元)' },
|
||||
{ key: 'remark', 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) * this.queryParams.pageSize + index + 1;
|
||||
} else if (col.key === 'cost') {
|
||||
// 处理费用字段格式
|
||||
return row.cost ? parseFloat(row.cost.toFixed(2)) : 0.00;
|
||||
} 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: 20 }, // 机具名称
|
||||
{ wch: 15 }, // 机具规格
|
||||
{ wch: 8 }, // 单位
|
||||
{ wch: 10 }, // 报废数量
|
||||
{ wch: 15 }, // 报废费用
|
||||
{ wch: 20 } // 备注
|
||||
];
|
||||
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失败,请稍后重试');
|
||||
}
|
||||
const currentTime = formatTime(new Date());
|
||||
this.download(
|
||||
'/material/slt_agreement_info/exportScrapList',
|
||||
{
|
||||
...this.queryParams,
|
||||
},
|
||||
`报废费用报表_${currentTime}.xlsx`
|
||||
)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,9 +110,9 @@
|
|||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="合计费用(元)" align="center" prop="costs" :show-overflow-tooltip="true">
|
||||
<el-table-column label="合计费用(元)" align="center" prop="totalCostAll" :show-overflow-tooltip="true">
|
||||
<template slot-scope="scope">
|
||||
<span v-if="scope.row.costs != null && scope.row.costs != ''">
|
||||
<span v-if="scope.row.totalCostAll != null && scope.row.totalCostAll != ''">
|
||||
<el-button
|
||||
type="text"
|
||||
@click="showCostDetail(scope.row, 'total')"
|
||||
|
|
@ -940,106 +940,30 @@ export default {
|
|||
},
|
||||
|
||||
// 导出主表格Excel
|
||||
exportExcel() {
|
||||
exportExcel(){
|
||||
if (!this.tableList || this.tableList.length === 0) {
|
||||
this.$modal.msgWarning('没有可导出的数据');
|
||||
return;
|
||||
}
|
||||
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}`;
|
||||
};
|
||||
|
||||
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: 'reductionCost', 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 parseFloat(this.calculateTotalCost(row).toFixed(2));
|
||||
} else if (col.key === 'leaseCost' || col.key === 'repairCost' || col.key === 'loseCost' || col.key === 'scrapCost' || col.key === 'reductionCost') {
|
||||
// 处理费用字段格式
|
||||
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, '未结算记录');
|
||||
|
||||
// 生成文件名
|
||||
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失败,请稍后重试');
|
||||
}
|
||||
const currentTime = formatTime(new Date());
|
||||
this.download(
|
||||
'/material/slt_agreement_info/exportUnreported',
|
||||
{
|
||||
...this.queryParams,
|
||||
disabled: false,
|
||||
},
|
||||
`未结算报表_${currentTime}.xlsx`
|
||||
)
|
||||
},
|
||||
|
||||
// 导出费用详情为Excel
|
||||
|
|
|
|||
|
|
@ -0,0 +1,243 @@
|
|||
<template>
|
||||
<!-- 会签配置管理 列表页面 -->
|
||||
<div class="app-container">
|
||||
|
||||
<el-table v-loading="loading" :data="configList" ref="multipleTable">
|
||||
<el-table-column
|
||||
width="80"
|
||||
label="序号"
|
||||
type="index"
|
||||
align="center"
|
||||
:index="indexContinuation(queryParams.pageNum, queryParams.pageSize)"
|
||||
/>
|
||||
|
||||
<!-- 点击跳转到二级页面配置审核流程 -->
|
||||
<el-table-column label="结算类型" align="center" prop="processName" show-overflow-tooltip>
|
||||
<template slot-scope="scope">
|
||||
<el-tag
|
||||
:type="scope.row.processName == '安全工器具' ? 'warning' : ''"
|
||||
effect="plain">
|
||||
{{ scope.row.processName }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="配置人员" align="center" prop="userNameStr" width="500" >
|
||||
<template slot-scope="scope">
|
||||
<span>{{ sortUserNames(scope.row.userNameStr) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" width="250">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
type="primary"
|
||||
icon="el-icon-edit"
|
||||
@click="handleUpdate(scope.row)"
|
||||
>
|
||||
人员配置
|
||||
</el-button>
|
||||
<!-- <el-button
|
||||
size="mini"
|
||||
type="danger"
|
||||
icon="el-icon-delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
>
|
||||
删除
|
||||
</el-button> -->
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
:total="total"
|
||||
v-show="total > 0"
|
||||
@pagination="getList"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
/>
|
||||
|
||||
<!-- 新增或修改弹窗 -->
|
||||
<el-dialog :title="title" :visible.sync="showConfig" width="40%" append-to-body @close="onDialogClose">
|
||||
<el-form ref="form" :model="form" label-width="120px">
|
||||
<el-row :gutter="24">
|
||||
<el-col :span="20">
|
||||
<el-form-item label="配置人员" prop="typeName">
|
||||
<el-select
|
||||
v-model="form.userIds"
|
||||
filterable multiple
|
||||
placeholder="请选择人员"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="keeper in userOptions"
|
||||
:key="keeper.userId+''"
|
||||
:label="keeper.nickName"
|
||||
:value="keeper.userId+''"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getCostConfigListApi,getCostConfigUserListApi, editCostConfigApi,deleteCostConfigApi, deleteConfigApi } from '@/api/countersign/countersign'
|
||||
import { getKeeperIds } from '@/api/ma/typeConfigKeeper'
|
||||
export default {
|
||||
name: 'CostConfig',
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: false,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
showConfig: false,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 会签配置表格数据
|
||||
configList: [],
|
||||
userOptions:[],
|
||||
// 弹出层标题
|
||||
title: '',
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
keyWord: undefined
|
||||
},
|
||||
// 表单参数
|
||||
form: {
|
||||
id: '',
|
||||
userIds: [],
|
||||
itemName: '',
|
||||
},
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getList()
|
||||
},
|
||||
|
||||
methods: {
|
||||
sortUserNames(userNameStr) {
|
||||
if (!userNameStr) return '';
|
||||
|
||||
// 分割、排序、再合并
|
||||
return userNameStr.split(',')
|
||||
.map(name => name.trim())
|
||||
.filter(name => name)
|
||||
.sort((a, b) => a.localeCompare(b)) // 明确指定比较规则
|
||||
.join(', ');
|
||||
},
|
||||
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.showConfig = false
|
||||
},
|
||||
|
||||
// 搜索
|
||||
handleQuery() {
|
||||
this.getList()
|
||||
},
|
||||
|
||||
// 弹框关闭时触发
|
||||
onDialogClose() {
|
||||
this.$refs.form.resetFields()
|
||||
},
|
||||
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
typeName: '',
|
||||
taskType: ''
|
||||
}
|
||||
this.resetForm('form')
|
||||
},
|
||||
// 重置
|
||||
resetQuery() {
|
||||
this.resetForm('queryForm')
|
||||
this.queryParams.keyWord = null
|
||||
this.queryParams.pageNum = 1
|
||||
this.queryParams.pageSize = 10
|
||||
this.handleQuery()
|
||||
},
|
||||
|
||||
// 编辑
|
||||
async handleUpdate(row) {
|
||||
this.form.id = row.id
|
||||
this.userOptions = []
|
||||
let roleIds = ''
|
||||
await getKeeperIds(row.itemName).then((response) => {
|
||||
roleIds = response.rows[response.rows.length - 1].itemValue
|
||||
})
|
||||
await getCostConfigUserListApi({userNameStr:roleIds}).then((response) => {
|
||||
this.userOptions = response.rows.sort((a, b) =>
|
||||
a.nickName.localeCompare(b.nickName, 'zh-CN')
|
||||
)
|
||||
})
|
||||
if (row.itemValue) {
|
||||
const userIds = row.itemValue.split(',')
|
||||
// 根据 keeperIds 从 KeeperOptions 中获取对应的 keeper 对象
|
||||
const users = userIds.map((id) =>
|
||||
this.userOptions.find((user) => user.userId + '' == id)
|
||||
).filter(Boolean) // 过滤掉可能不存在的 keeper
|
||||
|
||||
// 根据 keeperName 中文排序
|
||||
users.sort((a, b) =>
|
||||
a.nickName.localeCompare(b.nickName, 'zh-CN')
|
||||
)
|
||||
|
||||
// 提取排序后的 keeperId
|
||||
this.form.userIds = users.map((user) => user.userId + '')
|
||||
} else {
|
||||
this.form.userIds = [] // 如果不存在,设置为空数组
|
||||
}
|
||||
this.title = '人员配置'
|
||||
this.showConfig = true
|
||||
},
|
||||
|
||||
// 查询列表
|
||||
async getList() {
|
||||
this.loading = true
|
||||
const res = await getCostConfigListApi()
|
||||
this.configList = res.rows
|
||||
this.total = res.total
|
||||
this.loading = false
|
||||
},
|
||||
|
||||
// 删除
|
||||
handleDelete(row) {
|
||||
const id = row.id
|
||||
this.$modal
|
||||
.confirm('是否确认删除数据项?')
|
||||
.then(function () {
|
||||
return deleteCostConfigApi({ id })
|
||||
})
|
||||
.then(() => {
|
||||
this.$modal.msgSuccess('删除成功')
|
||||
this.getList()
|
||||
})
|
||||
.catch(() => {})
|
||||
},
|
||||
|
||||
// 提交
|
||||
submitForm() {
|
||||
console.log("xxxxxxxxxxxxxx",this.form)
|
||||
editCostConfigApi(this.form).then(res => {
|
||||
this.$modal.msgSuccess('修改成功')
|
||||
this.showConfig = false
|
||||
this.getList()
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Loading…
Reference in New Issue