glj_view.js 87 KB

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