<template>
    <div>
        <el-checkbox-group v-model="result">
          <el-checkbox v-for="(check,index) in checkBoxData" :key="index" :label="check.label" :disabled="!item.enabled" ></el-checkbox>
        </el-checkbox-group>
        <div v-if="newForm[item.explain]">{{ newForm[item.explain] }}</div>
    </div>
</template>

<script>

import { createDb } from '../utils/CommonRequest'

const $metiiAPI = createDb();

export default {
    data(){
        return {
            result: [],
            checkBoxData:[]
        }
    },
    props:{
        newForm: Object,
        item: Object
    },
    watch:{
        result(n){
            this.$emit('checked',{
                name: this.item.english,
                data: this.result
            })
        }
    },
    mounted(){
        this.getCheckBoxData()
    },
    methods:{
        getCheckBoxData(){
            $metiiAPI.getFormtData(this.item.sourcedata)
            .then(res => {
                console.log(res)
                this.checkBoxData = res
            })
            
        }
    }
}
</script>