123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- /**
- * Created by Mai on 2017/4/1.
- */
- var Bills = {
- createNew: function (project) {
- var billsTreeSetting = {
- id: 'ID',
- pid: 'ParentID',
- nid: 'NextSiblingID',
- rootId: -1,
- autoUpdate: false
- };
- // 用户定义private方法
- var tools = {};
- // 所有通过this访问的属性,都不应在此单元外部进行写入操作
- var bills = function (proj) {
- this.project = proj;
- this.datas = null;
- this.tree = idTree.createNew(billsTreeSetting);
- var sourceType = ModuleNames.bills;
- this.getSourceType = function () {
- return sourceType;
- }
- proj.registerModule(ModuleNames.bills, this);
- };
- // 从后台获取数据
- /*bills.prototype.pullData = function (){
- this.project.pullData(
- '/bills/getData',
- {projectID: this.project.ID},
- function(result){
- if (result.error ===0){
- this.loadDatas(result.data);
- }
- else {
- // to do: ?错误处理需要细化
- alert(result.message);
- }
- },
- function (){}// to do: 错误处理需要细化
- )
- };*/
- // prototype用于定义public方法
- bills.prototype.loadData = 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);
- };
- // 提交数据后的错误处理方法
- bills.prototype.doAfterUpdate = function(err, data){
- // to do
- };
- return new bills(project);
- }
- };
|