gljComponent.js 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  1. /**
  2. * Created by Zhong on 2017/8/15.
  3. */
  4. let gljComponentOprObj = {
  5. workBook: null,
  6. setting: {
  7. owner: "gljComponent",
  8. /* header:[
  9. {headerName:"编码",headerWidth:50,dataCode:"code", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
  10. {headerName:"名称",headerWidth:60,dataCode:"name", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
  11. {headerName:"单位",headerWidth:60,dataCode:"unit", dataType: "String", hAlign: "center", vAlign: "center"},
  12. {headerName:"单价",headerWidth:50,dataCode:"basePrice", dataType: "Number", formatter: "0.00", hAlign: "right", vAlign: "center"},
  13. {headerName:"消耗量",headerWidth:55,dataCode:"consumeAmt", dataType: "Number", formatter: "0.000", hAlign: "right", vAlign: "center"}
  14. ],*/
  15. header:[
  16. {headerName:"编码",headerWidth:80,dataCode:"code", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
  17. {headerName:"名称",headerWidth:90,dataCode:"name", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
  18. {headerName:"单位",headerWidth:45,dataCode:"unit", dataType: "String", hAlign: "center", vAlign: "center"},
  19. {headerName:"单价",headerWidth:60,dataCode:"basePrice", dataType: "Number", formatter: "0.00", hAlign: "right", vAlign: "center"},
  20. {headerName:"消耗量",headerWidth:70,dataCode:"consumeAmt", dataType: "Number", formatter: "0.000", hAlign: "right", vAlign: "center"}
  21. ],
  22. view: {
  23. lockedCols:[1, 2, 3]
  24. }
  25. },
  26. buildSheet: function(container) {
  27. let me = gljComponentOprObj;
  28. me.workBook = sheetCommonObj.buildSheet(container, me.setting, 30, me);
  29. me.workBook.getSheet(0).setColumnWidth(0, 20, GC.Spread.Sheets.SheetArea.rowHeader);
  30. me.workBook.getSheet(0).setFormatter(-1, 0, "@", GC.Spread.Sheets.SheetArea.viewport);
  31. sheetCommonObj.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
  32. me.gljComponentDelOpr();
  33. me.onContextmenuOpr();
  34. me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
  35. me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
  36. me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditStarting, me.onCellEditStart);
  37. me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditEnded, me.onCellEditEnd);
  38. },
  39. getRowData: function (sheet, row, setting) {
  40. let rst = {};
  41. for(let i = 0; i < setting.header.length; i++){
  42. rst[setting.header[i].dataCode] = sheet.getValue(row, i);
  43. }
  44. return rst;
  45. },
  46. getComponent: function (sheet, rowCount) {
  47. let component = [];
  48. for(let row = 0; row < rowCount; row++){
  49. let obj = {};
  50. obj.consumeAmt = sheet.getValue(row, 4);
  51. obj.ID = sheet.getTag(row, 0);
  52. component.push(obj);
  53. }
  54. return component;
  55. },
  56. gljComponentDelOpr: function () {
  57. let me = gljComponentOprObj, that = repositoryGljObj, updateArr = [], removeArr = [], isUpdate = false, updateBasePrc= [];
  58. me.workBook.commandManager().register('gljComponentDel', function () {
  59. let sels = me.workBook.getSheet(0).getSelections();
  60. if(sels.length > 0 && that.currentComponent.length > 0){
  61. let component = that.currentGlj.component;
  62. for(let i = 0; i < sels.length > 0; i++){
  63. if(sels[i].colCount === me.setting.header.length){//可删除
  64. for(let j = 0; j < sels[i].rowCount; j++){
  65. if(sels[i].row + j < that.currentComponent.length){
  66. removeArr.push(that.currentComponent[sels[i].row + j].ID);
  67. }
  68. }
  69. }
  70. else if(sels[i].col === 0){
  71. //编码不可为空
  72. alert("编码不可为空!");
  73. }
  74. else if(sels[i].col === 4){//消耗量修改为0
  75. if(sels[i].row === -1){//全修改
  76. for(let j = 0; j < that.currentComponent.length; j++){
  77. isUpdate = true;
  78. that.currentComponent[j].consumeAmt = 0;
  79. for(let k = 0; k < component.length; k++){
  80. if(component[k].ID === that.currentComponent[j].ID){
  81. component[k].consumeAmt = 0;
  82. break;
  83. }
  84. }
  85. }
  86. }
  87. else{//部分修改
  88. for(let j = 0; j < sels[i].rowCount; j++){
  89. if(sels[i].row + j < that.currentComponent.length){
  90. isUpdate = true;
  91. that.currentComponent[sels[i].row + j].consumeAmt = 0;
  92. for(let k = 0; k < component.length; k++){
  93. if(component[k].ID === that.currentComponent[sels[i].row + j].ID){
  94. component[k].consumeAmt = 0;
  95. break;
  96. }
  97. }
  98. }
  99. }
  100. }
  101. }
  102. }
  103. if(removeArr.length > 0 || isUpdate){
  104. for(let i = 0; i < removeArr.length; i++){
  105. for(let j = 0; j < that.currentComponent.length; j++){
  106. if(that.currentComponent[j].ID === removeArr[i]){
  107. that.currentComponent.splice(j--, 1);
  108. }
  109. }
  110. for(let j = 0; j < component.length; j++){
  111. if(component[j].ID === removeArr[i]){
  112. component.splice(j--, 1);
  113. }
  114. }
  115. }
  116. //重新计算工料机
  117. let gljBasePrc = me.reCalGljBasePrc(that.currentComponent);
  118. if(gljBasePrc !== that.currentGlj.basePrice){
  119. that.currentGlj.basePrice = gljBasePrc;
  120. that.reshowGljBasePrc(that.currentGlj);
  121. updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
  122. }
  123. updateArr.push(that.currentGlj);
  124. me.updateComponent(updateArr);
  125. if(updateBasePrc.length > 0){
  126. that.updateRationBasePrcRq(updateBasePrc);
  127. }
  128. }
  129. }
  130. });
  131. me.workBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.del, false, false, false, false);
  132. me.workBook.commandManager().setShortcutKey('gljComponentDel', GC.Spread.Commands.Key.del, false, false, false, false);
  133. },
  134. onContextmenuOpr: function () {
  135. let me = gljComponentOprObj, that = repositoryGljObj, co = componentOprObj;
  136. $.contextMenu({
  137. selector: '#gljComponentSheet',
  138. build: function($triggerElement, e){
  139. //控制允许右键菜单在哪个位置出现
  140. let sheet = me.workBook.getSheet(0);
  141. let offset = $("#gljComponentSheet").offset(),
  142. x = e.pageX - offset.left,
  143. y = e.pageY - offset.top;
  144. let target = sheet.hitTest(x, y);
  145. if(target.hitTestType === 3 && typeof target.row !== 'undefined' && typeof target.col !== 'undefined'){//在表格内
  146. sheet.setActiveCell(target.row, target.col);
  147. //getCurrentGlj
  148. let thatRow = that.workBook.getSheet(0).getSelections()[0].row;
  149. that.currentGlj = thatRow < that.currentCache.length ? that.currentCache[thatRow] : null;
  150. that.currentComponent = that.currentGlj ? that.getCurrentComponent(that.currentGlj.component) : [];
  151. //控制按钮是否可用
  152. let insertDis = false,
  153. delDis = false;
  154. if(!(that.currentGlj && that.allowComponent.indexOf(that.currentGlj.gljType) !== -1) || (that.currentGlj.gljType === 4 && that.isComponent(that.currentGlj.ID, that.gljList))){
  155. insertDis = true;
  156. }
  157. if(!that.currentGlj || typeof that.currentComponent === 'undefined' || (typeof that.currentComponent !== 'undefined' && target.row >= that.currentComponent.length)){//右键定位在有组成物的行,删除键才显示可用
  158. delDis = true;
  159. }
  160. return {
  161. callback: function(){},
  162. items: {
  163. "insert": {name: "插入", disabled: insertDis, icon: "fa-sign-in", callback: function (key, opt) {
  164. //默认radio所有工料机
  165. co.initRadio();
  166. co.gljCurTypeId = null;
  167. //默认点击树根节点
  168. if(co.rootNode){
  169. co.treeObj.selectNode(co.rootNode);
  170. componentTypeTreeOprObj.onClick(null, 'componentTree', co.rootNode);
  171. }
  172. //弹出窗口
  173. $('#componentBtn').click();
  174. }},
  175. "delete": {name: "删除", disabled: delDis, icon: "fa-remove", callback: function (key, opt) {
  176. //删除
  177. let deleteObj = that.currentComponent[target.row];
  178. let gljComponent = that.currentGlj.component;
  179. let updateArr = [], updateBasePrcArr = [];
  180. //更新当前工料机的组成物列表
  181. for(let i = 0, len = gljComponent.length; i < len; i++){
  182. if(gljComponent[i].ID === deleteObj.ID){
  183. gljComponent.splice(i, 1);
  184. break;
  185. }
  186. }
  187. //重新计算工料机
  188. let gljBasePrc = me.reCalGljBasePrc(that.getCurrentComponent(gljComponent));
  189. if(gljBasePrc !== that.currentGlj.basePrice){
  190. that.currentGlj.basePrice = gljBasePrc;
  191. that.reshowGljBasePrc(that.currentGlj);
  192. updateBasePrcArr.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
  193. }
  194. updateArr.push(that.currentGlj);
  195. me.updateComponent(updateArr);
  196. if(updateBasePrcArr.length > 0 && that.rationLibs.length > 0){
  197. that.updateRationBasePrcRq(updateBasePrcArr);
  198. }
  199. }}
  200. }
  201. };
  202. }
  203. else{
  204. return false;
  205. }
  206. }
  207. });
  208. },
  209. onCellEditStart: function(sender, args) {
  210. let me = gljComponentOprObj, that = repositoryGljObj;
  211. let rObj = me.getRowData(args.sheet, args.row, me.setting);
  212. me.currentEditingComponent = rObj;
  213. let thatRow = that.workBook.getSheet(0).getSelections()[0].row;
  214. if(thatRow < that.currentCache.length){
  215. that.currentGlj = that.currentCache[thatRow];
  216. if(me.setting.view.lockedCols.indexOf(args.col) !== -1 || that.allowComponent.indexOf(that.currentGlj.gljType) === -1 ||
  217. (that.currentGlj.gljType === 4 && that.isComponent(that.currentGlj.ID, that.gljList)) ||
  218. (args.col === 4 && (!that.currentComponent|| args.row >= that.currentComponent.length))){
  219. args.cancel = true;
  220. }
  221. }
  222. else {
  223. args.cancel = true;
  224. }
  225. },
  226. onCellEditEnd: function (sender, args) {
  227. let me = gljComponentOprObj, that = repositoryGljObj, updateBasePrc = [];
  228. let gljList = that.gljList, updateArr = [], materialComponent = [202, 203, 204], machineComponent = [302, 303];
  229. //if(args.editingText !== me.currentEditingComponent.code){
  230. if(args.col === 0 && args.editingText && args.editingText.trim().length > 0 && args.editingText !== me.currentEditingComponent.code){
  231. let component = that.currentGlj.component, hasCode = false;
  232. for(let i = 0; i < gljList.length; i++){
  233. if(gljList[i].code === args.editingText){//有效的组成物
  234. hasCode = true;
  235. if((materialComponent.indexOf(that.currentGlj.gljType) !== -1 && gljList[i].gljType === 201)
  236. || (that.currentGlj.gljType === 301 && machineComponent.indexOf(gljList[i].gljType) !== -1 )){//普通材料
  237. //是否与原有组成物不同
  238. let isExist = false;
  239. for(let j = 0; j < component.length; j++){
  240. if(component[j].ID === gljList[i].ID){
  241. isExist = true;
  242. break;
  243. }
  244. }
  245. if(!isExist){
  246. let rObj = {};
  247. rObj.ID = gljList[i].ID;
  248. //rObj.basePrice = gljList[i].basePrice;
  249. if(typeof that.currentComponent[args.row] !== 'undefined'){
  250. rObj.consumeAmt = that.currentComponent[args.row].consumeAmt;
  251. let index;
  252. for(let j = 0; j < component.length; j++){
  253. if(component[j].ID === that.currentComponent[args.row].ID){
  254. index = j;
  255. break;
  256. }
  257. }
  258. component.splice(index, 1);
  259. component.splice(index, 0, rObj);
  260. //计算工料机单价
  261. let gljBasePrc = me.reCalGljBasePrc(that.getCurrentComponent(component));
  262. if(gljBasePrc !== that.currentGlj.basePrice){
  263. that.currentGlj.basePrice = gljBasePrc;
  264. that.reshowGljBasePrc(that.currentGlj);
  265. //工料机单价改变,重算引用了该工料机的定额单价
  266. updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
  267. }
  268. updateArr.push(that.currentGlj);
  269. }
  270. else{
  271. rObj.consumeAmt = 0;
  272. component.push(rObj);
  273. //计算工料机单价
  274. let gljBasePrc = me.reCalGljBasePrc(that.getCurrentComponent(component));
  275. if(gljBasePrc !== that.currentGlj.basePrice){
  276. that.currentGlj.basePrice = gljBasePrc;
  277. that.reshowGljBasePrc(that.currentGlj);
  278. //工料机单价改变,重算引用了该工料机的定额单价
  279. updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
  280. }
  281. updateArr.push(that.currentGlj);
  282. }
  283. break;
  284. }
  285. else{
  286. //已存在
  287. alert("已存在!");
  288. args.sheet.setValue(args.row, args.col, me.currentEditingComponent[me.setting.header[args.col].dataCode] ?
  289. me.currentEditingComponent[me.setting.header[args.col].dataCode]: '');
  290. }
  291. }
  292. else{
  293. if(materialComponent.indexOf(that.currentGlj.gljType) === 1){
  294. alert("该组成物只能是普通材料!");
  295. }
  296. else if(that.currentGlj.gljType === 301){
  297. alert("该组成物只能是机械组成物或机上人工!")
  298. }
  299. args.sheet.setValue(args.row, args.col, me.currentEditingComponent[me.setting.header[args.col].dataCode] ?
  300. me.currentEditingComponent[me.setting.header[args.col].dataCode]: '');
  301. //无效
  302. }
  303. }
  304. }
  305. if(!hasCode){
  306. alert("不存在此工料机,请先添加!");
  307. args.sheet.setValue(args.row, args.col, me.currentEditingComponent[me.setting.header[args.col].dataCode] ?
  308. me.currentEditingComponent[me.setting.header[args.col].dataCode] : '');
  309. //不存在
  310. }
  311. }
  312. else if(args.col === 4 && me.currentEditingComponent.code && args.editingText && args.editingText.trim().length > 0){//消耗量
  313. let consumeAmt = parseFloat(args.editingText);
  314. if(!isNaN(consumeAmt) && consumeAmt !== me.currentEditingComponent.consumeAmt){
  315. let roundCons = scMathUtil.roundTo(parseFloat(consumeAmt), -3);
  316. let component = that.currentGlj.component;
  317. for(let i = 0; i < component.length; i++){
  318. if(component[i].ID === that.currentComponent[args.row].ID){
  319. component[i].consumeAmt = roundCons;
  320. }
  321. }
  322. that.currentComponent[args.row].consumeAmt = roundCons;
  323. //计算工料机单价
  324. let gljBasePrc = me.reCalGljBasePrc(that.currentComponent);
  325. if(gljBasePrc !== that.currentGlj.basePrice){
  326. that.currentGlj.basePrice = gljBasePrc;
  327. that.reshowGljBasePrc(that.currentGlj);
  328. //工料机单价改变,重算引用了该工料机的定额单价
  329. updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
  330. }
  331. updateArr.push(that.currentGlj);
  332. }
  333. else{
  334. //只能输入数值
  335. args.sheet.setValue(args.row, args.col, me.currentEditingComponent[me.setting.header[args.col].dataCode] ?
  336. me.currentEditingComponent[me.setting.header[args.col].dataCode]: 0);
  337. }
  338. }
  339. else{
  340. args.sheet.setValue(args.row, args.col, me.currentEditingComponent[me.setting.header[args.col].dataCode] ?
  341. me.currentEditingComponent[me.setting.header[args.col].dataCode]: '');
  342. }
  343. if(updateArr.length > 0){
  344. me.updateComponent(updateArr);
  345. if(updateBasePrc.length > 0){
  346. that.updateRationBasePrcRq(updateBasePrc)
  347. }
  348. }
  349. },
  350. onClipboardPasting: function (sender, info) {
  351. let me = gljComponentOprObj;
  352. let that = repositoryGljObj;
  353. let maxCol = info.cellRange.col + info.cellRange.colCount - 1;
  354. //复制的列数超过正确的列数,不可复制
  355. if(info.cellRange.col !== 0 && info.cellRange.col !== 4 || info.cellRange.colCount > 1 || (that.currentGlj.gljType === 4 && that.isComponent(that.currentGlj.ID, that.gljList))){
  356. args.cancel = true;
  357. }
  358. },
  359. onClipboardPasted: function (sender, info) {
  360. let me = gljComponentOprObj, that = repositoryGljObj, updateArr = [] ,materialComponent = [202, 203, 204], machineComponent = [302, 303],
  361. component = that.currentGlj.component, newComponent = [], concatComponent = [], isChange = false, updateBasePrc = [];
  362. let items = sheetCommonObj.analyzePasteData(me.setting, info);
  363. let gljCache = that.gljList;
  364. if(info.cellRange.col === 0){
  365. for(let i = 0; i < items.length; i++){
  366. for(let j = 0; j < gljCache.length; j++){
  367. if(items[i].code === gljCache[j].code){
  368. if((materialComponent.indexOf(that.currentGlj.gljType) !== -1 && gljCache[j].gljType === 201)
  369. || (that.currentGlj.gljType === 301 && machineComponent.indexOf(gljCache[j].gljType) !== -1 )){
  370. //是否与原有组成物不同
  371. let isExist = false;
  372. for(let k = 0; k < component.length; k++){
  373. if(component[k].ID === gljCache[j].ID){
  374. isExist = true;
  375. me.workBook.getSheet(0).setValue(info.cellRange.row + i, info.cellRange.col,
  376. typeof that.currentComponent[info.cellRange.row + i] !== 'undefined'? that.currentComponent[info.cellRange.row + i].code : '');
  377. break;
  378. }
  379. }
  380. if(!isExist){
  381. isChange = true;
  382. let obj = {};
  383. obj.ID = gljCache[j].ID;
  384. if(typeof that.currentComponent[info.cellRange.row + i] !== 'undefined'){//更新
  385. obj.consumeAmt = that.currentComponent[info.cellRange.row + i].consumeAmt;
  386. let index;
  387. for(let k = 0; k < component.length; k++){
  388. if(that.currentComponent[info.cellRange.row + i].ID === component[k].ID){
  389. index = k;
  390. break;
  391. }
  392. }
  393. component.splice(index, 1);
  394. component.splice(index, 0, obj);
  395. }
  396. else{//新增
  397. obj.consumeAmt = 0;
  398. component.push(obj);
  399. }
  400. break;
  401. }
  402. }
  403. else{
  404. me.workBook.getSheet(0).setValue(info.cellRange.row + i, info.cellRange.col,
  405. typeof that.currentComponent[info.cellRange.row + i] !== 'undefined'? that.currentComponent[info.cellRange.row + i].code : '');
  406. }
  407. }
  408. else{
  409. me.workBook.getSheet(0).setValue(info.cellRange.row + i, info.cellRange.col,
  410. typeof that.currentComponent[info.cellRange.row + i] !== 'undefined'? that.currentComponent[info.cellRange.row + i].code : '');
  411. }
  412. }
  413. }
  414. if(isChange){
  415. //计算工料机单价
  416. let gljBasePrc = me.reCalGljBasePrc(that.getCurrentComponent(component));
  417. if(gljBasePrc !== that.currentGlj.basePrice){
  418. that.currentGlj.basePrice = gljBasePrc;
  419. that.reshowGljBasePrc(that.currentGlj);
  420. updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
  421. }
  422. updateArr.push(that.currentGlj);
  423. }
  424. }
  425. else if(info.cellRange.col === 4){
  426. let items = sheetCommonObj.analyzePasteData(me.setting, info);
  427. let row = info.cellRange.row;
  428. for(let i = 0; i < items.length; i++){
  429. if(row + i < that.currentComponent.length){
  430. let currentObj = that.currentComponent[row + i];
  431. if(items[i].consumeAmt.trim().length > 0 && items[i].consumeAmt !== currentObj.consumeAmt){
  432. let roundCons = scMathUtil.roundTo(parseFloat(items[i].consumeAmt), -3);
  433. isChange = true;
  434. currentObj.consumeAmt = roundCons;
  435. for(let j = 0; j < component.length; j++){
  436. if(component[j].ID === currentObj.ID){
  437. component[j].consumeAmt = currentObj.consumeAmt;
  438. break;
  439. }
  440. }
  441. }
  442. else{
  443. me.workBook.getSheet(0).setValue(row + i, info.cellRange.col, currentObj.consumeAmt);
  444. }
  445. }
  446. else{
  447. me.workBook.getSheet(0).setValue(row + i, info.cellRange.col, '');
  448. }
  449. }
  450. if(isChange){
  451. //计算工料机单价
  452. let gljBasePrc = me.reCalGljBasePrc(that.currentComponent);
  453. if(gljBasePrc !== that.currentGlj.basePrice){
  454. that.currentGlj.basePrice = gljBasePrc;
  455. that.reshowGljBasePrc(that.currentGlj);
  456. updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
  457. }
  458. updateArr.push(that.currentGlj);
  459. }
  460. }
  461. if(updateArr.length > 0){
  462. me.updateComponent(updateArr);
  463. if(updateBasePrc.length > 0){
  464. that.updateRationBasePrcRq(updateBasePrc);
  465. }
  466. }
  467. },
  468. updateComponent: function (updateArr) {
  469. let me = gljComponentOprObj, that = repositoryGljObj;
  470. repositoryGljObj.saveInString(updateArr);
  471. $.ajax({
  472. type: 'post',
  473. url: 'api/updateComponent',
  474. data: {libId: pageOprObj.gljLibId, updateArr: updateArr, oprtor: userAccount},
  475. dataType: 'json',
  476. success: function (result) {
  477. if(result.data.length > 0){
  478. if(result.data[0]){
  479. that.currentComponent = that.getCurrentComponent(result.data[0].component);
  480. me.workBook.getSheet(0).getSelections()[0]
  481. sheetCommonObj.cleanData(me.workBook.getSheet(0), me.setting, -1);
  482. sheetsOprObj.showData(me.workBook.getSheet(0), me.setting, that.currentComponent);
  483. }
  484. }
  485. }
  486. })
  487. },
  488. reCalGljBasePrc: function (component) {
  489. let me = gljComponentOprObj, gljBasePrc = 0;
  490. for(let i = 0; i < component.length; i++){
  491. let roundBasePrc = scMathUtil.roundTo(parseFloat(component[i].basePrice), -2);
  492. gljBasePrc += scMathUtil.roundTo(roundBasePrc * parseFloat(component[i].consumeAmt), -2);
  493. }
  494. return gljBasePrc;
  495. }
  496. };