forked from mt-fe-group/mt-yd-ui
Compare commits
10 Commits
37df2abcc5
...
626e543fa5
Author | SHA1 | Date | |
---|---|---|---|
626e543fa5 | |||
2e40570969 | |||
70485d293c | |||
6bbc0d3d08 | |||
8f124e06b1 | |||
4297798d44 | |||
9a22601f5b | |||
69dda72fab | |||
0b4433dd80 | |||
a30e2e1ae2 |
@ -31,7 +31,7 @@
|
||||
<!-- 开发环境 -->
|
||||
<% if (process.env.VUE_APP_NODE_ENV === 'dev') { %>
|
||||
<script>
|
||||
window.SITE_CONFIG['apiURL'] = 'http://192.168.1.65:8080';
|
||||
window.SITE_CONFIG['apiURL'] = 'http://192.168.1.28:8080';
|
||||
</script>
|
||||
<% } %>
|
||||
<!-- 集成测试环境 -->
|
||||
|
@ -24,6 +24,8 @@ export default {
|
||||
},
|
||||
colors: {
|
||||
delete: '#FF5454',
|
||||
preview: '#f09843',
|
||||
design: '#99089f'
|
||||
// add more...
|
||||
},
|
||||
text: {
|
||||
@ -31,22 +33,35 @@ export default {
|
||||
edit: '编辑',
|
||||
detail: '详情',
|
||||
delete: '删除',
|
||||
viewAttr: '查看属性'
|
||||
viewAttr: '查看属性',
|
||||
preview: '预览',
|
||||
design: '设计'
|
||||
// add more...
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 发射事件
|
||||
emit(eventType) {
|
||||
this.$emit('emit-data', { type: eventType, data: this.injectData.head?.emitFullData ? this.injectData : this.injectData.id })
|
||||
emit(opt) {
|
||||
let emitFull = false
|
||||
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) {
|
||||
let btns = []
|
||||
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: 'text' }, style: { color: this.colors[optionStr] || '#409EFF' }, on: { click: this.emit.bind(null, optionStr) } }, this.text[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]))
|
||||
}
|
||||
return h('span', null, btns)
|
||||
}
|
||||
|
40
src/components/base-table/components/table-head.vue
Normal file
40
src/components/base-table/components/table-head.vue
Normal file
@ -0,0 +1,40 @@
|
||||
<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,6 +1,14 @@
|
||||
<template>
|
||||
<div class="base-table">
|
||||
<el-table :data="data" style="width: 100%" fit border :header-cell-style="{ background: '#FAFAFA', color: '#606266', height: '40px' }" :max-height="maxHeight">
|
||||
<el-table
|
||||
: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">
|
||||
<!-- 带type的表头 -->
|
||||
@ -17,15 +25,15 @@
|
||||
<!-- 普通的表头 -->
|
||||
<el-table-column
|
||||
v-else
|
||||
:key="idx+'else'"
|
||||
:key="idx + 'else'"
|
||||
:label="head.label ? head.label : head.name"
|
||||
:prop="head.prop"
|
||||
:width="head.width"
|
||||
:min-width="head.minWidth"
|
||||
:fixed="head.fixed"
|
||||
:prop="head.prop || null"
|
||||
:width="head.width || null"
|
||||
:min-width="head.minWidth || null"
|
||||
:fixed="head.fixed || null"
|
||||
:show-overflow-tooltip="head.showOverflowTooltip || false"
|
||||
filter-placement="top"
|
||||
:align="head.align"
|
||||
:align="head.align || null"
|
||||
v-bind="head.more"
|
||||
>
|
||||
<!-- 子组件 -->
|
||||
@ -34,6 +42,11 @@
|
||||
<!-- 直接展示数据或应用过滤器 -->
|
||||
<span v-else>{{ scope.row[head.prop] | commonFilter(head.filter) }}</span>
|
||||
</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>
|
||||
</template>
|
||||
</el-table>
|
||||
@ -41,6 +54,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import TableHead from './components/table-head.vue'
|
||||
export default {
|
||||
name: 'BaseTable',
|
||||
props: {
|
||||
@ -55,6 +69,13 @@ export default {
|
||||
maxHeight: {
|
||||
type: Number,
|
||||
default: 500
|
||||
},
|
||||
spanMethod: {
|
||||
type: Function,
|
||||
default: () => {
|
||||
() => [0, 0]
|
||||
},
|
||||
required: false
|
||||
}
|
||||
},
|
||||
filters: {
|
||||
@ -69,6 +90,7 @@ export default {
|
||||
handleSubEmitData(payload) {
|
||||
this.$emit('operate-event', payload)
|
||||
}
|
||||
}
|
||||
},
|
||||
components: { TableHead }
|
||||
}
|
||||
</script>
|
||||
|
200
src/views/modules/monitoring/realtimeEquipment.vue
Normal file
200
src/views/modules/monitoring/realtimeEquipment.vue
Normal file
@ -0,0 +1,200 @@
|
||||
<!--
|
||||
* @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>
|
162
src/views/modules/monitoring/realtimeProductLine.vue
Normal file
162
src/views/modules/monitoring/realtimeProductLine.vue
Normal file
@ -0,0 +1,162 @@
|
||||
<!--
|
||||
* @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>
|
145
src/views/modules/monitoring/realtimeQualityInspection.vue
Normal file
145
src/views/modules/monitoring/realtimeQualityInspection.vue
Normal file
@ -0,0 +1,145 @@
|
||||
<!--
|
||||
* @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,7 +6,8 @@
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<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>
|
||||
|
||||
@ -49,82 +50,37 @@ const CategoryList = {
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
console.log(this.injectData)
|
||||
this.pickedId = this.injectData[this.injectData.head.prop]
|
||||
console.log('picked id : ', this.pickedId)
|
||||
},
|
||||
methods: {
|
||||
handleChange(id) {
|
||||
this.pickedId = id
|
||||
this.$emit('emit-data', { id })
|
||||
this.$emit('emit-data', {
|
||||
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) {
|
||||
const childOptions = []
|
||||
this.injectData.head.options?.forEach(item => {
|
||||
console.log('item', item)
|
||||
childOptions.push(h('el-option', { props: { label: item.label, value: item.value } }, null)) // TODO:<=== 去他妈的
|
||||
console.log('item', item.value)
|
||||
childOptions.push(h('el-option', { props: { label: item.label, value: item.value } }, null))
|
||||
})
|
||||
return h('el-select', { on: { change: this.handleChange } }, childOptions)
|
||||
return h('el-select', { props: { value: this.pickedId }, on: { change: this.handleChange } }, childOptions)
|
||||
}
|
||||
}
|
||||
|
||||
const addOrUpdateConfigs = {
|
||||
type: 'dialog',
|
||||
infoUrl: '/monitoring/equipmentPlcConnect',
|
||||
fields: [
|
||||
{ name: 'equipmentId', label: '设备', required: true, type: 'select', options: [] },
|
||||
{ name: 'plcId', label: 'PLC名称', required: true, type: 'select', options: [] }
|
||||
],
|
||||
infoUrl: '/monitoring/reportSheet',
|
||||
fields: [{ name: 'fileName', label: '报表名称', required: true, span: 24 }],
|
||||
operations: [
|
||||
{ name: 'cancel', url: true, showAlways: true },
|
||||
{ name: 'save', url: '/monitoring/equipmentPlcConnect', permission: '', showOnEdit: false },
|
||||
{ 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'] }
|
||||
]
|
||||
}
|
||||
{ name: 'save', url: '/monitoring/reportSheet', permission: '', showOnEdit: false },
|
||||
{ name: 'update', url: '/monitoring/reportSheet', permission: '', showOnEdit: true }
|
||||
]
|
||||
}
|
||||
|
||||
export default {
|
||||
@ -149,46 +105,89 @@ export default {
|
||||
BaseTable
|
||||
},
|
||||
activated() {
|
||||
this.dataList.splice(0)
|
||||
this.getAllCategories()
|
||||
this.getDataList()
|
||||
},
|
||||
computed: {
|
||||
trueTableConfigs() {}
|
||||
},
|
||||
computed: {},
|
||||
methods: {
|
||||
getAllCategories() {
|
||||
axios.get(axios.adornUrl('/monitoring/reportSheetCategory/page')).then(({ data: res }) => {
|
||||
if (res.data && res.data.list) {
|
||||
const categories = res.data.list.map(item => ({ label: item.name, value: item.id }))
|
||||
console.log('categories', categories)
|
||||
this.tableConfigs = [
|
||||
{ type: 'index', name: '序号' },
|
||||
{ prop: 'createTime', name: '创建时间', width: 200 },
|
||||
{ prop: 'fileName', name: '报表名称' },
|
||||
{ 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: id }) {
|
||||
handleOperations({ type, data }) {
|
||||
console.log('operation data: ', data)
|
||||
let id = data
|
||||
switch (type) {
|
||||
case 'change-category':
|
||||
return this.updateCategory(data)
|
||||
case 'edit':
|
||||
return this.addOrUpdateHandle(id)
|
||||
case 'delete':
|
||||
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() {
|
||||
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({
|
||||
url: this.$http.adornUrl('/monitoring/reportSheet/page'),
|
||||
method: 'get',
|
||||
params: this.$http.adornParams({
|
||||
page: this.pageIndex,
|
||||
limit: this.pageSize,
|
||||
key: this.dataForm.key
|
||||
})
|
||||
params: this.$http.adornParams(queries)
|
||||
}).then(({ data }) => {
|
||||
if (data && data.code === 0) {
|
||||
this.dataList = data.data.list
|
||||
@ -215,8 +214,14 @@ export default {
|
||||
selectionChangeHandle(val) {
|
||||
this.dataListSelections = val
|
||||
},
|
||||
// 新增 / 修改
|
||||
// 新增 - 跳转到设计
|
||||
handleAdd() {
|
||||
this.$router.push({
|
||||
name: 'monitoring-reportDesign'
|
||||
})
|
||||
},
|
||||
addOrUpdateHandle(id) {
|
||||
console.log('edit:', id)
|
||||
this.addOrUpdateVisible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs.addOrUpdate.init(id)
|
||||
|
@ -44,12 +44,12 @@ export default {
|
||||
method: 'get',
|
||||
params: {}
|
||||
}).then(({ data: res }) => {
|
||||
this.allNum = 0
|
||||
this.allNum = 0
|
||||
if (res.data) {
|
||||
this.dataList = res.data
|
||||
res.data.forEach(item => {
|
||||
this.allNum += item.quantity
|
||||
})
|
||||
res.data.forEach(item => {
|
||||
this.allNum += item.quantity
|
||||
})
|
||||
} else this.dataList.splice(0)
|
||||
})
|
||||
},
|
||||
@ -58,7 +58,7 @@ export default {
|
||||
this.$router.push({
|
||||
name: 'monitoring-reportDetail',
|
||||
query: {
|
||||
sortId: id
|
||||
category: id
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -7,14 +7,16 @@
|
||||
-->
|
||||
<template>
|
||||
<div v-loading="loading" :class="$style.container">
|
||||
<h1 >{{ $route.query.name }}</h1>
|
||||
<small-title :size="'md'" style="margin-bottom: 10px">报表名称:{{ $route.query.name }}</small-title>
|
||||
|
||||
<iframe id="reportView" :class="$style.mainIframe" name="mainIframe" :src="url" frameborder="0" scrolling="auto" />
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import SmallTitle from '@/components/small-title'
|
||||
|
||||
export default {
|
||||
components: {},
|
||||
components: { SmallTitle },
|
||||
props: {},
|
||||
data() {
|
||||
return {
|
||||
|
41
src/views/modules/monitoring/testMultiBaseTable.vue
Normal file
41
src/views/modules/monitoring/testMultiBaseTable.vue
Normal file
@ -0,0 +1,41 @@
|
||||
<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