<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="selectList"
				item-text="commCdNm"
				item-value="commCd"
				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,
		},
		diffModel: {
			type: String,
			require: false,
		},
		textCols: {
			type: Number,
			require: false,
			default: 7,
		},
		labelCols: {
			type: Number,
			require: false,
			default: 4,
		},
	},
	data() {
		return {
			label: '설비그룹종류',
		};
	},
	computed: {
		...mapState({
			searchParam: state => state.pageData,
			menuData: 'menuData',
		}),
		selectValue: {
			get() {
				if (!this.diffModel) {
					return this.searchParam[this.parentPrgmId].eqpmGrpKind;
				} else {
					return this.searchParam[this.parentPrgmId][this.diffModel];
				}
			},
			set(value) {
				if (!this.diffModel) {
					return this.setPageData({ eqpmGrpKind: value });
				} else {
					return this.setPageData({ [this.diffModel]: value });
				}
			},
		},
		selectList() {
			let list = this.searchParam[this.parentPrgmId].eqpmGrpKindList;
			return list;
		},
	},
	created() {
		const params = {
			commGrpCd: 'CM_EQKIND',
			useFg: '1',
		};
		this.getEqpmGrpKindList(params);
	},
	methods: {
		...mapMutations({ setPageData: 'setPageData' }),
		...mapActions({
			getEqpmGrpKindList: 'modules/search/getEqpmGrpKindList',
		}),
	},
};
</script>

<style></style>
