<template>
	<view>
		<uni-table ref="table" border stripe emptyText="暂无更多数据" >
			<uni-tr>
				<uni-th align="center">开炉记录编码</uni-th>
				<uni-th align="center">工单编码</uni-th>
				<uni-th align="center">物料名称</uni-th>
				<uni-th align="center">参数1</uni-th>
				<uni-th align="center">参数2</uni-th>
				<uni-th align="center">参数3</uni-th>
			</uni-tr>
			<uni-tr v-for="(item, index) in tableData" :key="index">
				<uni-td align="center">{{ item.furnaceOpRecCode }}</uni-td>
				<uni-td align="center">{{ item.pwoCode }}</uni-td>
				<uni-td align="center">{{ item.materialName }}</uni-td>
				<uni-td align="center">{{ item.parameter1 }}</uni-td>
				<uni-td align="center">{{ item.parameter2 }}</uni-td>
				<uni-td align="center">{{ item.parameter3 }}</uni-td>
			</uni-tr>
		</uni-table>
		<uni-popup ref="popup" type="center" background-color="#fff" :is-mask-click="false">
			<!-- 加载动画 -->
			<loding-vue/>
		</uni-popup>
		<uni-popup ref="message" type="message">
			<uni-popup-message :type="message.msgType" :message="message.messageText" :duration="2000"></uni-popup-message>
		</uni-popup>
	</view>
</template>

<script>
	import {
		listMesFurnaceOperationRecordDetail,
	} from '@/api/mes/bom.js'
	import lodingVue from "@/utils/loding/loding.vue";
	export default {
		onLoad: function (option) { //option为object类型，会序列化上个页面传递的参数
			const _self = this;
			const eventChannel = _self.getOpenerEventChannel();
			eventChannel.on('data', function(data) {
				console.log(data,_self)
				_self[data.type](data.value)
			})
		},
		data() {
			return {
				tableData:{},
				message:{
					msgType:'error',
					messageText:'接口请求出错'
				},
			}
		},
		methods: {
			/**
			* 接口访问方法
			* @param {Object} api 接口名称
			* @param {Object} value 带入参数
			 */
			async fnApi(api,value){
				const _self = this;
				const objApi = {
					listMesFurnaceOperationRecordDetail
				}
				try{
					const data = (await objApi[api](value)).rows
					_self.$nextTick(()=>{
						_self.$refs.popup.open()
					})
					return data
				}catch(e){
					//TODO handle the exception
					_self.$nextTick(()=>{
						_self.$refs.message.open()
					})
				}finally{
					_self.$nextTick(()=>{
						_self.$refs.popup.close()
					})
				}
			},
			/**
			 * 炉长记录查询
			 * @param {Object} value
			 */
			async chiefRecords(value){
				const _self = this;
				const {id} = value;
				const obj = {
					pageNum: 1,
					pageSize: 50,
					furnaceOpRecId: id,
				}
				_self.tableData = await _self.fnApi('listMesFurnaceOperationRecordDetail',obj)
			},
		},
	}
</script>

<style lang="scss" scoped>
	page{
		$fontSize:5vw;
		background-color: #ffffff;
		font-size: $fontSize;
		color: #6a6663;
		view {
			 width: 98vw;
			 margin: 0 auto;
		}
	}
</style>
<style>
	page{
		background-color: #ffffff ;
	}
</style>