yudao-dev/src/views/cost/deep/costDeepRatioHis/index.vue
2025-03-10 16:32:02 +08:00

396 lines
8.6 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">
<search-bar
:formConfigs="formConfig"
ref="searchBarForm"
@headBtnClick="buttonClick" />
<!-- 列表 -->
<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">
<method-btn
v-if="tableBtn.length"
slot="handleBtn"
:width="80"
label="操作"
:method-list="tableBtn"
@clickBtn="handleClick" />
</base-table>
</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"
:name-arr="formConfig[1].selectOptions"
@refreshDataList="successSubmit"></add-or-update>
</base-dialog>
</div>
</div>
</template>
<script>
import AddOrUpdate from './add-or-updata';
import basicPage from '@/mixins/basic-page';
import { getLinePage } from '@/api/base/productionLine';
import {
getDeepPDRatioHisPage,
getDeepWSRatioHisPage,
exportDeepWSRatioHisExcel,
exportDeepPDRatioHisExcel,
} from '@/api/cost/costDeepRatioHis';
import { parseTime } from '@/filter/code-filter';
import tableHeightMixin from '@/mixins/lb/tableHeightMixin';
import ButtonNav from '@/components/ButtonNav';
const tableProps = [
{
prop: 'time',
label: '日期',
},
{
prop: 'remark',
label: '备注',
},
{
prop: 'productionLineName',
label: '产线',
},
{
prop: 'spec',
label: '规格',
},
{
prop: 'innum',
label: '上片数量',
filter: (val) => (val != null ? Number(val).toFixed(2) : '-'),
},
{
prop: 'outnum',
label: '下片数量',
filter: (val) => (val != null ? Number(val).toFixed(2) : '-'),
},
{
prop: 'ratio',
label: '良品率',
filter: (val) => (val ? Number(val * 100).toFixed(2) + '%' : '-'),
},
];
const tableProps2 = [
{
prop: 'time',
label: '日期',
},
{
prop: 'remark',
label: '备注',
},
{
prop: 'productionLineName',
label: '产线',
},
{
prop: 'workshopSectionName',
label: '工段',
},
{
prop: 'innum',
label: '进片数量',
filter: (val) => (val != null ? Number(val).toFixed(2) : '-'),
},
{
prop: 'outnum',
label: '出片数量',
filter: (val) => (val != null ? Number(val).toFixed(2) : '-'),
},
{
prop: 'ratio',
label: '良品率',
filter: (val) => (val ? Number(val * 100).toFixed(2) + '%' : '-'),
},
];
export default {
name: 'costDeepRatioHis',
mixins: [basicPage, tableHeightMixin],
data() {
return {
urlOptions: {
getDataListURL: getDeepPDRatioHisPage,
},
formConfig: [
{
type: 'select',
label: '维度',
selectOptions: [
{ id: 1, name: '日' },
{ id: 2, name: '周' },
{ id: 3, name: '月' },
],
param: 'statisticType',
defaultSelect: 1, // 默认值,
clearable: false,
},
{
type: 'select',
label: '产线',
selectOptions: [],
param: 'name',
filterable: true,
},
{
type: 'datePicker',
label: '时间范围',
dateType: 'datetimerange',
format: 'yyyy-MM-dd HH:mm:ss',
valueFormat: 'yyyy-MM-dd HH:mm:ss',
rangeSeparator: '-',
startPlaceholder: '开始时间',
endPlaceholder: '结束时间',
defaultTime: ['08:30:00', '08:30:00'],
param: 'searchTime',
width: 350,
},
{
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() {
const params ={
pageNo: 1,
pageSize: 100,
pdType: 0
}
getLinePage(params).then((response) => {
this.formConfig[1].selectOptions = response.data.list;
});
},
methods: {
buttonClick(val) {
switch (val.btnName) {
case 'search':
this.listQuery.pageNo = 1;
this.listQuery.pageSize = 20;
this.listQuery.productionLineId = 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]
: 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.productionLineId = 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]
: 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.productionLineId = null;
this.listQuery.startTime = null;
this.listQuery.endTime = null;
this.listQuery.statisticType = 1;
this.listQuery.pageNo = 1;
this.getDataList();
} else {
this.$refs.searchBarForm.resetForm();
this.listQuery.productionLineId = null;
this.listQuery.startTime = null;
this.listQuery.endTime = null;
this.listQuery.statisticType = 1;
this.listQuery.pageNo = 1;
this.getDataList2();
}
},
// 获取数据2列表
getDataList2() {
getDeepWSRatioHisPage(this.listQuery).then((response) => {
this.tableData2 = response.data.list;
this.listQuery.total = response.data.total;
});
},
//tableBtn点击
handleClick(val) {
if (val.type === 'edit') {
this.addOrUpdateVisible = true;
this.addOrEditTitle = '编辑';
this.$nextTick(() => {
this.$refs.addOrUpdate.init(
val.data,
this.listQuery.statisticType,
this.activeName
);
});
} else {
this.otherMethods(val);
}
},
getNavDataList(){
if (this.activeName === 'his') {
this.getDataList();
} else {
this.getDataList2();
}
},
successSubmit() {
this.handleCancel();
if (this.activeName === 'his') {
this.getDataList();
} else {
this.getDataList2();
}
},
/** 导出按钮操作 */
handleExport() {
let exportURL, title;
if (this.activeName === 'his') {
exportURL = exportDeepPDRatioHisExcel;
title = '深加工-产线良品率';
} else {
exportURL = exportDeepWSRatioHisExcel;
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>