<template>
    <div style="width: 100%">
        <Container>
        <Select v-model="val" style="width:96.5%;" >
            <Option v-for="item in optionsData" :value="item.selectName||''" :key="item.selectName">{{ item.selectName }}</Option>
        </Select>
    </Container>
    </div>
</template>

<script>
    import * as components from './style';
    import {PropertyMixin} from '../../service/main-tool-editor-type-mixin';
    export default {
        components: {
            ...components
        },
        mixins: [PropertyMixin],
        position: 'mainToolEditorTypeSelect',
        name: 'main-tool-editor-type-select',
        data () {
            return {
                val:this.editor.val||''
            };
        },
        props: {
            instanceInfo: Object,
            editor: Object
        },
        computed: {
            applicationState () {
                return this.$store.state.application;
            },
            viewportState () {
                return this.$store.state.viewport;
            },
            optionsData () {
                debugger;
                if (localStorage.getItem("page") && localStorage.getItem("page") != null) {

                } else {
                    /*
                    this.$Modal.success({
                        title: "友情提示",
                        content: "请先全局设置！"
                    });
                    */
                    return;
                }
                let pageObj = eval('(' + localStorage.getItem("page") + ')');//JSON.parse(localStorage.getItem("page"));
                console.log(pageObj);
                let optionData= pageObj.fullModel.templateCache.selectArr||[];
                optionData.forEach(function (el,index) {
                    el.selectName="templateCache."+el.selectName;
                });
                let _data =  optionData;
                return _data;
            }
        },
        methods: {
            initCurrtField () {
                let props = this.instanceInfo.vm.$data;
                let val = _.get(props, this.field);
                if (val !== undefined) {//改为undefined,校验boolean类型false错误
                    this.val = val;
                }
            },
            handleChange () {

            }
        },
        mounted() {
            debugger;
            this.initCurrtField();
        },
        watch: {
            field (n, o) {

                if (n === o) {
                    return;
                }
                deep:true//对象内部的属性监听，也叫深度监听

                //  this.setInstanceProps(n);
            },
            val (n, o) {
                debugger;
                if (n === o) {
                    return;
                }
                this.setInstanceProps(n);
            }
        }
    };
</script>

<style>

</style>
