<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="this.energyList"
				item-text="enrgNm"
				item-value="cd"
				solo
				outlined
				:hide-details="true"
				append-icon="mdi-chevron-down"
				class="v-select__custom"
			></v-select>
			<!-- @change="updateBlocCode($event)" -->
		</v-col>
	</v-row>
</template>

<script>
import { mapState, mapMutations, mapActions } from 'vuex';
export default {
	props: {
		parentPrgmId: {
			type: String,
			require: true,
		},
		autoLoad: {
			type: Boolean,
			require: false,
			default: true,
		},
		label: {
			type: String,
			require: false,
			default: '검침대상유형',
		},
		textCols: {
			type: Number,
			require: false,
			default: 8,
		},
		labelCols: {
			type: Number,
			require: false,
			default: 4,
		},
		enrgCd: {
			type: String,
			require: true,
		},
	},
	data() {
		return {
			energyList: [],
		};
	},
	computed: {
		...mapState({
			searchParam: state => state.pageData,
		}),
		selectValue: {
			get() {
				return this.searchParam[this.parentPrgmId][this.enrgCd];
			},
			set(value) {
				console.log('value : ', value);
				return this.setPageData({ [this.enrgCd]: value });
			},
		},
	},
	created() {
		this.energyList = [
			{
				cd: 'ROI000001',
				enrgNm: '전력',
				unit: 'kwh',
				enrgUnit: '008',
				readObjNm: '전력',
				enrgDiv: 'MTT_ELEC',
				ercCd: 'ERC000001',
			},
			{
				cd: 'ROI000002',
				enrgNm: '스팀',
				unit: '㎥',
				enrgUnit: '009',
				readObjNm: '스팀',
				enrgDiv: 'MTT_HEAT',
				ercCd: 'ERC000002',
			},
			{
				cd: 'ROI000072',
				enrgNm: '정수',
				unit: 'ton',
				enrgUnit: '003',
				readObjNm: '정수',
				enrgDiv: 'MTT_WTER',
				ercCd: 'ERC000005',
			},
			{
				cd: 'ROI000070',
				enrgNm: '여과수',
				unit: 'ton',
				enrgUnit: '003',
				readObjNm: '여과수',
				enrgDiv: 'MTT_WTER',
				ercCd: 'ERC000005',
			},
		];
	},
	methods: {
		...mapMutations({ setPageData: 'setPageData' }),
		...mapActions({}),
	},
};
</script>

<style></style>
