<!--
 * @Author: zwq
 * @Date: 2023-08-02 15:12:42
 * @LastEditors: zwq
 * @LastEditTime: 2024-11-29 13:25:51
 * @Description:
-->
<template>
	<div class="app-container">
		<search-bar
			:formConfigs="[{ label: '产线在制工艺', type: 'title' }]"
			ref="searchBarForm" />
		<base-table
			v-loading="dataListLoading"
			:table-props="tableProps"
			:page="listQuery.pageNo"
			:limit="listQuery.pageSize"
			:table-data="tableData"
			@emitFun="inputChange" />
		<pagination
			:limit.sync="listQuery.pageSize"
			:page.sync="listQuery.pageNo"
			:total="listQuery.total"
			@pagination="getDataList" />
	</div>
</template>

<script>
import basicPage from '../../mixins/basic-page';
import { parseTime } from '../../mixins/code-filter';
import { getLineBindProcessPage } from '@/api/core/base/lineBindProcess';
import selectProduct from './selectProduct';

const tableProps = [
	{
		prop: 'lineName',
		label: '产线'
	},
	{
		prop: 'processDictName',
		label: '在制工艺',
		list: [],
		subcomponent: selectProduct,
	},
	{
		prop: 'recordTime',
		label: '开始时间',
		filter: parseTime,
	},
];

export default {
	mixins: [basicPage, selectProduct],
	data() {
		return {
			urlOptions: {
				getDataListURL: getLineBindProcessPage,
			},
			tableProps,
			tableData: [],
			// formConfig: [
			// 	{
			// 		type: 'button',
			// 		btnName: '同步',
			// 		name: 'search',
			// 		color: 'primary',
			// 	},
			// ],
		};
	},
	components: {},
	created() {
	},
	methods: {
    // 获取数据列表
    getDataList() {
      this.dataListLoading = true;
      this.urlOptions.getDataListURL(this.listQuery).then(response => {
        this.tableData = response.data;
        this.dataListLoading = false;
      });
    },
		buttonClick(val) {
			switch (val.btnName) {
				case 'search':
					this.listQuery.pageNo = 1;
					this.listQuery.pageSize = 10;
					this.getDataList();
					break;
				default:
					console.log(val);
			}
		},
		inputChange() {
			this.getDataList();
		},
	},
};
</script>
