mt-yd-ui/src/views/modules/monitoring/equipmentException.vue

211 lines
5.4 KiB
Vue
Raw Normal View History

2022-09-20 15:59:45 +08:00
<template>
<!-- 设备效率分析 -->
2022-09-20 15:59:45 +08:00
<div class="mod-config">
<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
<!-- 月份 -->
2022-09-20 15:59:45 +08:00
<el-form-item>
<el-date-picker key="month-picker" v-model="rawTime" type="month" :placeholder="'请选择月份'" format="yyyy-MM" />
2022-09-20 15:59:45 +08:00
</el-form-item>
<!-- 产线 -->
<el-form-item>
<el-select v-model="dataForm.productlines" :placeholder="'产线'" multiple clearable>
<el-option v-for="productLine in productLineList" :key="productLine.id" :value="productLine.id" :label="productLine.name" />
</el-select>
</el-form-item>
<!-- 按钮 -->
2022-09-20 15:59:45 +08:00
<el-form-item>
<el-button @click="getDataList()">{{ $t('search') }}</el-button>
<!-- <el-button v-if="$hasPermission('monitoring:equipmentEffiency:save')" type="primary" @click="addOrUpdateHandle()">{{ $t('add') }}</el-button> -->
2022-09-20 15:59:45 +08:00
</el-form-item>
</el-form>
<base-table :data="dataList" :table-head-configs="tableConfigs" :max-height="calcMaxHeight(8)" @operate-event="handleOperations" @refreshDataList="getDataList" />
<el-pagination
@size-change="sizeChangeHandle"
@current-change="currentChangeHandle"
:current-page="pageIndex"
:page-sizes="[10, 20, 50, 100]"
:page-size="pageSize"
:total="totalPage"
layout="total, sizes, prev, pager, next, jumper"
></el-pagination>
</div>
</template>
<script>
import i18n from '@/i18n'
import BaseTable from '@/components/base-table'
import TableOperateComponent from '@/components/base-table/components/operationComponent'
import TableTextComponent from '@/components/base-table/components/detailComponent'
2022-09-20 15:59:45 +08:00
import { calcMaxHeight } from '@/utils'
import { timeFilter } from '@/utils/filters'
import moment from 'moment'
2022-09-20 15:59:45 +08:00
const tableConfigs = [
{
type: 'index',
name: i18n.t('index')
},
{ prop: 'pdlName', name: '产线名称' },
{ prop: 'wsName', name: '工序' },
{ prop: 'eqName', name: '设备' },
{ prop: 'mtbf', name: '平均故障间隔时间[MTBF] (h)', width: 220 },
{ prop: 'mttr', name: '平均维修时间[MTTR] (h)', width: 190 },
{ prop: 'workTime', name: '工作时长 (h)' },
{ prop: 'downTime', name: '故障时长 (h)' },
{ prop: 'downCount', name: '故障次数' },
2022-09-20 15:59:45 +08:00
{
prop: 'operations',
name: i18n.t('handle'),
fixed: 'right',
width: 180,
subcomponent: TableOperateComponent,
// options: ['edit', 'delete']
options: ['view-trend'] // 查看趋势
2022-09-20 15:59:45 +08:00
}
]
export default {
data() {
return {
/** hfxny part */
factoryList: [],
productLineList: [],
/** */
2022-09-20 15:59:45 +08:00
calcMaxHeight,
tableConfigs,
timeType: 'range',
rawTime: null, // [] or datetime
2022-09-20 15:59:45 +08:00
dataForm: {
type: 1,
ftId: null,
productlines: [],
startTime: null,
entTime: null
2022-09-20 15:59:45 +08:00
},
dataList: [],
pageIndex: 1,
pageSize: 10,
totalPage: 0,
dataListLoading: false
2022-09-20 15:59:45 +08:00
}
},
components: {
BaseTable
},
created() {
this.getFactoryList()
// this.getProductLineList()
2022-09-20 15:59:45 +08:00
},
watch: {},
2022-09-20 15:59:45 +08:00
methods: {
// 获取工厂列表
getFactoryList() {
2022-09-20 15:59:45 +08:00
this.$http({
url: this.$http.adornUrl('/monitoring/factory/page'),
method: 'get'
2022-09-20 15:59:45 +08:00
}).then(({ data }) => {
if (data && data.code === 0) {
this.factoryList = data.data.list
/** set default */
if (this.factoryList.length) {
this.dataForm.ftId = this.factoryList[0].id
}
} else {
this.factoryList = []
this.dataForm.ftId = null
}
2022-09-20 15:59:45 +08:00
})
},
// 获取产线列表
getProductLineList() {
2022-09-20 15:59:45 +08:00
this.$http({
url: this.$http.adornUrl('/monitoring/productionLine/page'),
method: 'get'
2022-09-20 15:59:45 +08:00
}).then(({ data }) => {
if (data && data.code === 0) {
this.productLineList = data.data.list
/** set default */
if (this.productLineList.length) {
this.dataForm.productlines = [this.productLineList[0].id]
}
} else {
this.productLineList = []
}
2022-09-20 15:59:45 +08:00
})
},
// 时间类型预处理
getTimeRange() {
let startTime
let endTime
if (this.rawTime instanceof Array) {
startTime = this.rawTime[0] ? moment(this.rawTime[0]).format('YYYY-MM-DDTHH:mm:ss') : '' // 强制axios使用北京时间
endTime = this.rawTime[1] ? moment(this.rawTime[1]).format('YYYY-MM-DDTHH:mm:ss') : ''
} else {
if (this.rawTime) {
startTime = moment(this.rawTime).format('YYYY-MM-DDTHH:mm:ss')
endTime = moment(startTime)
.add(1, 'd')
.format('YYYY-MM-DDTHH:mm:ss')
} else {
startTime = ''
endTime = ''
}
}
return { startTime, endTime }
},
2022-09-20 15:59:45 +08:00
// 获取数据列表
getDataList() {
const { startTime, endTime } = this.getTimeRange()
2022-09-20 15:59:45 +08:00
this.dataListLoading = true
this.$http({
url: this.$http.adornUrl('/monitoring/eqAnalysis/oee'),
method: 'post',
data: {
startTime,
endTime,
ftId: this.dataForm.ftId,
productlines: this.dataForm.productlines,
limit: this.pageIndex,
page: this.pageSize,
type: 1
2022-09-20 15:59:45 +08:00
}
}).then(({ data: res }) => {
console.log('oee data:', res)
2022-09-20 15:59:45 +08:00
})
},
// 每页数
sizeChangeHandle(val) {
this.pageSize = val
this.pageIndex = 1
this.getDataList()
},
// 当前页
currentChangeHandle(val) {
this.pageIndex = val
this.getDataList()
},
// 多选
selectionChangeHandle(val) {
this.dataListSelections = val
},
handleOperations({ type, data: id }) {
switch (type) {
case 'view-detail':
return this.addOrUpdateHandle(id, true)
case 'edit':
return this.addOrUpdateHandle(id)
case 'delete':
return this.deleteHandle(id)
}
}
}
}
</script>