<template>
    <div>
        <template>
            <div v-if="tag" :type="type" @click="runEvent" @dblclick="runEvent" :style="diyStyle">
                {{result}}
            </div>
            <div v-else @click="runEvent" @dblclick="runEvent" :style="diyStyle">
               {{result}}
            </div>
        </template>
    </div>
</template>
<script>
import EventParentRender from "../../eventParentRender";
import {AjaxUtil} from "sasp-base";
export default {
    name: "font-format-render",
    extends: EventParentRender,
    data(){
        return {
            tag:true,
            result:"",
            type:"",
            diyStyle:{},

            /**
             * 内置对象
             *  用于预览
             *  defaultObj 默认参数配置
             *  defaultVal 默认列值
             *
             *  columnValue 当前列实际值
             *  configObj 当前列实际配置（根据配置模版中 getConfigDatas（） 返回值 ）
             */
        }
    },
    created() {
        this.initData();
    },
    watch:{
        columnValue(){
            this.initData();
        }
    },
    methods:{
        initData: function () {
            // if (this.value) {
                if (this.value && this.configData) {
                    // 格式数据
                    let configData = this.configData;
                    //修改其他样式
                    if (configData.fontColor) {
                        this.diyStyle['color'] = configData.fontColor || '';
                    }
                    if (configData.fontSize) {
                        this.diyStyle['font-size'] = (configData.fontSize || '14') + 'px';
                    }
                    if (configData.showFontWeight == 1) {
                        this.diyStyle['font-weight'] = 'bold';
                    }
                    if (configData.showFontLean == 1) {
                        this.diyStyle['font-style'] = 'oblique';
                    }
                    if ("default" == configData.value) {
                        // 判断为defult时候
                        this.result = this.value;
                    } else {
                        // 判断为diy时候  获取方法体  自定义代码块
                         this.result = new Function("vm,formData,Ajax,CTX", this.configData.msg)(this, this.rowData, AjaxUtil ,'');
                    }
                    if (this.formatObj['chooseEvent']) {
                      this.diyStyle['cursor'] = "pointer";
                      this.diyStyle['color'] = this.diyStyle['color'] ? this.diyStyle['color'] : "blue";
                    }
                }
            // }
        },
    }

}
</script>

<style scoped>

</style>
