glj_view.js 86 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961
  1. /**
  2. * Created by CSL on 2017-05-12.
  3. */
  4. var gljOprObj = {
  5. sheet: null,
  6. libID: null,
  7. ration: null,
  8. sheetData: [],
  9. checkb: null,
  10. rationGljEditObj:null,//编辑定额工料机还没提交的缓存数据
  11. cancelUpdate:true,
  12. mainTreeSelectedChange:false,
  13. detailSheet: null,
  14. detailData: [],
  15. GLJSelection: [],
  16. pagingType: {
  17. stdGLJ: 1,
  18. complementaryGLJs: 2
  19. },
  20. // 是否正在分页
  21. loadingPagination: false,
  22. // 当前筛选条件下总数据数,用于判断是否需要继续分页
  23. curPageTotal: 0,
  24. selectedGLJClass: null,
  25. parentNodeIds: {},
  26. preActiveTab: '', //提升焦点变换性能 2019年4月12日
  27. activeTab: '#linkGLJ',
  28. rationTab:'#linkGLJ',
  29. billsTab:'#linkQDJL',
  30. setting: {},
  31. detailSetting: {
  32. header: [
  33. {headerName: "名称", headerWidth: 100, dataCode: "name", dataType: "String"},
  34. {headerName: "计算式", headerWidth: 120, dataCode: "regex", dataType: "String"},
  35. {headerName: "结果(C)", headerWidth: 120, dataCode: "result", dataType: "Number", decimalField: "quantity_detail"},
  36. {headerName: "累加", headerWidth: 120, dataCode: "isSummation", dataType: "String", cellType: "checkBox"}
  37. ],
  38. view: {
  39. lockColumns: [2, 3],
  40. rowHeaderWidth:25
  41. }
  42. },
  43. gljTreeSetting: {
  44. view: {
  45. expandSpeed: "",
  46. selectedMulti: false
  47. },
  48. edit: {
  49. enable: false,
  50. editNameSelectAll: true,
  51. showRemoveBtn: true,
  52. showRenameBtn: true,
  53. removeTitle: "删除节点",
  54. renameTitle: "更改名称"
  55. },
  56. data: {
  57. keep: {
  58. parent: true,
  59. leaf: true
  60. },
  61. key: {
  62. children: "items",
  63. name: "Name"
  64. },
  65. simpleData: {
  66. enable: false,
  67. idKey: "ID",
  68. pIdKey: "ParentID",
  69. rootPId: -1
  70. }
  71. },
  72. callback: {
  73. onClick: function (event, treeId, treeNode) {
  74. if (treeId == 'gljTree') {
  75. let me = gljOprObj, gljTypeId = treeNode.ID;
  76. if (treeNode.ID) {
  77. me.gljCurTypeId = treeNode.ID;
  78. /* me.filterLibGLJSheetData();
  79. me.showLibGLJSheetData();*/
  80. me.loadPageData(gljOprObj.gljLibSheet, true, 0);
  81. //gljOprObj.initSelection({row: me.gljLibSheet.getActiveRowIndex()});
  82. }
  83. } else {
  84. if (treeNode.isParent) {
  85. $('#class_selected_conf').attr("disabled", "disabled");
  86. $('#selected_class').val("");
  87. } else {
  88. $('#class_selected_conf').removeAttr("disabled");
  89. $('#selected_class').val(treeNode.ID);
  90. }
  91. }
  92. }
  93. }
  94. },
  95. gljLibSheetSetting: {
  96. owner: 'gljTree',
  97. header: [
  98. {headerName: "选择", headerWidth: 40, dataCode: "select", hAlign: "center", vAlign: "center", cellType: "checkBox"},
  99. {headerName: "编码", headerWidth: 80, dataCode: "code", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
  100. {headerName: "名称", headerWidth: 160, dataCode: "name", dataType: "String", hAlign: "left", vAlign: "center"},
  101. {headerName: "规格型号", headerWidth: 160, dataCode: "specs", dataType: "String", hAlign: "left", vAlign: "center"},
  102. {headerName: "单位", headerWidth: 40, dataCode: "unit", dataType: "String", hAlign: "center", vAlign: "center"},
  103. {headerName: "单价", headerWidth: 55, dataCode: "basePrice", dataType: "Number", formatter: "0.00", hAlign: "right", vAlign: "center"},
  104. {headerName: "类型", headerWidth: 60, dataCode: "typeName", dataType: "String", hAlign: "center", vAlign: "center"},
  105. {headerName: "新增", headerWidth: 40, dataCode: "isComplementary", dataType: "String", hAlign: "center", vAlign: "center", cellType: "checkBox", readOnly: true}
  106. ],
  107. view: {
  108. lockColumns: [0, 1, 2, 3, 4, 5, 6]
  109. }
  110. },
  111. gljLibSheet: null,
  112. scopeSetting:{},
  113. scopeSpread:null,
  114. scopeSheet:null,
  115. scopeDatas:[],
  116. scopeSelectedIDMap:{},
  117. initSheet: function (sheet,name="ration_glj") {
  118. var me = this;
  119. me.sheet = sheet;
  120. sheetCommonObj.initSheet(me.sheet, me.setting, 30);
  121. sheet.name(name);
  122. me.bindSheetEvent(sheet);
  123. sheet.bind(GC.Spread.Sheets.Events.CellDoubleClick, me.onCellDoubleClick);
  124. sheet.bind(GC.Spread.Sheets.Events.ClipboardChanged, me.onClipboardChanged);
  125. subSpread.bind(GC.Spread.Sheets.Events.ButtonClicked, me.onButtonClick);
  126. if(!projectReadOnly){
  127. gljContextMenu.loadGLJSpreadContextMenu();
  128. me.bindGLJEnterKey(subSpread,sheet);
  129. }
  130. sheet.bind(GC.Spread.Sheets.Events.SelectionChanged,me.onRationGLJSelectionChange);
  131. sheet.bind(GC.Spread.Sheets.Events.CellClick,function () {
  132. //这里主要记录是否点击了sheet以外的地方,如果点击了sheet里的单元格,则将cancelUpdate设置为true不触发提交更新操作
  133. me.cancelUpdate = true;//取消延时任务由selection change 事件处理
  134. });
  135. },
  136. onRationGLJSelectionChange:function(sender,args){
  137. let me = gljOprObj;
  138. let selected = args.newSelections[0] ? args.newSelections[0] : {row: 0, col: 0};
  139. //这主要记录是否点击了sheet以外的地方,如果点击了sheet里的单元格,则将cancelUpdate设置为true不触发提交更新操作
  140. me.cancelUpdate = true;//取消延时任务由这里进行判断处理
  141. me.sheetInitSelection(selected);
  142. if(me.rationGljEditObj){
  143. if(ifNeedUpdate(selected)){
  144. me.updateGljFromCache();
  145. }
  146. }
  147. function ifNeedUpdate(selected) {
  148. let navigationRightCol = me.setting.navigationRightCol , fieldID = me.setting.header[selected.col].dataCode;
  149. if(me.rationGljEditObj.row == selected.row && navigationRightCol.indexOf(fieldID)!= -1){//如果换行或者超出了三个编辑列,则提交更新
  150. return false;
  151. }
  152. return true;
  153. }
  154. },
  155. updateGljFromCache:function () {
  156. let me = this;
  157. if(me.rationGljEditObj){
  158. projectObj.project.ration_glj.submitChange(me.rationGljEditObj.recode, me.rationGljEditObj.doc);
  159. }
  160. me.rationGljEditObj = null;
  161. },
  162. bindGLJEnterKey:function (spread,sheet) {
  163. let me = this;
  164. subSpread.commandManager().register('myEnter', enterKeyAction);
  165. subSpread.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.enter, false, false, false, false);
  166. subSpread.commandManager().setShortcutKey('myEnter', GC.Spread.Commands.Key.enter, false, false, false, false);
  167. function enterKeyAction(spd,sheeName) {
  168. let editRow = sheet.getActiveRowIndex(),orgCol = sheet.getActiveColumnIndex();
  169. let fieldID = me.setting.header[orgCol].dataCode;
  170. if(sheeName=="ration_glj" && me.setting.navigationRightCol.indexOf(fieldID) != -1){
  171. if(sheet.isEditing()) sheet.endEdit();
  172. GC.Spread.Sheets.Commands.navigationRight.execute(spd,sheeName);
  173. }else {
  174. GC.Spread.Sheets.Commands.commitInputNavigationDown.execute(spd,sheeName);
  175. }
  176. }
  177. },
  178. sheetInitSelection: function (selected) {
  179. let me = gljOprObj;
  180. let style = {};
  181. if(selected.row < me.sheetData.length){
  182. if(me.setting.getStyle) style = me.setting.getStyle(me.sheetData[selected.row]);
  183. me.sheet.setStyle(selected.row, -1, me.getSelStyle(true,style));
  184. }
  185. me.sheet.repaint();
  186. if(me.preGljSelection && me.preGljSelection.row !== selected.row){
  187. if(me.setting.getStyle && me.preGljSelection.row < me.sheetData.length) style = me.setting.getStyle(me.sheetData[me.preGljSelection.row]);
  188. me.sheet.setStyle(me.preGljSelection.row, -1, me.getSelStyle(false,style));
  189. }
  190. me.preGljSelection = selected;
  191. },
  192. initDetailSheet: function (sheet) {
  193. var me = this;
  194. me.detailSheet = sheet;
  195. sheetCommonObj.initSheet(me.detailSheet, me.detailSetting, 30);
  196. // me.detailSheet.selectionUnit(0);//0 cell,1 row,2 col;
  197. sheet.name('quantity_detail');
  198. me.bindSheetEvent(sheet);
  199. },
  200. detailSheetReadonly:function () {
  201. let selected = projectObj.project.mainTree.selected;
  202. let Bills = projectObj.project.Bills;
  203. if(selected) {
  204. //清单锁定时只读
  205. if(selected.sourceType == ModuleNames.bills && projectObj.project.isBillsLocked() && projectObj.project.withinBillsLocked(selected)){
  206. return true;
  207. }
  208. //大项费用、分部节点层次时,工程量明细只读。
  209. if(indicativeInfoObj.isDXFY(selected) || indicativeInfoObj.isFB(selected)){
  210. return true;
  211. }
  212. //是主材或者是设备时只读
  213. if(selected.sourceType == ModuleNames.ration_glj){
  214. return true;
  215. }else if(gljOprObj.isInstallationNode(selected) || OVER_HEIGHT.isOverHeight(selected)){//是补项或者是安装、超高类型的定额时只读
  216. return true;
  217. }
  218. return false;
  219. }
  220. return true;
  221. },
  222. bindSheetEvent: function (sheet) {
  223. var me = this;
  224. sheet.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
  225. sheet.bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
  226. sheet.bind(GC.Spread.Sheets.Events.EditEnded, me.onEditEnded);
  227. sheet.bind(GC.Spread.Sheets.Events.RangeChanged, me.onRangeChanged);
  228. sheet.bind(GC.Spread.Sheets.Events.EditStarting, me.startEditChecking);
  229. // sheet.bind(GC.Spread.Sheets.Events.CellClick, me.onCellClick);
  230. },
  231. onClipboardPasting: function (sender, args) {
  232. var me = gljOprObj;
  233. if(args.sheetName!="quantity_detail"&&(args.cellRange.rowCount!=1||args.cellRange.colCount!=1)){//工程量明细做特殊处理
  234. args.cancel = true;
  235. }
  236. },
  237. onClipboardPasted: function (e, info) {
  238. var me = gljOprObj;
  239. console.log('past');
  240. // if (!me.ration) {return;};
  241. // your code...
  242. },
  243. startEditChecking:function (sender,args) {
  244. let me = gljOprObj;
  245. let selected = projectObj.project.mainTree.selected;
  246. if($.bootstrapLoading.isLoading()) args.cancel = true;
  247. if(selected){
  248. if(me.isInstallationNode(selected)==true || me.isItemIncreaseNode(selected)==true|| OVER_HEIGHT.isOverHeight(selected)){
  249. args.cancel = true;
  250. }else {
  251. if(args.sheetName == 'quantity_detail'){//工程量明细表
  252. if(me.detailSheetReadonly()){
  253. args.cancel = true;
  254. }else {
  255. if(args.sheet.getValue(args.row,args.col)==null){//这里是为了解决当单元格里的值是null的时候,在单元格里输入数据,按键盘箭头移动光标的时候,会直接结束编辑,跳到另外的单元格。
  256. args.sheet.setValue(args.row,args.col,"");
  257. }
  258. }
  259. }
  260. if(args.sheetName == 'ration_glj'){//定额工料机表
  261. if(!me.rationGLJEditCheck(args)) args.cancel = true;
  262. }
  263. }
  264. }else {
  265. args.cancel = true;
  266. }
  267. },
  268. isInstallationNode:function(node){
  269. if(node.sourceType == ModuleNames.ration&&node.data.type == rationType.install){//是定额安装费类型时只读,原先是补项的时候也是控制只读的||(node.sourceType == ModuleNames.bills&&node.data.type==billType.BX)){//是定额安装费类型或者补项
  270. return true;
  271. }
  272. return false
  273. },
  274. isItemIncreaseNode:function(node){//子目增加费节点
  275. if(node.sourceType == ModuleNames.ration&&node.data.type == rationType.itemIncrease){//是定额安装费类型时只读,原先是补项的时候也是控制只读的||(node.sourceType == ModuleNames.bills&&node.data.type==billType.BX)){//是定额安装费类型或者补项
  276. return true;
  277. }
  278. return false
  279. },
  280. onEditEnded: function (sender, args) {
  281. var me = gljOprObj;
  282. if (args.sheetName == 'ration_glj') {
  283. me.onEditGLJSheet(args)
  284. }
  285. if (args.sheetName == 'quantity_detail') {
  286. me.onEditDetailSheet(args);
  287. }
  288. },
  289. onEditDetailSheet: function (args,callback) {
  290. var me = gljOprObj;
  291. if (args.row > me.detailData.length) {
  292. return;
  293. }
  294. if (args.row == me.detailData.length && args.editingText == null) {
  295. return;
  296. }
  297. var selected = projectObj.project.mainTree.selected;//因为使用了延时方法,所以要先取得选中行;
  298. var detailList = me.detailData;
  299. if(args.editingText){
  300. args.editingText = args.editingText.replace(/(/g, "(");//替换中文左右括号;
  301. args.editingText = args.editingText.replace(/)/g, ")");
  302. }
  303. if (args.row == detailList.length) {
  304. projectObj.project.quantity_detail.saveQuantityDetail(args, me.detailSetting.header[args.col].dataCode, selected,callback);
  305. }
  306. if (args.row < detailList.length) {
  307. projectObj.project.quantity_detail.updateQuantityDetail(args, me.detailSetting.header[args.col].dataCode, detailList[args.row], selected,callback);
  308. }
  309. },
  310. onEditGLJSheet: function (args) {
  311. var me = gljOprObj;
  312. if (args.row >= me.sheetData.length) {
  313. me.sheet.getCell(args.row, args.col).value(null);
  314. return;
  315. }
  316. me.updateRationGLJ(args);
  317. },
  318. onSelectionChanged: function (sender, args) {
  319. let me = gljOprObj;
  320. me.initSelection(args.newSelections.length > 0 ? {row: args.newSelections[0].row} : {row: 0});
  321. },
  322. onTopRowChanged: function (sender, args) {
  323. const me = gljOprObj;
  324. const topRow = args.newTopRow;
  325. const bottomRow = args.sheet.getViewportBottomRow(1);
  326. const radioType = $("input[name='glj']:checked").val();
  327. const curRecord = radioType === 'stdGLJ' ? me.stdGLJ : me.complementaryGLJs;
  328. // 当前表显示数据数大于等于当前筛选情况下最大数据数,不获取下一分页
  329. if (curRecord.length >= me.curPageTotal ||
  330. me.loadingPagination) {
  331. return;
  332. }
  333. if (curRecord.length -1 === bottomRow) {
  334. // 获取第curRecord.length行开始的数据
  335. me.loadPageData(args.sheet, false, curRecord.length);
  336. }
  337. },
  338. loadPageData: function (sheet, reset, index) {
  339. let condition = this.getPagingCondition(false, reset, false, index);
  340. let getPagingFun = typeof unitPriceObj != 'undefined' ? unitPriceObj.getGLJDataPaging:projectObj.project.ration_glj.getGLJDataPaging;
  341. getPagingFun(condition, function (data) {
  342. sheetCommonObj.appendData(sheet, condition.index, 0, gljOprObj.gljLibSheetSetting, data);
  343. gljOprObj.initSelection({row: gljOprObj.gljLibSheet.getActiveRowIndex()});
  344. });
  345. },
  346. getSelStyle: function (selected,settingStyle,rcolor) {
  347. let style = new GC.Spread.Sheets.Style();
  348. if(settingStyle){
  349. for(let key in settingStyle){
  350. style[key] = settingStyle[key];
  351. }
  352. }
  353. style.borderLeft = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
  354. style.borderTop = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
  355. style.borderRight = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
  356. style.borderBottom = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
  357. let colorOpts = optionsOprObj.getOption(optionsOprObj.optionsTypes.COLOROPTS);
  358. if(!colorOpts) colorOpts = {SELECTED:{backColor:"#FFFACD"}};
  359. let selectedColor = colorOpts.SELECTED.backColor,
  360. recColor = rcolor?rcolor:'White';
  361. style.backColor = selected ? selectedColor : recColor;
  362. return style;
  363. },
  364. initSelection: function (sel) {
  365. let me = gljOprObj;
  366. if(sel){
  367. sel.row = !sel.row || sel.row == -1 ? 0 : sel.row;
  368. me.gljLibSheet.setStyle(sel.row, -1, me.getSelStyle(true));
  369. }
  370. if(me.preGljLibSelection && me.preGljLibSelection.row !== sel.row){
  371. me.gljLibSheet.setStyle(me.preGljLibSelection.row, -1, me.getSelStyle(false));
  372. }
  373. me.preGljLibSelection = sel;
  374. },
  375. onButtonClick: function (sender, args) {
  376. if(args.sheet.isEditing()){
  377. args.sheet.endEdit();
  378. }
  379. var me = gljOprObj;
  380. var sheet = args.sheet, row = args.row, col = args.col;
  381. var cellType = sheet.getCellType(row, col);
  382. if (cellType instanceof GC.Spread.Sheets.CellTypes.Button) {
  383. if(args.sheetName == 'rationInstallSheet'){
  384. installationFeeObj.onPositionButtonClick(sender,args);
  385. }
  386. } else {
  387. me.onCheckBoxClick(sender, args)
  388. }
  389. },
  390. onCheckBoxClick: function (sender, args) {
  391. if(typeof projectObj != 'undefined'){
  392. let selected = projectObj.project.mainTree.selected;
  393. if(selected.sourceType == ModuleNames.ration_glj){//选中的是工料机时不可编辑
  394. return ;
  395. }
  396. if(gljOprObj.isInstallationNode(selected)==true || OVER_HEIGHT.isOverHeight(selected)){
  397. return;
  398. }
  399. }
  400. let checkboxValue = args.sheet.getCell(args.row, args.col).value();
  401. if(args.sheetName == 'rationInstallSheet' && checkboxValue){
  402. return;
  403. }
  404. let newval = checkboxValue? 0:1;
  405. args.sheet.getCell(args.row, args.col).value(newval);
  406. if (args.sheetName == 'ration_glj') {
  407. gljOprObj.updateIsEstimate(args,newval);
  408. } else if (args.sheetName == 'quantity_detail') {
  409. projectObj.project.quantity_detail.isSummationUpdate(args, gljOprObj.detailData, newval);
  410. } else if (args.sheetName == 'glj_lib') {
  411. if (gljOprObj.gljLibSheetSetting.header[args.col].readOnly) {
  412. args.sheet.getCell(args.row, args.col).value(checkboxValue);
  413. return;
  414. }
  415. if(gljOprObj.gljLibSheetSetting.header[args.col].dataCode === 'select'){
  416. gljOprObj.setGLJSelection(args, newval);
  417. }
  418. }else if(args.sheetName == 'rationInstallSheet'){
  419. args.newValue = newval;
  420. installationFeeObj.onRationInstallValueChange(sender,args);
  421. }
  422. },
  423. onCellDoubleClick:function (sender, args) {
  424. // 含组成物的材料市场价改为只读,改为双击无反应不提示
  425. /* var me = gljOprObj;
  426. var header = me.setting.header;
  427. if (args.row >= me.sheetData.length) {
  428. return;
  429. }
  430. if (header[args.col] && header[args.col].dataCode == 'marketPrice') {
  431. if(me.hasComposition(me.sheetData[args.row])){
  432. alert("当前工料机的市场价由组成物计算得出,不可直接修改。");
  433. }
  434. }
  435. if (header[args.col] && header[args.col].dataCode == 'basePrice') {
  436. var isAdd = me.sheetData[args.row].isAdd;
  437. if(isAdd==1){//是新增但没有组成物时允许修改定额价
  438. if(me.hasComposition(me.sheetData[args.row])){//如果有组成物,不可修改
  439. alert("当前工料机的定额价由组成物计算得出,不可直接修改。");
  440. }
  441. }
  442. }*/
  443. },
  444. onClipboardChanged: function (sender, info) {
  445. let cDatas = sheetCommonObj.getTableData(info.sheet, null);
  446. sheetCommonObj.copyTextToClipboard(cDatas);
  447. return;
  448. },
  449. rationGLJEditCheck:function (args) {//true 可以编辑,false 不能编辑
  450. let me = gljOprObj,header = me.setting.header;
  451. let dataCode = header[args.col] && header[args.col].dataCode?header[args.col].dataCode:null,recode = me.sheetData[args.row];
  452. if(me.sheet.getTag(args.row,args.col)=="locked") return false;//如果是双击树节点编号里设置了锁定标记,不能编辑
  453. if (_.includes(me.setting.view.lockColumns, args.col)) return false;//如果是锁定的列,不能编辑
  454. if(recode != undefined){
  455. if(recode.isMixRatio){//对于组成物列 - 可修改市场价和
  456. return dataCode == 'marketPrice' || dataCode == 'rationItemQuantity'
  457. }else {
  458. if(dataCode == 'rationItemQuantity') return false;
  459. if (dataCode && dataCode == 'marketPrice') {
  460. return !me.marketPriceReadOnly({data:me.sheetData[args.row]});
  461. }
  462. if (dataCode && dataCode == 'basePrice') {
  463. var isAdd = recode.isAdd;
  464. if(isAdd==1){//是新增但没有组成物时允许修改定额价
  465. return !me.marketPriceReadOnly({data:recode});//如果有组成物,不可修改
  466. } else {
  467. return false;
  468. }
  469. }
  470. if(me.isExtraType(recode.type)&&(dataCode == 'name'||dataCode == 'specs'||dataCode == 'unit')){//人材机窗口中的“企业管理费”“利润”“一般风险费”的名称、规格、单位改为只读。
  471. return false;
  472. }
  473. return true;
  474. }
  475. }else {
  476. return false
  477. }
  478. },
  479. hasComposition:function (ration_glj,isRationType) {//判断是否有组成物,有则返回true 现在主材类型的工料机也有可能有组成物。
  480. let type = isRationType==true? ration_glj.subType:ration_glj.type;
  481. if(gljUtil.notEditType.indexOf(type)!=-1||type==gljType.MAIN_MATERIAL){
  482. let keyArray = isRationType==true? rationKeyArray:gljKeyArray;
  483. let con_key = this.getIndex(ration_glj,keyArray);
  484. var mixRatioMap = projectObj.project.projectGLJ.datas.mixRatioMap;
  485. if(mixRatioMap[con_key]&&mixRatioMap[con_key].length>0){
  486. return true;
  487. }
  488. }
  489. return false;
  490. },
  491. onRangeChanged: function (sender, args) {
  492. var me = gljOprObj;
  493. if(args.sheetName == 'quantity_detail'){
  494. me.batchUpdateQuantityDetail(args);
  495. }else {
  496. if (args.action == GC.Spread.Sheets.RangeChangedAction.clear) {
  497. args.editingText = null;
  498. }else if(args.action == GC.Spread.Sheets.RangeChangedAction.paste){
  499. args.editingText = args.sheet.getCell(args.row,args.col).value();
  500. }else {
  501. return;
  502. }
  503. if (args.sheetName == 'ration_glj') {
  504. me.onEditGLJSheet(args);
  505. }
  506. }
  507. },
  508. batchUpdateQuantityDetail:function (args) {
  509. let me = gljOprObj;
  510. let updateArray = [];
  511. for(let i =0;i<args.changedCells.length;i++){
  512. let c = args.changedCells[i];
  513. let tem = {
  514. row:c.row,
  515. col:c.col,
  516. editingText:args.sheet.getCell(c.row,c.col).text(),
  517. sheet:args.sheet,
  518. sheetName:args.sheetName,
  519. index:i
  520. };
  521. updateArray.push(tem);
  522. }
  523. if(updateArray.length>0){
  524. updateArray.length == 1?me.onEditDetailSheet(updateArray[0]):me.onEditDetailSheet(updateArray[0],updateCallback);
  525. }
  526. function updateCallback(i_args) {
  527. let index = i_args.index;
  528. if(index < updateArray.length-1){
  529. let nextIndex = index+1;
  530. updateArray[nextIndex].replace = i_args.replace;
  531. if(nextIndex == updateArray.length-1){//是最后一个,则不用调callback了
  532. me.onEditDetailSheet(updateArray[nextIndex]);
  533. }else {
  534. me.onEditDetailSheet(updateArray[nextIndex],updateCallback);
  535. }
  536. }
  537. }
  538. },
  539. showDataIfRationSelect: function (node,selectedNodeId) {
  540. var isShow = false;
  541. if(projectReadOnly && this.setting.view.lockColumns){
  542. this.setting.view.lockColumns = null;
  543. }
  544. if(selectedNodeId){
  545. this.selectedNodeId = selectedNodeId;
  546. }
  547. if (node) {
  548. if (this.selectedNodeId && this.selectedNodeId == node.getID()) {
  549. return;
  550. } else {
  551. //恢复底色
  552. this.sheet.setStyle(this.sheet.getActiveRowIndex(), -1, this.getSelStyle(false,this.setting.style));
  553. this.selectedNodeId = node.getID();
  554. }
  555. if (node.sourceType == "ration") {
  556. if(node.data.type==rationType.gljRation){
  557. if($('#linkGLJ').hasClass('active')) this.showMixRatio(node);
  558. }else {
  559. if($('#linkGLJ').hasClass('active')){
  560. this.showRationGLJData(node);
  561. subObj.showGljSubTabData();
  562. // MaterialController.showReplaceDiv(node);
  563. }
  564. if($('#linkAZZJF').hasClass('active')) installationFeeObj.showRationInstallationData(node);
  565. if($('#linkMBZM').hasClass('active')) mbzm_obj.showMBZMData(node);
  566. }
  567. isShow = true;
  568. }
  569. if(node.sourceType == ModuleNames.ration_glj){
  570. if($('#linkGLJ').hasClass('active')) this.showMixRatio(node);
  571. MaterialController.hideReplaceDiv();
  572. isShow = true;
  573. }
  574. if($('#linkGCLMX').hasClass('active')) this.showQuantityDetailData(node);
  575. } else {
  576. this.selectedNodeId = null;
  577. }
  578. if (!isShow) {
  579. this.clearSheetData();
  580. MaterialController.hideReplaceDiv();
  581. }
  582. //子目换算
  583. //zmhs_obj.showZMHSData(node);
  584. // $('#dropdown').hide();
  585. },
  586. showMixRatio:function (node) {//显示组成物到定额工料机
  587. let mixRatioMap = projectObj.project.projectGLJ.datas.mixRatioMap;
  588. let projectGljs = projectObj.project.projectGLJ.datas.gljList;
  589. let indexArray =node.sourceType==ModuleNames.ration?rationKeyArray:gljKeyArray;
  590. let connect_index = this.getIndex(node.data,indexArray);
  591. let gljList=[];
  592. if(mixRatioMap[connect_index]){ //说明是有组成物的类型
  593. gljList = this.getMixRationShowDatas(mixRatioMap[connect_index], projectGljs);
  594. }
  595. if(gljList.length>0){//计算总消耗量
  596. if(node.sourceType==ModuleNames.ration){
  597. this.calcMixRationTotalQuantity(gljList,node.data.quantity);
  598. }else {
  599. let totalQuantity = this.getTotalQuantity(node.data);
  600. this.calcMixRationTotalQuantity(gljList,totalQuantity)
  601. }
  602. }
  603. this.sheetData = gljList;
  604. this.sheet.setRowCount(0);
  605. this.sheetData = gljUtil.sortRationGLJ(this.sheetData);
  606. this.sheet.getRange(-1, 0, -1, 1).cellType(this.getTreeNodeCellType([]));
  607. sheetCommonObj.showData(this.sheet, this.setting, this.sheetData);
  608. //初始选择
  609. this.preGljSelection = null;
  610. this.sheetInitSelection({row: this.sheet.getActiveRowIndex(), col: 0});
  611. this.sheet.getRange(-1, 0, -1, this.setting.header.length).locked(true);//锁住定额工料机的所有列
  612. this.detailSheet.getRange(-1, 0, -1, this.detailSetting.header.length).locked(true);//锁住工程量明细的所有列
  613. },
  614. showRationGLJData: function (node) {
  615. let startTime = +new Date();
  616. let gljList = [];
  617. let ration_glj = projectObj.project.ration_glj;
  618. node = node ? node : projectObj.project.mainTree.selected;
  619. if (node.sourceType == ModuleNames.ration) {
  620. if(node.data.type==rationType.gljRation){
  621. this.showMixRatio(node);
  622. }else {
  623. let ration = node.data;
  624. gljList = this.filterGljByRation(ration, ration_glj.datas);
  625. this.showInSheet(gljList);
  626. }
  627. }else if(node.sourceType == ModuleNames.ration_glj){
  628. this.showMixRatio(node);
  629. }
  630. },
  631. showRationGLJSheetData: function (init) {
  632. let me = this;
  633. let selected = this.sheet.getSelections();
  634. this.combineWithProjectGlj(this.sheetData);
  635. this.sheet.setRowCount(0);
  636. this.sheetData = gljUtil.sortRationGLJ(this.sheetData);
  637. this.sumQuantity();//计算总消耗量
  638. this.addMixRatioToShow();//显示组成物信息
  639. let itreeTime = +new Date();
  640. this.initRationTree(init,this.getUnitPriceCodeMap());
  641. sheetCommonObj.showData(this.sheet, this.setting, this.sheetData,null,function () {
  642. if(me.mainTreeSelectedChange == true){
  643. me.sheet.setSelection(0,1,1,1);//默认选中第一行,第二列(名称列)
  644. me.mainTreeSelectedChange = false;
  645. }else if(selected){//定位光标到之前的位置
  646. me.sheet.setSelection(selected[0].row,selected[0].col,selected[0].rowCount,selected[0].colCount);
  647. }
  648. //初始选择
  649. me.preGljSelection = null;
  650. me.sheetInitSelection({row: me.sheet.getActiveRowIndex(), col: me.sheet.getActiveColumnIndex()});
  651. });
  652. },
  653. getSelectedRationGlj:function () {
  654. let selected = this.sheet.getSelections()[0];
  655. let ration_glj = this.sheetData[selected.row];
  656. return ration_glj;
  657. },
  658. getUnitPriceCodeMap : function () {//取单价文件中,编码前缀一样的映射表
  659. let codeMap = {};
  660. let priceMap = projectObj.project.projectGLJ.datas.unitPriceMap;
  661. if(priceMap){
  662. for(let connectKey in priceMap){
  663. let code = priceMap[connectKey].code;
  664. let name = priceMap[connectKey].name;
  665. let specs = priceMap[connectKey].specs;
  666. if(code){
  667. let displayText = code +" "+name +" "+specs;
  668. let preCode = code.split("-")[0];
  669. if(codeMap[preCode]) {
  670. codeMap[preCode].push({text:displayText,value:connectKey});
  671. }else {
  672. codeMap[preCode]=[{text:displayText ,value:connectKey}];
  673. }
  674. }
  675. }
  676. }
  677. return codeMap;
  678. },
  679. initRationTree: function (init,codeMap) {
  680. this.sheet.suspendPaint();
  681. this.sheet.suspendEvent();
  682. this.sheet.setRowCount(this.sheetData.length >30?this.sheetData.length:30);
  683. for (var i = 0; i < this.sheetData.length; i++) {
  684. let options = this.getCodeOptions(this.sheetData[i],codeMap);
  685. this.sheet.setCellType(i, 0,this.getTreeNodeCellType(this.sheetData,options),GC.Spread.Sheets.SheetArea.viewport);
  686. if (this.sheetData[i].hasOwnProperty('subList')) {
  687. var collapsed = this.sheetData[i].collapsed == undefined ? true : this.sheetData[i].collapsed;
  688. if (collapsed == true) {
  689. this.sheet.getRange(i + 1, -1, this.sheetData[i].subList.length, -1).visible(false);
  690. }
  691. }
  692. }
  693. this.sheet.resumeEvent();
  694. this.sheet.resumePaint();
  695. },
  696. getCodeOptions:function (recode,codeMap) {
  697. let options = [];
  698. if(recode.isMixRatio ===true){
  699. return null;
  700. }
  701. let code = recode.code;
  702. if(code) {
  703. let preCode = code.split("-")[0];
  704. if( codeMap[preCode]) options = codeMap[preCode];
  705. if(options.length>0) _.remove(options,{'value':gljOprObj.getIndex(recode, gljKeyArray)})//去掉本身
  706. }
  707. return _.sortBy(options,'text');
  708. },
  709. filterGljByRation: function (ration, datas) {
  710. var gljList = [];
  711. if (datas && datas.length > 0) {
  712. gljList = _.filter(datas, {'rationID': ration.ID})
  713. }
  714. return gljList;
  715. },
  716. showInSheet: function (gljList) {
  717. this.sheetData = gljList;
  718. this.showRationGLJSheetData(true);
  719. },
  720. sumQuantity: function (node) {
  721. if (this.sheetData.length > 0) {
  722. node = node ? node : projectObj.project.mainTree.selected;
  723. let ration = node.data;
  724. let quantity = ration.quantity;
  725. quantity = (quantity == 0 || quantity == undefined || quantity == null || quantity == "") ? 0 : quantity;
  726. for (let glj of this.sheetData) {
  727. glj.totalQuantity= this.getTotalQuantity(glj,ration);
  728. }
  729. }
  730. },
  731. getTotalQuantity:function(glj,ration){
  732. if (glj.isMixRatio == true) return;//如果是用于显示的组成物,则不用计算,跳过
  733. ration=ration?ration: _.find(projectObj.project.Ration.datas,{"ID":glj.rationID});
  734. glj.totalQuantity = gljUtil.getTotalQuantity(glj,ration,getDecimal("ration.quantity"),getDecimal("glj.quantity"));
  735. if (glj.hasOwnProperty('subList')) {//需要计算glj下挂的组成物的总消耗量
  736. this.calcMixRationTotalQuantity(glj.subList,glj.totalQuantity);
  737. }
  738. return glj.totalQuantity;
  739. },
  740. calcMixRationTotalQuantity(mList,pTotal){ //计算组成物的总消耗量
  741. for (let subG of mList) {
  742. subG.rationItemQuantity = scMathUtil.roundForObj(subG.rationItemQuantity, getDecimal("glj.quantity"));
  743. subG.totalQuantity = scMathUtil.roundToString(subG.rationItemQuantity * pTotal, getDecimal("glj.quantity"));
  744. }
  745. },
  746. addMixRatioToShow: function () {
  747. var newList = [];
  748. _.remove(this.sheetData, {'isMixRatio': true});
  749. for (var i = 0; i < this.sheetData.length; i++) {
  750. newList.push(this.sheetData[i]);
  751. if (this.sheetData[i].hasOwnProperty('subList')) {
  752. newList = newList.concat(this.sheetData[i].subList);
  753. }
  754. }
  755. this.sheetData = newList;
  756. },
  757. combineWithProjectGlj: function (ration_gljs,needRatio=true,ration,p_gljMap) {
  758. let projectGLJData = projectObj.project.projectGLJ.datas;
  759. let projectGljs = projectGLJData.gljList;
  760. let mixRatioMap = projectGLJData.mixRatioMap;
  761. if (ration_gljs && ration_gljs.length > 0 && projectGljs && projectGljs.length > 0) {
  762. let pgljMap = p_gljMap?p_gljMap:_.indexBy(projectGljs, 'id');
  763. for (let i = 0; i < ration_gljs.length; i++) {
  764. let glj = pgljMap[ration_gljs[i].projectGLJID];
  765. if (glj) {
  766. if(projectObj.project.projectGLJ.isEstimateType(ration_gljs[i].type )){
  767. ration_gljs[i].isEstimate = glj.is_evaluate;
  768. }
  769. ration_gljs[i].shortName =projectObj.project.projectGLJ.getShortNameByID(ration_gljs[i].type);
  770. ration_gljs[i].isAdd = glj.unit_price.is_add;
  771. ration_gljs[i]=this.setGLJPrice(ration_gljs[i],glj);//设置工料机价格
  772. let connect_index = this.getIndex(glj, gljKeyArray);
  773. if (needRatio==true&&mixRatioMap.hasOwnProperty(connect_index)) {
  774. let mixRatios = this.getMixRationShowDatas(mixRatioMap[connect_index], projectGljs,glj);
  775. ration_gljs[i].subList = mixRatios;
  776. }
  777. if(ration) gljOprObj.getTotalQuantity(ration_gljs[i], ration);
  778. }else {
  779. console.log("没有找到工料机:"+ration_gljs[i].name)
  780. }
  781. }
  782. }
  783. return ration_gljs;
  784. },
  785. setGLJPrice:function (data,glj,isRadio = false) {//isRadio 标记是否算组成物的价格
  786. let proGLJ = projectObj.project.projectGLJ;
  787. let calcOptions=projectObj.project.projectInfo.property.calcOptions;
  788. let decimalObj = projectObj.project.projectInfo.property.decimal;
  789. let labourCoeDatas = projectObj.project.labourCoe.datas;
  790. glj = glj?glj:_.find(proGLJ.datas.gljList, {'id': data.projectGLJID});
  791. if(glj){
  792. let tenderCoe = projectObj.project.projectGLJ.getTenderPriceCoe(glj);
  793. let result = gljUtil.getGLJPrice(glj,proGLJ.datas,calcOptions,labourCoeDatas,decimalObj,isRadio,_,scMathUtil,tenderCoe);
  794. data.marketPrice = result.marketPrice;
  795. data.tenderPrice = result.tenderPrice;
  796. data.basePrice = result.basePrice;
  797. data.adjustPrice = result.adjustPrice;
  798. data.marketUnitFee = data.marketPrice;//更新树节点市场单价列的值
  799. data.taxRate = glj.unit_price.taxRate;//税率
  800. }
  801. return data;
  802. },
  803. getBasePrice:function (treeNode) {//造价书中的工料机修改的节点要用到
  804. let proGLJ = projectObj.project.projectGLJ;
  805. let glj =_.find(proGLJ.datas.gljList, {'id': treeNode.data.projectGLJID});
  806. if(this.calcPriceDiff(glj)==true){
  807. return proGLJ.getBasePrice(glj);
  808. }else {
  809. return scMathUtil.roundForObj(treeNode.data.marketUnitFee,getDecimal("glj.unitPrice"));
  810. }
  811. },
  812. calcPriceDiff:function (glj) {
  813. let calcOptions=projectObj.project.projectInfo.property.calcOptions;
  814. return gljUtil.calcPriceDiff(glj,calcOptions);
  815. },
  816. getIndex(obj, pops){
  817. return gljUtil.getIndex(obj,pops);
  818. /* let t_index = '';
  819. let k_arr = [];
  820. for (let p of pops) {
  821. let tmpK = (obj[p] == undefined || obj[p] == null || obj[p] == '') ? 'null' : obj[p];
  822. k_arr.push(tmpK);
  823. }
  824. t_index = k_arr.join("|-|");
  825. return t_index;*/
  826. },
  827. getConditionByKey(conKey){//将连接字符串转换成对象
  828. let valueArray = conKey.split("|-|");
  829. let obj ={};
  830. for(let i = 0;i<valueArray.length;i++){
  831. if(valueArray[i]!='null'){
  832. if(gljKeyArray[i]=='type'){
  833. valueArray[i] = parseInt(valueArray[i]);
  834. }
  835. obj[gljKeyArray[i]]=valueArray[i];
  836. }
  837. }
  838. return obj;
  839. },
  840. getMixRationShowDatas: function (mixRatioList, projectGljs,parentGLJ) {
  841. var temRationGLJs = [];
  842. for (var i = 0; i < mixRatioList.length; i++) {
  843. let mIndex = gljOprObj.getIndex(mixRatioList[i],gljKeyArray);
  844. var pg = _.find(projectGljs, function (item) {
  845. return gljOprObj.getIndex(item,gljKeyArray) == mIndex
  846. });//改关联关系
  847. if(pg){
  848. let tem = {
  849. mixRatioId:mixRatioList[i].id,
  850. projectGLJID: pg.id,
  851. code: pg.code,
  852. name: pg.name,
  853. specs: pg.specs,
  854. unit: pg.unit,
  855. type:mixRatioList[i].type,
  856. shortName: projectObj.project.projectGLJ.getShortNameByID(mixRatioList[i].type),
  857. consumption:mixRatioList[i].consumption,
  858. rationItemQuantity: mixRatioList[i].consumption,
  859. // quantity:mixRatioList[i].consumption,
  860. /* basePrice: pg.unit_price.base_price,
  861. marketPrice: pg.unit_price.market_price,
  862. adjustPrice: pg.adjust_price,*/
  863. //isEstimate: pg.is_evaluate,
  864. isMixRatio: true,
  865. isAdd: pg.unit_price.is_add,
  866. GLJID: pg.glj_id,
  867. parentGLJ:parentGLJ
  868. };
  869. if(projectObj.project.projectGLJ.isEstimateType(pg.type)){
  870. tem.isEstimate = pg.is_evaluate;
  871. }
  872. this.setGLJPrice(tem,pg);
  873. temRationGLJs.push(tem);
  874. }else {
  875. console.log("没有找到工料机:"+mIndex)
  876. }
  877. }
  878. temRationGLJs = gljUtil.sortRationGLJ(temRationGLJs);
  879. return temRationGLJs;
  880. },
  881. showQuantityDetailData: function (node) {
  882. node = node ? node : projectObj.project.mainTree.selected;
  883. var quantity_detail = projectObj.project.quantity_detail;
  884. let field = node.sourceType == ModuleNames.ration?'rationID':'billID';
  885. let details = quantity_detail.getListByID(node.data.ID,field);
  886. sheetCommonObj.showData(this.detailSheet, this.detailSetting, details);
  887. this.detailData = details;
  888. if (MainTreeCol.readOnly.forQuantifyDetail(node)) {
  889. this.detailSheet.getRange(-1, 0, -1, this.detailSetting.header.length).locked(true);
  890. }
  891. },
  892. clearSheetData: function () {
  893. if($('#linkGLJ').hasClass('active')){
  894. sheetCommonObj.showData(this.sheet, this.setting, []);
  895. }
  896. if($('#linkAZZJF').hasClass('active')){
  897. installationFeeObj.rationInstallSheet.setRowCount(0);//清除combobox cell
  898. sheetCommonObj.showData(installationFeeObj.rationInstallSheet, installationFeeObj.rationInstallSetting, []);
  899. }
  900. // sheetCommonObj.showData(this.detailSheet,this.detailSetting,[]);
  901. this.sheetData = [];
  902. installationFeeObj.rationInstallData = [];
  903. //this.detailData=[];
  904. },
  905. updateRationGLJ: function (args) {
  906. var me = this;
  907. var updateField = me.setting.header[args.col].dataCode;
  908. var recode = me.sheetData[args.row];
  909. var newval;
  910. if(!me.rationGLJEditCheck(args)){
  911. recode? me.sheet.getCell(args.row, args.col).value(recode[updateField]): me.sheet.getCell(args.row, args.col).value(null);
  912. return;
  913. }
  914. if(args.editingText){
  915. args.editingText = args.editingText+"";
  916. args.editingText = args.editingText.replace(/[\r\n]/g, "");//去掉回车换行等字符;
  917. me.sheet.getCell(args.row, args.col).value(args.editingText);
  918. }
  919. if (updateField == 'marketPrice' || updateField == 'customQuantity' || updateField == 'basePrice') {
  920. if (args.editingText == null) {
  921. updateField == 'marketPrice' ? newval = 0 : newval = "";
  922. } else {
  923. var decimal = updateField == 'customQuantity'||updateField == 'rationItemQuantity' ? getDecimal("glj.quantity") : 6;//对于市场价和定额价,这里只是中间的小数位数,后面更新前会根据有没有组成物再取值
  924. newval = number_util.checkNumberValue(args.editingText, decimal);
  925. if (newval == null) {
  926. me.sheet.getCell(args.row, args.col).value(recode[updateField]);
  927. return;
  928. }
  929. }
  930. } else {
  931. if (updateField == 'name' || updateField == 'unit') {
  932. if (args.editingText === null) {
  933. alert(me.setting.header[args.col].headerName + '不能为空!');
  934. me.sheet.getCell(args.row, args.col).value(recode[updateField]);
  935. return;
  936. }
  937. }
  938. if(updateField == 'code'){
  939. if (!gljUtil.isDef(args.editingText)||args.editingText==''||args.editingText.indexOf('|-|') === -1||this.isRationGLJExit(args.editingText)) {//说明是选中自已,或者是已存在的工料机
  940. me.sheet.getCell(args.row, args.col).value(recode[updateField]);
  941. return;
  942. }
  943. }
  944. newval = args.editingText == null ? "" : args.editingText;
  945. }
  946. if (newval === recode[updateField]) {//如果值完全相等,则不需要更新
  947. return
  948. }
  949. if (updateField == 'marketPrice' || updateField == 'basePrice') {
  950. projectObj.project.projectGLJ.updatePriceFromRG(recode, updateField, newval);
  951. }else if(updateField == 'code'){//替换单价文件中已经有的工料机
  952. projectObj.project.ration_glj.updateRationGLJByChangeCode(recode, updateField, newval);
  953. }else if(me.setting.navigationRightCol.indexOf(updateField) != -1){//对于名称、规格、单位先跳到下一列,保存至缓存
  954. me.setToEditCache(recode,updateField, newval,args);
  955. }else if(updateField == 'rationItemQuantity'){//修改组成物的消耗量
  956. me.updateRatio(recode,{consumption:newval})
  957. console.log(recode);
  958. } else {
  959. projectObj.project.ration_glj.updateRationGLJByEdit(recode, updateField, newval);
  960. }
  961. },
  962. setToEditCache:function(recode,updateField,value,args){
  963. let me = this;
  964. if(me.rationGljEditObj == null){
  965. me.rationGljEditObj = {
  966. recode:recode,
  967. doc:{},
  968. row:args.row
  969. }
  970. me.rationGljEditObj.doc[updateField] = value;
  971. }else {
  972. if(me.rationGljEditObj.recode.ID == recode.ID){//确保编辑的是同一条数据
  973. me.rationGljEditObj.doc[updateField] = value;
  974. }
  975. }
  976. },
  977. isRationGLJExit:function (connectKey) {
  978. for(let rg of gljOprObj.sheetData){
  979. if(rg.isMixRatio == true){
  980. continue;
  981. }
  982. if(gljOprObj.getIndex(rg, gljKeyArray) == connectKey){//存在一样的工料机
  983. return true;
  984. }
  985. }
  986. return false;
  987. },
  988. getParentPrice:function(subList,value,radio,type = 'modify'){
  989. let marketPrice = 0,basePrice=0;
  990. let decimal = getDecimal('glj.unitPrice');
  991. for(let s of subList){
  992. let c = parseFloat(s.consumption);
  993. if(s.mixRatioId == radio.mixRatioId) c = value;
  994. if(type == 'delete' && s.mixRatioId == radio.mixRatioId) continue;
  995. let m = scMathUtil.roundForObj(s.marketPrice * c,decimal);
  996. let b = scMathUtil.roundForObj(s.basePrice * c,decimal);
  997. marketPrice += m;
  998. basePrice +=b;
  999. }
  1000. return [scMathUtil.roundForObj(marketPrice,decimal),scMathUtil.roundForObj(basePrice,decimal)]
  1001. },
  1002. deleteRatio:async function(row){
  1003. let ratio = this.sheetData[row];
  1004. let pgljData = projectObj.project.projectGLJ.datas;
  1005. for(let rg of this.sheetData){
  1006. if(rg.projectGLJID == ratio.parentGLJ.id) {
  1007. subList = rg.subList;
  1008. break;
  1009. }
  1010. }
  1011. let [marketPrice,basePrice] = this.getParentPrice(subList,0,ratio,"delete");
  1012. try {
  1013. $.bootstrapLoading.start()
  1014. projectData = await ajaxPost('/glj/updateRatio', {id: ratio.mixRatioId,type:'delete',pid:ratio.parentGLJ.unit_price.id,market_price: marketPrice,base_price: basePrice});
  1015. //更新缓存
  1016. let pk = gljUtil.getIndex(ratio.parentGLJ);
  1017. if(pgljData.mixRatioMap && pgljData.mixRatioMap[pk]){
  1018. _.remove(pgljData.mixRatioMap[pk],{"id":ratio.mixRatioId});
  1019. }
  1020. for(let r of ratio.parentGLJ.ratio_data){
  1021. _.remove(ratio.parentGLJ.ratio_data,{"id":ratio.mixRatioId});
  1022. }
  1023. ratio.parentGLJ.unit_price.market_price = marketPrice;
  1024. ratio.parentGLJ.unit_price.base_price = basePrice;
  1025. //重新计算消耗量
  1026. projectObj.project.projectGLJ.calcQuantity();
  1027. let priceData = {};
  1028. priceData =this.setGLJPrice(priceData,ratio.parentGLJ);
  1029. projectGljObject.updateParentNodes(ratio.parentGLJ.id,priceData.marketPrice);
  1030. projectGljObject.onUnitFileChange(ratio);
  1031. } catch (error) {
  1032. console.log(error)
  1033. }finally{
  1034. $.bootstrapLoading.end()
  1035. }
  1036. },
  1037. updateRatio:async function(ratio,doc){
  1038. let pgljData = projectObj.project.projectGLJ.datas;
  1039. let subList = [];
  1040. for(let rg of this.sheetData){
  1041. if(rg.projectGLJID == ratio.parentGLJ.id) {
  1042. subList = rg.subList;
  1043. break;
  1044. }
  1045. }
  1046. let [marketPrice,basePrice] = this.getParentPrice(subList,doc.consumption,ratio);
  1047. try {
  1048. $.bootstrapLoading.start()
  1049. projectData = await ajaxPost('/glj/updateRatio', {id: ratio.mixRatioId, doc:doc,pid:ratio.parentGLJ.id,market_price: marketPrice,base_price: basePrice});
  1050. //更新缓存
  1051. let pk = gljUtil.getIndex(ratio.parentGLJ);
  1052. if(pgljData.mixRatioMap && pgljData.mixRatioMap[pk]){
  1053. for(let m of pgljData.mixRatioMap[pk]){
  1054. if(m.id == ratio.mixRatioId) gljUtil.setProperty(m,doc);
  1055. }
  1056. }
  1057. for(let r of ratio.parentGLJ.ratio_data){
  1058. if(r.id == ratio.mixRatioId) gljUtil.setProperty(r,doc);
  1059. }
  1060. ratio.parentGLJ.unit_price.market_price = marketPrice;
  1061. ratio.parentGLJ.unit_price.base_price = basePrice;
  1062. //重新计算消耗量
  1063. projectObj.project.projectGLJ.calcQuantity();
  1064. let priceData = {};
  1065. priceData =this.setGLJPrice(priceData,ratio.parentGLJ);
  1066. projectGljObject.updateParentNodes(ratio.parentGLJ.id,priceData.marketPrice);
  1067. projectGljObject.onUnitFileChange(ratio);
  1068. } catch (error) {
  1069. console.log(error)
  1070. }finally{
  1071. $.bootstrapLoading.end()
  1072. }
  1073. },
  1074. updateRationTypeGLJ: function (value, node, fieldName,editingText) {
  1075. let newval;
  1076. let updatePrice = false;
  1077. if (fieldName == "marketUnitFee") {
  1078. updatePrice = true;
  1079. if (value == null) {
  1080. newval = 0;
  1081. } else {
  1082. var decimal = getDecimal("glj.unitPrice");
  1083. newval = number_util.checkNumberValue(value, decimal);
  1084. }
  1085. } else {
  1086. if (value != null) {
  1087. projectObj.project.projectGLJ.updatePropertyFromMainSpread(node, fieldName, value,editingText);
  1088. return;
  1089. }
  1090. }
  1091. if (newval && updatePrice == true) {
  1092. projectObj.project.projectGLJ.updatePriceFromRG(node.data, "marketPrice", newval);
  1093. return
  1094. }
  1095. projectObj.mainController.refreshTreeNode([node]);
  1096. },
  1097. updateIsEstimate:function (args, newval) {
  1098. var me = gljOprObj;
  1099. if(me.setting.header[args.col].dataCode=="isEstimate"){
  1100. var pspread= new ProjectGLJSpread();
  1101. var recode = me.sheetData[args.row];
  1102. let projectGljs = projectObj.project.projectGLJ.datas.gljList;
  1103. let glj = _.find(projectGljs, {'id': recode.projectGLJID});
  1104. if(glj){
  1105. glj["is_evaluate"]=newval;
  1106. args.fromRG=true;
  1107. pspread.postUpdate(recode.projectGLJID,"is_evaluate",newval,args,null,successTrigger);
  1108. }
  1109. }
  1110. },
  1111. showLibGLJSheetData: function () {
  1112. this.gljLibSheetData = _.sortBy(this.gljLibSheetData, 'code');
  1113. sheetCommonObj.showData(this.gljLibSheet, this.gljLibSheetSetting, this.gljLibSheetData, gljOprObj.distTypeTree);
  1114. this.gljLibSheet.setRowCount(this.gljLibSheetData.length);
  1115. },
  1116. // 根据人材机类型,设置人材机类型显示名称
  1117. setTypeName: function (distTypeData, data) {
  1118. data.forEach(item => {
  1119. let typeData = distTypeData.find(typeItem => typeItem.value === item.gljType);
  1120. if (typeData) {
  1121. item.typeName = typeData.text;
  1122. }
  1123. });
  1124. },
  1125. /*
  1126. * 获取分页查询所需要的条件数据
  1127. * @param {Boolean}init 是否是初始化
  1128. * {Boolean}reset 是否重置数据 (点击分类树等)
  1129. * {Boolean}location 是否定位(替换初始化)
  1130. * {Number}index 下一页数据开始索引,根据这个值获取上次分页最大的编码数据(不用skip进行分页,skip跳过大量数据会降低性能,用$gt: data.code)
  1131. * @return {Object}
  1132. * */
  1133. getPagingCondition: function (init, reset, location, index) {
  1134. // 上一次分页的最末人材机编码,index为0时,code为空
  1135. const code = gljOprObj.AllRecode && gljOprObj.AllRecode[index - 1] ? gljOprObj.AllRecode[index - 1].code : '';
  1136. // 初始化情况下的条件
  1137. let condition = {
  1138. code,
  1139. // 是否重置数据
  1140. reset,
  1141. // 是否定位
  1142. location,
  1143. index,
  1144. // 限制条数
  1145. limit: 50,
  1146. // 初始化
  1147. init: init,
  1148. // 所在部分(标准、补充)
  1149. type: this.pagingType.stdGLJ,
  1150. // 替换数据,替换操作下有数据:编码、名称、规格、单位、类型
  1151. replace: null,
  1152. // 添加组成物的查询扩展
  1153. queryExtend: {},
  1154. // 所在分类节点
  1155. classList: [],
  1156. // 搜索文本
  1157. search: ''
  1158. };
  1159. // 触发入口(添加、替换、批量替换)
  1160. const actionType = $('#actionType').val();
  1161. const replaceActions = ['replace', 'm_replace'];
  1162. // 替换相关
  1163. if (replaceActions.includes(actionType)) {
  1164. // 定额人材机界面选中的人材机
  1165. const selected = gljOprObj.sheetData[gljContextMenu.selectedRow];
  1166. condition.replace = {
  1167. code: selected.code,
  1168. name: selected.name,
  1169. specs: selected.specs,
  1170. unit: selected.unit,
  1171. gljType: selected.type
  1172. };
  1173. } else if (actionType === 'addMix'|| actionType === 'unitPriceAddMix') {
  1174. condition.queryExtend = projectGljObject.getQueryExtForMixRatio();
  1175. }
  1176. if (init) {
  1177. return condition;
  1178. }
  1179. condition.init = false;
  1180. // 标准、补充的选择
  1181. if ($('#glj_tree_div').is(':visible')) {
  1182. let radioType = $("input[name='glj']:checked").val();
  1183. condition.type = this.pagingType[radioType];
  1184. }
  1185. // 选中的分类
  1186. if (this.treeObj) {
  1187. let selNode = this.treeObj.getNodeByParam('ID', this.gljCurTypeId);
  1188. // 不为最顶层节点时,才赋值给withinClass
  1189. if (selNode && selNode.ParentID !== -1) {
  1190. const classList = this.parentNodeIds['_pNodeId_' + this.gljCurTypeId];
  1191. condition.classList = classList ? classList : [this.gljCurTypeId];
  1192. }
  1193. }
  1194. // 搜索文本
  1195. let searchStr = $('#gljSearchKeyword').val().trim();
  1196. if(searchStr){
  1197. condition.search = searchStr;
  1198. }
  1199. return condition;
  1200. },
  1201. filterLibGLJSheetData: function () {
  1202. let me = this;
  1203. let val = $("input[name='glj']:checked").val();
  1204. if (val == 'allGljs') {
  1205. me.gljLibSheetData = me.stdGLJ.concat(me.complementaryGLJs);
  1206. } else {
  1207. me.gljLibSheetData = me[val];
  1208. }
  1209. if ($('#actionType').val() == 'replace' || $('#actionType').val() == 'm_replace') {
  1210. me.filterLibGLJByType();
  1211. }else if($('#actionType').val() == 'addMix' || $('#actionType').val() == 'unitPriceAddMix'){
  1212. projectGljObject.filterLibGLJForMixRatio();
  1213. }
  1214. //文本筛选
  1215. let searchStr = $('#gljSearchKeyword').val();
  1216. if(searchStr && searchStr.trim() != ''){
  1217. let reg = new RegExp(searchStr);
  1218. me.gljLibSheetData = _.filter(me.gljLibSheetData, function (data) {
  1219. return reg.test(data.code) || reg.test(data.name);
  1220. });
  1221. }
  1222. if (me.gljCurTypeId == undefined) {
  1223. return;
  1224. }
  1225. if (me.parentNodeIds["_pNodeId_" + me.gljCurTypeId]) {
  1226. me.gljLibSheetData = _.filter(me.gljLibSheetData, function (n) {
  1227. return _.includes(me.parentNodeIds["_pNodeId_" + me.gljCurTypeId], n.gljClass);
  1228. });
  1229. } else {
  1230. me.gljLibSheetData = _.filter(me.gljLibSheetData, {'gljClass': me.gljCurTypeId});
  1231. }
  1232. },
  1233. setGLJSelection: function (args, newVal) {
  1234. if ($('#actionType').val() == 'add' || $('#actionType').val() == 'insert'|| $('#actionType').val() == 'addMix'|| $('#actionType').val() == 'unitPriceAddMix') {
  1235. this.addGLJsSelection(args, newVal);
  1236. } else {
  1237. this.replaceGLJSelection(args, newVal);
  1238. }
  1239. },
  1240. addGLJsSelection: function (args, newVal) {
  1241. const curGLJ = this.AllRecode[args.row];
  1242. const con_key = this.getIndex(curGLJ, gljLibKeyArray);
  1243. if (newVal == 1) {
  1244. this.GLJSelection.push(con_key);
  1245. } else if (newVal == 0) {
  1246. _.pull(this.GLJSelection, con_key);
  1247. }
  1248. },
  1249. replaceGLJSelection: function (args, newVal) {
  1250. var me = this;
  1251. var oldSelection = this.GLJSelection[0];
  1252. if (newVal == 0) {
  1253. args.sheet.getCell(args.row, args.col).value(1);
  1254. return;
  1255. }
  1256. const curGLJ = this.AllRecode[args.row];
  1257. const connectKey = this.getIndex(curGLJ, gljLibKeyArray);
  1258. this.GLJSelection = [connectKey];
  1259. var oindex = _.findIndex(this.AllRecode, function (item) {
  1260. var i_key = me.getIndex(item, gljLibKeyArray);
  1261. return oldSelection == i_key;
  1262. });
  1263. if (oindex != -1) {
  1264. args.sheet.getCell(oindex, args.col).value(0);
  1265. } else {
  1266. var oldData = _.find(gljOprObj.AllRecode, function (item) {
  1267. var i_key = me.getIndex(item, gljLibKeyArray);
  1268. return oldSelection == i_key;
  1269. });
  1270. }
  1271. },
  1272. filterLibGLJByType: function () {
  1273. var me = this;
  1274. var selected = me.sheetData[gljContextMenu.selectedRow];
  1275. //当前人材机类型是“混凝土、砂浆、配合比、商品混凝土、商品砂浆”时,筛选的可替换的人材机类型应是“混凝土、或砂浆、或配合比、或商品混凝土、或商品砂浆”。
  1276. let materialTypes = [202, 203, 204, 205, 206];//除了普通材料
  1277. let filterTypes = materialTypes.includes(selected.type) ? materialTypes : [selected.type];
  1278. me.gljLibSheetData = _.filter(me.gljLibSheetData, function (data) {
  1279. return filterTypes.includes(data.gljType);
  1280. });
  1281. },
  1282. getComboData: function (gljDistType) {
  1283. let me = this;
  1284. let distType;
  1285. let distTypeTree = {
  1286. prefix: 'gljType',
  1287. distTypes: {},
  1288. comboDatas: [],
  1289. distTypesArr: []
  1290. };
  1291. gljDistType.forEach(function (typeData) {
  1292. let typeObj = {
  1293. data: typeData,
  1294. children: [],
  1295. parent: null
  1296. }
  1297. distTypeTree.distTypes[distTypeTree.prefix + typeData.ID] = typeObj;
  1298. distTypeTree.distTypesArr.push(typeObj);
  1299. });
  1300. gljDistType.forEach(function (typeData) {
  1301. distType = distTypeTree.distTypes[distTypeTree.prefix + typeData.ID];
  1302. let parent = distTypeTree.distTypes[distTypeTree.prefix + typeData.ParentID];
  1303. if (parent) {
  1304. distType.parent = parent;
  1305. parent.children.push(distType);
  1306. }
  1307. });
  1308. distTypeTree.distTypesArr.forEach(function (distTypeObj) {
  1309. if (distTypeObj.data.fullName !== '材料' && distTypeObj.data.fullName !== '机械') {
  1310. distTypeTree.comboDatas.push({text: distTypeObj.data.fullName, value: distTypeObj.data.ID});
  1311. }
  1312. });
  1313. return distTypeTree;
  1314. },
  1315. doInsertGLJ: function () {
  1316. var me = this;
  1317. var selected = projectObj.project.mainTree.selected;
  1318. var project = projectObj.project;
  1319. if (me.GLJSelection.length <= 0) {
  1320. return;
  1321. }
  1322. $.bootstrapLoading.start();
  1323. project.ration_glj.insertGLJAsRation(me.GLJSelection, selected, function (parentNodeID,nextNodeID,data) {
  1324. let newNode=null;
  1325. for (let r_glj of data) {
  1326. r_glj.quantity = r_glj.quantity + "";
  1327. project.Ration.datas.push(r_glj);
  1328. }//要先更新树节点工程量,加载项目工料机并计算消耗量才有值
  1329. project.projectGLJ.loadData(function () {
  1330. for(let r_glj of data){
  1331. r_glj = me.setGLJPrice(r_glj);//设置工料机价格
  1332. newNode = project.mainTree.insert(parentNodeID, nextNodeID, r_glj.ID);
  1333. newNode.source = r_glj;
  1334. newNode.sourceType = project.Ration.getSourceType();
  1335. newNode.data = r_glj;
  1336. ProjectController.syncDisplayNewNode(projectObj.mainController, newNode);
  1337. }
  1338. project.calcProgram.calcLeafAndSave(newNode.parent);//计算父级清单的所有子节点
  1339. projectObj.mainController.refreshTreeNode([newNode]);
  1340. if(me.hasComposition(newNode.data,true)){
  1341. me.showMixRatio(newNode);
  1342. }else {
  1343. me.showRationGLJSheetData();
  1344. }
  1345. $.bootstrapLoading.end();
  1346. });
  1347. })
  1348. },
  1349. doAddGLJ: function () {
  1350. var selected = projectObj.project.mainTree.selected;
  1351. var project = projectObj.project;
  1352. gljOprObj.GLJSelection = _.filter(gljOprObj.GLJSelection, function (n) {
  1353. var rg = _.find(gljOprObj.sheetData, function (item) {
  1354. if(item.isMixRatio == true){
  1355. return false;
  1356. }
  1357. var i_key = gljOprObj.getIndex(item, gljKeyArray);
  1358. return n == i_key
  1359. });
  1360. return rg ? false : true;
  1361. })
  1362. if (gljOprObj.GLJSelection.length > 0 && selected && selected.sourceType == ModuleNames.ration) {
  1363. project.ration_glj.addGLJByLib(gljOprObj.GLJSelection, selected.data, function (result) {
  1364. if (result) {
  1365. selected.data.adjustState = result.adjustState;
  1366. //project.ration_glj.datas = project.ration_glj.datas.concat(result.newRecodes);//显示和缓存统一,这样的话就不用更新两个位置了
  1367. project.ration_glj.datas = project.ration_glj.datas.concat(result.showData);
  1368. gljOprObj.sheetData = gljOprObj.sheetData.concat(result.showData);
  1369. project.projectGLJ.loadNewProjectGLJToCaches(result.projectGLJList,true);
  1370. project.ration_glj.addToMainTree(result.showData);
  1371. gljOprObj.showRationGLJSheetData();
  1372. project.calcProgram.calcAndSave(selected);
  1373. projectObj.mainController.refreshTreeNode([selected]);
  1374. $.bootstrapLoading.end();
  1375. }
  1376. });//doc.rationID=selected.data.ID;
  1377. }
  1378. },
  1379. doReplaceGLJ: function () {
  1380. let me = this;
  1381. let oldData = me.sheetData[gljContextMenu.selectedRow];
  1382. let project = projectObj.project;
  1383. let selectCode = gljOprObj.GLJSelection[0];
  1384. let selected = projectObj.project.mainTree.selected;
  1385. project.ration_glj.replaceGLJ(selectCode, oldData, function (result) {
  1386. if (result) {
  1387. //result.adjustState;
  1388. let glj_list = projectObj.project.ration_glj.datas;
  1389. let data = result.data;
  1390. let index = _.findIndex(gljOprObj.sheetData, {'ID': data.ID});
  1391. let list_index = _.findIndex(glj_list, {'ID': data.ID});
  1392. let nodes = [selected];
  1393. gljOprObj.sheetData[index] = data;
  1394. glj_list[list_index] = data;
  1395. project.projectGLJ.loadNewProjectGLJToCaches([result.projectGLJ],true);
  1396. gljOprObj.showRationGLJSheetData();
  1397. let node = project.ration_glj.updateGLJNodeAfterReplace(data);
  1398. if(node) nodes.push(node);
  1399. /*if (project.ration_glj.needShowToTree(data)) {//当替换的是主材或设备时,刷新对应的树节点
  1400. var node = project.ration_glj.findGLJNodeByID(data.ID);
  1401. if (node) {
  1402. project.ration_glj.transferToNodeData(data);
  1403. node.source = data;
  1404. node.data = data;
  1405. }
  1406. node ? nodes.push(node) : "";
  1407. }*/
  1408. //project.ration_glj.addToMainTree(data);
  1409. selected.data.adjustState = result.adjustState;
  1410. selected.data.name = result.name;
  1411. projectObj.mainController.refreshTreeNode(nodes);
  1412. project.calcProgram.calcAndSave(selected, async function () {
  1413. await OVER_HEIGHT.reCalcOverHeightFee();
  1414. await itemIncreaseFeeObj.calcItemIncreaseFeeByNodes([selected]);
  1415. });
  1416. $.bootstrapLoading.end();
  1417. }
  1418. })
  1419. },
  1420. doMReplaceGLJ: function () {
  1421. let me = this;
  1422. let oldData = me.sheetData[gljContextMenu.selectedRow];
  1423. let project = projectObj.project;
  1424. let selectCode = me.GLJSelection[0];
  1425. project.ration_glj.mReplaceGLJ(selectCode, oldData, function (result,updateMap) {
  1426. if(result == null){
  1427. return;
  1428. }
  1429. let data = result.data;
  1430. let stateList = result.stateList;
  1431. //let n_index = me.getIndex(data.query, gljKeyArray);
  1432. let nodes = [];
  1433. _.forEach(project.ration_glj.datas, function (t) {
  1434. // let t_index = me.getIndex(t, gljKeyArray);
  1435. if (updateMap[t.ID]) {
  1436. me.updateProperty(t, data.doc);
  1437. me.updateProperty(t, updateMap[t.ID]);
  1438. if (project.ration_glj.needShowToTree(t)) {//如果是造价书中的树节点,则也须刷新
  1439. project.ration_glj.transferToNodeData(t);
  1440. var node = project.ration_glj.findGLJNodeByID(t.ID);
  1441. node ? nodes.push(node):'';
  1442. }
  1443. }
  1444. })
  1445. project.projectGLJ.loadNewProjectGLJToCaches([result.projectGLJ],true);
  1446. me.showRationGLJSheetData();
  1447. var rationNodes = me.refreshStateAfterMreplace(stateList, nodes);
  1448. project.calcProgram.calcNodesAndSave(rationNodes, async function () {
  1449. await OVER_HEIGHT.reCalcOverHeightFee();
  1450. await await itemIncreaseFeeObj.calcItemIncreaseFeeByNodes(rationNodes);
  1451. });
  1452. $.bootstrapLoading.end();
  1453. })
  1454. },
  1455. updateProperty: function (obj, doc) {
  1456. _.forEach(doc, function (n, key) {
  1457. obj[key] = n;
  1458. });
  1459. },
  1460. refreshStateAfterMreplace: function (stateList, gljNodes) {
  1461. let nodes = [];
  1462. let rationNodes = [];
  1463. _.forEach(stateList, function (s) {
  1464. let node = _.find(projectObj.project.mainTree.items, function (n) {
  1465. return n.sourceType == ModuleNames.ration && n.data.ID == s.rationID;
  1466. })
  1467. if (node) {
  1468. node.data.adjustState = s.adjustState;
  1469. node.data.name = s.name;
  1470. nodes.push(node);
  1471. rationNodes.push(node);
  1472. }
  1473. });
  1474. gljNodes.length > 0 ? nodes = nodes.concat(gljNodes) : "";
  1475. projectObj.mainController.refreshTreeNode(nodes);
  1476. return rationNodes;
  1477. },
  1478. refreshView: function () {
  1479. let node = projectObj.project.mainTree.selected;
  1480. this.showDataIfRationSelect(node,"111111");
  1481. },
  1482. refreshTreeNode: function (obj) {
  1483. if (!obj) {
  1484. return;
  1485. }
  1486. let objectArray = [];
  1487. let nodes = [];
  1488. if (obj instanceof Array) {
  1489. objectArray.concat(obj);
  1490. } else {
  1491. objectArray.push(obj);
  1492. }
  1493. for (let o of objectArray) {
  1494. let node = this.updateDataNodeProperty(o.ID,o.data);
  1495. if (node) {
  1496. nodes.push(node);
  1497. }
  1498. }
  1499. projectObj.mainController.refreshTreeNode(nodes);
  1500. return nodes;
  1501. },
  1502. updateDataNodeProperty:function(nodeID,data){
  1503. let node = projectObj.project.mainTree.findNode(nodeID);
  1504. if (node) {
  1505. for (let k in data) {
  1506. node.data[k] = data[k];
  1507. }
  1508. }
  1509. return node;
  1510. },
  1511. getTreeNodeCellType: function (data,comboboxOptions) {
  1512. let ns = GC.Spread.Sheets;
  1513. let rectW = 10;
  1514. let rectH = 10;
  1515. let margin = 3;
  1516. function TreeNodeCellType() {
  1517. this.ctx = null;
  1518. }
  1519. TreeNodeCellType.prototype = comboboxOptions?sheetCommonObj.getDynamicCombo():new ns.CellTypes.Text();
  1520. TreeNodeCellType.prototype.paint = function (ctx, value, x, y, w, h, style, options) {
  1521. this.ctx= ctx;
  1522. if (style.backColor) {//先画背景色
  1523. ctx.save();
  1524. ctx.fillStyle = style.backColor;
  1525. ctx.fillRect(x, y, w, h);
  1526. ctx.restore();
  1527. } else {
  1528. ctx.clearRect(x, y, w, h);
  1529. }
  1530. if (value != null) {
  1531. let offset = margin + rectW + 6;
  1532. let recode = data[options.row];
  1533. if (recode && recode.hasOwnProperty('subList')) {
  1534. sheetCommonObj.drowRect(ctx, x, y, w, h,rectW,rectH,margin);
  1535. let collapsed = recode.collapsed == undefined ? true : recode.collapsed;//options.sheet.getTag(options.row,options.col);
  1536. sheetCommonObj.drowSymbol(ctx, x, y, w, h,rectW,rectH,margin, collapsed);
  1537. } else if (recode && recode.isMixRatio) {
  1538. let hasNext = data[options.row + 1] && data[options.row + 1].isMixRatio;
  1539. offset = sheetCommonObj.drowSubItem(ctx, x, y, w, h, offset,hasNext);
  1540. offset += 1;
  1541. }
  1542. arguments[2] = x + offset;
  1543. arguments[4] = w - offset;
  1544. //x = x + offset;
  1545. //w = w - offset;
  1546. GC.Spread.Sheets.CellTypes.Text.prototype.paint.apply(this, arguments);
  1547. }
  1548. };
  1549. TreeNodeCellType.prototype.getHitInfo = function (x, y, cellStyle, cellRect, context) {
  1550. if(x < cellRect.x+cellRect.width -15){//这里要判断点击的位置来决定return的内容,不能直接用combobox的方法
  1551. return {
  1552. x: x,
  1553. y: y,
  1554. row: context.row,
  1555. col: context.col,
  1556. cellStyle: cellStyle,
  1557. cellRect: cellRect,
  1558. sheetArea: context.sheetArea
  1559. };
  1560. }else {
  1561. return GC.Spread.Sheets.CellTypes.ComboBox.prototype.getHitInfo.apply(this, arguments);
  1562. }
  1563. };
  1564. TreeNodeCellType.prototype.processMouseDown = function (hitinfo) {
  1565. let recode = data[hitinfo.row];
  1566. if(hitinfo.x < hitinfo.cellRect.x+hitinfo.cellRect.width -15){
  1567. hitinfo.sheet.setTag(hitinfo.row,hitinfo.col,"locked")//通过这个来控制除了点击下拉框的三角形,点击其它地方不充许进入编辑状态,不然不好控制下拉框超出页面后调整滚动条
  1568. }
  1569. if (recode && recode.hasOwnProperty('subList')) {
  1570. let hoffset = hitinfo.cellRect.x + 3;
  1571. if (hitinfo.x > hoffset && hitinfo.x < hoffset + 10) {
  1572. let collapsed = recode.collapsed == undefined ? true : recode.collapsed;
  1573. collapsed = !collapsed
  1574. recode.collapsed = collapsed;
  1575. //hitinfo.sheet.setTag(hitinfo.row,hitinfo.col,collapsed);
  1576. hitinfo.sheet.getRange(hitinfo.row + 1, -1, recode.subList.length, -1).visible(!collapsed);
  1577. hitinfo.sheet.invalidateLayout();
  1578. hitinfo.sheet.repaint();
  1579. return;
  1580. }
  1581. }
  1582. if(comboboxOptions&&hitinfo.x > hitinfo.cellRect.x+hitinfo.cellRect.width -15){//点击了下拉框按钮,这里要判断下拉框是否会被挡住,从而决定是否自动调整滚动条
  1583. hitinfo.sheet.setTag(hitinfo.row,hitinfo.col,"");
  1584. sheetCommonObj.scrollSheetForOption(hitinfo.sheet,this.ctx,hitinfo.cellRect,hitinfo.row,comboboxOptions);//下拉框超出显示后自动调整滚动条
  1585. GC.Spread.Sheets.CellTypes.ComboBox.prototype.processMouseDown.apply(this, arguments);
  1586. }
  1587. };
  1588. let cellType = new TreeNodeCellType();
  1589. if(comboboxOptions){
  1590. cellType.editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.value);
  1591. cellType.itemHeight(comboboxOptions.length).items(comboboxOptions);
  1592. }
  1593. return cellType;
  1594. },
  1595. marketPriceReadOnly: function (node) {
  1596. let hasCom = false;
  1597. if(node.sourceType==ModuleNames.ration&&node.data.type==rationType.gljRation){
  1598. hasCom = this.hasComposition(node.data,true);
  1599. }else {
  1600. hasCom = this.hasComposition(node.data);
  1601. }
  1602. return hasCom;//2018-9-14 需求变更暂估工料机也能修改市场价原语句:return hasCom|| node.data.isEstimate == 1
  1603. },
  1604. locateZTree: function(ID) {
  1605. let zTree = $.fn.zTree.getZTreeObj("gljTree");
  1606. let node = null;
  1607. if (ID) node = zTree.getNodesByParam('ID', ID, null)[0];
  1608. if (!node) node = zTree.getNodeByTId('gljTree_1');
  1609. zTree.selectNode(node);
  1610. gljOprObj.gljCurTypeId = ID;
  1611. //--gljOprObj.filterLibGLJSheetData();
  1612. //--gljOprObj.showLibGLJSheetData();
  1613. },
  1614. isExtraType:function (type) {
  1615. return _.includes(gljUtil.extraType,type)
  1616. },
  1617. setNodeShowTab:function () {
  1618. let node = projectObj.project.mainTree.selected;
  1619. if(node && node.sourceType==ModuleNames.ration){
  1620. gljOprObj.rationTab = gljOprObj.activeTab;
  1621. }else {
  1622. gljOprObj.billsTab = gljOprObj.activeTab;
  1623. }
  1624. },
  1625. //初始化分类树
  1626. //@param {String}type(标准或补充) {Array}treeData(树数据)
  1627. initClassTree: function (type, treeData, initSel = false) {
  1628. let me = this;
  1629. if (me.treeObj) {
  1630. me.treeObj.destroy();
  1631. me.parentNodeIds = {};
  1632. }
  1633. zTreeHelper.createTree(treeData, me.gljTreeSetting, "gljTree", me);
  1634. if (initSel) {
  1635. let rootNode = me.treeObj.getNodes()[0];
  1636. if(rootNode && rootNode.isParent && rootNode.isFirstNode){
  1637. me.rootNode = rootNode;
  1638. }
  1639. if(me.rootNode){
  1640. me.treeObj.selectNode(me.rootNode);
  1641. me.gljTreeSetting.callback.onClick(null, 'gljTree', me.rootNode);
  1642. }
  1643. }
  1644. },
  1645. initScopeSpread:function() {
  1646. if (this.scopeSpread) return this.scopeSpread.repaint();
  1647. this.scopeSpread = SheetDataHelper.createNewSpread($('#scopeSpread')[0]);
  1648. sheetCommonObj.spreadDefaultStyle(this.scopeSpread);
  1649. this.scopeTree = idTree.createNew({id: 'ID', pid: 'ParentID', nid: 'NextSiblingID', rootId: -1, autoUpdate: false});
  1650. this.scopeTreeController = TREE_SHEET_CONTROLLER.createNew(this.scopeTree, this.scopeSpread.getActiveSheet(), this.scopeSetting);
  1651. this.scopeSheet = this.scopeSpread.getActiveSheet();
  1652. this.scopeSpread.bind(GC.Spread.Sheets.Events.ButtonClicked, this.onScopeChecked);
  1653. },
  1654. showScopeDatas:function () {
  1655. this.initScopeSpread();
  1656. this.scopeDatas =this.getScopeDatas();
  1657. this.scopeTree.loadDatas(this.scopeDatas);
  1658. this.scopeTreeController.showTreeData();
  1659. },
  1660. getScopeDatas:function () {
  1661. let controller = projectObj.mainController, project = projectObj.project;
  1662. let allNodes = [],datas = []
  1663. for(let rootNode of controller.tree.roots){
  1664. allNodes.push(rootNode);
  1665. controller.tree.getAllSubNode(rootNode.source,allNodes);
  1666. }
  1667. for(let n of allNodes){
  1668. let temData = {
  1669. ID:n.data.ID,
  1670. NextSiblingID:n.data.NextSiblingID,
  1671. ParentID:n.data.ParentID,
  1672. unit : n.data.unit,
  1673. code : n.data.code,
  1674. selected:0,
  1675. name : n.data.name,
  1676. quantity:calcTools.uiNodeQty(n)?calcTools.uiNodeQty(n):"",
  1677. };
  1678. if(n.data.feesIndex && n.data.feesIndex.common){
  1679. temData.unitPrice = n.data.feesIndex.common.unitFee;
  1680. temData.totalPrice = n.data.feesIndex.common.totalFee;
  1681. }
  1682. datas.push(temData);
  1683. }
  1684. return datas;
  1685. },
  1686. onScopeChecked:function (e,args) {
  1687. let me = gljOprObj,nodes = [];
  1688. var checkboxValue = args.sheet.getCell(args.row, args.col).value();
  1689. var newval = checkboxValue?0:1;
  1690. let node = me.scopeTree.items[args.row];
  1691. setNodeAndChildreSelected(node,newval,nodes);
  1692. me.scopeTreeController.refreshTreeNode(nodes);
  1693. function setNodeAndChildreSelected(n,val,arr){
  1694. n.data.selected = val;
  1695. nodes.push(n);
  1696. for(let c of n.children){
  1697. setNodeAndChildreSelected(c,val,arr)
  1698. }
  1699. }
  1700. },
  1701. setScopeSelection:function () {
  1702. for(let node of this.scopeTree.items){
  1703. //挑出选中数,过滤父节点
  1704. if(node.data.selected == 1 && node.children.length == 0) this.scopeSelectedIDMap[node.data.ID] = true
  1705. }
  1706. }
  1707. }
  1708. // 人材机选择界面的功能进行了适合分页的重构
  1709. // 重构时,只有添加、替换、批量替换的入口。因此只对这三个入口相关的地方进行重构,其他入口的代码没有变更
  1710. // 若以后放开其他入口,需要将其他入口的相应方法进行重构
  1711. $(function () {
  1712. $('#glj_tree_div').on('hidden.bs.modal', function () {
  1713. // 清空搜索框
  1714. $('#gljSearchKeyword').val('');
  1715. projectGljObject.subList = [];
  1716. });
  1717. $('#glj_tree_div').on('shown.bs.modal', function (e) {
  1718. if (gljOprObj.gljLibSpresd == undefined) {
  1719. gljOprObj.gljLibSpresd = sheetCommonObj.buildSheet($('#gljLibSheet')[0], gljOprObj.gljLibSheetSetting, gljOprObj.stdGLJ.length + gljOprObj.complementaryGLJs.length);
  1720. sheetCommonObj.spreadDefaultStyle(gljOprObj.gljLibSpresd);
  1721. gljOprObj.gljLibSpresd.bind(GC.Spread.Sheets.Events.ButtonClicked, gljOprObj.onButtonClick);
  1722. gljOprObj.gljLibSheet = gljOprObj.gljLibSpresd.getSheet(0);
  1723. gljOprObj.gljLibSheet.bind(GC.Spread.Sheets.Events.SelectionChanged, gljOprObj.onSelectionChanged);
  1724. gljOprObj.gljLibSheet.bind(GC.Spread.Sheets.Events.TopRowChanged, _.debounce(gljOprObj.onTopRowChanged, 100));
  1725. gljOprObj.gljLibSheet.setColumnWidth(0, 20, GC.Spread.Sheets.SheetArea.rowHeader);
  1726. gljOprObj.gljLibSheet.options.isProtected = true;
  1727. gljOprObj.gljLibSheet.name('glj_lib');
  1728. sheetCommonObj.setSheetBySetting(gljOprObj.gljLibSheet, gljOprObj.gljLibSheetSetting);
  1729. }
  1730. let gljClass = 0,
  1731. selected,
  1732. connect_key;
  1733. const actionType = $('#actionType').val();
  1734. const addActions = ['add', 'insert', 'addMix','unitPriceAddMix'];
  1735. const replaceActions = ['m_replace', 'replace'];
  1736. if (addActions.includes(actionType)) {//插入,添加,添加组成物(项目人材机页面)
  1737. gljOprObj.GLJSelection = [];
  1738. } else if(replaceActions.includes(actionType)){//替换、批量替换
  1739. selected = gljOprObj.sheetData[gljContextMenu.selectedRow];
  1740. connect_key = gljOprObj.getIndex(selected, gljKeyArray);
  1741. gljOprObj.GLJSelection = [connect_key];
  1742. // 找到定位的分类树
  1743. const locatedItem = gljOprObj.AllRecode.find(item => gljOprObj.getIndex(item, gljLibKeyArray) === connect_key);
  1744. if (locatedItem) {
  1745. gljClass = locatedItem.gljClass;
  1746. locatedItem.select = 1;
  1747. }
  1748. }
  1749. //替换,焦点定位至当前选中人材机
  1750. if (replaceActions.includes(actionType)) {
  1751. gljOprObj.locateZTree(gljClass);
  1752. sheetCommonObj.appendData(gljOprObj.gljLibSheet, 0, 0, gljOprObj.gljLibSheetSetting, gljOprObj.AllRecode);
  1753. const index = gljOprObj.AllRecode.findIndex(item => gljOprObj.getIndex(item, gljLibKeyArray) === connect_key);
  1754. gljOprObj.gljLibSheet.showRow(index, GC.Spread.Sheets.VerticalPosition.center);
  1755. gljOprObj.gljLibSheet.setActiveCell(index, 0);
  1756. gljOprObj.initSelection({row: index});
  1757. gljOprObj.gljLibSpresd.focus(true);
  1758. } else if (actionType === 'add' || actionType === 'addMix'|| actionType === 'unitPriceAddMix') {
  1759. gljOprObj.locateZTree(null);
  1760. sheetCommonObj.appendData(gljOprObj.gljLibSheet, 0, 0, gljOprObj.gljLibSheetSetting, gljOprObj.AllRecode);
  1761. gljOprObj.gljLibSheet.showRow(0, GC.Spread.Sheets.VerticalPosition.top);
  1762. gljOprObj.gljLibSheet.setActiveCell(0, 0);
  1763. gljOprObj.initSelection({row: 0});
  1764. } else {
  1765. gljOprObj.showLibGLJSheetData();
  1766. }
  1767. console.timeEnd('getGLJData');
  1768. });
  1769. $('#mreplace_next_div').on('shown.bs.modal', function (e) {
  1770. gljOprObj.scopeSelectedIDMap = {};
  1771. gljOprObj.showScopeDatas();
  1772. });
  1773. // 人材机选择界面标准、补充单选
  1774. $('.glj-radio').change(function () {
  1775. const val = $("input[name='glj']:checked").val();
  1776. if (val === 'stdGLJ') {
  1777. gljOprObj.initClassTree('std', gljOprObj.treeData.std, true);
  1778. } else {
  1779. gljOprObj.initClassTree('comple', gljOprObj.treeData.comple, true);
  1780. }
  1781. gljOprObj.initSelection({row: 0});
  1782. });
  1783. // 人材机选择页面搜索框
  1784. $('#gljSearchKeyword').bind('keyup', _.debounce(function() {
  1785. gljOprObj.loadPageData(gljOprObj.gljLibSheet, true, 0);
  1786. }, 500));
  1787. $('#glj_selected_conf').click(function () {
  1788. if (gljOprObj.GLJSelection.length < 1) {
  1789. return;
  1790. }
  1791. if ($('#actionType').val() == 'insert') { //造价书页面中插入定额类型的工料机
  1792. gljOprObj.doInsertGLJ();
  1793. } else if ($('#actionType').val() == 'add') { //添加工料机
  1794. gljOprObj.doAddGLJ();
  1795. } else if ($('#actionType').val() == 'replace') {//替换工料机
  1796. gljOprObj.doReplaceGLJ();
  1797. } else if ($('#actionType').val() == 'm_replace') {//批量替换工料机
  1798. gljOprObj.doMReplaceGLJ();
  1799. }else if($('#actionType').val() == 'addMix'){
  1800. projectGljObject.addMixRatio();
  1801. }else if($('#actionType').val() == 'unitPriceAddMix'){
  1802. unitPriceObj.addMixRatio();
  1803. }
  1804. $("#glj_tree_div").modal('hide');
  1805. })
  1806. $('#scope_position_confirm').click(function () {
  1807. gljOprObj.setScopeSelection();
  1808. gljOprObj.doMReplaceGLJ();
  1809. });
  1810. $('#replace_next_btn').click(function () {
  1811. $("#glj_tree_div").modal('hide');
  1812. $("#mreplace_next_div").modal('show');
  1813. });
  1814. $('#class_selected_conf').click(function () {
  1815. var gljClass = $('#selected_class').val();
  1816. var glj = gljOprObj.selectedGLJClass;
  1817. if (glj && gljClass && gljClass != "") {
  1818. //保存到我的工料机库
  1819. /*1 检查是否有组成物
  1820. * 2 如果有,则检查组成物中是否有新增的记录,如果有,查看是否已经保存了,没有的话,要先添加组成物到补充工料机库
  1821. * 3 保存
  1822. * */
  1823. var newItem = {
  1824. code: glj.code,
  1825. name: glj.name,
  1826. specs: glj.specs,
  1827. unit: glj.unit,
  1828. basePrice: glj.basePrice,
  1829. gljType: glj.type,
  1830. shortName: glj.shortName,
  1831. component: [],
  1832. gljClass: gljClass
  1833. };
  1834. if (glj.hasOwnProperty("subList") && glj.subList.length > 0) {//有组成物,检查组成物信息,目前组成物不允许修改,所以暂时不用考虑组成物是新增的情况
  1835. for (var i = 0; i < glj.subList.length; i++) {
  1836. let tem = {
  1837. ID: glj.subList[i].GLJID,
  1838. consumeAmt: glj.rationItemQuantity,
  1839. isStd: true
  1840. }
  1841. newItem.component.push(tem);
  1842. }
  1843. }
  1844. var data = getcmpUpdateData([newItem]);
  1845. $.bootstrapLoading.start();
  1846. var callback = function (data) {
  1847. $("#glj_class_div").modal('hide');
  1848. $.bootstrapLoading.end();
  1849. }
  1850. CommonAjax.post("complementartGlj/api/mixUpdateGljItems", data, callback, function () {
  1851. $.bootstrapLoading.end();
  1852. });
  1853. }
  1854. })
  1855. $('#glj_class_div').on('hidden.bs.modal', function (e) {
  1856. gljOprObj.selectedGLJClass = null;
  1857. $('#class_selected_conf').attr("disabled", "disabled");
  1858. $('#selected_class').val("");
  1859. })
  1860. $("#subSpread").focusout(function(e){//当本身或子元素失去焦点时这个事件都会发生,而且不好判断点击的是哪里。
  1861. if(gljOprObj.rationGljEditObj){
  1862. gljOprObj.cancelUpdate = false;
  1863. gljOprObj.timeStamp = e.timeStamp;//设置时间戳,有可能用户在表格上乱点,这个事件被触发多次
  1864. setTimeout(function () {//延时执行提交操作,如果点击的是spread里的地方,会把cancelUpdate改成true,这样的话就不执行提交操作
  1865. if(gljOprObj.timeStamp == e.timeStamp && gljOprObj.cancelUpdate !== true){//时间戳要相同
  1866. gljOprObj.updateGljFromCache();
  1867. }
  1868. },200)
  1869. }
  1870. });
  1871. function getcmpUpdateData(items) {
  1872. var data = {
  1873. "updateItems": [],
  1874. "removeIds": []
  1875. }
  1876. data.addItems = items;
  1877. return data;
  1878. }
  1879. })
  1880. function operationWithRound(value1,value2,field,symble) {
  1881. let decimal = getDecimal(field);
  1882. value1 = scMathUtil.roundForObj(value1,decimal);
  1883. value2 = scMathUtil.roundForObj(value2,decimal);
  1884. let result;
  1885. switch (symble){
  1886. case "+" :
  1887. result=scMathUtil.roundForObj(value1 + value2,decimal);
  1888. break;
  1889. case "-":
  1890. result=scMathUtil.roundForObj(value1 - value2,decimal);
  1891. break;
  1892. case "*":
  1893. result=scMathUtil.roundForObj(value1 * value2,decimal);
  1894. break;
  1895. case "/":
  1896. result=scMathUtil.roundForObj(value1 / value2,decimal);
  1897. break
  1898. }
  1899. return result;
  1900. }
  1901. function getDecimal(fieldID, node) {
  1902. if (node) {
  1903. return decimalObj.decimal(fieldID, node);
  1904. } else if (fieldID.indexOf(".") != -1) {
  1905. var keyArray = fieldID.split(".");
  1906. return decimalObj[keyArray[0]][keyArray[1]];
  1907. } else {
  1908. return decimalObj.decimal(fieldID);
  1909. }
  1910. }
  1911. function compareRationGLJ(a, b) {
  1912. if ((a.type + "") < (b.type + "")) {
  1913. return true
  1914. }
  1915. if ((a.type + "") == (b.type + "")) {
  1916. if (a.code < b.code) {
  1917. return true
  1918. }
  1919. }
  1920. return false;
  1921. }