import ViewMessageService from '../view-message-service';
/**
 * 表单新建默认值视图消息服务对象基类
 *
 * @export
 * @class ViewMsg4MessageServiceBase
 */
export default class ViewMsg4MessageServiceBase extends ViewMessageService {


    /**
     * Creates an instance of  ViewMsg4MessageServiceBase.
     * 
     * @param {*} [opts={}]
     * @memberof  ViewMsg4MessageServiceBase
     */
    constructor(opts: any = {}) {
        super(opts);
    }

    /**
     * 初始化基础参数
     * 
     * @memberof ViewMsg4MessageServiceBase
     */
    public initBasicParam(){
        this.id = "71630E0E-47C6-4891-8699-94DA61C8F5CF";
        this.name = "表单新建默认值";
        this.codename = "ViewMsg4";
        this.title = "";
        this.content = "本示例展示表单的新建默认值功能；展示内容包含【订单时间】默认为【当前时间】、【订单状态】默认为【未提交】";
        this.closeMode = 0;
        this.position = "TOP";
        this.type = "error";
        this.isEnableRemove = false;
        this.order = 1;
        this.dynamicMode = "STATIC";
        this.hasMessageTemp = false;
        this.messageType = "TEXT";
    }

    /**
     * 转化消息模板标题和内容
     *      
     * @target {*} target 返回目标数据
     * @param {*} context 应用上下文
     * @param {*} viewparam 视图参数
     * @param {*} item 源数据
     * 
     * @memberof ViewMsg4MessageServiceBase
     */
    public translateMessageTemp(target:any,context:any,viewparam:any,item?:any){
        if(this.hasMessageTemp && Object.is(this.messageType,"HTML")){
            Object.assign(target,{title:``});
            Object.assign(target,{content:``});
        }
        if(this.hasMessageTemp && Object.is(this.messageType,"TEXT")){
            Object.assign(target,{title:""});
            Object.assign(target,{content:""});
        }
    }

}