ration.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  1. /**
  2. * Created by Mai on 2017/4/1.
  3. */
  4. var Ration = {
  5. createNew: function (project) {
  6. // 用户定义private方法
  7. var tools = {
  8. formatRationUpdateData: function (data) {
  9. let uData = JSON.parse(JSON.stringify(data));
  10. delete uData.feesIndex;
  11. delete uData.flagsIndex;
  12. // if (uData.fees) {
  13. // for (let fee of uData.fees) {
  14. // fee.unitFee = fee.unitFee.toFixed(2);
  15. // fee.totalFee = fee.totalFee.toFixed(2);
  16. // fee.tenderUnitFee = fee.tenderUnitFee.toFixed(2);
  17. // fee.tenderTotalFee = fee.tenderTotalFee.toFixed(2);
  18. // }
  19. // }
  20. return uData;
  21. }
  22. };
  23. // 所有通过this访问的属性,都不应在此单元外部进行写入操作
  24. var ration = function (proj) {
  25. this.project = proj;
  26. this.datas = null;
  27. var sourceType = ModuleNames.ration;
  28. this.getSourceType = function () {
  29. return sourceType;
  30. }
  31. proj.registerModule(ModuleNames.ration, this);
  32. var maxRationID = 0;
  33. this.getNewRationID = function () {
  34. return uuid.v1();
  35. //return maxRationID += 1;
  36. };
  37. this.maxRationID = function (maxID) {
  38. if (arguments.length === 0) {
  39. return maxRationID;
  40. } else {
  41. maxRationID = Math.max(maxID, maxRationID);
  42. }
  43. };
  44. };
  45. // prototype用于定义public方法
  46. ration.prototype.loadData = function (datas) {
  47. var that = this;
  48. this.datas = datas;
  49. // generate Fees & Flags Index,For View & Calculate
  50. this.datas.forEach(function (data) {
  51. data.feesIndex = {};
  52. data.fees.forEach(function (fee) {
  53. data.feesIndex[fee.fieldName] = fee;
  54. });
  55. data.flagsIndex = {};
  56. data.flags.forEach(function (flag) {
  57. data.flagsIndex[flag.fieldName] = flag;
  58. });
  59. that.maxRationID(data.ID);
  60. });
  61. };
  62. ration.prototype.setMaxID = function (ID) {
  63. this.maxRationID(ID);
  64. }
  65. // refresh after update
  66. ration.prototype.doAfterUpdate = function(err, data){
  67. if(data.stateRefresh){
  68. this.refreshAdjustState(data);
  69. }
  70. if(data.quantityRefresh){
  71. this.refreshQuantity(data);
  72. }
  73. };
  74. ration.prototype.refreshAdjustState = function(data){
  75. this.refreshDatas(data,'adjustState');
  76. if(data.hasOwnProperty('name')){
  77. this.refreshDatas(data,'name')
  78. }
  79. };
  80. ration.prototype.refreshQuantity = function(data){
  81. this.refreshDatas(data,'quantity');
  82. };
  83. ration.prototype.refreshDatas = function(data,fieldName){
  84. var dataIndex = _.findIndex(this.datas,function(item) {
  85. return item.ID ==data.rationID;
  86. });
  87. this.datas[dataIndex][fieldName] = data[fieldName];
  88. if(fieldName=='quantity'){
  89. this.datas[dataIndex]['isFromDetail']=1
  90. }
  91. var controller = projectObj.mainController;
  92. var selected = controller.sheet.getSelections();
  93. var col = _.findIndex(project.projSetting.main_tree_col.cols,function (col) {
  94. return col.data.field ==fieldName;
  95. });
  96. controller.sheet.getCell(selected[0].row,col).value(data[fieldName]);
  97. };
  98. ration.prototype.getTempRationData = function (id, billsID, serialNo, rType) {
  99. var newData = {'ID': id, 'serialNo': serialNo, projectID: this.project.ID()};
  100. newData[project.masterField.ration] = billsID;
  101. newData['type'] = rType;
  102. if (rType == rationType.volumePrice){
  103. newData['subType'] = gljType.GENERAL_MATERIAL; // 默认的量价类型为材料
  104. newData['programID'] = projectInfoObj.projectInfo.property.engineering;
  105. };
  106. return newData;
  107. };
  108. ration.prototype.getBillsSortRation = function (billsID) { // 该方法只适用于叶子清单
  109. var rations = this.datas.filter(function (data) {
  110. return data[project.masterField.ration] === billsID;
  111. });
  112. rations.sort(function (x, y) {
  113. return x.serialNo - y.serialNo;
  114. });
  115. return rations;
  116. };
  117. // CSL, 2017-11-13 取任何清单(父清单、叶子清单)下的所有定额
  118. ration.prototype.getRationNodes = function (billNode) {
  119. if (billNode.sourceType != ModuleNames.bills) return [];
  120. let rations = [], IDs = [];
  121. function getSubBillsIDs(node) {
  122. if (!node) return;
  123. if (node.sourceType != sBills) return;
  124. if (!node.children || node.children.length == 0 || node.children[0].sourceType != sBills)
  125. IDs.push(node.data.ID)
  126. else
  127. getSubBillsIDs(node.children[0]);
  128. getSubBillsIDs(node.nextSibling);
  129. };
  130. if (billNode.source.children.length == 0)
  131. IDs.push(billNode.data.ID)
  132. else
  133. getSubBillsIDs(billNode.children[0]);
  134. for (let id of IDs){
  135. let subRations = this.datas.filter(function (data) {
  136. return data[project.masterField.ration] === id;
  137. });
  138. rations.push(...subRations);
  139. };
  140. rations.sort(function (x, y) {
  141. return x.serialNo - y.serialNo;
  142. });
  143. let rationNodes = [];
  144. for (let ration of rations){
  145. rationNodes.push(projectObj.project.mainTree.nodes['id_' + ration.ID]);
  146. }
  147. return rationNodes;
  148. };
  149. ration.prototype.getInsertRationData = function (billsID, preRation, rationType) {
  150. var br = this.getBillsSortRation(billsID);
  151. var updateData = [];
  152. if (preRation) {
  153. var preIndex = br.indexOf(preRation), i;
  154. updateData.push({updateType: 'ut_create', updateData: this.getTempRationData(this.getNewRationID(), billsID, preIndex < br.length - 1 ? br[preIndex + 1].serialNo : br[preIndex].serialNo + 1, rationType)});
  155. for (i = preIndex + 1; i < br.length; i++) {
  156. updateData.push({updateType: 'ut_update', updateData: this.getTempRationData(br[i].ID, billsID, i < br.length - 1 ? br[i+1].serialNo : br[i].serialNo + 1, br[i].type)});
  157. }
  158. } else {
  159. updateData.push({updateType: 'ut_create', updateData: this.getTempRationData(this.getNewRationID(), billsID, br.length > 0 ? br[br.length - 1].serialNo + 1 : 1, rationType)});
  160. }
  161. return updateData;
  162. };
  163. ration.prototype.getCounterData = function (count) {
  164. var updateData = {'projectID': this.project.ID()};
  165. if (count) {
  166. updateData[this.getSourceType()] = this.maxRationID() + count;
  167. } else {
  168. updateData[this.getSourceType()] = this.maxRationID() + 1;
  169. }
  170. return updateData;
  171. };
  172. ration.prototype.insertRation = function (billsID, preRation, rationType) {
  173. var br = this.getBillsSortRation(billsID);
  174. let insertData = this.getInsertRationData(billsID, preRation, rationType);
  175. this.project.pushNow('insertRation', [this.getSourceType(), this.project.projCounter()],
  176. [insertData, this.getCounterData()]);
  177. var newRation = null;
  178. let newID = -1;
  179. for(let data of insertData){
  180. if(data.updateType === 'ut_create'){
  181. newID = data.updateData.ID;
  182. }
  183. }
  184. if (preRation) {
  185. var preIndex = br.indexOf(preRation), i;
  186. newRation = this.getTempRationData(newID, billsID, preIndex < br.length - 1 ? br[preIndex + 1].serialNo : br[preIndex].serialNo + 1, rationType);
  187. this.datas.push(newRation);
  188. for (i = preIndex + 1; i < br.length; i++) {
  189. br[i].serialNo = i < br.length - 1 ? br [i + 1].serialNo : br[i].serialNo + 1;
  190. }
  191. } else {
  192. newRation = this.getTempRationData(newID, billsID, br.length > 0 ? br[br.length - 1].serialNo + 1 : 1, rationType);
  193. this.datas.push(newRation);
  194. }
  195. return newRation;
  196. };
  197. ration.prototype.insertStdRation = function (billsID, preRation, std) {
  198. var br = this.getBillsSortRation(billsID), updateData = this.getInsertRationData(billsID, preRation, rationType.ration), newRation = null, that = this;
  199. updateData.forEach(function (data) {
  200. if (data.updateType === 'ut_create') {
  201. data.updateData.code = std.code;
  202. data.updateData.name = std.name;
  203. data.updateData.caption = std.caption;
  204. data.updateData.unit = std.unit;
  205. data.updateData.libID = std.rationRepId;
  206. data.updateData.content = std.jobContent;
  207. if (std.chapter) {
  208. data.updateData.comments = std.chapter.explanation;
  209. data.updateData.ruleText = std.chapter.ruleText;
  210. }
  211. data.updateData.from = std.type === 'complementary' ? 'cpt' : 'std';
  212. data.updateData.programID = std.feeType;
  213. data.updateData.rationAssList = projectObj.project.ration_ass.CreateNewAss(std);
  214. // calculate ration Quantity
  215. that.CalculateQuantity(data.updateData);
  216. newRation = data.updateData;
  217. }
  218. });
  219. this.project.pushNow('insertRation', [this.getSourceType(), this.project.projCounter()], [updateData, this.getCounterData()]);
  220. //newRation.ID = this.getNewRationID();
  221. if (preRation) {
  222. var preIndex = br.indexOf(preRation), i;
  223. this.datas.push(newRation);
  224. for (i = preIndex + 1; i < br.length; i++) {
  225. br[i].serialNo = i < br.length - 1 ? br [i + 1].serialNo : br[i].serialNo + 1;
  226. }
  227. } else {
  228. this.datas.push(newRation);
  229. }
  230. return newRation;
  231. };
  232. ration.prototype.getDeleteData = function (rationData) {
  233. var updateData = [];
  234. updateData.push({'updateType': 'ut_delete', 'updateData': {'ID': rationData.ID, 'projectID': this.project.ID()}});
  235. return updateData;
  236. };
  237. ration.prototype.delete = function (ration) {
  238. var ration_glj =projectObj.project.ration_glj;
  239. this.project.pushNow('deleteRation', [this.getSourceType(),ration_glj.getSourceType()], [this.getDeleteData(ration),ration_glj.getDeleteDataByRation(ration)]);
  240. project.ration_glj.deleteByRation(ration);
  241. project.ration_coe.deleteByRation(ration);
  242. project.quantity_detail.deleteByRation(ration);
  243. project.ration_installation.deleteByRation(ration);
  244. this.datas.splice(this.datas.indexOf(ration), 1);
  245. };
  246. ration.prototype.getDeleteDataByBill = function (nodes) {
  247. let updateData = [];
  248. for (let node of nodes) {
  249. if (node.children.length > 0) {
  250. updateData = updateData.concat(this.getDeleteDataByBill(node.children));
  251. } else {
  252. let rations = this.getBillsSortRation(node.getID());
  253. for (let r of rations) {
  254. updateData.push({'updateType': 'ut_delete', 'updateData': {'ID': r.ID, 'projectID': this.project.ID()}});
  255. }
  256. }
  257. }
  258. return updateData;
  259. };
  260. ration.prototype.deleteByBills = function (nodes) {
  261. for (let node of nodes) {
  262. if (node.children.length > 0) {
  263. this.deleteByBills(node.children);
  264. } else {
  265. let rations = this.getBillsSortRation(node.getID());
  266. for (let r of rations) {
  267. this.datas.splice(this.datas.indexOf(r), 1);
  268. }
  269. }
  270. }
  271. }
  272. ration.prototype.getChangePosUpdateData = function (ration1, ration2) {
  273. var updateData = [];
  274. updateData.push({updateType: 'ut_update', updateData: this.getTempRationData(ration1.ID, ration1.billsItemID, ration2.serialNo)});
  275. updateData.push({updateType: 'ut_update', updateData: this.getTempRationData(ration2.ID, ration2.billsItemID, ration1.serialNo)});
  276. return updateData;
  277. };
  278. ration.prototype.changePos = function (ration1, ration2) {
  279. var updateData = this.getChangePosUpdateData(ration1, ration2);
  280. this.project.pushNow('insertRation', [this.getSourceType()], [updateData]);
  281. var preSerialNo = ration1.serialNo;
  282. ration1.serialNo = ration2.serialNo;
  283. ration2.serialNo = preSerialNo;
  284. };
  285. ration.prototype.updateField = function (ration, field, newValue) {
  286. calcFees.setFee(ration, field, newValue);
  287. let updateData = [];
  288. let data = {'ID': ration.ID, 'projectID': this.project.ID()};
  289. if (field === 'quantity') {
  290. data[field] = newValue;
  291. data.isFromDetail=0;
  292. // to do Calculate
  293. if (ration.fees) {
  294. data.fees = ration.fees;
  295. }
  296. } else if (field === 'feesIndex.common.unitFee') {
  297. // to do Calculate
  298. if (ration.fees) {
  299. data.fees = ration.fees;
  300. }
  301. } else {
  302. data[field] = newValue;
  303. }
  304. updateData.push({'updateType': 'ut_update', 'updateData': data});
  305. this.project.pushNow('updateBills', this.getSourceType(), updateData);
  306. };
  307. ration.prototype.updateRation = function (ration, updateNow) {
  308. let updateData = [];
  309. updateData.push({'updateType': 'ut_update', 'updateData': tools.formatRationUpdateData(ration)});
  310. if (updateNow) {
  311. this.project.pushNow('updateRations', this.getSourceType(), updateData);
  312. } else {
  313. this.project.push(this.getSourceType(), updateData);
  314. }
  315. };
  316. ration.prototype.FilterNumberFromUnit = function (unit) {
  317. let reg = new RegExp('^[0-9]+');
  318. if (reg.test(unit)) {
  319. return parseInt(unit.match(reg)[0]);
  320. } else {
  321. return 1;
  322. }
  323. };
  324. ration.prototype.CalculateQuantity = function (ration) {
  325. // calculate ration Quantity
  326. let quantity_decimal = getDecimal("ration.quantity");
  327. let process_decimal = getDecimal("process");
  328. if (optionsOprObj.getOption(optionsOprObj.optionsTypes.GENERALOPTS, 'rationQuanACToBillsQuan')) {
  329. let billsNode = this.project.Bills.tree.findNode(ration[this.project.masterField.ration]);
  330. let billsQuantity = billsNode.data.quantity ? billsNode.data.quantity : 0;
  331. billsQuantity=scMathUtil.roundForObj(billsQuantity,quantity_decimal);
  332. ration.quantityEXP="QDL";
  333. /* if (optionsOprObj.getOption(optionsOprObj.optionsTypes.GENERALOPTS, 'rationQuanACToRationUnit')) {
  334. ration.quantity = (billsQuantity / this.FilterNumberFromUnit(ration.unit)).toDecimal(quantity_decimal);
  335. } else {
  336. ration.quantity = billsQuantity.toDecimal(quantity_decimal);
  337. }*/
  338. ration.quantity = (billsQuantity / this.FilterNumberFromUnit(ration.unit)).toDecimal(quantity_decimal);//改成不管是否打勾都做转换
  339. ration.contain = scMathUtil.roundForObj(ration.quantity/billsQuantity,process_decimal);
  340. }
  341. };
  342. ration.prototype.updateRationCodes = function (recodes) {
  343. let libID = projectInfoObj.projectInfo.engineeringInfo.ration_lib[0].id;
  344. let projectID = projectInfoObj.projectInfo.ID;
  345. let project = projectObj.project;
  346. let mainTree = project.mainTree;
  347. let nodeInfo =[];
  348. let refershNodes = [];
  349. for(let r of recodes){
  350. nodeInfo.push({ID:r.node.data.ID,billsItemID:r.node.data.billsItemID,newCode:r.value});
  351. refershNodes.push(r.node);
  352. }
  353. let calQuantity = optionsOprObj.getOption(optionsOprObj.optionsTypes.GENERALOPTS, 'rationQuanACToBillsQuan');
  354. $.bootstrapLoading.start();
  355. CommonAjax.post("/ration/replaceRations",{nodeInfo:nodeInfo,libID:libID,projectID:projectID,calQuantity:calQuantity},function (data) {
  356. for(let recode of data){
  357. let node = mainTree.getNodeByID(recode.ration.ID);
  358. if(node) {
  359. for(let temkey in recode.ration){//更新缓存
  360. node.data[temkey] = recode.ration[temkey];
  361. }
  362. node.data.feesIndex = {};
  363. project.Ration.deleteSubListOfRation(recode.ration);//删除旧定额下的相关记录
  364. //添加新的记录
  365. project.ration_glj.addDatasToList(recode.ration_gljs);
  366. project.ration_coe.addDatasToList(recode.ration_coes);
  367. //to do 添加增加安装费
  368. }
  369. }
  370. project.projectGLJ.loadData(function () {
  371. gljOprObj.refreshView();
  372. project.calcProgram.calcRationsAndSave(refershNodes);
  373. projectObj.mainController.refreshTreeNode(refershNodes, true);
  374. $.bootstrapLoading.end();
  375. });
  376. if(data.length<recodes.length){//说明有部分定额编号没找到记录
  377. alert('当前库中找不到定额"' + recodes[data.length-1].value + '"');
  378. }
  379. })
  380. };
  381. ration.prototype.addNewRation = function (itemQuery,rationType) {
  382. let me = this;
  383. let project = projectObj.project, sheetController = projectObj.mainController;
  384. let selected = project.mainTree.selected, newSource = null, newNode = null,pre=null,br=null;
  385. let billItemID = null,serialNo=1,nextID=null;
  386. if (selected === null) { return; }
  387. if (selected.sourceType === project.Bills.getSourceType() && selected.depth() > 0) {
  388. if (selected.source.children.length > 0) {
  389. alert('当前清单已有清单子项,不能套用定额。');
  390. } else if (selected.data.calcBase&&selected.data.calcBase!="") {
  391. alert('当前有基数计算不能插入定额/量价/工料机。');
  392. } else {
  393. if(selected.data.type === billType.FB){
  394. return;
  395. }
  396. billItemID = selected.source.getID();
  397. nextID = selected.tree.rootID();
  398. br = this.getBillsSortRation(billItemID);
  399. serialNo = br.length > 0 ? br[br.length - 1].serialNo + 1 : 1
  400. }
  401. } else if (selected.sourceType === project.Ration.getSourceType()) {
  402. billItemID = selected.getParentID();
  403. br = this.getBillsSortRation(billItemID);
  404. serialNo = selected.data.serialNo+1;
  405. nextID = selected.getNextSiblingID();
  406. pre = selected.source;
  407. };
  408. if(billItemID){
  409. let newData = me.getTempRationData(me.getNewRationID(), billItemID, serialNo, rationType);
  410. let calQuantity = optionsOprObj.getOption(optionsOprObj.optionsTypes.GENERALOPTS, 'rationQuanACToBillsQuan');
  411. let brUpdate = [];
  412. //更新兄弟节点的序列号
  413. if (pre) {
  414. let preIndex = br.indexOf(pre), i;
  415. for (i = preIndex + 1; i < br.length; i++) {
  416. br[i].serialNo = i < br.length - 1 ? br [i + 1].serialNo : br[i].serialNo + 1;
  417. brUpdate.push({projectID:newData.projectID,ID:br[i].ID,serialNo:br[i].serialNo});
  418. }
  419. }
  420. $.bootstrapLoading.start();
  421. CommonAjax.post("/ration/addNewRation",{itemQuery:itemQuery,newData:newData,calQuantity:calQuantity,brUpdate:brUpdate},function (data) {
  422. //更新缓存
  423. console.log(data);
  424. me.datas.push(data.ration);
  425. project.ration_glj.addDatasToList(data.ration_gljs);
  426. project.ration_coe.addDatasToList(data.ration_coes);
  427. project.ration_installation.addDatasToList(data.ration_installs);
  428. //插入树节点
  429. newSource = data.ration;
  430. newNode = project.mainTree.insert(billItemID, nextID, newSource.ID);
  431. newNode.source = newSource;
  432. newNode.sourceType = project.Ration.getSourceType();
  433. newNode.data = newSource;
  434. ProjectController.syncDisplayNewNode(sheetController, newNode);
  435. project.projectGLJ.loadData(function () {
  436. project.ration_glj.addToMainTree(data.ration_gljs);
  437. project.calcProgram.calcAndSave(newNode);
  438. projectObj.mainController.refreshTreeNode([newNode], false);
  439. $.bootstrapLoading.end();
  440. });
  441. console.log(data);
  442. })
  443. }
  444. };
  445. ration.prototype.deleteSubListOfRation = function(ration){
  446. projectObj.project.ration_glj.deleteByRation(ration);
  447. projectObj.project.ration_coe.deleteByRation(ration);
  448. projectObj.project.quantity_detail.deleteByRation(ration);
  449. //to do 删除安装增加费
  450. };
  451. ration.prototype.replaceRation = function (ration, std) {
  452. this.project.beginUpdate('replaceRation');
  453. // delete
  454. let ration_glj =projectObj.project.ration_glj;
  455. this.project.push(this.project.ration_glj.getSourceType(), this.project.ration_glj.getDeleteDataByRation(ration));
  456. this.deleteSubListOfRation(ration);
  457. // insertNewRation
  458. let updateData = [];
  459. ration.code = std.code;
  460. ration.name = std.name;
  461. ration.caption = std.caption;
  462. ration.unit = std.unit;
  463. ration.libID = std.rationRepId;
  464. ration.content = std.jobContent;
  465. ration.adjustState = '';
  466. if (std.chapter) {
  467. ration.comments = std.chapter.explanation;
  468. ration.ruleText = std.chapter.ruleText;
  469. }
  470. ration.from = std.type === 'complementary' ? 'cpt' : 'std';
  471. ration.programID = std.feeType;
  472. ration.rationAssList = projectObj.project.ration_ass.CreateNewAss(std);
  473. // calculate ration Quantity
  474. this.CalculateQuantity(ration);
  475. updateData.push({updateType: 'ut_update', updateData: ration});
  476. this.project.push(this.getSourceType(), updateData);
  477. this.project.endUpdate();
  478. };
  479. ration.prototype.updateContain=function (value,node) {
  480. if(isNaN(value)){
  481. alert("当前输入的数据类型不正确,请重新输入");
  482. projectObj.mainController.refreshTreeNode([node]);
  483. return;
  484. }
  485. let billNode = node.parent;
  486. let contain = scMathUtil.roundForObj(value,getDecimal("process"));
  487. if(node.data.quantityEXP=="GCLMXHJ"){//如果定额工程量是来自工程量明细
  488. var c = confirm('已有工程量明细,是否清空明细表,采用手工输入的表达式?');
  489. if(c){
  490. node.data.isFromDetail=0;
  491. project.quantity_detail.cleanQuantityDetail(node,true);
  492. }else {
  493. projectObj.mainController.refreshTreeNode([node]);
  494. return;
  495. }
  496. }
  497. let billQuantity = billNode.data.quantity||billNode.data.quantity!=""?billNode.data.quantity:0;
  498. billQuantity = parseFloat(billQuantity);
  499. node.data.contain = contain;
  500. node.data.quantityEXP="QDL*"+contain;
  501. node.data.quantity=scMathUtil.roundForObj(billQuantity*contain,getDecimal("quantity"),node);
  502. let times = parseInt(node.data.unit)
  503. if (!isNaN(times)) {
  504. node.data.quantityEXP+='*'+times;
  505. }
  506. // node.data.quantity = projectObj.project.quantity_detail.autoTransformQuantity(node.data.quantity,node);//按单位做转换
  507. node.changed = true;
  508. project.calcProgram.calcAndSave(node, function () {
  509. project.projectGLJ.loadData();
  510. });
  511. projectObj.mainController.refreshTreeNode(node.children);//刷新子工料机树节点总消耗量
  512. };
  513. ration.prototype.addRationChecking=function(selected){
  514. if (selected) {// Vincent, 2018-01-02
  515. if(selected.sourceType === project.Ration.getSourceType()){ // 焦点行是定额/量价/工料机,有效显示。
  516. return false;
  517. }else if(selected.sourceType === project.Bills.getSourceType()){
  518. if(selected.data.type == billType.FX){//焦点行是分项,有效显示。
  519. return false
  520. }
  521. if(selected.data.type == billType.BILL && selected.source.children.length === 0){//焦点行是清单,且没有子项,有效显示。
  522. return false
  523. }
  524. }
  525. }
  526. return true;
  527. };
  528. return new ration(project);
  529. }
  530. };