123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- /**
- * Created by Mai on 2017/4/1.
- */
- var ration_coe = {
- createNew: function (project) {
- // 用户定义private方法
- var tools = {};
- // 所有通过this访问的属性,都不应在此单元外部进行写入操作
- var ration_coe = function (proj) {
- this.gljTree = cacheTree.createNew(this);
- // this.project = proj;
- this.datas = [];
- var sourceType = ModuleNames.ration_coe;
- this.getSourceType = function () {
- return sourceType;
- }
- proj.registerModule(ModuleNames.ration_coe, this);
- };
- // prototype用于定义public方法
- ration_coe.prototype.loadData = function (datas) {
- this.datas = datas;
- };
- // 提交数据后返回数据处理
- ration_coe.prototype.doAfterUpdate = function(err, data){
- if(!err){
- if(data.updateTpye=='ut_update'){
- this.refreshAfterUpdate(data);
- }else if(data.updateTpye=='ut_delete'){
- this.refreshAfterDelete(data);
- } else {
- this.refreshAfterSave(data);
- }
- }
- };
- ration_coe.prototype.refreshAfterSave=function(data){
- if(projectObj.project.ration_coe.datas&&Array.isArray(projectObj.project.ration_coe.datas)){
- projectObj.project.ration_coe.datas = projectObj.project.ration_coe.datas.concat(data);
- }else {
- projectObj.project.ration_coe.datas = data;
- }
- sheetCommonObj.showData(gljOprObj.coeSheet,gljOprObj.coeSetting,data);
- gljOprObj.coeSheetData=data;
- // SheetDataHelper.loadSheetData(setting, rationLibObj.sectionRationsSpread.getActiveSheet(), datas);
- };
- ration_coe.prototype.refreshAfterUpdate=function(data){
- var glj_list = projectObj.project.ration_coe.datas;
- var glj_index= _.findIndex(glj_list,(glj)=>{
- return glj.ID==data.query.ID&&glj.projectID==data.query.projectID;
- })
- _.forEach(data.doc, function(n, key) {
- glj_list[glj_index][key] = n;
- });
- var showList = _.filter(glj_list,{'projectID':data.query.projectID,'rationID':glj_list[glj_index].rationID});
- gljOprObj.coeSheetData=showList;
- sheetCommonObj.showData(gljOprObj.coeSheet,gljOprObj.coeSetting,showList);
- };
- ration_coe.prototype.refreshAfterDelete=function(data){
- var glj_list = projectObj.project.ration_coe.datas;
- _.remove(glj_list,data.query);
- _.remove(gljOprObj.sheetData,data.query);
- sheetCommonObj.showData(gljOprObj.coeSheet,gljOprObj.coeSetting,gljOprObj.sheetData);
- };
- ration_coe.prototype.getRationCoedata=function(newRation,data){
- var criteria= {};
- criteria.ration_coe_list = [];
- var dataLength = 0;
- if(data.hasOwnProperty('rationCoeList')&&data.rationCoeList.length>0){
- dataLength = data.rationCoeList.length
- }
- for(var i=0;i<=dataLength;i++){;
- var newCoe = {
- libID :data.rationRepId,
- rationID:newRation.ID,
- projectID : newRation.projectID
- }
- if(i==dataLength){
- newCoe.coeID=-1;
- newCoe.name = '自定义系数';
- newCoe.content='人工×1,材料×1,机械×1,主材×1,设备×1';
- newCoe.isAdjust=0;
- }else {
- newCoe.coeID= data.rationCoeList[i];
- }
- criteria.ration_coe_list.push(newCoe);
- }
- criteria.updateType = 'ut_create';
- return criteria;
- };
- ration_coe.prototype.deleteByRation = function(ration){
- var coe_list = projectObj.project.ration_coe.datas;
- var newList =_.filter(coe_list,(coe)=>{
- return coe.rationID!=ration.ID;
- });
- if(newList!=undefined){
- projectObj.project.ration_coe.datas = newList;
- }
- };
- return new ration_coe(project);
- }
- };
|