project.js 30 KB

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