123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766 |
- /**
- * Created by Mai on 2017/4/1.
- */
- var PROJECT = {
- createNew: function (projectID, userID) {
- // 定义private方法
- var tools = {
- _project: null,
- _ID: parseInt(projectID),
- _userID: userID,
- updateLock: 0,
- updateData: [],
- operation: '',
- modules: {},
- projCounter: 'projCounter',
- projSetting: 'proj_setting'
- };
- var me = tools;
- tools.doAfterUpdate = function(result){
- if (!result) { return }
- result.forEach(function(item){
- if(_.isArray(item)){
- item.forEach(function (e) {
- me.eachItem(e);
- })
- }else {
- me.eachItem(item)
- }
- });
- };
- // isInit: 是否是初始化,导出接口用到getData,但是非初始化,多次调用getData不会覆盖原有缓存数据
- tools.doAfterLoad = function(result, isInit, callback){
- var counter;
- //必须要先load ProjectInfo的信息
- let projectInfoModule = result.find(data => data.moduleName === ModuleNames.projectInfo);
- if (projectInfoModule) {
- me._project.projectInfo = projectInfoModule.data;
- OVER_HEIGHT.init(me._project.projectInfo.property.overHeight);
- }
- result.forEach(function(item){
- if (item.moduleName !== ModuleNames.projectInfo) {
- if (me.modules[item.moduleName]){
- me.modules[item.moduleName].loadData(item.data, isInit);
- } else if (item.moduleName === me.projCounter) {
- counter = item.data;
- } else if (item.moduleName === me.projSetting) {
- me._project.projSetting = item.data;
- me._project.projSetting.moduleName = me.projSetting;
- } else if(item.moduleName === ModuleNames.projectGLJ){
- me._project.projectGLJ.loadToCache(item.data);
- }
- }
- });
- for (module in counter) {
- if (me.modules[module]) {
- me.modules[module].setMaxID(counter[module]);
- }
- }
- if (isInit) {
- projectInfoObj.showProjectInfo(me._project.projectInfo);
- }
- me._project.property = me._project.projectInfo.property;
- me._project.loadMainTree();
- //me.test(result[0].data[0]);
- if (callback) {
- callback(0);
- }
- };
- tools.eachItem=function(item){
- if (me.modules[item.moduleName]){
- me.modules[item.moduleName].doAfterUpdate(item.err, item.data);
- }
- };
- /*tools.test = function(data){
- me._project.beginUpdate('修改名称');
- data.name = 'test';
- data['updateType'] = 'ut_update';
- me._project.push(ModuleNames.bills, [data]);
- me._project.endUpdate();
- };*/
- // 所有通过this访问的属性,都不应在此单元外部进行写入操作
- var project = function () {
- tools._project = this;
- this.mainTree = cacheTree.createNew(this);
- this.Bills = Bills.createNew(this);
- this.Ration = Ration.createNew(this);
- this.GLJ = GLJ.createNew(this);
- this.ration_glj = ration_glj.createNew(this);
- this.ration_coe = ration_coe.createNew(this);
- this.ration_ass = ration_ass.createNew(this);
- this.ration_installation = ration_installation.createNew(this);
- this.ration_template = ration_template.createNew(this);
- this.quantity_detail = quantity_detail.createNew(this);
- this.installation_fee = installation_fee.createNew(this);
- this.FeeRate = FeeRate.createNew(this);
- // this.VolumePrice = VolumePrice.createNew(this);
- this.projectGLJ = new ProjectGLJ();
- // this.projectGLJ.loadData();
- this.composition = new Composition();
- this.composition.loadData();
- this.labourCoe = new LabourCoe(this);
- this.calcProgram = new CalcProgram(this);
- this.evaluate_list = new EvaluateList(this);
- this.bid_evaluation_list = new BidEvaluationList(this);
- this.contractor_list = new ContractorList(this);
- this.calcBase = calcBase;
- // this.masterField = {ration: 'billsItemID', volumePrice: 'billsItemID'};
- this.masterField = {ration: 'billsItemID'};
- };
- // prototype用于定义public方法
- project.prototype.modify = function (modifyDatas, callback) {
- // To Do
- };
- // prototype用于定义public方法
- project.prototype.ID = function () {
- return tools._ID;
- };
- project.prototype.projCounter = function () {
- return tools.projCounter;
- };
- project.prototype.getDecimal = function (fullName) {
- let names = fullName.split('.'), decimal = this.Decimal;
- for (let name of names) {
- if (decimal[name]) {
- decimal = decimal[name];
- } else {
- return null;
- }
- }
- if (Object.prototype.toString.apply(decimal) === '[object Number]') {
- return decimal;
- } else {
- return null;
- }
- };
- project.prototype.loadMainTree = function () {
- var that = this;
- let loadRationGLJNode = function (cacheNode) {
- var newNode, bj = that.ration_glj.getMainAndEquGLJ(cacheNode.source.ID), i;
- for(i=0;i<bj.length;i++){
- that.ration_glj.transferToNodeData(bj[i]);
- newNode = that.mainTree.addNode(cacheNode, null, bj[i].ID);
- newNode.source = bj[i];
- newNode.sourceType = that.ration_glj.getSourceType();
- newNode.data = bj[i];
- }
- };
- var loadRationNode = function (rations, cacheNode) {
- var newNode, br = that.Ration.getBillsSortRation(cacheNode.source.getID()), i;
- for (i = 0; i < br.length; i++) {
- newNode = that.mainTree.addNode(cacheNode, null, br[i].ID);
- if(br[i].type==rationType.gljRation){
- br[i]= that.ration_glj.combineRationAndGLJ(br[i]);
- }
- newNode.source = br[i];
- newNode.sourceType = that.Ration.getSourceType();
- newNode.data = br[i];
- if(projectObj.project.projectInfo.property.displaySetting !== undefined &&
- projectObj.project.projectInfo.property.displaySetting.disPlayMainMaterial==true){
- loadRationGLJNode(newNode);
- }
- }
- };
- /* let loadVolumePriceNode = function (cacheNode) {
- let newNode = null, bv = that.VolumePrice.getBillsSortVolumePrice(cacheNode.source.getID());
- for (let v of bv) {
- newNode = that.mainTree.addNode(cacheNode);
- newNode.source = v;
- newNode.sourceType = that.VolumePrice.getSourceType();
- newNode.data = v;
- }
- };*/
- var loadIdTreeNode = function (nodes, parent) {
- var newNode, i;
- for (i = 0; i < nodes.length; i++) {
- newNode = that.mainTree.addNode(parent, null, nodes[i].data.ID);
- newNode.source = nodes[i];
- newNode.sourceType = that.Bills.getSourceType();
- newNode.data = nodes[i].data;
- that.FeeRate.loadFeeRateToBill(newNode);
- if (nodes[i].children.length === 0) {
- loadRationNode(that.Ration.datas, newNode);
- // loadVolumePriceNode(newNode);
- } else {
- loadIdTreeNode(nodes[i].children, newNode);
- }
- }
- };
- loadIdTreeNode(this.Bills.tree.roots, null);
- this.mainTree.sortTreeItems();
- this.mainTree.selected = this.mainTree.firstNode();
- };
- project.prototype.getParentTarget = function (node, targetField, targetValue) {
- var parent = node;
- while (parent && parent[targetField] !== targetValue) {
- parent = parent.parent;
- }
- return parent;
- };
- // 提供给各模块调用的统一从后台获取数据的方法
- /*project.prototype.pullData = function (url, data, successCallback, errorCallback) {
- $.ajax({
- type:"POST",
- url: url,
- data: {'data': JSON.stringify(data)},
- dataType: 'json',
- cache: false,
- timeout: 50000,
- success: function(result){
- successCallback(result);
- },
- error: function(jqXHR, textStatus, errorThrown){
- alert('error ' + textStatus + " " + errorThrown);
- errorCallback();
- }
- });
- };*/
- // 所有模块在此从后台获取数据
- project.prototype.loadDatas = function (callback){
- $.ajax({
- type: "POST",
- url: '/project/getData',
- data: {'data': JSON.stringify({
- "project_id": tools._ID,
- "user_id": tools._userID
- })},
- dataType: 'json',
- cache: false,
- timeout: 50000,
- success: function (result) {
- if (!result.error) {
- const isInit = true;
- tools.doAfterLoad(result.data, isInit, callback);
- // for test calc
- //tools.doAfterLoad([{moduleName: 'bills', data: BillsData}, {'moduleName': 'ration', data: DrawingData}], callback);
- } else {
- alert('error: ' + result.message);
- callback(result.error);
- }
- },
- error: function(jqXHR, textStatus, errorThrown){
- alert('error ' + textStatus + " " + errorThrown);
- }
- });
- };
- project.prototype.loadDataSync = async function () {
- const data = await ajaxPost('/project/getDataForInterface', {user_id: tools._userID, project_id: tools._ID});
- if (data) {
- const isInit = false;
- tools.doAfterLoad(data, isInit);
- }
- };
- project.prototype.beginUpdate = function(operation){
- if (tools.updateLock === 0){
- tools.operation = operation
- }
- tools.updateLock += 1;
- };
- project.prototype.endUpdate = function(){
- if (tools.updateLock === 0){
- throw "project can not endUpdate before beginUpdate";
- }
- tools.updateLock -= 1;
- if (tools.updateLock === 0) {
- $.ajax({
- type: "POST",
- url: '/project/save',
- data: {'data': JSON.stringify({
- "project_id": tools._ID,
- "user_id": tools._userID,
- "date": new Date,
- "operation": tools.operation,
- "update_data": tools.updateData
- })},
- dataType: 'json',
- cache: false,
- timeout: 50000,
- success: function (result) {
- if (!result.error) {
- tools.doAfterUpdate(result.data);
- } else {
- alert('error: ' + result.message);
- }
- $.bootstrapLoading.end();
- },
- error: function(jqXHR, textStatus, errorThrown){
- alert('error ' + textStatus + " " + errorThrown);
- $.bootstrapLoading.end();
- }
- });
- tools.updateData = [];
- tools.operation = "";
- }
- };
- project.prototype.push = function(moduleName, data){
- if (tools.updateLock === 0){
- throw "project can not push data before beginUpdate";
- }
- var moduleData = {
- moduleName: moduleName,
- data: data
- };
- tools.updateData.push(moduleData);
- };
- project.prototype.pushNow = function (operation, moduleName, data) {
- var that = this;
- this.beginUpdate(operation);
- if (Object.prototype.toString.apply(moduleName) === "[object Array]" && Object.prototype.toString.apply(data) === "[object Array]") {
- moduleName.forEach(function (name, index) {
- if(name != 'projCounter'){
- that.push(moduleName[index], data[index]);
- }
- });
- } else {
- this.push(moduleName, data);
- }
- this.endUpdate();
- };
- project.prototype.registerModule = function(moduleName, obj){
- if (!tools.modules.hasOwnProperty(moduleName)){
- tools.modules[moduleName] = obj;
- }
- };
- project.prototype.markUpdateProject = function (data,type,callback) {
- $.bootstrapLoading.start()
- CommonAjax.post("/project/markUpdateProject",{updateInfo:data,type:type},function(){
- if(callback) callback();
- $.bootstrapLoading.end()
- });
- };
- project.prototype.saveProperty = function (propertyName, propertyValue) {
- CommonAjax.post("/project/saveProperty", {projectID: this.ID(), propertyName: propertyName, propertyValue: propertyValue});
- };
- project.prototype.projectMarkChecking = function () {
- let me = this;
- let changeMark = projectObj.project.projectInfo.changeMark;
- if(changeMark&&changeMark!=''){
- this.Bills.getEngineeringCostNode(projectObj.mainController).changed = true;
- this.calcProgram.calcAllNodesAndSave();
- CommonAjax.post("/project/removeProjectMark",{projectID:me.ID()},function (data) {
- delete projectObj.project.projectInfo.changeMark;
- if(socket.connected == true){//如果这时候socket已经连接成功,则发送删除标记广播
- socket.emit('removeProjectMark',{projectID:me.ID(),userID:userID});
- }else {//如果还没连接成功,则放入消息对象缓存,等socket连接成功后发送
- socketObject.messages.push({message:'removeProjectMark',data:{projectID:me.ID(),userID:userID}});
- }
- });
- }
- };
- project.prototype.updateLockBills = function (value,callback) {
- let mixDatas = {
- projectID: projectObj.project.ID(),
- updateType: 'update',
- properties: {
- "property.lockBills":value
- },
- labourCoes: {},
- rations: [],
- bills: []
- };
- $.bootstrapLoading.start();
- CommonAjax.post('/pm/api/updateMixDatas', {user_id: userID, mixDataArr: mixDatas}, function (rstData) {
- projectObj.project.projectInfo.property.lockBills = value;
- if(callback){
- callback();
- }
- $.bootstrapLoading.end();
- });
- };
- //返回清单是否被锁定
- project.prototype.isBillsLocked =function(){
- if(projectObj.project.projectInfo.property.lockBills == true){
- return true;
- }
- return false;
- };
- //清单是否属于锁定范围(分部分项、措施项目)
- project.prototype.withinBillsLocked = function (node) {
- const lockedFixFlag = [fixedFlag.SUB_ENGINERRING, fixedFlag.MEASURE];
- while(node){
- if(!node.parent){
- if(node.data.flagsIndex && node.data.flagsIndex.fixed && lockedFixFlag.includes(node.data.flagsIndex.fixed.flag)){
- return true;
- }
- else {
- return false;
- }
- }
- node = node.parent;
- }
- return true;
- };
- project.prototype.updateProjectProperty = function(datas,field,callback){
- let pfield = "property."+field;
- let tem ={
- type:'project',
- data:{ID:projectObj.project.ID()}
- };
- tem.data[pfield] = datas;
- projectObj.project.updateNodes([tem],function () {
- projectObj.project.property[field] = datas;
- if(callback) callback();
- })
- };
- project.prototype.updateCasCadeBills = function(node,newval,fieldName,needSetParent = true){
- let datas = [];
- let data = {
- type:node.sourceType,
- data:{ID:node.data.ID}
- };
- setData(data.data,newval,fieldName, node);
- datas.push(data);
- setChildren(node,newval,datas);//同步设置所有子项
- if(needSetParent) setParent(node,newval,datas);//设置父节点
- $.bootstrapLoading.start();
- this.updateNodes(datas,function () {
- let nodes = [];
- for(let d of datas){
- let node = projectObj.project.mainTree.findNode(d.data.ID);
- if(node){
- for(let key in d.data){
- if(key == 'ID') continue;
- node.data[key] = d.data[key];
- }
- nodes.push(node)
- }
- }
- projectObj.mainController.refreshTreeNode(nodes);
- //取消锁定,则自动重新计算。
- if(fieldName == "lockUnitPrice" && newval == false) projectObj.project.calcProgram.calcAllNodesAndSave();
- $.bootstrapLoading.end();
- });
- function setChildren(pnode,newValue,datas) {//同步设置所有子项
- if(pnode.children.length > 0 && pnode.children[0].sourceType == ModuleNames.bills){//设置子项不包括定额
- for(let c of pnode.children){
- let data = {
- type:c.sourceType,
- data:{ID:c.data.ID}
- };
- //有基数计算的子项值清空
- let val = fieldName == "lockUnitPrice" && c.data.calcBase && c.data.calcBase != ""?null:newval;
- setData(data.data,val,fieldName, c);
- datas.push(data);
- setChildren(c,newValue,datas)
- }
- }
- }
- function setParent(cnode,newValue,datas) {
- let diferrent = false;
- if(cnode.parent && !projectObj.project.Bills.isMeasureNode(cnode.parent)){//排除措施项目节点
- for(b of cnode.parent.children){
- if(b == cnode) continue
- if(b.data[fieldName]!== newValue){//有兄弟节点的值和本节点不一样,则父节点设置为null
- diferrent = true;
- break;
- }
- }
- let pvalue = diferrent === true?null:newValue;
- let data = {
- type:cnode.parent.sourceType,
- data:{ID:cnode.parent.data.ID}
- };
- setData(data.data,pvalue,fieldName, cnode.parent);
- datas.push(data);
- setParent(cnode.parent,pvalue,datas);
- }
- }
- function setData(data,avalue,fieldName, node) {
- data[fieldName] = avalue;
- // 二次修改项目属性上下限设置,前端的最高、最低限价不重算,要去掉输出限价列的√,再重新勾选才计算。因此输出最高限价、输出限价时,需要给节点的maxPrice、minPrice设置一个算好的值
- if (['outPutLimitPrice', 'outPutMaxPrice'].includes(fieldName)) {
- if (avalue) {
- const unitFee = node.data && node.data.feesIndex && node.data.feesIndex.common && node.data.feesIndex.common.unitFee || 0;
- const maxPriceRate = projectObj.project.property.maxPriceRate || 0;
- data.maxPrice = scMathUtil.roundForObj(unitFee * (1 + maxPriceRate * 0.01), decimalObj.bills.unitPrice) || null;
- const minPriceRate = projectObj.project.property.minPriceRate || 0;
- data.minPrice = scMathUtil.roundForObj(unitFee * (1 - minPriceRate * 0.01), decimalObj.bills.unitPrice) || null;
- } else {
- data.maxPrice = null;
- data.minPrice = null;
- }
- }
- }
- };
- project.prototype.updateNodesAndRefresh=function (datas,callback) {
- let me = this;
- this.updateNodes(datas,function () {
- let nodes = me.updateNodesCache(datas);
- if(callback) callback(nodes);
- })
- };
- project.prototype.syncUpdateNodesAndRefresh =async function (datas) {
- let me = this;
- return new Promise(function (resolve, reject) {
- me.updateNodes(datas,function (result) {
- let nodes = me.updateNodesCache(result);
- projectObj.mainController.refreshTreeNode(nodes);
- resolve(nodes);
- });
- });
- };
- project.prototype.updateNodes = function (datas,callback) {
- /* let datas = [
- {
- type:'ration',
- data:{
- projectID:1605,
- ID:"7b962fb0-1131-11e8-b3da-af725dadd7ae",
- name:'testRation'
- }
- },
- {
- type:'bills',
- data:{
- projectID:1605,
- ID:"af9f0081-1127-11e8-99a8-2fc02230b6e7",
- name:'安全文明施工专项费用123'
- }
- }
- ]*/
- $.bootstrapLoading.start();
- CommonAjax.post("/project/updateNodes",datas,function (data) {
- if(callback){
- callback(data);
- $.bootstrapLoading.end();
- }
- })
- };
- project.prototype.updateParentNode = function(node,parentID,addNodeDatas){
- addNodeDatas.push({type:node.sourceType,data:node.data,parentID:parentID});
- for(let c of node.children){
- this.updateParentNode(c,node.getID(),addNodeDatas);
- }
-
- };
- project.prototype.updateNodesCache =function (datas) {
- let refreshNode = [];
- let reclacQuantity = false;
- let deleteNode=[],addNodeDatas=[];
- // let changeParentIDMap = {}; 确定刷新无错后删除
- for(let d of datas){
- let temObj = null;
- if(d.type == ModuleNames.bills || d.type == ModuleNames.ration){//如果是树节点类型,直接取树节点更新
- if(d.action =="add"){
- if(d.type == ModuleNames.ration) this.Ration.datas.push(d.data);
- reclacQuantity = true;
- addNodeDatas.push(d);
- }else {
- let temNode = this.mainTree.getNodeByID(d.data.ID);
- if(temNode){
- if(d.action =="delete"){
- if(d.type == ModuleNames.ration){
- _.remove(this.Ration.datas,{'ID':d.data.ID});
- this.Ration.deleteSubListOfRation({ID:d.data.ID});
- reclacQuantity = true;
- }
- deleteNode.push(temNode);//对于删除节点,统一不加入refreshNode中,由外部加入,避免重复
- }else {
- temObj = temNode.data;
- if(gljUtil.isDef(d.data.quantity))reclacQuantity = true;
- refreshNode.push(temNode);
- if(d.data.ParentID){//更新了父节点-相当于删了再添加
- //changeParentIDMap[temNode.data.ParentID] = true;
- deleteNode.push(temNode);
- this.updateParentNode(temNode,d.data.ParentID,addNodeDatas);
- }
- }
- }
- }
- }else if(d.type == ModuleNames.project){
- temObj = d.isInfo?this.projectInfo:this;
- }else if (d.type == ModuleNames.ration_glj && d.action == "add"){
- this[d.type].datas.push(d.data);
- if(d.projectGLJ) this.projectGLJ.loadNewProjectGLJToCache(d.projectGLJ);
- } else {//其它类型,更新datas
- temObj = _.find(this[d.type].datas,{"ID":d.data.ID});
- }
- if(temObj){
- for(let key in d.data){
- if(key == 'ID' || key == 'id'){
- continue;
- }
- this.setValue(temObj,key,d.data[key])
- }
- }
- }
- //对树节点的操作并删除、添加清单、删除添加定额、删除对应的定额工料机缓存
- TREE_SHEET_HELPER.massOperationSheet(projectObj.mainController.sheet, function () {
- let rationsDatas=[];
- let billsDatas=[];
- for(let a of addNodeDatas){
- if(a.type == ModuleNames.bills) billsDatas.push(a);
- if(a.type == ModuleNames.ration) rationsDatas.push(a);
- }
- deleteTreeNodes(deleteNode);
- addNewNodes(billsDatas,refreshNode);
- addNewNodes(rationsDatas,refreshNode);
- });
- /* for(let pID in changeParentIDMap){
- let pnode = this.mainTree.getNodeByID(pID);
- getNextRefreshNode(pnode,refreshNode);
- } */
- if(reclacQuantity) this.projectGLJ.calcQuantity();
- return refreshNode;
- /* function getNextRefreshNode(node,refreshNode){
- if(node.nextSibling){
- refreshNode.push(node.nextSibling)
- getNextRefreshNode(node.nextSibling,refreshNode)
- }
- }; */
- function deleteTreeNodes(deleteNodes) {
- let controller = projectObj.mainController, project = projectObj.project;
- let Bill = project.Bills, Ration = project.Ration;
- for(let rd of deleteNodes){
- controller.sheet.deleteRows(rd.serialNo(),rd.posterityCount() + 1);
- controller.tree.delete(rd);
- if(rd.sourceType == Bill.getSourceType()) Bill.tree.delete(rd.source);
- }
- }
- function addNewNodes(newDatas,refreshNode) {
- let controller = projectObj.mainController;
- let Bill = projectObj.project.Bills;
- let newAddNode = [];
- for(let nr of newDatas){
- let nextID = -1;
- let parentID = nr.parentID || (nr.data && nr.data.ParentID || -1);
- let preNode = projectObj.project.mainTree.getNodeByID(nr.preSiblingID);
- if(preNode) nextID = preNode.getNextSiblingID();
- let newNode = projectObj.project.mainTree.insert(parentID, nextID, nr.data.ID);
- if(nr.type == ModuleNames.bills){
- let newSource = Bill.tree.insertByData(nr.data, parentID, nextID, true);
- newNode.source = newSource;
- }else {
- newNode.source = nr.data;
- }
- newNode.sourceType = nr.type;
- newNode.data = nr.data;
- controller.sheet.addRows(newNode.serialNo(), 1);
- controller.sheet.showRow(newNode.serialNo(), GC.Spread.Sheets.VerticalPosition.center);
- newAddNode.push(newNode);
- refreshNode.push(newNode);
- }
- TREE_SHEET_HELPER.refreshTreeNodeData(controller.setting, controller.sheet, newAddNode, false);
- }
- };
- project.prototype.setValue=function (obj,key,value) {
- let keyArray = key.split('.');
- t_set(obj,value,keyArray,0);
- function t_set(obj,value,arr,index) {
- let nextIndex = index + 1;
- let tkey = arr[index];
- if(nextIndex < arr.length){
- if(obj[tkey]==undefined){
- obj[tkey] = {};
- }
- t_set(obj[tkey],value,arr,nextIndex)
- }else if(nextIndex == arr.length){
- obj[tkey] = value;
- }
- }
- }
- project.prototype.updateEvalproject = function (evalProject,data,callback){
- let programID = null;
- if(evalProject ==1){//当打勾估价项目选项后,该定额取费专业读取计算程序名称为“估价项目”的计算程序,且为只读状态
- programID = this.calcProgram.compiledTemplateMaps["估价项目"];
- if(callback) callback(programID);
- }else {//如果evalProject==0,则是去掉勾选估价项目选项,需要获取定额默认的取费专业。
- let libID = data.from == 'cpt'?"compleRationLib":data.libID;
- let query = {code:data.code,projectID:data.projectID,libID:libID};
- CommonAjax.post("/ration/getDefaultProgramID",query,function (result) {
- if(callback) callback(result);
- })
- }
- };
- //判断项目是否安装工程
- project.prototype.isInstall = function () {
- return projectObj.project.projectInfo.property.isInstall?true:false;//如果是undefinded 就也返回false
- };
- // 判断项目能否使用超高降效相关功能 (是否含有超高降效库数据)
- project.prototype.isOverHeightProject = function () {
- const overHeight = projectObj.project.projectInfo.property.overHeight;
- return Array.isArray(overHeight) && overHeight.length;
- }
- /* project.prototype.setBillsCalcMode = function (calcMode) {
- this.property.billsCalcMode = calcMode;
- this.initCalcFields();
- };*/
- /*project.prototype.initCalcFields = function () {
- // let settingConst = this.projSetting.settingConst;
- if (this.calcFields) {
- for (let field of this.calcFields) {
- // unitFeeCalcFlag
- if (field.type === 'zangu') {
- field.unitFeeFlag = converseUnitFeeFlag;
- } else {
- // if (this.projSetting.billsCalcMode === settingConst.billsCalcMode.rationContent) {
- if (this.property.billsCalcMode === leafBillGetFeeType.rationContent) {
- field.unitFeeFlag = rationContentUnitFeeFlag;
- // } else if ( this.projSetting.billsCalcMode === settingConst.billsCalcMode.billsPrice) {
- } else if ( this.property.billsCalcMode === leafBillGetFeeType.billsPrice) {
- field.unitFeeFlag = billsPriceUnitFeeFlag;
- } else {
- field.unitFeeFlag = averageQtyUnitFeeFlag;
- }
- }
- // totalFeeCalcFlag
- if (field.type === 'common') {
- // if (this.projSetting.billsCalcMode === settingConst.billsCalcMode.rationPriceConverse) {
- if (this.property.billsCalcMode === leafBillGetFeeType.rationPriceConverse) {
- field.totalFeeFlag = sumTotalFeeFlag;
- } else {
- field.totalFeeFlag = totalFeeFlag;
- }
- } else {
- field.totalFeeFlag = sumTotalFeeFlag;
- }
- }
- }
- }*/
- return new project();
- }
- };
|