| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 | /** * Created by Mai on 2017/4/1. */var Bills = {    createNew: function (project) {        var billsTreeSetting = {            id: 'ID',            pid: 'ParentID',            nid: 'NextSiblingID',            rootId: -1        };        // 用户定义private方法        var tools = {};        // 所有通过this访问的属性,都不应在此单元外部进行写入操作        var bills = function (proj) {            this.project = proj;            this.datas = null;            this.tree = idTree.createNew(billsTreeSetting);            var sourceType = 'bills';            this.getSourceType = function () {                return sourceType;            }        };        // prototype用于定义public方法        bills.prototype.loadDatas = function (datas) {            this.datas = datas;            // generate Fees & Flags Index, For View & Calculate            this.datas.forEach(function (data) {                data.FeesIndex = {};                if (data.fees) {                    data.fees.forEach(function (fee) {                        data.FeesIndex[fee.fieldName] = fee;                    });                }                data.FlagsIndex = {};                if (data.flags) {                    data.flags.forEach(function (flag) {                        data.FlagsIndex[flag.fieldName] = flag;                    });                }            });            // datas load to Tree            this.tree.loadDatas(this.datas);        };        return new bills(project);    }};
 |