<template>
	<v-row class="search-box">
		<v-col v-if="label" :cols="labelCols">
			<label for="" class="search-box-label ft-size_14 ft-clr_g-c">
				{{ label }}
			</label>
		</v-col>
		<v-col :cols="label ? textCols : ''">
			<v-select
				v-model="selectValue"
				:items="selectList"
				item-text="commCdNm"
				item-value="commCd"
				solo
				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].prgmTpCd;
				} else {
					return this.searchParam[this.parentPrgmId][this.diffModel];
				}
			},
			set(value) {
				if (!this.diffModel) {
					return this.setPageData({ prgmTpCd: value });
				} else {
					return this.setPageData({ [this.diffModel]: value });
				}
			},
		},
		selectList() {
			let list = this.searchParam[this.parentPrgmId].prgmTpCdList;
			const dummyData = [
				{
					rowStat: null,
					commGrpCd: 'CO_USEFG',
					commCd: '1',
					commCdNm: '프로그램',
					useFg: '1',
					sortSeq: 1,
				},
				{
					rowStat: null,
					commGrpCd: 'CO_USEFG',
					commCd: '2',
					commCdNm: '팝업',
					useFg: '1',
					sortSeq: 2,
				},
			];
			this.setPageData({ prgmTpCdList: dummyData });
			list = dummyData;
			return list;
		},
	},
	created() {
		const params = {
			commGrpCd: 'CO_USEFG',
			useFg: '1',
		};
		this.getPrgmTpCdList(params);
	},
	methods: {
		...mapMutations({ setPageData: 'setPageData' }),
		...mapActions({
			getPrgmTpCdList: 'modules/search/getPrgmTpCdList',
		}),
	},
};
</script>

<style></style>
