forked from mt-fe-group/mt-yd-ui
Compare commits
No commits in common. "626e543fa580d9abbf504df82dcf0ecadf3514f5" and "37df2abcc58f57517feae231dc20e7e84e008f66" have entirely different histories.
626e543fa5
...
37df2abcc5
@ -31,7 +31,7 @@
|
|||||||
<!-- 开发环境 -->
|
<!-- 开发环境 -->
|
||||||
<% if (process.env.VUE_APP_NODE_ENV === 'dev') { %>
|
<% if (process.env.VUE_APP_NODE_ENV === 'dev') { %>
|
||||||
<script>
|
<script>
|
||||||
window.SITE_CONFIG['apiURL'] = 'http://192.168.1.28:8080';
|
window.SITE_CONFIG['apiURL'] = 'http://192.168.1.65:8080';
|
||||||
</script>
|
</script>
|
||||||
<% } %>
|
<% } %>
|
||||||
<!-- 集成测试环境 -->
|
<!-- 集成测试环境 -->
|
||||||
|
@ -24,8 +24,6 @@ export default {
|
|||||||
},
|
},
|
||||||
colors: {
|
colors: {
|
||||||
delete: '#FF5454',
|
delete: '#FF5454',
|
||||||
preview: '#f09843',
|
|
||||||
design: '#99089f'
|
|
||||||
// add more...
|
// add more...
|
||||||
},
|
},
|
||||||
text: {
|
text: {
|
||||||
@ -33,35 +31,22 @@ export default {
|
|||||||
edit: '编辑',
|
edit: '编辑',
|
||||||
detail: '详情',
|
detail: '详情',
|
||||||
delete: '删除',
|
delete: '删除',
|
||||||
viewAttr: '查看属性',
|
viewAttr: '查看属性'
|
||||||
preview: '预览',
|
|
||||||
design: '设计'
|
|
||||||
// add more...
|
// add more...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
// 发射事件
|
// 发射事件
|
||||||
emit(opt) {
|
emit(eventType) {
|
||||||
let emitFull = false
|
this.$emit('emit-data', { type: eventType, data: this.injectData.head?.emitFullData ? this.injectData : this.injectData.id })
|
||||||
let eventType = 'default'
|
|
||||||
let customField
|
|
||||||
if (typeof opt === 'object') {
|
|
||||||
eventType = opt.name
|
|
||||||
customField = opt.emitField || 'id'
|
|
||||||
emitFull = opt.emitFull || false
|
|
||||||
} else {
|
|
||||||
eventType = opt
|
|
||||||
}
|
|
||||||
this.$emit('emit-data', { type: eventType, data: emitFull ? this.injectData : customField ? this.injectData[customField] : this.injectData.id })
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
render: function (h) {
|
render: function (h) {
|
||||||
let btns = []
|
let btns = []
|
||||||
for (const optionStr of this.injectData.head?.options) {
|
for (const optionStr of this.injectData.head?.options) {
|
||||||
const optObj = typeof optionStr === 'object'
|
|
||||||
// btns.push(h('el-button', { props: { type: this.btnTypes[optionStr] } }, optionStr))
|
// btns.push(h('el-button', { props: { type: this.btnTypes[optionStr] } }, optionStr))
|
||||||
btns.push(h('el-button', { props: { type: 'text' }, style: { color: optObj ? this.colors[optionStr.name] : this.colors[optionStr] || '#409EFF' }, on: { click: this.emit.bind(null, optionStr) } }, typeof optionStr === 'object' ? this.text[optionStr.name] : this.text[optionStr]))
|
btns.push(h('el-button', { props: { type: 'text' }, style: { color: this.colors[optionStr] || '#409EFF' }, on: { click: this.emit.bind(null, optionStr) } }, this.text[optionStr]))
|
||||||
}
|
}
|
||||||
return h('span', null, btns)
|
return h('span', null, btns)
|
||||||
}
|
}
|
||||||
|
@ -1,40 +0,0 @@
|
|||||||
<template>
|
|
||||||
<el-table-column
|
|
||||||
:label="opt.label ? opt.label : opt.name"
|
|
||||||
:prop="opt.prop || null"
|
|
||||||
:width="opt.width || null"
|
|
||||||
:min-width="opt.minWidth || null"
|
|
||||||
:fixed="opt.fixed || null"
|
|
||||||
:show-overflow-tooltip="opt.showOverflowTooltip || false"
|
|
||||||
filter-placement="top"
|
|
||||||
:align="opt.align || null"
|
|
||||||
v-bind="opt.more"
|
|
||||||
>
|
|
||||||
<template v-if="opt.prop" slot-scope="scope">
|
|
||||||
<component v-if="opt.subcomponent" :is="opt.subcomponent" :key="idx + 'sub'" :inject-data="{ ...scope.row, head: opt }" @emit-data="handleSubEmitData" />
|
|
||||||
<!-- 直接展示数据或应用过滤器 -->
|
|
||||||
<span v-else>{{ scope.row[opt.prop] | commonFilter(opt.filter) }}</span>
|
|
||||||
</template>
|
|
||||||
<!-- 递归 -->
|
|
||||||
<template v-if="!opt.prop && opt.children">
|
|
||||||
<TableHead v-for="(subhead, index) in opt.children" :key="'subhead' + index" :opt="subhead" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
name: 'TableHead',
|
|
||||||
filters: {
|
|
||||||
commonFilter: (source, filterType = a => a) => {
|
|
||||||
return filterType(source)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
opt: {
|
|
||||||
type: Object,
|
|
||||||
default: () => ({})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
@ -1,14 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="base-table">
|
<div class="base-table">
|
||||||
<el-table
|
<el-table :data="data" style="width: 100%" fit border :header-cell-style="{ background: '#FAFAFA', color: '#606266', height: '40px' }" :max-height="maxHeight">
|
||||||
:data="data"
|
|
||||||
style="width: 100%"
|
|
||||||
fit
|
|
||||||
border
|
|
||||||
:header-cell-style="{ background: '#FAFAFA', color: '#606266', height: '40px' }"
|
|
||||||
:max-height="maxHeight"
|
|
||||||
:span-method="spanMethod || null"
|
|
||||||
>
|
|
||||||
<!-- 表格头定义 -->
|
<!-- 表格头定义 -->
|
||||||
<template v-for="(head, idx) in tableHeadConfigs">
|
<template v-for="(head, idx) in tableHeadConfigs">
|
||||||
<!-- 带type的表头 -->
|
<!-- 带type的表头 -->
|
||||||
@ -27,13 +19,13 @@
|
|||||||
v-else
|
v-else
|
||||||
:key="idx+'else'"
|
:key="idx+'else'"
|
||||||
:label="head.label ? head.label : head.name"
|
:label="head.label ? head.label : head.name"
|
||||||
:prop="head.prop || null"
|
:prop="head.prop"
|
||||||
:width="head.width || null"
|
:width="head.width"
|
||||||
:min-width="head.minWidth || null"
|
:min-width="head.minWidth"
|
||||||
:fixed="head.fixed || null"
|
:fixed="head.fixed"
|
||||||
:show-overflow-tooltip="head.showOverflowTooltip || false"
|
:show-overflow-tooltip="head.showOverflowTooltip || false"
|
||||||
filter-placement="top"
|
filter-placement="top"
|
||||||
:align="head.align || null"
|
:align="head.align"
|
||||||
v-bind="head.more"
|
v-bind="head.more"
|
||||||
>
|
>
|
||||||
<!-- 子组件 -->
|
<!-- 子组件 -->
|
||||||
@ -42,11 +34,6 @@
|
|||||||
<!-- 直接展示数据或应用过滤器 -->
|
<!-- 直接展示数据或应用过滤器 -->
|
||||||
<span v-else>{{ scope.row[head.prop] | commonFilter(head.filter) }}</span>
|
<span v-else>{{ scope.row[head.prop] | commonFilter(head.filter) }}</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<!-- 多级表头 -->
|
|
||||||
<template v-if="!head.prop && head.children">
|
|
||||||
<TableHead v-for="(subhead, subindex) in head.children" :key="'subhead-' + idx + '-subindex-' + subindex" :opt="subhead" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</template>
|
</template>
|
||||||
</el-table>
|
</el-table>
|
||||||
@ -54,7 +41,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import TableHead from './components/table-head.vue'
|
|
||||||
export default {
|
export default {
|
||||||
name: 'BaseTable',
|
name: 'BaseTable',
|
||||||
props: {
|
props: {
|
||||||
@ -69,13 +55,6 @@ export default {
|
|||||||
maxHeight: {
|
maxHeight: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: 500
|
default: 500
|
||||||
},
|
|
||||||
spanMethod: {
|
|
||||||
type: Function,
|
|
||||||
default: () => {
|
|
||||||
() => [0, 0]
|
|
||||||
},
|
|
||||||
required: false
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
filters: {
|
filters: {
|
||||||
@ -90,7 +69,6 @@ export default {
|
|||||||
handleSubEmitData(payload) {
|
handleSubEmitData(payload) {
|
||||||
this.$emit('operate-event', payload)
|
this.$emit('operate-event', payload)
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
components: { TableHead }
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,200 +0,0 @@
|
|||||||
<!--
|
|
||||||
* @Author: lb
|
|
||||||
* @Date: 2022-06-22 14:00:17
|
|
||||||
* @LastEditors: lb
|
|
||||||
* @LastEditTime: 2022-06-22 14:00:17
|
|
||||||
* @Description: 设备生产实时数据
|
|
||||||
-->
|
|
||||||
<template>
|
|
||||||
<div>
|
|
||||||
<div class="app-container">
|
|
||||||
<small-title :size="'md'">设备生产实时数据</small-title>
|
|
||||||
<base-table v-if="loadTable" :table-head-configs="tableProps" :data="tableData.length ? tableData : []" :span-method="spanMethod" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import BaseTable from '@/components/base-table'
|
|
||||||
import SmallTitle from '@/components/small-title'
|
|
||||||
import moment from 'moment'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'RealtimeDataOfEquipment',
|
|
||||||
components: { BaseTable, SmallTitle },
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
loadTable: false,
|
|
||||||
tableProps: [{ label: 'default', prop: 'default' }],
|
|
||||||
stepOneArray: [],
|
|
||||||
tableData: [],
|
|
||||||
testData: null,
|
|
||||||
equipmentCount: {}, // 每个产线的设备数量记录
|
|
||||||
dynamicPropSet: false, // 是否设置过动态prop
|
|
||||||
listLoading: false,
|
|
||||||
rowNum: 0,
|
|
||||||
intervalId: null
|
|
||||||
}
|
|
||||||
},
|
|
||||||
created() {
|
|
||||||
this.clearData()
|
|
||||||
this.fetchList().then(({ data: res }) => {
|
|
||||||
this.testData = res.data.filter(item => !!item.equDet)
|
|
||||||
this.handleData()
|
|
||||||
})
|
|
||||||
this.intervalId = setInterval(() => {
|
|
||||||
this.$message({
|
|
||||||
type: 'warning',
|
|
||||||
duration: 1500,
|
|
||||||
onClose: () => {
|
|
||||||
this.clearData()
|
|
||||||
this.fetchList().then(({ data: res }) => {
|
|
||||||
this.testData = res.data.filter(item => !!item.equDet)
|
|
||||||
this.handleData()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}, 1000 * 60 * 5)
|
|
||||||
},
|
|
||||||
beforeDestroy() {
|
|
||||||
if (this.intervalId) clearInterval(this.intervalId)
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
clearData() {
|
|
||||||
this.tableData.splice(0)
|
|
||||||
this.tableProps.splice(0)
|
|
||||||
this.stepOneArray.splice(0)
|
|
||||||
this.dynamicPropSet = false
|
|
||||||
this.rowNum = 0
|
|
||||||
this.testData = null
|
|
||||||
this.loadTable = false
|
|
||||||
this.equipmentCount = {}
|
|
||||||
this.setStaticTableProps()
|
|
||||||
},
|
|
||||||
|
|
||||||
handleData() {
|
|
||||||
this.expandDataStepOne()
|
|
||||||
this.expandDataStepTwo()
|
|
||||||
this.loadTable = true
|
|
||||||
},
|
|
||||||
|
|
||||||
fetchList() {
|
|
||||||
// 获取设备实时数据
|
|
||||||
return this.$http({
|
|
||||||
url: this.$http.adornUrl('/monitoring/productionMonitoring/equipmentProductionRealTimeData'),
|
|
||||||
method: 'post'
|
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
expandDataStepOne() {
|
|
||||||
// console.log('testdata: ', this.testData)
|
|
||||||
this.stepOneArray = this.testData.map(item => {
|
|
||||||
if (item.equDet) {
|
|
||||||
item.equDet.forEach((equipment, index) => {
|
|
||||||
equipment.lineName = item.lineName
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return item.equDet
|
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
expandDataStepTwo() {
|
|
||||||
// 扩展服务器返回的数据第二阶段
|
|
||||||
this.rowNum = 0
|
|
||||||
|
|
||||||
this.stepOneArray.forEach(line => {
|
|
||||||
let avaliableEquipmentCount = 0
|
|
||||||
|
|
||||||
line.forEach(equipment => {
|
|
||||||
const newItem = {
|
|
||||||
equId: equipment.equId,
|
|
||||||
lineName: equipment.lineName,
|
|
||||||
equName: equipment.equName,
|
|
||||||
externalCode: equipment.externalCode,
|
|
||||||
totalProduction: equipment.totalProduction ?? '-'
|
|
||||||
}
|
|
||||||
|
|
||||||
if (equipment.det) {
|
|
||||||
avaliableEquipmentCount += 1
|
|
||||||
equipment.det.forEach(obj => {
|
|
||||||
if (!this.dynamicPropSet) {
|
|
||||||
if (obj.recordTime) {
|
|
||||||
// 如果 obj.recordTime 是有效的
|
|
||||||
this.tableProps.push({
|
|
||||||
label: moment(obj.recordTime).format('YYYY-MM-DD HH:mm:ss'),
|
|
||||||
children: [
|
|
||||||
{ prop: obj.recordTime + '-inputNum', label: '进数据' },
|
|
||||||
{ prop: obj.recordTime + '-outputNum', label: '出数据' },
|
|
||||||
{ prop: obj.recordTime + '-scrapNum', label: '报废数据' },
|
|
||||||
{ prop: obj.recordTime + '-scrapRate', label: '报废比例' }
|
|
||||||
]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Object.defineProperty(newItem, obj.recordTime + '-inputNum', {
|
|
||||||
value: obj.inputNum ?? '-',
|
|
||||||
enumerable: true,
|
|
||||||
writable: true
|
|
||||||
})
|
|
||||||
Object.defineProperty(newItem, obj.recordTime + '-outputNum', {
|
|
||||||
value: obj.outputNum ?? '-',
|
|
||||||
enumerable: true,
|
|
||||||
writable: true
|
|
||||||
})
|
|
||||||
Object.defineProperty(newItem, obj.recordTime + '-scrapNum', {
|
|
||||||
value: obj.scrapNum ?? '-',
|
|
||||||
enumerable: true,
|
|
||||||
writable: true
|
|
||||||
})
|
|
||||||
Object.defineProperty(newItem, obj.recordTime + '-scrapRate', {
|
|
||||||
value: obj.scrapRate ?? '-',
|
|
||||||
enumerable: true,
|
|
||||||
writable: true
|
|
||||||
})
|
|
||||||
Object.defineProperty(newItem, 'recordTime', {
|
|
||||||
value: obj.recordTime,
|
|
||||||
enumerable: true,
|
|
||||||
writable: true
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
if (!this.dynamicPropSet) this.dynamicPropSet = true
|
|
||||||
this.tableData.push(newItem)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
this.$set(this.equipmentCount, [this.rowNum], avaliableEquipmentCount)
|
|
||||||
this.rowNum += avaliableEquipmentCount
|
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
setStaticTableProps() {
|
|
||||||
// Step1: 设置静态的 table props
|
|
||||||
const staticTableProps = [
|
|
||||||
{ prop: 'lineName', label: '产线', fixed: true },
|
|
||||||
{ prop: 'equName', label: '设备', fixed: true },
|
|
||||||
{ prop: 'totalProduction', label: '总产量', fixed: true }
|
|
||||||
]
|
|
||||||
this.tableProps = staticTableProps
|
|
||||||
},
|
|
||||||
|
|
||||||
spanMethod({ row, column, rowIndex, columnIndex }) {
|
|
||||||
// 设置合并行列的方式
|
|
||||||
if (columnIndex === 0) {
|
|
||||||
if (this.equipmentCount[rowIndex]) {
|
|
||||||
// 如果找到需要合并的行号
|
|
||||||
return {
|
|
||||||
rowspan: this.equipmentCount[rowIndex],
|
|
||||||
colspan: 1
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return {
|
|
||||||
rowspan: 0,
|
|
||||||
colspan: 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
@ -1,162 +0,0 @@
|
|||||||
<!--
|
|
||||||
* @Author: lb
|
|
||||||
* @Date: 2022-06-22 14:00:17
|
|
||||||
* @LastEditors: lb
|
|
||||||
* @LastEditTime: 2022-06-22 14:00:17
|
|
||||||
* @Description: 产线生产实时数据
|
|
||||||
-->
|
|
||||||
<template>
|
|
||||||
<div>
|
|
||||||
<div class="app-container">
|
|
||||||
<small-title :size="'md'">产线生产实时数据</small-title>
|
|
||||||
<base-table v-if="loadTable" :table-head-configs="tableProps" :data="tableData.length ? tableData : []" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import BaseTable from '@/components/base-table'
|
|
||||||
import SmallTitle from '@/components/small-title'
|
|
||||||
import moment from 'moment'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'RealtimeDataOfLine',
|
|
||||||
components: { BaseTable, SmallTitle },
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
loadTable: false,
|
|
||||||
dynamicPropSet: false,
|
|
||||||
tableProps: [{ label: 'default', prop: 'default' }],
|
|
||||||
tableData: [],
|
|
||||||
testData: null,
|
|
||||||
listLoading: false,
|
|
||||||
intervalId: null
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
mounted() {
|
|
||||||
this.clearData()
|
|
||||||
this.fetchList().then(({ data: res }) => {
|
|
||||||
// console.log('fetchlist:', res)
|
|
||||||
this.testData = res
|
|
||||||
this.handleData()
|
|
||||||
})
|
|
||||||
|
|
||||||
this.intervalId = setInterval(() => {
|
|
||||||
this.$message({
|
|
||||||
message: this.$t('module.factory.realtime.productLine.refresh'),
|
|
||||||
type: 'warning',
|
|
||||||
onClose: () => {
|
|
||||||
this.clearData()
|
|
||||||
this.fetchList().then(res => {
|
|
||||||
this.testData = res
|
|
||||||
this.handleData()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}, 1000 * 60 * 5)
|
|
||||||
},
|
|
||||||
|
|
||||||
beforeDestroy() {
|
|
||||||
if (this.intervalId) clearInterval(this.intervalId)
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
|
||||||
fetchList() {
|
|
||||||
return this.$http({
|
|
||||||
url: this.$http.adornUrl('/monitoring/productionMonitoring/lineProductionRealTimeData'),
|
|
||||||
method: 'post'
|
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
clearData() {
|
|
||||||
this.dynamicPropSet = false
|
|
||||||
this.loadTable = false
|
|
||||||
this.testData = null
|
|
||||||
this.tableData.splice(0)
|
|
||||||
this.tableProps.splice(0)
|
|
||||||
this.setStaticTableProps()
|
|
||||||
},
|
|
||||||
|
|
||||||
handleData() {
|
|
||||||
this.expandDataStepOne()
|
|
||||||
// this.expandDataStepTwo()
|
|
||||||
if (this.tableData.length > 0) this.loadTable = true
|
|
||||||
else {
|
|
||||||
this.$message({
|
|
||||||
message: '没有查询到相关数据!',
|
|
||||||
type: 'error',
|
|
||||||
duration: 2000
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
expandDataStepOne() {
|
|
||||||
// 扩展服务器返回的数据第一阶段
|
|
||||||
// console.log('create new one')
|
|
||||||
this.tableData = this.testData.data.map(item => {
|
|
||||||
const newItem = {
|
|
||||||
lineName: item.lineName,
|
|
||||||
orderName: item.orderName,
|
|
||||||
productSize: item.productSize ?? '-'
|
|
||||||
}
|
|
||||||
|
|
||||||
if (item.det) {
|
|
||||||
item.det.forEach(obj => {
|
|
||||||
// Step2: 设置动态props
|
|
||||||
if (!this.dynamicPropSet) {
|
|
||||||
this.tableProps.push({
|
|
||||||
label: moment(obj.recordTime).format('YYYY-MM-DD HH:mm:ss'),
|
|
||||||
children: [
|
|
||||||
{ prop: obj.recordTime + '-inputNum', label: '进数据' },
|
|
||||||
{ prop: obj.recordTime + '-outputNum', label: '出数据' },
|
|
||||||
{ prop: obj.recordTime + '-passArea', label: '良品率' },
|
|
||||||
{ prop: obj.recordTime + '-scrapNum', label: '报废数量' },
|
|
||||||
{ prop: obj.recordTime + '-scrapRate', label: '报废比例' }
|
|
||||||
]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
Object.defineProperty(newItem, obj.recordTime + '-inputNum', {
|
|
||||||
value: obj.inputNum ?? '-',
|
|
||||||
enumerable: true,
|
|
||||||
writable: true
|
|
||||||
})
|
|
||||||
Object.defineProperty(newItem, obj.recordTime + '-outputNum', {
|
|
||||||
value: obj.outputNum ?? '-',
|
|
||||||
enumerable: true,
|
|
||||||
writable: true
|
|
||||||
})
|
|
||||||
Object.defineProperty(newItem, obj.recordTime + '-scrapNum', {
|
|
||||||
value: obj.scrapNum ?? '-',
|
|
||||||
enumerable: true,
|
|
||||||
writable: true
|
|
||||||
})
|
|
||||||
|
|
||||||
const scrapRate = obj.scrapRate ?? '-'
|
|
||||||
Object.defineProperty(newItem, obj.recordTime + '-scrapRate', {
|
|
||||||
value: scrapRate === '-' ? '-' : scrapRate * 100 + '%',
|
|
||||||
enumerable: true,
|
|
||||||
writable: true
|
|
||||||
})
|
|
||||||
Object.defineProperty(newItem, obj.recordTime + '-passArea', {
|
|
||||||
value: obj.passArea ?? '-',
|
|
||||||
enumerable: true,
|
|
||||||
writable: true
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
this.dynamicPropSet = true
|
|
||||||
return newItem
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
setStaticTableProps() {
|
|
||||||
// Step1: 设置静态的 table props
|
|
||||||
const staticTableProps = [{ prop: 'lineName', label: '产线', fixed: true }]
|
|
||||||
this.tableProps = staticTableProps
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
@ -1,145 +0,0 @@
|
|||||||
<!--
|
|
||||||
* @Author: lb
|
|
||||||
* @Date: 2022-06-22 14:00:17
|
|
||||||
* @LastEditors: lb
|
|
||||||
* @LastEditTime: 2022-06-22 14:00:17
|
|
||||||
* @Description: 质量检查实时数据
|
|
||||||
-->
|
|
||||||
<template>
|
|
||||||
<div>
|
|
||||||
<div class="app-container">
|
|
||||||
<small-title :size="'md'">质量检查实时数据</small-title>
|
|
||||||
<base-table v-if="loadTable" :table-head-configs="tableProps" :data="tableData.length ? tableData : []" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import BaseTable from '@/components/base-table'
|
|
||||||
import SmallTitle from '@/components/small-title'
|
|
||||||
import moment from 'moment'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'RealtimeDataOfTeam',
|
|
||||||
components: { BaseTable, SmallTitle },
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
loadTable: false,
|
|
||||||
// dynamicPropSet: false,
|
|
||||||
tableProps: [{ label: 'default', prop: 'default' }],
|
|
||||||
tableData: [],
|
|
||||||
testData: null,
|
|
||||||
listLoading: false,
|
|
||||||
intervalId: null
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
mounted() {
|
|
||||||
this.clearData()
|
|
||||||
|
|
||||||
this.fetchList().then(({ data: res }) => {
|
|
||||||
this.testData = res
|
|
||||||
this.handleData()
|
|
||||||
})
|
|
||||||
|
|
||||||
this.intervalId = setInterval(() => {
|
|
||||||
this.clearData()
|
|
||||||
this.fetchList().then(res => {
|
|
||||||
this.testData = res
|
|
||||||
this.handleData()
|
|
||||||
})
|
|
||||||
}, 1000 * 60 * 5)
|
|
||||||
},
|
|
||||||
|
|
||||||
beforeDestroy() {
|
|
||||||
if (this.intervalId) clearInterval(this.intervalId)
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
|
||||||
fetchList() {
|
|
||||||
// 获取质量数据
|
|
||||||
return this.$http({
|
|
||||||
url: this.$http.adornUrl('/monitoring/productionMonitoring/qualityInspectionRealTimeData'),
|
|
||||||
method: 'post'
|
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
clearData() {
|
|
||||||
this.loadTable = false
|
|
||||||
this.testData = null
|
|
||||||
this.tableData.splice(0)
|
|
||||||
this.tableProps.splice(0)
|
|
||||||
},
|
|
||||||
|
|
||||||
handleData() {
|
|
||||||
// console.log('testData ===> ', this.testData)
|
|
||||||
this.initProps()
|
|
||||||
// console.log('props ===> ', this.tableProps)
|
|
||||||
this.initData()
|
|
||||||
// console.log('datas ===> ', this.tableData)
|
|
||||||
this.loadTable = true
|
|
||||||
},
|
|
||||||
|
|
||||||
handleRow(data) {
|
|
||||||
// data: { data:[], checkType: '' }
|
|
||||||
const item = {}
|
|
||||||
item.checkType = data.checkType
|
|
||||||
|
|
||||||
data.data.forEach(timepoint => {
|
|
||||||
if (timepoint.children && timepoint.children.length) {
|
|
||||||
timepoint.children.forEach(line => {
|
|
||||||
// item[timepoint.dynamicValue + line.dynamicName] = line.dynamicValue
|
|
||||||
item[timepoint.dynamicName + line.dynamicName] = line.dynamicValue
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
return item
|
|
||||||
},
|
|
||||||
|
|
||||||
initData() {
|
|
||||||
this.tableData = this.testData.data.data.map(row => this.handleRow(row))
|
|
||||||
},
|
|
||||||
|
|
||||||
initProps() {
|
|
||||||
this.tableProps = this.handlePropsEntry(this.testData.data.nameData)
|
|
||||||
},
|
|
||||||
|
|
||||||
handlePropsEntry(nameData) {
|
|
||||||
const dynamicPropNames = []
|
|
||||||
const timeMap = {}
|
|
||||||
|
|
||||||
const parentNode = nameData.filter(item => item.tree === 1)
|
|
||||||
const childNode = nameData.filter(item => item.tree === 2)
|
|
||||||
|
|
||||||
const handleChild = function(prop) {
|
|
||||||
const time = parentNode.find(item => item.id === prop.parentId).name
|
|
||||||
// 填充 timeMap
|
|
||||||
timeMap[time] = timeMap[time] ? timeMap[time] : {}
|
|
||||||
timeMap[time][prop.name] = true
|
|
||||||
}
|
|
||||||
|
|
||||||
childNode.forEach(item => {
|
|
||||||
handleChild(item)
|
|
||||||
})
|
|
||||||
|
|
||||||
// 对键值排序(时间排序)
|
|
||||||
const sortedTime = Object.keys(timeMap).sort((a, b) => {
|
|
||||||
if (moment(a).isBefore(b)) return -1
|
|
||||||
else return 1
|
|
||||||
})
|
|
||||||
|
|
||||||
// 保存为 props
|
|
||||||
for (const key of sortedTime) {
|
|
||||||
const prop = { label: key, children: [] }
|
|
||||||
for (const subKey in timeMap[key]) {
|
|
||||||
prop.children.push({ label: subKey, prop: key + subKey })
|
|
||||||
}
|
|
||||||
dynamicPropNames.push(prop)
|
|
||||||
}
|
|
||||||
|
|
||||||
return [{ prop: 'checkType', label: '检查类型', isFixed: true }, ...dynamicPropNames]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
@ -6,8 +6,7 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button @click="getDataList()">查询</el-button>
|
<el-button @click="getDataList()">查询</el-button>
|
||||||
<!-- <el-button v-if="$hasPermission('')" type="primary" @click="addOrUpdateHandle()">新增(跳到设计)</el-button> -->
|
<el-button v-if="$hasPermission('')" type="primary" @click="addOrUpdateHandle()">新增(跳到设计)</el-button>
|
||||||
<el-button type="primary" @click="handleAdd()">新增</el-button>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
@ -50,37 +49,82 @@ const CategoryList = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
console.log(this.injectData)
|
|
||||||
this.pickedId = this.injectData[this.injectData.head.prop]
|
this.pickedId = this.injectData[this.injectData.head.prop]
|
||||||
|
console.log('picked id : ', this.pickedId)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleChange(id) {
|
handleChange(id) {
|
||||||
this.pickedId = id
|
this.pickedId = id
|
||||||
this.$emit('emit-data', {
|
this.$emit('emit-data', { id })
|
||||||
type: 'change-category',
|
|
||||||
data: { id: this.injectData.id, fileName: this.injectData.fileName, name: this.injectData.name, url: this.injectData.url, categoryId: id }
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
render: function(h) {
|
render: function(h) {
|
||||||
const childOptions = []
|
const childOptions = []
|
||||||
this.injectData.head.options?.forEach(item => {
|
this.injectData.head.options?.forEach(item => {
|
||||||
console.log('item', item.value)
|
console.log('item', item)
|
||||||
childOptions.push(h('el-option', { props: { label: item.label, value: item.value } }, null))
|
childOptions.push(h('el-option', { props: { label: item.label, value: item.value } }, null)) // TODO:<=== 去他妈的
|
||||||
})
|
})
|
||||||
return h('el-select', { props: { value: this.pickedId }, on: { change: this.handleChange } }, childOptions)
|
return h('el-select', { on: { change: this.handleChange } }, childOptions)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const addOrUpdateConfigs = {
|
const addOrUpdateConfigs = {
|
||||||
type: 'dialog',
|
type: 'dialog',
|
||||||
infoUrl: '/monitoring/reportSheet',
|
infoUrl: '/monitoring/equipmentPlcConnect',
|
||||||
fields: [{ name: 'fileName', label: '报表名称', required: true, span: 24 }],
|
fields: [
|
||||||
|
{ name: 'equipmentId', label: '设备', required: true, type: 'select', options: [] },
|
||||||
|
{ name: 'plcId', label: 'PLC名称', required: true, type: 'select', options: [] }
|
||||||
|
],
|
||||||
operations: [
|
operations: [
|
||||||
{ name: 'cancel', url: true, showAlways: true },
|
{ name: 'cancel', url: true, showAlways: true },
|
||||||
{ name: 'save', url: '/monitoring/reportSheet', permission: '', showOnEdit: false },
|
{ name: 'save', url: '/monitoring/equipmentPlcConnect', permission: '', showOnEdit: false },
|
||||||
{ name: 'update', url: '/monitoring/reportSheet', permission: '', showOnEdit: true }
|
{ name: 'update', url: '/monitoring/equipmentPlcConnect', permission: '', showOnEdit: true }
|
||||||
|
],
|
||||||
|
subtable: {
|
||||||
|
title: 'PLC采集参数',
|
||||||
|
url: '/monitoring/equipmentPlcParam',
|
||||||
|
relatedField: 'plcConId',
|
||||||
|
tableConfigs: [
|
||||||
|
{ type: 'index', name: '序号' },
|
||||||
|
// { prop: 'plcConId', name: 'plc连接表ID' },
|
||||||
|
{ prop: 'paramCode', name: '参数编码', formField: true, rules: [{ required: true, message: '必填', trigger: 'blur' }] },
|
||||||
|
{ prop: 'paramName', name: '参数名称', formField: true, rules: [{ required: true, message: '必填', trigger: 'blur' }] },
|
||||||
|
{ prop: 'paramAddress', name: '参数地址', formField: true },
|
||||||
|
{ prop: 'description', name: '描述', formField: true },
|
||||||
|
{
|
||||||
|
prop: 'enabled',
|
||||||
|
name: '启用状态',
|
||||||
|
filter: val => ['停用', '启用'][+val],
|
||||||
|
// filter: val => ({0:'停用', 1:'启用'}[+val]),
|
||||||
|
rules: [{ required: true, message: '必填', trigger: 'blur' }],
|
||||||
|
formField: true,
|
||||||
|
formType: 'select',
|
||||||
|
formOptions: [
|
||||||
|
{ value: 0, label: '停用' },
|
||||||
|
{ value: 1, label: '启用' }
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{ prop: 'remark', name: '备注', formField: true },
|
||||||
|
// { prop: 'createTime', name: '添加时间' },
|
||||||
|
{
|
||||||
|
prop: 'collection',
|
||||||
|
name: '是否采集',
|
||||||
|
filter: val => ['不采集', '采集'][+val],
|
||||||
|
rules: [{ required: true, message: '必填', trigger: 'blur' }],
|
||||||
|
formField: true,
|
||||||
|
formType: 'select',
|
||||||
|
formOptions: [
|
||||||
|
{ value: 0, label: '不采集' },
|
||||||
|
{ value: 1, label: '采集' }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
// { prop: 'collectionCycle', name: '采集周期(s) 暂不使用' },
|
||||||
|
// { prop: 'reportingCycle', name: '上报周期(s) 暂不使用' },
|
||||||
|
// { prop: 'reportingMethod', name: '上报方式 暂不使用' },
|
||||||
|
// { prop: 'reportingCode', name: '上报编码 暂不使用' },
|
||||||
|
{ prop: 'operations', name: '操作', fixed: 'right', width: 180, subcomponent: TableOperateComponent, options: ['edit', 'delete'] }
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -105,89 +149,46 @@ export default {
|
|||||||
BaseTable
|
BaseTable
|
||||||
},
|
},
|
||||||
activated() {
|
activated() {
|
||||||
this.dataList.splice(0)
|
|
||||||
this.getAllCategories()
|
this.getAllCategories()
|
||||||
this.getDataList()
|
this.getDataList()
|
||||||
},
|
},
|
||||||
computed: {},
|
computed: {
|
||||||
|
trueTableConfigs() {}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getAllCategories() {
|
getAllCategories() {
|
||||||
axios.get(axios.adornUrl('/monitoring/reportSheetCategory/page')).then(({ data: res }) => {
|
axios.get(axios.adornUrl('/monitoring/reportSheetCategory/page')).then(({ data: res }) => {
|
||||||
if (res.data && res.data.list) {
|
if (res.data && res.data.list) {
|
||||||
const categories = res.data.list.map(item => ({ label: item.name, value: item.id }))
|
const categories = res.data.list.map(item => ({ label: item.name, value: item.id }))
|
||||||
|
console.log('categories', categories)
|
||||||
this.tableConfigs = [
|
this.tableConfigs = [
|
||||||
{ type: 'index', name: '序号' },
|
{ type: 'index', name: '序号' },
|
||||||
{ prop: 'createTime', name: '创建时间', width: 200 },
|
|
||||||
{ prop: 'fileName', name: '报表名称' },
|
{ prop: 'fileName', name: '报表名称' },
|
||||||
{ prop: 'category', name: '报表分类', subcomponent: CategoryList, options: categories },
|
{ prop: 'category', name: '报表分类', subcomponent: CategoryList, options: categories },
|
||||||
{
|
{ prop: 'operations', name: '操作', fixed: 'right', width: 180, subcomponent: TableOperateComponent, options: ['edit', 'delete'] }
|
||||||
prop: 'operations',
|
|
||||||
name: '操作',
|
|
||||||
fixed: 'right',
|
|
||||||
width: 180,
|
|
||||||
subcomponent: TableOperateComponent,
|
|
||||||
options: [{ name: 'preview', emitField: 'fileName' }, { name: 'design', emitField: 'name' }, 'edit', 'delete']
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
handleOperations({ type, data }) {
|
handleOperations({ type, data: id }) {
|
||||||
console.log('operation data: ', data)
|
|
||||||
let id = data
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'change-category':
|
|
||||||
return this.updateCategory(data)
|
|
||||||
case 'edit':
|
case 'edit':
|
||||||
return this.addOrUpdateHandle(id)
|
return this.addOrUpdateHandle(id)
|
||||||
case 'delete':
|
case 'delete':
|
||||||
return this.deleteHandle(id)
|
return this.deleteHandle(id)
|
||||||
case 'design':
|
|
||||||
return this.$router.push({
|
|
||||||
name: 'monitoring-reportDesign',
|
|
||||||
query: {
|
|
||||||
// data 的数据是 emitField 的值
|
|
||||||
name: data
|
|
||||||
}
|
}
|
||||||
})
|
|
||||||
case 'preview':
|
|
||||||
return this.$router.push({
|
|
||||||
name: 'monitoring-reportPreview',
|
|
||||||
query: {
|
|
||||||
name: data
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
updateCategory({ id, fileName, categoryId }) {
|
|
||||||
this.$http({
|
|
||||||
url: this.$http.adornUrl('/monitoring/reportSheet'),
|
|
||||||
method: 'put',
|
|
||||||
data: {
|
|
||||||
id,
|
|
||||||
fileName,
|
|
||||||
category: categoryId
|
|
||||||
}
|
|
||||||
}).then(({ data: res }) => {
|
|
||||||
this.$message.success('修改成功!')
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
// 获取数据列表
|
// 获取数据列表
|
||||||
getDataList() {
|
getDataList() {
|
||||||
this.dataListLoading = true
|
this.dataListLoading = true
|
||||||
|
|
||||||
const queries = {
|
|
||||||
page: this.pageIndex,
|
|
||||||
limit: this.pageSize,
|
|
||||||
key: this.dataForm.key
|
|
||||||
}
|
|
||||||
if (this.$route.query.category) {
|
|
||||||
queries['category'] = this.$route.query.category
|
|
||||||
}
|
|
||||||
this.$http({
|
this.$http({
|
||||||
url: this.$http.adornUrl('/monitoring/reportSheet/page'),
|
url: this.$http.adornUrl('/monitoring/reportSheet/page'),
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: this.$http.adornParams(queries)
|
params: this.$http.adornParams({
|
||||||
|
page: this.pageIndex,
|
||||||
|
limit: this.pageSize,
|
||||||
|
key: this.dataForm.key
|
||||||
|
})
|
||||||
}).then(({ data }) => {
|
}).then(({ data }) => {
|
||||||
if (data && data.code === 0) {
|
if (data && data.code === 0) {
|
||||||
this.dataList = data.data.list
|
this.dataList = data.data.list
|
||||||
@ -214,14 +215,8 @@ export default {
|
|||||||
selectionChangeHandle(val) {
|
selectionChangeHandle(val) {
|
||||||
this.dataListSelections = val
|
this.dataListSelections = val
|
||||||
},
|
},
|
||||||
// 新增 - 跳转到设计
|
// 新增 / 修改
|
||||||
handleAdd() {
|
|
||||||
this.$router.push({
|
|
||||||
name: 'monitoring-reportDesign'
|
|
||||||
})
|
|
||||||
},
|
|
||||||
addOrUpdateHandle(id) {
|
addOrUpdateHandle(id) {
|
||||||
console.log('edit:', id)
|
|
||||||
this.addOrUpdateVisible = true
|
this.addOrUpdateVisible = true
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$refs.addOrUpdate.init(id)
|
this.$refs.addOrUpdate.init(id)
|
||||||
|
@ -58,7 +58,7 @@ export default {
|
|||||||
this.$router.push({
|
this.$router.push({
|
||||||
name: 'monitoring-reportDetail',
|
name: 'monitoring-reportDetail',
|
||||||
query: {
|
query: {
|
||||||
category: id
|
sortId: id
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -7,16 +7,14 @@
|
|||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
<div v-loading="loading" :class="$style.container">
|
<div v-loading="loading" :class="$style.container">
|
||||||
<small-title :size="'md'" style="margin-bottom: 10px">报表名称:{{ $route.query.name }}</small-title>
|
<h1 >{{ $route.query.name }}</h1>
|
||||||
|
|
||||||
<iframe id="reportView" :class="$style.mainIframe" name="mainIframe" :src="url" frameborder="0" scrolling="auto" />
|
<iframe id="reportView" :class="$style.mainIframe" name="mainIframe" :src="url" frameborder="0" scrolling="auto" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import SmallTitle from '@/components/small-title'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: { SmallTitle },
|
components: {},
|
||||||
props: {},
|
props: {},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -1,41 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div style="background: #ccc; width: 800px; height: 800px;">
|
|
||||||
<base-table :table-head-configs="configs" :data="dataList" />
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import BaseTable from '@/components/base-table'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'Test',
|
|
||||||
components: { BaseTable },
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
configs: [
|
|
||||||
{ prop: 'createTime', name: '创建日期' },
|
|
||||||
{ prop: 'name', name: '名称' },
|
|
||||||
{
|
|
||||||
label: '地址',
|
|
||||||
children: [
|
|
||||||
{ prop: 'province', name: '省' },
|
|
||||||
{
|
|
||||||
// prop: 'city',
|
|
||||||
name: '市',
|
|
||||||
children: [
|
|
||||||
{ prop: 'county', name: '县' },
|
|
||||||
{ prop: 'downtown', name: '镇' }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{ prop: 'status', name: '状态', filter: val => ['激活', '注销'][val] }
|
|
||||||
],
|
|
||||||
dataList: [
|
|
||||||
{ createTime: '2022-01-01', name: '奥特曼', province: '北京', city: '昌平', county: '怀宁', downtown: '石牌', status: 0 },
|
|
||||||
{ createTime: '2022-01-02', name: '盈江', province: '上海', city: '徐家汇', status: 1 }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
Loading…
Reference in New Issue
Block a user