/**
 * Created by zhang on 2018/11/26.
 */
let ration_template = {
    createNew: function (project) {
        let ration_template = function (proj){
            this.datas = [];

            var sourceType = ModuleNames.ration_template;
            this.getSourceType = function () {
                return sourceType;
            }
            proj.registerModule(ModuleNames.ration_template, this);

        };
        // prototype用于定义public方法
        ration_template.prototype.loadData = function (datas) {
            this.datas = datas;
        };
        ration_template.prototype.addDatasToList = function (datas) {
            let  me = this;
            if(datas&&datas.length>0){
                if (me.datas && Array.isArray(me.datas)) {
                    me.datas = me.datas.concat(datas);
                } else {
                    me.datas = datas;
                }
            }
        };
        ration_template.prototype.getTemplateByRationID = function (rationID) {
            return _.find(this.datas, {'rationID': rationID});
        };
        ration_template.prototype.deleteByRation = function(ration){
            _.remove(this.datas,{'rationID':ration.ID});
        };
        return new ration_template(project);
    }
}
