<template>
    <div class="row go-form-row flex-div go-common-drop-ctl" :id="dropCtlId">
        <go-input v-model="showValue" :readOnly="true" :suffix="suffixIcon"
                       @inputClick="inputClick" :width="this.width" :item="this.inputItem"></go-input>


        <go-win v-model="showWinFlag" @ok="selImgItem"  title="请选择图片" :height="imgSelHeight" :width="imgSelWidth">
            <!--空间设置界面-->
            <imgSelCtl :multiple="multiple" :showWinFlag="showWinFlag" ref="imgSelCtl"></imgSelCtl>
        </go-win>

    </div>
</template>

<script>
    import imgSelCtl from "./img-sel-ctl";
    import {AssertUtils, GoingUtils} from "goingutils";
    import formMixin from "../../../mixins/formMixins";

    export default {
        name: "go-img-sel",
        mixins: [formMixin],
        data: function () {
            return {
                showWinFlag:false,
                winId: GoingUtils.getUUid(12),
                clearFlag: false,
                dropCtlId: GoingUtils.getUUid(12),
                inputId: GoingUtils.getUUid(12),
                imgSelWidth:$(window).width()-120,
                imgSelHeight:$(window).height()-80
            };
        },
        props: {
            multiple:{
                type:Boolean,
                default:false
            },
        },
        computed: {},
        mounted() {

        },
        methods: {
            selImgItem(){
                //获取图片展示组件
                let imgSelCtlObj=this.$refs.imgSelCtl.getCtlObj();
                let ids = imgSelCtlObj.getSelectedRowIds();
                let imgIds = imgSelCtlObj.getSelectedRowImgIds();
                //回调填写相应的字体图标信息
                if (AssertUtils.isNotEmpty(ids)) {
                    let imgNames = imgSelCtlObj.getImgNames(ids);
                    this.$emit("input", imgNames);
                    this.$emit("getIds", imgIds);
                    this.showWinFlag=!this.showWinFlag;
                } else {
                    GoingUtils.showErrorMessage("请选择相应的图标后再确定!");
                }
            },
            //点击输入框 弹出相应的界面
            inputClick() {
                let item = this.item;
                if (item.disabled) {
                    return void 0;
                }
                this.showWinFlag=!this.showWinFlag;
            }
        },
        components: {
            imgSelCtl: imgSelCtl
        },
        watch:{
            value(newVal){
                this.showValue=newVal;
            }
        }
    };
</script>
