project.js 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716
  1. /**
  2. * Created by Mai on 2017/4/1.
  3. */
  4. var PROJECT = {
  5. createNew: function (projectID, userID) {
  6. // 定义private方法
  7. var tools = {
  8. _project: null,
  9. _ID: parseInt(projectID),
  10. _userID: userID,
  11. updateLock: 0,
  12. updateData: [],
  13. operation: '',
  14. modules: {},
  15. projCounter: 'projCounter',
  16. projSetting: 'proj_setting'
  17. };
  18. var me = tools;
  19. tools.doAfterUpdate = function(result){
  20. if (!result) { return }
  21. result.forEach(function(item){
  22. if(_.isArray(item)){
  23. item.forEach(function (e) {
  24. me.eachItem(e);
  25. })
  26. }else {
  27. me.eachItem(item)
  28. }
  29. });
  30. };
  31. // isInit: 是否是初始化,导出接口用到getData,但是非初始化,多次调用getData不会覆盖原有缓存数据
  32. tools.doAfterLoad = function(result, isInit, callback){
  33. var counter;
  34. //必须要先load ProjectInfo的信息
  35. let projectInfoModule = result.find(data => data.moduleName === ModuleNames.projectInfo);
  36. if (projectInfoModule) {
  37. me._project.projectInfo = projectInfoModule.data;
  38. OVER_HEIGHT.init(me._project.projectInfo.property.overHeight);
  39. }
  40. result.forEach(function(item){
  41. if (item.moduleName !== ModuleNames.projectInfo) {
  42. if (me.modules[item.moduleName]){
  43. me.modules[item.moduleName].loadData(item.data, isInit);
  44. } else if (item.moduleName === me.projCounter) {
  45. counter = item.data;
  46. } else if (item.moduleName === me.projSetting) {
  47. me._project.projSetting = item.data;
  48. me._project.projSetting.moduleName = me.projSetting;
  49. } else if(item.moduleName === ModuleNames.projectGLJ){
  50. me._project.projectGLJ.loadToCache(item.data);
  51. }
  52. }
  53. });
  54. for (module in counter) {
  55. if (me.modules[module]) {
  56. me.modules[module].setMaxID(counter[module]);
  57. }
  58. }
  59. if (isInit) {
  60. projectInfoObj.showProjectInfo(me._project.projectInfo);
  61. }
  62. me._project.loadMainTree();
  63. //me.test(result[0].data[0]);
  64. if (callback) {
  65. callback(0);
  66. }
  67. };
  68. tools.eachItem=function(item){
  69. if (me.modules[item.moduleName]){
  70. me.modules[item.moduleName].doAfterUpdate(item.err, item.data);
  71. }
  72. };
  73. /*tools.test = function(data){
  74. me._project.beginUpdate('修改名称');
  75. data.name = 'test';
  76. data['updateType'] = 'ut_update';
  77. me._project.push(ModuleNames.bills, [data]);
  78. me._project.endUpdate();
  79. };*/
  80. // 所有通过this访问的属性,都不应在此单元外部进行写入操作
  81. var project = function () {
  82. tools._project = this;
  83. this.mainTree = cacheTree.createNew(this);
  84. this.Bills = Bills.createNew(this);
  85. this.Ration = Ration.createNew(this);
  86. this.GLJ = GLJ.createNew(this);
  87. this.ration_glj = ration_glj.createNew(this);
  88. this.ration_coe = ration_coe.createNew(this);
  89. this.ration_ass = ration_ass.createNew(this);
  90. this.ration_installation = ration_installation.createNew(this);
  91. this.ration_template = ration_template.createNew(this);
  92. this.quantity_detail = quantity_detail.createNew(this);
  93. this.installation_fee = installation_fee.createNew(this);
  94. this.FeeRate = FeeRate.createNew(this);
  95. // this.VolumePrice = VolumePrice.createNew(this);
  96. this.projectGLJ = new ProjectGLJ();
  97. // this.projectGLJ.loadData();
  98. this.composition = new Composition();
  99. this.composition.loadData();
  100. this.labourCoe = new LabourCoe(this);
  101. this.calcProgram = new CalcProgram(this);
  102. this.evaluate_list = new EvaluateList(this);
  103. this.bid_evaluation_list = new BidEvaluationList(this);
  104. this.contractor_list = new ContractorList(this);
  105. this.calcBase = calcBase;
  106. // this.masterField = {ration: 'billsItemID', volumePrice: 'billsItemID'};
  107. this.masterField = {ration: 'billsItemID'};
  108. };
  109. // prototype用于定义public方法
  110. project.prototype.modify = function (modifyDatas, callback) {
  111. // To Do
  112. };
  113. // prototype用于定义public方法
  114. project.prototype.ID = function () {
  115. return tools._ID;
  116. };
  117. project.prototype.projCounter = function () {
  118. return tools.projCounter;
  119. };
  120. project.prototype.getDecimal = function (fullName) {
  121. let names = fullName.split('.'), decimal = this.Decimal;
  122. for (let name of names) {
  123. if (decimal[name]) {
  124. decimal = decimal[name];
  125. } else {
  126. return null;
  127. }
  128. }
  129. if (Object.prototype.toString.apply(decimal) === '[object Number]') {
  130. return decimal;
  131. } else {
  132. return null;
  133. }
  134. };
  135. project.prototype.loadMainTree = function () {
  136. var that = this;
  137. let loadRationGLJNode = function (cacheNode) {
  138. var newNode, bj = that.ration_glj.getMainAndEquGLJ(cacheNode.source.ID), i;
  139. for(i=0;i<bj.length;i++){
  140. that.ration_glj.transferToNodeData(bj[i]);
  141. newNode = that.mainTree.addNode(cacheNode, null, bj[i].ID);
  142. newNode.source = bj[i];
  143. newNode.sourceType = that.ration_glj.getSourceType();
  144. newNode.data = bj[i];
  145. }
  146. };
  147. var loadRationNode = function (rations, cacheNode) {
  148. var newNode, br = that.Ration.getBillsSortRation(cacheNode.source.getID()), i;
  149. for (i = 0; i < br.length; i++) {
  150. newNode = that.mainTree.addNode(cacheNode, null, br[i].ID);
  151. if(br[i].type==rationType.gljRation){
  152. br[i]= that.ration_glj.combineRationAndGLJ(br[i]);
  153. }
  154. newNode.source = br[i];
  155. newNode.sourceType = that.Ration.getSourceType();
  156. newNode.data = br[i];
  157. if(projectObj.project.projectInfo.property.displaySetting !== undefined &&
  158. projectObj.project.projectInfo.property.displaySetting.disPlayMainMaterial==true){
  159. loadRationGLJNode(newNode);
  160. }
  161. }
  162. };
  163. /* let loadVolumePriceNode = function (cacheNode) {
  164. let newNode = null, bv = that.VolumePrice.getBillsSortVolumePrice(cacheNode.source.getID());
  165. for (let v of bv) {
  166. newNode = that.mainTree.addNode(cacheNode);
  167. newNode.source = v;
  168. newNode.sourceType = that.VolumePrice.getSourceType();
  169. newNode.data = v;
  170. }
  171. };*/
  172. var loadIdTreeNode = function (nodes, parent) {
  173. var newNode, i;
  174. for (i = 0; i < nodes.length; i++) {
  175. newNode = that.mainTree.addNode(parent, null, nodes[i].data.ID);
  176. newNode.source = nodes[i];
  177. newNode.sourceType = that.Bills.getSourceType();
  178. newNode.data = nodes[i].data;
  179. that.FeeRate.loadFeeRateToBill(newNode);
  180. if (nodes[i].children.length === 0) {
  181. loadRationNode(that.Ration.datas, newNode);
  182. // loadVolumePriceNode(newNode);
  183. } else {
  184. loadIdTreeNode(nodes[i].children, newNode);
  185. }
  186. }
  187. };
  188. loadIdTreeNode(this.Bills.tree.roots, null);
  189. this.mainTree.sortTreeItems();
  190. this.mainTree.selected = this.mainTree.firstNode();
  191. };
  192. project.prototype.getParentTarget = function (node, targetField, targetValue) {
  193. var parent = node;
  194. while (parent && parent[targetField] !== targetValue) {
  195. parent = parent.parent;
  196. }
  197. return parent;
  198. };
  199. // 提供给各模块调用的统一从后台获取数据的方法
  200. /*project.prototype.pullData = function (url, data, successCallback, errorCallback) {
  201. $.ajax({
  202. type:"POST",
  203. url: url,
  204. data: {'data': JSON.stringify(data)},
  205. dataType: 'json',
  206. cache: false,
  207. timeout: 50000,
  208. success: function(result){
  209. successCallback(result);
  210. },
  211. error: function(jqXHR, textStatus, errorThrown){
  212. alert('error ' + textStatus + " " + errorThrown);
  213. errorCallback();
  214. }
  215. });
  216. };*/
  217. // 所有模块在此从后台获取数据
  218. project.prototype.loadDatas = function (callback){
  219. $.ajax({
  220. type: "POST",
  221. url: '/project/getData',
  222. data: {'data': JSON.stringify({
  223. "project_id": tools._ID,
  224. "user_id": tools._userID
  225. })},
  226. dataType: 'json',
  227. cache: false,
  228. timeout: 50000,
  229. success: function (result) {
  230. if (!result.error) {
  231. const isInit = true;
  232. tools.doAfterLoad(result.data, isInit, callback);
  233. // for test calc
  234. //tools.doAfterLoad([{moduleName: 'bills', data: BillsData}, {'moduleName': 'ration', data: DrawingData}], callback);
  235. } else {
  236. alert('error: ' + result.message);
  237. callback(result.error);
  238. }
  239. },
  240. error: function(jqXHR, textStatus, errorThrown){
  241. alert('error ' + textStatus + " " + errorThrown);
  242. }
  243. });
  244. };
  245. project.prototype.loadDataSync = async function () {
  246. const data = await ajaxPost('/project/getDataForInterface', {user_id: tools._userID, project_id: tools._ID});
  247. if (data) {
  248. const isInit = false;
  249. tools.doAfterLoad(data, isInit);
  250. }
  251. };
  252. project.prototype.beginUpdate = function(operation){
  253. if (tools.updateLock === 0){
  254. tools.operation = operation
  255. }
  256. tools.updateLock += 1;
  257. };
  258. project.prototype.endUpdate = function(){
  259. if (tools.updateLock === 0){
  260. throw "project can not endUpdate before beginUpdate";
  261. }
  262. tools.updateLock -= 1;
  263. if (tools.updateLock === 0) {
  264. $.ajax({
  265. type: "POST",
  266. url: '/project/save',
  267. data: {'data': JSON.stringify({
  268. "project_id": tools._ID,
  269. "user_id": tools._userID,
  270. "date": new Date,
  271. "operation": tools.operation,
  272. "update_data": tools.updateData
  273. })},
  274. dataType: 'json',
  275. cache: false,
  276. timeout: 50000,
  277. success: function (result) {
  278. if (!result.error) {
  279. tools.doAfterUpdate(result.data);
  280. } else {
  281. alert('error: ' + result.message);
  282. }
  283. $.bootstrapLoading.end();
  284. },
  285. error: function(jqXHR, textStatus, errorThrown){
  286. alert('error ' + textStatus + " " + errorThrown);
  287. $.bootstrapLoading.end();
  288. }
  289. });
  290. tools.updateData = [];
  291. tools.operation = "";
  292. }
  293. };
  294. project.prototype.push = function(moduleName, data){
  295. if (tools.updateLock === 0){
  296. throw "project can not push data before beginUpdate";
  297. }
  298. var moduleData = {
  299. moduleName: moduleName,
  300. data: data
  301. };
  302. tools.updateData.push(moduleData);
  303. };
  304. project.prototype.pushNow = function (operation, moduleName, data) {
  305. var that = this;
  306. this.beginUpdate(operation);
  307. if (Object.prototype.toString.apply(moduleName) === "[object Array]" && Object.prototype.toString.apply(data) === "[object Array]") {
  308. moduleName.forEach(function (name, index) {
  309. if(name != 'projCounter'){
  310. that.push(moduleName[index], data[index]);
  311. }
  312. });
  313. } else {
  314. this.push(moduleName, data);
  315. }
  316. this.endUpdate();
  317. };
  318. project.prototype.registerModule = function(moduleName, obj){
  319. if (!tools.modules.hasOwnProperty(moduleName)){
  320. tools.modules[moduleName] = obj;
  321. }
  322. };
  323. project.prototype.markUpdateProject = function (data,type,callback) {
  324. $.bootstrapLoading.start()
  325. CommonAjax.post("/project/markUpdateProject",{updateInfo:data,type:type},function(){
  326. if(callback) callback();
  327. $.bootstrapLoading.end()
  328. });
  329. };
  330. project.prototype.saveProperty = function (propertyName, propertyValue) {
  331. CommonAjax.post("/project/saveProperty", {projectID: this.ID(), propertyName: propertyName, propertyValue: propertyValue});
  332. };
  333. project.prototype.projectMarkChecking = function () {
  334. let me = this;
  335. let changeMark = projectObj.project.projectInfo.changeMark;
  336. if(changeMark&&changeMark!=''){
  337. this.Bills.getEngineeringCostNode(projectObj.mainController).changed = true;
  338. this.calcProgram.calcAllNodesAndSave();
  339. CommonAjax.post("/project/removeProjectMark",{projectID:me.ID()},function (data) {
  340. delete projectObj.project.projectInfo.changeMark;
  341. if(socket.connected == true){//如果这时候socket已经连接成功,则发送删除标记广播
  342. socket.emit('removeProjectMark',{projectID:me.ID(),userID:userID});
  343. }else {//如果还没连接成功,则放入消息对象缓存,等socket连接成功后发送
  344. socketObject.messages.push({message:'removeProjectMark',data:{projectID:me.ID(),userID:userID}});
  345. }
  346. });
  347. }
  348. };
  349. project.prototype.updateLockBills = function (value,callback) {
  350. let mixDatas = {
  351. projectID: projectObj.project.ID(),
  352. updateType: 'update',
  353. properties: {
  354. "property.lockBills":value
  355. },
  356. labourCoes: {},
  357. rations: [],
  358. bills: []
  359. };
  360. $.bootstrapLoading.start();
  361. CommonAjax.post('/pm/api/updateMixDatas', {user_id: userID, mixDataArr: mixDatas}, function (rstData) {
  362. projectObj.project.projectInfo.property.lockBills = value;
  363. if(callback){
  364. callback();
  365. }
  366. $.bootstrapLoading.end();
  367. });
  368. };
  369. //返回清单是否被锁定
  370. project.prototype.isBillsLocked =function(){
  371. if(projectObj.project.projectInfo.property.lockBills == true){
  372. return true;
  373. }
  374. return false;
  375. };
  376. //清单是否属于锁定范围(分部分项、措施项目)
  377. project.prototype.withinBillsLocked = function (node) {
  378. const lockedFixFlag = [fixedFlag.SUB_ENGINERRING, fixedFlag.MEASURE];
  379. while(node){
  380. if(!node.parent){
  381. if(node.data.flagsIndex && node.data.flagsIndex.fixed && lockedFixFlag.includes(node.data.flagsIndex.fixed.flag)){
  382. return true;
  383. }
  384. else {
  385. return false;
  386. }
  387. }
  388. node = node.parent;
  389. }
  390. return true;
  391. };
  392. project.prototype.updateProjectProperty = function(datas,field,callback){
  393. let pfield = "property."+field;
  394. let tem ={
  395. type:'project',
  396. data:{ID:projectObj.project.ID()}
  397. };
  398. tem.data[pfield] = datas;
  399. projectObj.project.updateNodes([tem],function () {
  400. projectObj.project.property[field] = datas;
  401. if(callback) callback();
  402. })
  403. };
  404. project.prototype.updateCasCadeBills = function(node,newval,fieldName){
  405. let datas = [];
  406. let data = {
  407. type:node.sourceType,
  408. data:{ID:node.data.ID}
  409. };
  410. setData(data.data,newval,fieldName);
  411. datas.push(data);
  412. setChildren(node,newval,datas);//同步设置所有子项
  413. setParent(node,newval,datas);//设置父节点
  414. $.bootstrapLoading.start();
  415. this.updateNodes(datas,function () {
  416. let nodes = [];
  417. for(let d of datas){
  418. let node = projectObj.project.mainTree.findNode(d.data.ID);
  419. if(node){
  420. for(let key in d.data){
  421. if(key == 'ID') continue;
  422. node.data[key] = d.data[key];
  423. }
  424. nodes.push(node)
  425. }
  426. }
  427. projectObj.mainController.refreshTreeNode(nodes);
  428. $.bootstrapLoading.end();
  429. });
  430. function setChildren(pnode,newValue,datas) {//同步设置所有子项
  431. if(pnode.children.length > 0 && pnode.children[0].sourceType == ModuleNames.bills){//设置子项不包括定额
  432. for(let c of pnode.children){
  433. let data = {
  434. type:c.sourceType,
  435. data:{ID:c.data.ID}
  436. };
  437. setData(data.data,newval,fieldName);
  438. datas.push(data);
  439. setChildren(c,newValue,datas)
  440. }
  441. }
  442. }
  443. function setParent(cnode,newValue,datas) {
  444. let diferrent = false;
  445. if(cnode.parent && !projectObj.project.Bills.isMeasureNode(cnode.parent)){//排除措施项目节点
  446. for(b of cnode.parent.children){
  447. if(b == cnode) continue
  448. if(b.data[fieldName]!== newValue){//有兄弟节点的值和本节点不一样,则父节点设置为null
  449. diferrent = true;
  450. break;
  451. }
  452. }
  453. let pvalue = diferrent === true?null:newValue;
  454. let data = {
  455. type:cnode.parent.sourceType,
  456. data:{ID:cnode.parent.data.ID}
  457. };
  458. setData(data.data,pvalue,fieldName);
  459. datas.push(data);
  460. setParent(cnode.parent,pvalue,datas);
  461. }
  462. }
  463. function setData(data,avalue,fieldName) {
  464. data[fieldName] = avalue;
  465. if(fieldName == "outPutMaxPrice") data.maxPrice = null;
  466. }
  467. };
  468. project.prototype.updateNodesAndRefresh=function (datas,callback) {
  469. let me = this;
  470. this.updateNodes(datas,function () {
  471. let nodes = me.updateNodesCache(datas);
  472. if(callback) callback(nodes);
  473. })
  474. };
  475. project.prototype.syncUpdateNodesAndRefresh =async function (datas) {
  476. let me = this;
  477. return new Promise(function (resolve, reject) {
  478. me.updateNodes(datas,function (result) {
  479. let nodes = me.updateNodesCache(result);
  480. projectObj.mainController.refreshTreeNode(nodes);
  481. resolve(nodes);
  482. });
  483. });
  484. };
  485. project.prototype.updateNodes = function (datas,callback) {
  486. /* let datas = [
  487. {
  488. type:'ration',
  489. data:{
  490. projectID:1605,
  491. ID:"7b962fb0-1131-11e8-b3da-af725dadd7ae",
  492. name:'testRation'
  493. }
  494. },
  495. {
  496. type:'bills',
  497. data:{
  498. projectID:1605,
  499. ID:"af9f0081-1127-11e8-99a8-2fc02230b6e7",
  500. name:'安全文明施工专项费用123'
  501. }
  502. }
  503. ]*/
  504. $.bootstrapLoading.start();
  505. CommonAjax.post("/project/updateNodes",datas,function (data) {
  506. if(callback){
  507. callback(data);
  508. $.bootstrapLoading.end();
  509. }
  510. })
  511. };
  512. project.prototype.updateNodesCache =function (datas) {
  513. let refreshNode = [];
  514. let reclacQuantity = false;
  515. let deleteNode=[],addNodeDatas=[];
  516. for(let d of datas){
  517. let temObj = null;
  518. if(d.type == ModuleNames.bills || d.type == ModuleNames.ration){//如果是树节点类型,直接取树节点更新
  519. if(d.action =="add"){
  520. if(d.type == ModuleNames.ration) this.Ration.datas.push(d.data);
  521. reclacQuantity = true;
  522. addNodeDatas.push(d);
  523. }else {
  524. let temNode = this.mainTree.getNodeByID(d.data.ID);
  525. if(temNode){
  526. if(d.action =="delete"){
  527. if(d.type == ModuleNames.ration){
  528. _.remove(this.Ration.datas,{'ID':d.data.ID});
  529. this.Ration.deleteSubListOfRation({ID:d.data.ID});
  530. reclacQuantity = true;
  531. }
  532. deleteNode.push(temNode);//对于删除节点,统一不加入refreshNode中,由外部加入,避免重复
  533. }else {
  534. temObj = temNode.data;
  535. if(gljUtil.isDef(d.data.quantity))reclacQuantity = true;
  536. refreshNode.push(temNode);
  537. }
  538. }
  539. }
  540. }else if(d.type == ModuleNames.project){
  541. temObj = this;
  542. }else if (d.type == ModuleNames.ration_glj && d.action == "add"){
  543. this[d.type].datas.push(d.data);
  544. if(d.projectGLJ) this.projectGLJ.loadNewProjectGLJToCache(d.projectGLJ);
  545. } else {//其它类型,更新datas
  546. temObj = _.find(this[d.type].datas,{"ID":d.data.ID});
  547. }
  548. if(temObj){
  549. for(let key in d.data){
  550. if(key == 'ID' || key == 'id'){
  551. continue;
  552. }
  553. this.setValue(temObj,key,d.data[key])
  554. }
  555. }
  556. }
  557. //对树节点的操作并删除、添加清单、删除添加定额、删除对应的定额工料机缓存
  558. TREE_SHEET_HELPER.massOperationSheet(projectObj.mainController.sheet, function () {
  559. deleteTreeNodes(deleteNode);
  560. addNewNodes(addNodeDatas,refreshNode);
  561. });
  562. if(reclacQuantity) this.projectGLJ.calcQuantity();
  563. return refreshNode;
  564. function deleteTreeNodes(deleteNodes) {
  565. let controller = projectObj.mainController, project = projectObj.project;
  566. let Bill = project.Bills, Ration = project.Ration;
  567. for(let rd of deleteNodes){
  568. controller.sheet.deleteRows(rd.serialNo(),1);
  569. controller.tree.delete(rd);
  570. if(rd.sourceType == Bill.getSourceType()) Bill.tree.delete(rd.source);
  571. }
  572. }
  573. function addNewNodes(newDatas,refreshNode) {
  574. let controller = projectObj.mainController;
  575. let Bill = projectObj.project.Bills;
  576. let newAddNode = [];
  577. for(let nr of newDatas){
  578. let nextID = -1;
  579. let preNode = projectObj.project.mainTree.getNodeByID(nr.preSiblingID);
  580. if(preNode) nextID = preNode.getNextSiblingID();
  581. let newNode = projectObj.project.mainTree.insert(nr.parentID, nextID, nr.data.ID);
  582. if(nr.type == ModuleNames.bills){
  583. let newSource = Bill.tree.insertByData(nr.data, nr.ParentID, nextID, true);
  584. newNode.source = newSource;
  585. }else {
  586. newNode.source = nr.data;
  587. }
  588. newNode.sourceType = nr.type;
  589. newNode.data = nr.data;
  590. controller.sheet.addRows(newNode.serialNo(), 1);
  591. controller.sheet.showRow(newNode.serialNo(), GC.Spread.Sheets.VerticalPosition.center);
  592. newAddNode.push(newNode);
  593. refreshNode.push(newNode);
  594. }
  595. TREE_SHEET_HELPER.refreshTreeNodeData(controller.setting, controller.sheet, newAddNode, false);
  596. }
  597. };
  598. project.prototype.setValue=function (obj,key,value) {
  599. let keyArray = key.split('.');
  600. t_set(obj,value,keyArray,0);
  601. function t_set(obj,value,arr,index) {
  602. let nextIndex = index + 1;
  603. let tkey = arr[index];
  604. if(nextIndex < arr.length){
  605. if(obj[tkey]==undefined){
  606. obj[tkey] = {};
  607. }
  608. t_set(obj[tkey],value,arr,nextIndex)
  609. }else if(nextIndex == arr.length){
  610. obj[tkey] = value;
  611. }
  612. }
  613. }
  614. project.prototype.updateEvalproject = function (evalProject,data,callback){
  615. let programID = null;
  616. if(evalProject ==1){//当打勾估价项目选项后,该定额取费专业读取计算程序名称为“估价项目”的计算程序,且为只读状态
  617. programID = this.calcProgram.compiledTemplateMaps["估价项目"];
  618. if(callback) callback(programID);
  619. }else {//如果evalProject==0,则是去掉勾选估价项目选项,需要获取定额默认的取费专业。
  620. let libID = data.from == 'cpt'?"compleRationLib":data.libID;
  621. let query = {code:data.code,projectID:data.projectID,libID:libID};
  622. CommonAjax.post("/ration/getDefaultProgramID",query,function (result) {
  623. if(callback) callback(result);
  624. })
  625. }
  626. };
  627. //判断项目是否安装工程
  628. project.prototype.isInstall = function () {
  629. return projectObj.project.projectInfo.property.isInstall?true:false;//如果是undefinded 就也返回false
  630. };
  631. // 判断项目能否使用超高降效相关功能 (是否含有超高降效库数据)
  632. project.prototype.isOverHeightProject = function () {
  633. const overHeight = projectObj.project.projectInfo.property.overHeight;
  634. return Array.isArray(overHeight) && overHeight.length;
  635. }
  636. /* project.prototype.setBillsCalcMode = function (calcMode) {
  637. this.property.billsCalcMode = calcMode;
  638. this.initCalcFields();
  639. };*/
  640. /*project.prototype.initCalcFields = function () {
  641. // let settingConst = this.projSetting.settingConst;
  642. if (this.calcFields) {
  643. for (let field of this.calcFields) {
  644. // unitFeeCalcFlag
  645. if (field.type === 'zangu') {
  646. field.unitFeeFlag = converseUnitFeeFlag;
  647. } else {
  648. // if (this.projSetting.billsCalcMode === settingConst.billsCalcMode.rationContent) {
  649. if (this.property.billsCalcMode === leafBillGetFeeType.rationContent) {
  650. field.unitFeeFlag = rationContentUnitFeeFlag;
  651. // } else if ( this.projSetting.billsCalcMode === settingConst.billsCalcMode.billsPrice) {
  652. } else if ( this.property.billsCalcMode === leafBillGetFeeType.billsPrice) {
  653. field.unitFeeFlag = billsPriceUnitFeeFlag;
  654. } else {
  655. field.unitFeeFlag = averageQtyUnitFeeFlag;
  656. }
  657. }
  658. // totalFeeCalcFlag
  659. if (field.type === 'common') {
  660. // if (this.projSetting.billsCalcMode === settingConst.billsCalcMode.rationPriceConverse) {
  661. if (this.property.billsCalcMode === leafBillGetFeeType.rationPriceConverse) {
  662. field.totalFeeFlag = sumTotalFeeFlag;
  663. } else {
  664. field.totalFeeFlag = totalFeeFlag;
  665. }
  666. } else {
  667. field.totalFeeFlag = sumTotalFeeFlag;
  668. }
  669. }
  670. }
  671. }*/
  672. return new project();
  673. }
  674. };