<template>
<!--	<div :style="{ height: height, width: width }" />-->
	<dv-scroll-board :config="config" style="width:900px;height:240px" />
</template>

<script>
import * as echarts from 'echarts';
import { defineComponent } from 'vue';
import resize from './dashboard/mixins/resize';
import {option} from './options/mid_bot_options';
import { getOutputLog } from '~/src/service/api/produre/workRecords/index';
export default defineComponent({
	mixins: [resize],
	props: {
		year: null,
		className: {
			type: String,
			default: 'chart'
		},
		width: {
			type: String,
			default: '400px'
		},
		height: {
			type: String,
			default: '230px'
		},
		productionData : {
			type : Object,
			default () {
				return {}
			}
		}
	},
	data() {
		return {
			config: {
				header: ['工单类型', '机台', '订单编号', '报工数量','报工时间','报工人'],
				headerBGC: 'transparent',
				oddRowBGC: '#011B42',
				evenRowBGC: '#020D29',
				data: [
				],
				index: true,
				columnWidth: [80],
				align: ['center']
			},
			// myChart: null,
			loading: true,
			dataForCount: [],
			dataForWeight: [],
			chartOptions : {}
		};
	},
	async mounted() {
		// await this.getTypeData()
		// this.chartOptions =JSON.parse(JSON.stringify(option))
		// this.initChart()
		this.getTypeData()

		setInterval(() => {
			this.getTypeData()
		}, 500000)
	},
	// watch : {
	// 	productionData : {
	// 		handler (newValue) {
	// 			this.config.data = newValue.outputLogs && newValue.outputLogs.length && newValue.outputLogs.map(item => {
	// 				return [item.taskType == '0'?'金属':'板材', item.workstationName, item.orderSn, item.outputWeight, item.createTime, item.createBy]
	// 			}) || []
	// 		// this.initChart();
	// 	},
	// 	deep : true
	// 	}
	// },
	beforeUnmount() {
		// if (!this.myChart) {
		// 	return;
		// }
		// this.myChart.dispose();
		// this.myChart = null;
	},
	methods: {

		async getTypeData () {
			let res = await getOutputLog({
				pageNum : 1,
				pageSize : 10
			})
			this.config.data = res && res.rows && res.rows.length && res.rows.map(item => {
				return [item.taskType == '0'?'金属':'板材', item.workstationName, item.orderSn, item.outputWeight, item.createTime, item.createBy]
			}) || []
		},
		// initChart() {
		// 	let myChart = echarts.init(this.$el);
		// 	myChart.setOption(this.chartOptions);
		// 	this.$nextTick(() => {
		// 		myChart.resize()
		// 		this.$emit('endLoading', 11)
		// 	})
		// }
	}
});
</script>

<style scoped>
.dv-scroll-board .header{
		background-color: transparent;
	}
</style>
