update 产线实时
This commit is contained in:
		@@ -38,7 +38,7 @@ export default {
 | 
				
			|||||||
	},
 | 
						},
 | 
				
			||||||
	created() {
 | 
						created() {
 | 
				
			||||||
		this.clearData()
 | 
							this.clearData()
 | 
				
			||||||
		this.fetchList('equipment').then(({ data: res }) => {
 | 
							this.fetchList().then(({ data: res }) => {
 | 
				
			||||||
			this.testData = res.data.filter(item => !!item.equDet)
 | 
								this.testData = res.data.filter(item => !!item.equDet)
 | 
				
			||||||
			this.handleData()
 | 
								this.handleData()
 | 
				
			||||||
		})
 | 
							})
 | 
				
			||||||
@@ -48,7 +48,7 @@ export default {
 | 
				
			|||||||
				duration: 1500,
 | 
									duration: 1500,
 | 
				
			||||||
				onClose: () => {
 | 
									onClose: () => {
 | 
				
			||||||
					this.clearData()
 | 
										this.clearData()
 | 
				
			||||||
					fetchList('equipment').then(({ data: res }) => {
 | 
										this.fetchList().then(({ data: res }) => {
 | 
				
			||||||
						this.testData = res.data.filter(item => !!item.equDet)
 | 
											this.testData = res.data.filter(item => !!item.equDet)
 | 
				
			||||||
						this.handleData()
 | 
											this.handleData()
 | 
				
			||||||
					})
 | 
										})
 | 
				
			||||||
@@ -87,7 +87,7 @@ export default {
 | 
				
			|||||||
		},
 | 
							},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		expandDataStepOne() {
 | 
							expandDataStepOne() {
 | 
				
			||||||
			console.log('testdata: ', this.testData)
 | 
								// console.log('testdata: ', this.testData)
 | 
				
			||||||
			this.stepOneArray = this.testData.map(item => {
 | 
								this.stepOneArray = this.testData.map(item => {
 | 
				
			||||||
				if (item.equDet) {
 | 
									if (item.equDet) {
 | 
				
			||||||
					item.equDet.forEach((equipment, index) => {
 | 
										item.equDet.forEach((equipment, index) => {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,30 +8,23 @@
 | 
				
			|||||||
<template>
 | 
					<template>
 | 
				
			||||||
	<div>
 | 
						<div>
 | 
				
			||||||
		<div class="app-container">
 | 
							<div class="app-container">
 | 
				
			||||||
      <small-title :size="'md'">{{ $t('module.factory.realtime.productLine.name') }}</small-title>
 | 
								<small-title :size="'md'">产线生产实时数据</small-title>
 | 
				
			||||||
      <base-table
 | 
								<base-table v-if="loadTable" :table-head-configs="tableProps" :data="tableData.length ? tableData : []" />
 | 
				
			||||||
        v-if="tableReady"
 | 
					 | 
				
			||||||
        :table-config="tableProps"
 | 
					 | 
				
			||||||
        :table-data="tableData.length ? tableData : []"
 | 
					 | 
				
			||||||
        :is-loading="listLoading"
 | 
					 | 
				
			||||||
        :index-config="{ align: 'left', fixed: 'left' }"
 | 
					 | 
				
			||||||
      />
 | 
					 | 
				
			||||||
		</div>
 | 
							</div>
 | 
				
			||||||
	</div>
 | 
						</div>
 | 
				
			||||||
</template>
 | 
					</template>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<script>
 | 
					<script>
 | 
				
			||||||
// import BaseTable from '@/components/BaseTable/index-compound'
 | 
					import BaseTable from '@/components/base-table'
 | 
				
			||||||
import SmallTitle from '@/components/small-title'
 | 
					import SmallTitle from '@/components/small-title'
 | 
				
			||||||
import moment from 'moment'
 | 
					import moment from 'moment'
 | 
				
			||||||
// import fetchList from '@/api/factory-manage/realtimeData'
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default {
 | 
					export default {
 | 
				
			||||||
	name: 'RealtimeDataOfLine',
 | 
						name: 'RealtimeDataOfLine',
 | 
				
			||||||
	components: { BaseTable, SmallTitle },
 | 
						components: { BaseTable, SmallTitle },
 | 
				
			||||||
	data() {
 | 
						data() {
 | 
				
			||||||
		return {
 | 
							return {
 | 
				
			||||||
      tableReady: false,
 | 
								loadTable: false,
 | 
				
			||||||
			dynamicPropSet: false,
 | 
								dynamicPropSet: false,
 | 
				
			||||||
			tableProps: [{ label: 'default', prop: 'default' }],
 | 
								tableProps: [{ label: 'default', prop: 'default' }],
 | 
				
			||||||
			tableData: [],
 | 
								tableData: [],
 | 
				
			||||||
@@ -43,7 +36,8 @@ export default {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	mounted() {
 | 
						mounted() {
 | 
				
			||||||
		this.clearData()
 | 
							this.clearData()
 | 
				
			||||||
    fetchList('line').then(res => {
 | 
							this.fetchList().then(({ data: res }) => {
 | 
				
			||||||
 | 
								// console.log('fetchlist:', res)
 | 
				
			||||||
			this.testData = res
 | 
								this.testData = res
 | 
				
			||||||
			this.handleData()
 | 
								this.handleData()
 | 
				
			||||||
		})
 | 
							})
 | 
				
			||||||
@@ -54,7 +48,7 @@ export default {
 | 
				
			|||||||
				type: 'warning',
 | 
									type: 'warning',
 | 
				
			||||||
				onClose: () => {
 | 
									onClose: () => {
 | 
				
			||||||
					this.clearData()
 | 
										this.clearData()
 | 
				
			||||||
          fetchList('line').then(res => {
 | 
										this.fetchList().then(res => {
 | 
				
			||||||
						this.testData = res
 | 
											this.testData = res
 | 
				
			||||||
						this.handleData()
 | 
											this.handleData()
 | 
				
			||||||
					})
 | 
										})
 | 
				
			||||||
@@ -68,9 +62,16 @@ export default {
 | 
				
			|||||||
	},
 | 
						},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	methods: {
 | 
						methods: {
 | 
				
			||||||
 | 
							fetchList() {
 | 
				
			||||||
 | 
								return this.$http({
 | 
				
			||||||
 | 
									url: this.$http.adornUrl('/monitoring/productionMonitoring/lineProductionRealTimeData'),
 | 
				
			||||||
 | 
									method: 'post'
 | 
				
			||||||
 | 
								})
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		clearData() {
 | 
							clearData() {
 | 
				
			||||||
			this.dynamicPropSet = false
 | 
								this.dynamicPropSet = false
 | 
				
			||||||
      this.tableReady = false
 | 
								this.loadTable = false
 | 
				
			||||||
			this.testData = null
 | 
								this.testData = null
 | 
				
			||||||
			this.tableData.splice(0)
 | 
								this.tableData.splice(0)
 | 
				
			||||||
			this.tableProps.splice(0)
 | 
								this.tableProps.splice(0)
 | 
				
			||||||
@@ -80,7 +81,7 @@ export default {
 | 
				
			|||||||
		handleData() {
 | 
							handleData() {
 | 
				
			||||||
			this.expandDataStepOne()
 | 
								this.expandDataStepOne()
 | 
				
			||||||
			// this.expandDataStepTwo()
 | 
								// this.expandDataStepTwo()
 | 
				
			||||||
      if (this.tableData.length > 0) this.tableReady = true
 | 
								if (this.tableData.length > 0) this.loadTable = true
 | 
				
			||||||
			else {
 | 
								else {
 | 
				
			||||||
				this.$message({
 | 
									this.$message({
 | 
				
			||||||
					message: '没有查询到相关数据!',
 | 
										message: '没有查询到相关数据!',
 | 
				
			||||||
@@ -92,7 +93,7 @@ export default {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		expandDataStepOne() {
 | 
							expandDataStepOne() {
 | 
				
			||||||
			// 扩展服务器返回的数据第一阶段
 | 
								// 扩展服务器返回的数据第一阶段
 | 
				
			||||||
      console.log('create new one')
 | 
								// console.log('create new one')
 | 
				
			||||||
			this.tableData = this.testData.data.map(item => {
 | 
								this.tableData = this.testData.data.map(item => {
 | 
				
			||||||
				const newItem = {
 | 
									const newItem = {
 | 
				
			||||||
					lineName: item.lineName,
 | 
										lineName: item.lineName,
 | 
				
			||||||
@@ -107,20 +108,11 @@ export default {
 | 
				
			|||||||
							this.tableProps.push({
 | 
												this.tableProps.push({
 | 
				
			||||||
								label: moment(obj.recordTime).format('YYYY-MM-DD HH:mm:ss'),
 | 
													label: moment(obj.recordTime).format('YYYY-MM-DD HH:mm:ss'),
 | 
				
			||||||
								children: [
 | 
													children: [
 | 
				
			||||||
                  { prop: obj.recordTime + '-inputNum', label: this.$t('module.factory.realtime.productLine.input') },
 | 
														{ prop: obj.recordTime + '-inputNum', label: '进数据' },
 | 
				
			||||||
                  { prop: obj.recordTime + '-outputNum', label: this.$t('module.factory.realtime.productLine.output') },
 | 
														{ prop: obj.recordTime + '-outputNum', label: '出数据' },
 | 
				
			||||||
                  {
 | 
														{ prop: obj.recordTime + '-passArea', label: '良品率' },
 | 
				
			||||||
                    prop: obj.recordTime + '-passArea',
 | 
														{ prop: obj.recordTime + '-scrapNum', label: '报废数量' },
 | 
				
			||||||
                    label: this.$t('module.factory.realtime.productLine.passArea')
 | 
														{ prop: obj.recordTime + '-scrapRate', label: '报废比例' }
 | 
				
			||||||
                  },
 | 
					 | 
				
			||||||
                  {
 | 
					 | 
				
			||||||
                    prop: obj.recordTime + '-scrapNum',
 | 
					 | 
				
			||||||
                    label: this.$t('module.factory.realtime.productLine.scrapNum')
 | 
					 | 
				
			||||||
                  },
 | 
					 | 
				
			||||||
                  {
 | 
					 | 
				
			||||||
                    prop: obj.recordTime + '-scrapRate',
 | 
					 | 
				
			||||||
                    label: this.$t('module.factory.realtime.productLine.scrapRate')
 | 
					 | 
				
			||||||
                  }
 | 
					 | 
				
			||||||
								]
 | 
													]
 | 
				
			||||||
							})
 | 
												})
 | 
				
			||||||
						}
 | 
											}
 | 
				
			||||||
@@ -156,19 +148,13 @@ export default {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
					this.dynamicPropSet = true
 | 
										this.dynamicPropSet = true
 | 
				
			||||||
					return newItem
 | 
										return newItem
 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
          // console.log('没有item.det属性')
 | 
					 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			})
 | 
								})
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		setStaticTableProps() {
 | 
							setStaticTableProps() {
 | 
				
			||||||
			// Step1: 设置静态的 table props
 | 
								// Step1: 设置静态的 table props
 | 
				
			||||||
      const staticTableProps = [
 | 
								const staticTableProps = [{ prop: 'lineName', label: '产线', fixed: true }]
 | 
				
			||||||
        { prop: 'lineName', label: this.$t('module.factory.realtime.productLine.pl'), fixed: true },
 | 
					 | 
				
			||||||
        { prop: 'orderName', label: this.$t('module.factory.realtime.productLine.currOrder'), fixed: true },
 | 
					 | 
				
			||||||
        { prop: 'productSize', label: this.$t('module.factory.realtime.productLine.pSpecs'), fixed: true }
 | 
					 | 
				
			||||||
      ]
 | 
					 | 
				
			||||||
			this.tableProps = staticTableProps
 | 
								this.tableProps = staticTableProps
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user