/** * Created by Mai on 2017/4/1. */ var Rations = { createNew: function (project) { // 用户定义private方法 var tools = {}; // 所有通过this访问的属性,都不应在此单元外部进行写入操作 var rations = function (proj) { this.project = proj; this.datas = null; var sourceType = 'ration'; this.getSourceType = function () { return sourceType; } }; // prototype用于定义public方法 rations.prototype.loadDatas = function (datas) { this.datas = datas; // generate Fees & Flags Index,For View & Calculate this.datas.forEach(function (data) { data.FeesIndex = {}; data.fees.forEach(function (fee) { data.FeesIndex[fee.fieldName] = fee; }); data.FlagsIndex = {}; data.flags.forEach(function (flag) { data.FlagsIndex[flag.fieldName] = flag; }); }); }; return new rations(project); } };