<template>
	<v-row class="search-box" align="center" no-gutters>
		<v-col v-if="label" :cols="labelCols">
			<label for="" class="search-box-label">
				<v-icon x-small color="primary" class="mr-1">mdi-record-circle</v-icon>
				{{ label }}
			</label>
		</v-col>
		<v-col :cols="label ? textCols : ''">
			<v-select
				v-model="selectValue"
				:items="searchParam[parentPrgmId].factoryList"
				label="공장을 선택하세요"
				item-text="plcNm"
				item-value="idx"
				solo
				outlined
				:hide-details="true"
				append-icon="mdi-chevron-down"
				class="v-select__custom"
			></v-select>
		</v-col>
	</v-row>
</template>

<script>
import { mapState, mapMutations, mapActions } from 'vuex';
export default {
	props: {
		parentPrgmId: {
			type: String,
			require: true,
		},
		sendParam: {
			type: Object,
			require: false,
			default: () => {
				return {};
			},
		},
		textCols: {
			type: Number,
			require: false,
			default: 7,
		},
		labelCols: {
			type: Number,
			require: false,
			default: 4,
		},
	},
	data() {
		return {
			label: '공장',
			labelPrepend: true,
		};
	},
	computed: {
		...mapState({
			searchParam: state => state.pageData,
			menuData: 'menuData',
		}),
		selectValue: {
			get() {
				return this.searchParam[this.parentPrgmId].plcCd;
			},
			set(value) {
				return this.setPageData({ plcCd: value });
			},
		},
	},
	created() {
		const sendParam = {
			plcKind: 'LOC_FAC',
			plcCd: 'PLC00001',
		};
		this.getFactoryList(sendParam);
	},
	methods: {
		...mapMutations({ setPageData: 'setPageData' }),
		...mapActions({
			getFactoryList: 'modules/search/getFactoryList',
		}),
	},
};
</script>

<style></style>
