gljComponent.js 28 KB

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