|
@@ -0,0 +1,126 @@
|
|
|
+/**
|
|
|
+ * Created by Mai on 2017/4/1.
|
|
|
+ */
|
|
|
+var ration_ass = {
|
|
|
+ createNew: function (project) {
|
|
|
+ // 用户定义private方法
|
|
|
+ var tools = {};
|
|
|
+
|
|
|
+ // 所有通过this访问的属性,都不应在此单元外部进行写入操作
|
|
|
+ var ration_ass = function (proj) {
|
|
|
+ this.gljTree = cacheTree.createNew(this);
|
|
|
+ // this.project = proj;
|
|
|
+ this.datas = [];
|
|
|
+
|
|
|
+ var sourceType = ModuleNames.ration_ass;
|
|
|
+ this.getSourceType = function () {
|
|
|
+ return sourceType;
|
|
|
+ }
|
|
|
+ proj.registerModule(ModuleNames.ration_ass, this);
|
|
|
+ };
|
|
|
+
|
|
|
+ // prototype用于定义public方法
|
|
|
+ ration_ass.prototype.loadData = function (datas) {
|
|
|
+ this.datas = datas;
|
|
|
+ };
|
|
|
+
|
|
|
+ // 提交数据后返回数据处理
|
|
|
+ ration_ass.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_ass.prototype.refreshAfterSave=function(data){
|
|
|
+
|
|
|
+ };
|
|
|
+ ration_ass.prototype.refreshAfterUpdate=function(data){
|
|
|
+ console.log(data)
|
|
|
+ this.updateRation(data.rationID,data.doc);
|
|
|
+ this.updateRationGLJ(data.ration_glj_list);
|
|
|
+ gljOprObj.assSheetData[data.editIndex].actualValue = data.actualValue;
|
|
|
+ sheetCommonObj.showData(gljOprObj.assSheet,gljOprObj.assSetting,gljOprObj.assSheetData);
|
|
|
+ };
|
|
|
+
|
|
|
+ ration_ass.prototype.updateRation = function (rationID,doc) {
|
|
|
+ var index = _.findIndex(projectObj.project.Ration.datas,(ration)=>{
|
|
|
+ return ration.ID==rationID;
|
|
|
+ })
|
|
|
+ projectObj.project.Ration.datas[index].rationAssList = doc.rationAssList
|
|
|
+ };
|
|
|
+
|
|
|
+ ration_ass.prototype.updateRationGLJ = function (updateList) {
|
|
|
+ for(var i=0;i<updateList.length;i++){
|
|
|
+ var index = _.findIndex(projectObj.project.ration_glj.datas,(glj)=>{
|
|
|
+ return glj.ID==updateList[i].ID;
|
|
|
+ })
|
|
|
+ projectObj.project.ration_glj.datas[index].quantity=updateList[i].quantity;
|
|
|
+
|
|
|
+ var showIndex = _.findIndex(gljOprObj.sheetData,(shglj)=>{
|
|
|
+ return shglj.ID==updateList[i].ID;
|
|
|
+ })
|
|
|
+ gljOprObj.sheetData[showIndex].quantity=updateList[i].quantity;
|
|
|
+ }
|
|
|
+ sheetCommonObj.showData(gljOprObj.sheet,gljOprObj.setting,gljOprObj.sheetData);
|
|
|
+ };
|
|
|
+
|
|
|
+ ration_ass.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_ass.prototype.CreateNewAss = function (std) {
|
|
|
+ var newAssList = []
|
|
|
+ if(std.hasOwnProperty('rationAssList')&&std.rationAssList.length>0){
|
|
|
+ for(var i=0;i<std.rationAssList.length;i++){
|
|
|
+ var ass = std.rationAssList[i];
|
|
|
+ ass.actualValue = ass.stdValue;
|
|
|
+ newAssList.push(ass);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return newAssList;
|
|
|
+ };
|
|
|
+ ration_ass.prototype.getUpdateData=function(type,query,doc,callfunction){
|
|
|
+ var updateData = [];
|
|
|
+ var newobj = {
|
|
|
+ 'updateType': type,
|
|
|
+ 'query': query,
|
|
|
+ }
|
|
|
+ if(doc){
|
|
|
+ newobj['doc']=doc;
|
|
|
+ }
|
|
|
+ if(callfunction){
|
|
|
+ newobj['updateFunction']=callfunction;
|
|
|
+ }
|
|
|
+ updateData.push(newobj);
|
|
|
+ return updateData;
|
|
|
+ };
|
|
|
+ ration_ass.prototype.updateActualValue=function(assList,index,newVal){
|
|
|
+ var selected = projectObj.project.mainTree.selected;
|
|
|
+ assList[index].actualValue=newVal;
|
|
|
+ var query = {
|
|
|
+ 'ration':selected.data,
|
|
|
+ 'editAss':assList[index],
|
|
|
+ 'editIndex':index
|
|
|
+ };
|
|
|
+ var doc ={
|
|
|
+ rationAssList:assList,
|
|
|
+ };
|
|
|
+
|
|
|
+ var updateData = this.getUpdateData('ut_update',query,doc);
|
|
|
+
|
|
|
+ project.pushNow('updateRationAss',[this.getSourceType()],updateData);
|
|
|
+
|
|
|
+ };
|
|
|
+ return new ration_ass(project);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+};
|