<template>
    <div>
        <PageTable ref="valueSetTable" action="GetValueSetList" :highlightRow="true" :columns="columns" :initParam="formSearch">
        </PageTable>
    </div>
</template>
<script>
    export default{
        components:{

        },
        data(){
            return{
                columns: [
                    {
                    title: this.$t("module.valueSet.vsCode"),
                    align: "center",
                    key: "vsCode",
                    },
                    {
                    title: this.$t("module.valueSet.vsName"),
                    align: "center",
                    key: "vsName"
                    },
                    {
                    title: this.$t("module.valueSet.vsType"),
                    align: "center",
                    key: "vsType",
                    render: (h, params) => {
                        return h("span", params.row.vsType == "1" ? this.$t("module.valueSet.independent") : this.$t("module.valueSet.subordinate"));
                    }
                    },
                    {
                    title: this.$t("module.valueSet.vsValueSource"),
                    align: "center",
                    key: "vsValueSource",
                    render: (h, params) => {
                        return h(
                        "span",
                        params.row.vsValueSource == "1" ? this.$t("module.valueSet.userDefine") : this.$t("module.valueSet.dynamicSql")
                        );
                    }
                    },
                    {
                    title: this.$t("module.userManage.affiliation"),
                    align: "center",
                    key: "orgName",
                    },
                    {
                    title: this.$t("common.status"),
                    align: "center",
                    key: "enabled",
                    render: (h, params) => {
                        return h(
                        "Tag",
                        {
                            props: {
                                type: "dot",
                                color: params.row.enabled == 1 ? "blue" : "red"
                                }
                        },
                        params.row.enabled == 1 ?this.$t("common.valid") : this.$t("common.invalid")
                        );
                    }
                    }
                ],
            }
        },
        computed:{

        },
        created:function(){
            this.$emit("SetTitle", this.$t("module.valueSet.selectParentVs"));
            this.$emit("SetPageSize", 700);
            this.$emit('SetPageActions', [
            {
                text: this.$t("common.confirm"),
                theme: "success",
                icon: "checkmark-round",
                handle: this.selectParentVs,
            }
            ])    
        },
        beforeMount:function(){

     },
        mounted:function(){

        },
        beforeDestroy:function(){

        },
        destroyed:function(){

        },
        methods:{
            selectParentVs(){
                let currentRow = this.$refs["valueSetTable"].getHighlightRow();
                if(currentRow.vsCode){
                    let obj = {vsCode: currentRow.vsCode , vsName: currentRow.vsName }
                    this.$emit("Close", obj);
                }else{
                    this.$Message.warning({
                        content: this.$t("module.valueSet.selectAffiliation"),
                        duration: 3
                        });
                    return ;
                }
            },
            cancel(){
                this.$emit("Close")
            }
        },
        watch:{

        },
        directives:{

        }
    }
</script>
