glj_view.js 86 KB

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