405 lines
9.2 KiB
Vue
405 lines
9.2 KiB
Vue
<template>
|
|
<div>
|
|
<!-- <div style="background: #f2f4f9; height: 40px; width: 100%">
|
|
<ButtonNav :menus="['按日期', '按规格']" @change="currentMenu">
|
|
<template v-slot:tab1>
|
|
<div>按日期</div>
|
|
</template>
|
|
<template v-slot:tab2>
|
|
<div>按规格</div>
|
|
</template>
|
|
</ButtonNav>
|
|
</div> -->
|
|
<div class="app-container energyOverlimitLog">
|
|
<div v-show="activeName === 'his'">
|
|
<!-- 搜索工作栏 -->
|
|
<search-bar
|
|
:formConfigs="formConfig"
|
|
ref="searchBarForm"
|
|
@headBtnClick="buttonClick" />
|
|
</div>
|
|
<div v-show="activeName === 'now'">
|
|
<!-- 搜索工作栏 -->
|
|
<search-bar
|
|
:formConfigs="formConfig2"
|
|
ref="searchBarForm2"
|
|
@headBtnClick="buttonClick" />
|
|
</div>
|
|
<!-- 列表 -->
|
|
<div v-if="activeName === 'his'">
|
|
<base-table
|
|
:page="listQuery.pageNo"
|
|
:limit="listQuery.pageSize"
|
|
:table-props="tableProps"
|
|
:table-data="tableData"
|
|
:max-height="tableH">
|
|
<method-btn
|
|
v-if="tableBtn.length"
|
|
slot="handleBtn"
|
|
:width="80"
|
|
label="操作"
|
|
:method-list="tableBtn"
|
|
@clickBtn="handleClick" />
|
|
</base-table>
|
|
</div>
|
|
<div v-if="activeName === 'now'">
|
|
<base-table
|
|
:page="listQuery.pageNo"
|
|
:limit="listQuery.pageSize"
|
|
:table-props="tableProps2"
|
|
:table-data="tableData2"
|
|
:max-height="tableH" />
|
|
</div>
|
|
<pagination
|
|
:page.sync="listQuery.pageNo"
|
|
:limit.sync="listQuery.pageSize"
|
|
:total="listQuery.total"
|
|
@pagination="getNavDataList" />
|
|
<base-dialog
|
|
:dialogTitle="addOrEditTitle"
|
|
:dialogVisible="addOrUpdateVisible"
|
|
@cancel="handleCancel"
|
|
@confirm="handleConfirm"
|
|
:before-close="handleCancel"
|
|
width="50%">
|
|
<add-or-update
|
|
ref="addOrUpdate"
|
|
@refreshDataList="successSubmit"></add-or-update>
|
|
</base-dialog>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import AddOrUpdate from './add-or-updata';
|
|
import basicPage from '@/mixins/basic-page';
|
|
import {
|
|
getCostSumPage,
|
|
getRawCostStatisticsRealtimePage,
|
|
exportRawStatisticsRealtimeExcel,
|
|
exportCostSumExcel
|
|
} from '@/api/cost/allCost';
|
|
import { parseTime } from '@/filter/code-filter';
|
|
import tableHeightMixin from '@/mixins/lb/tableHeightMixin';
|
|
import typeRule from './typeRule';
|
|
import ButtonNav from '@/components/ButtonNav';
|
|
|
|
const tableProps = [
|
|
{
|
|
prop: 'time',
|
|
label: '日期',
|
|
},
|
|
{
|
|
prop: 'originArea',
|
|
label: '原片下片面积',
|
|
filter: (val) => (val != null ? Number(val).toFixed(2) : '-'),
|
|
},
|
|
{
|
|
prop: 'deepArea',
|
|
label: '深加工下片面积',
|
|
filter: (val) => (val != null ? Number(val).toFixed(2) : '-'),
|
|
},
|
|
{
|
|
prop: 'originPrice',
|
|
label: '原片成本/元',
|
|
align: 'right',
|
|
filter: (val) => (val != null ? Number(val).toFixed(2) : '-'),
|
|
},
|
|
{
|
|
prop: 'deepPrice',
|
|
label: '深加工成本/元',
|
|
align: 'right',
|
|
filter: (val) => (val != null ? Number(val).toFixed(2) : '-'),
|
|
},
|
|
{
|
|
prop: 'price',
|
|
label: '总成本/元',
|
|
align: 'right',
|
|
filter: (val) => (val != null ? Number(val).toFixed(2) : '-'),
|
|
},
|
|
];
|
|
const tableProps2 = [
|
|
{
|
|
prop: 'bindObjectName',
|
|
label: '产品名称',
|
|
},
|
|
{
|
|
prop: 'spec',
|
|
label: '规格',
|
|
},
|
|
{
|
|
prop: 'costSum',
|
|
label: '原片单片成本/元',
|
|
align: 'right',
|
|
},
|
|
{
|
|
prop: 'costPiece',
|
|
label: '深加工单片成本/元',
|
|
align: 'right',
|
|
},
|
|
{
|
|
prop: 'costPiece',
|
|
label: '成品单片成本/元',
|
|
align: 'right',
|
|
},
|
|
{
|
|
prop: 'costArea',
|
|
label: '每平米成本/元',
|
|
align: 'right',
|
|
},
|
|
];
|
|
export default {
|
|
name: 'allCost',
|
|
mixins: [basicPage, tableHeightMixin],
|
|
data() {
|
|
return {
|
|
urlOptions: {
|
|
getDataListURL: getCostSumPage,
|
|
},
|
|
formConfig: [
|
|
{
|
|
type: 'select',
|
|
label: '维度',
|
|
selectOptions: [
|
|
{ id: 1, name: '日' },
|
|
{ id: 2, name: '周' },
|
|
{ id: 3, name: '月' },
|
|
],
|
|
param: 'statisticType',
|
|
defaultSelect: 1, // 默认值,
|
|
clearable: false,
|
|
},
|
|
{
|
|
type: 'datePicker',
|
|
label: '时间范围',
|
|
dateType: 'daterange',
|
|
format: 'yyyy-MM-dd',
|
|
valueFormat: 'yyyy-MM-dd HH:mm:ss',
|
|
rangeSeparator: '-',
|
|
startPlaceholder: '开始时间',
|
|
endPlaceholder: '结束时间',
|
|
param: 'searchTime',
|
|
},
|
|
{
|
|
type: 'button',
|
|
btnName: '查询',
|
|
name: 'search',
|
|
color: 'primary',
|
|
},
|
|
{
|
|
type: 'separate',
|
|
},
|
|
{
|
|
type: 'button',
|
|
btnName: '导出',
|
|
name: 'export',
|
|
color: 'warning',
|
|
},
|
|
],
|
|
formConfig2: [
|
|
{
|
|
type: 'datePicker',
|
|
label: '时间范围',
|
|
dateType: 'daterange',
|
|
format: 'yyyy-MM-dd',
|
|
valueFormat: 'yyyy-MM-dd HH:mm:ss',
|
|
rangeSeparator: '-',
|
|
startPlaceholder: '开始时间',
|
|
endPlaceholder: '结束时间',
|
|
param: 'searchTime',
|
|
},
|
|
{
|
|
type: 'button',
|
|
btnName: '查询',
|
|
name: 'search',
|
|
color: 'primary',
|
|
},
|
|
{
|
|
type: 'separate',
|
|
},
|
|
{
|
|
type: 'button',
|
|
btnName: '导出',
|
|
name: 'export',
|
|
color: 'warning',
|
|
},
|
|
],
|
|
listQuery: {
|
|
statisticType: 1,
|
|
},
|
|
activeName: 'his',
|
|
tableProps,
|
|
tableProps2,
|
|
tableBtn: [
|
|
{
|
|
type: 'edit',
|
|
btnName: '编辑',
|
|
}
|
|
].filter((v) => v),
|
|
tableData: [],
|
|
tableData2: [],
|
|
};
|
|
},
|
|
components: {
|
|
AddOrUpdate,
|
|
ButtonNav,
|
|
},
|
|
created() {
|
|
},
|
|
methods: {
|
|
buttonClick(val) {
|
|
this.formConfig2[0].startPlaceholder = '开始时间';
|
|
this.formConfig2[0].endPlaceholder = '结束时间';
|
|
switch (val.btnName) {
|
|
case 'search':
|
|
this.listQuery.pageNo = 1;
|
|
this.listQuery.pageSize = 20;
|
|
this.listQuery.bindObjectId = val.name || null;
|
|
this.listQuery.statisticType = val.statisticType || 1;
|
|
this.listQuery.startTime = val.searchTime ? val.searchTime[0] : null;
|
|
this.listQuery.endTime = val.searchTime
|
|
? val.searchTime[1].substr(0, 10) + ' 23:59:59'
|
|
: null;
|
|
if (this.activeName === 'his') {
|
|
this.getDataList();
|
|
} else {
|
|
this.getDataList2();
|
|
}
|
|
break;
|
|
case 'add':
|
|
this.addOrUpdateHandle();
|
|
break;
|
|
case 'export':
|
|
this.listQuery.pageNo = 1;
|
|
this.listQuery.pageSize = 20;
|
|
this.listQuery.bindObjectId = val.name || null;
|
|
this.listQuery.statisticType = val.statisticType || 1;
|
|
this.listQuery.startTime = val.searchTime ? val.searchTime[0] : null;
|
|
this.listQuery.endTime = val.searchTime
|
|
? val.searchTime[1].substr(0, 10) + ' 23:59:59'
|
|
: null;
|
|
this.handleExport();
|
|
break;
|
|
default:
|
|
console.log(val);
|
|
}
|
|
},
|
|
currentMenu(val) {
|
|
this.activeName = val === '按日期' ? 'his' : 'now';
|
|
if (this.activeName === 'his') {
|
|
this.$refs.searchBarForm.resetForm();
|
|
this.listQuery.name = null;
|
|
this.listQuery.startTime = null;
|
|
this.listQuery.endTime = null;
|
|
this.listQuery.statisticType = 1;
|
|
this.listQuery.pageNo = 1;
|
|
this.getDataList();
|
|
} else {
|
|
this.$refs.searchBarForm2.resetForm();
|
|
const end = new Date();
|
|
const start = new Date();
|
|
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
|
|
this.listQuery.startTime = parseTime(start).substr(0, 10) + ' 00:00:00';
|
|
this.listQuery.endTime = parseTime(end).substr(0, 10) + ' 23:59:59';
|
|
this.formConfig2[0].startPlaceholder = parseTime(start).substr(0, 10);
|
|
this.formConfig2[0].endPlaceholder = parseTime(end).substr(0, 10);
|
|
this.listQuery.name = null;
|
|
this.listQuery.pageNo = 1;
|
|
this.getDataList2();
|
|
}
|
|
},
|
|
// 获取数据2列表
|
|
getDataList2() {
|
|
if (this.listQuery.startTime) {
|
|
getRawCostStatisticsRealtimePage(this.listQuery).then((response) => {
|
|
this.tableData2 = response.data.list;
|
|
this.listQuery.total = response.data.total;
|
|
});
|
|
} else {
|
|
this.$message.warning('请选择时间范围');
|
|
}
|
|
},
|
|
//tableBtn点击
|
|
handleClick(val) {
|
|
if (val.type === 'edit') {
|
|
this.addOrUpdateVisible = true;
|
|
this.addOrEditTitle = '编辑';
|
|
this.$nextTick(() => {
|
|
this.$refs.addOrUpdate.init(val.data, this.listQuery.statisticType);
|
|
});
|
|
} else {
|
|
this.otherMethods(val);
|
|
}
|
|
},
|
|
getNavDataList(){
|
|
if (this.activeName === 'his') {
|
|
this.getDataList();
|
|
} else {
|
|
this.getDataList2();
|
|
}
|
|
},
|
|
/** 导出按钮操作 */
|
|
handleExport() {
|
|
let exportURL, title;
|
|
if (this.activeName === 'his') {
|
|
exportURL = exportCostSumExcel;
|
|
title = '总成本统计';
|
|
} else {
|
|
exportURL = exportRawStatisticsRealtimeExcel;
|
|
title = '总成本统计-按规格';
|
|
}
|
|
// 处理查询参数
|
|
let params = { ...this.listQuery };
|
|
params.pageNo = undefined;
|
|
params.pageSize = undefined;
|
|
this.$modal
|
|
.confirm('是否确认导出所有数据项?')
|
|
.then(() => {
|
|
return exportURL(params);
|
|
})
|
|
.then((response) => {
|
|
this.$download.excel(response, title + '报表.xls');
|
|
})
|
|
.catch(() => {});
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
<style lang="scss">
|
|
.energyOverlimitLog {
|
|
.el-tabs__nav::after {
|
|
content: '';
|
|
position: absolute;
|
|
left: 0;
|
|
bottom: 0;
|
|
width: 100%;
|
|
height: 2px;
|
|
background-color: #e4e7ed;
|
|
}
|
|
|
|
.el-tabs__nav-wrap::after {
|
|
width: 0;
|
|
}
|
|
|
|
.el-tabs__item {
|
|
padding: 0 10px;
|
|
}
|
|
|
|
.el-tabs__item:hover {
|
|
color: rgba(0, 0, 0, 0.85);
|
|
}
|
|
|
|
.el-tabs__item.is-active {
|
|
color: rgba(0, 0, 0, 0.85);
|
|
}
|
|
|
|
.el-tabs__item {
|
|
color: rgba(0, 0, 0, 0.45);
|
|
}
|
|
|
|
.searchBarBox {
|
|
margin-bottom: 0;
|
|
}
|
|
}
|
|
</style>
|