<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="'#fb8200'" class="mr-1" -->
				<v-icon 
					v-if="iconShow"
					small 
					:color="'#4777d9'" 
					:class="['mr-1', required ? 'icon-orange' : 'icon-blue']"
					>$icoBulletPoint</v-icon
				>
				{{ label }}
			</label>
		</v-col>
		<v-col :cols="label ? textCols : ''">
			<v-select
				v-model="selectValue"
				:items="searchParam[parentPrgmId][dataKey + 'List']"
				item-text="addGrpNm"
				item-value="addGrpId"
				solo
				outlined
				append-icon="mdi-chevron-down"
				:class="['v-select__custom', customClass]"
			></v-select>
		</v-col>
	</v-row>
</template>

<script>
import { mapState, mapMutations, mapActions } from 'vuex';
export default {
	props: {
		parentPrgmId: {
			type: String,
			require: true,
		},
		dataKey: {
			type: String,
			require: true,
		},
		autoLoad: {
			type: Boolean,
			require: false,
			default: true,
		},
		label: {
			type: String,
			require: false,
			default: null,
		},
		sendParam: {
			type: Object,
			require: false,
			default: () => {
				return {};
			},
		},
		addAll: {
			type: Boolean,
			require: false,
			default: false,
		},
		textCols: {
			type: Number,
			require: false,
			default: 12,
		},
		labelCols: {
			type: Number,
			require: false,
			default: 12,
		},
		iconShow: {
			type: Boolean,
			require: false,
			default: true
		},
		customClass: {
			type: String,
			require: false,
		},
		required: {
			type: Boolean,
			default: false
		},
	},
	data() {
		return {};
	},
	computed: {
		...mapState({
			searchParam: state => state.pageData,
			menuData: 'menuData',
		}),
		selectValue: {
			get() {
				return this.searchParam[this.parentPrgmId][this.dataKey];
			},
			set(value) {
				return this.setPageData({ [this.dataKey]: value });
			},
		},
	},
	created() {
		if (this.autoLoad)
			this.getAddGrpInfoList({
				dataKey: this.dataKey,
				params: this.sendParam,
				addAll: this.addAll,
			});
	},
	methods: {
		...mapMutations({ setPageData: 'setPageData' }),
		...mapActions({
			getAddGrpInfoList: 'modules/search/getAddGrpInfoList',
		}),
	},
};
</script>

<style></style>
