gljComponent.js 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  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. me.onContextmenuOpr();//右键菜单
  38. me.gljComponentDelOpr();
  39. me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditStarting, me.onCellEditStart);
  40. me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditEnded, me.onCellEditEnd);
  41. me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
  42. me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
  43. },
  44. getRowData: function (sheet, row, setting) {
  45. let rst = {};
  46. for(let i = 0; i < setting.header.length; i++){
  47. rst[setting.header[i].dataCode] = sheet.getValue(row, i);
  48. }
  49. return rst;
  50. },
  51. getComponent: function (sheet, rowCount) {
  52. let component = [];
  53. for(let row = 0; row < rowCount; row++){
  54. let obj = {};
  55. obj.consumeAmt = sheet.getValue(row, 4);
  56. obj.ID = sheet.getTag(row, 0);
  57. component.push(obj);
  58. }
  59. return component;
  60. },
  61. onContextmenuOpr: function () {
  62. let me = gljComponentOprObj, that = repositoryGljObj, co = componentOprObj;
  63. $.contextMenu({
  64. selector: '#gljComponentSheet',
  65. build: function($triggerElement, e){
  66. //控制允许右键菜单在哪个位置出现
  67. let sheet = me.workBook.getSheet(0);
  68. let offset = $("#gljComponentSheet").offset(),
  69. x = e.pageX - offset.left,
  70. y = e.pageY - offset.top;
  71. let target = sheet.hitTest(x, y);
  72. if(target.hitTestType === 3 && typeof target.row !== 'undefined' && typeof target.col !== 'undefined'){//在表格内
  73. sheet.setActiveCell(target.row, target.col);
  74. //getCurrentGlj
  75. let thatRow = that.workBook.getSheet(0).getSelections()[0].row
  76. that.currentGlj = thatRow < that.currentCache.length ? that.currentCache[thatRow] : null;
  77. that.currentComponent = that.currentGlj ? that.getCurrentComponent(that.currentGlj.component) : [];
  78. //控制按钮是否可用
  79. let insertDis = false,
  80. delDis = false;
  81. if(!(that.currentGlj && allowComponent.includes(that.currentGlj.gljType))){
  82. insertDis = true;
  83. }
  84. if(!that.currentGlj || typeof that.currentComponent === 'undefined' ||
  85. (typeof that.currentComponent !== 'undefined' && target.row >= that.currentComponent.length)){//右键定位在有组成物的行,删除键才显示可用
  86. delDis = true;
  87. }
  88. return {
  89. callback: function(){},
  90. items: {
  91. "insert": {name: "插入", disabled: insertDis, icon: "fa-sign-in", callback: function (key, opt) {
  92. //默认radio所有工料机
  93. co.initRadio();
  94. co.gljCurTypeId = null;
  95. //默认点击树根节点
  96. co.initClassTree('std', gljClassTreeObj.treeData.std);
  97. //弹出窗口
  98. $('#component').modal('show');
  99. }},
  100. "delete": {name: "删除", disabled: delDis, icon: "fa-remove", callback: function (key, opt) {
  101. //删除
  102. let deleteObj = that.currentComponent[target.row];
  103. let gljComponent = that.currentGlj.component;
  104. let updateArr = [];
  105. //更新当前工料机的组成物列表
  106. for(let i = 0, len = gljComponent.length; i < len; i++){
  107. if(gljComponent[i].ID === deleteObj.ID){
  108. gljComponent.splice(i, 1);
  109. break;
  110. }
  111. }
  112. //重新计算工料机
  113. let gljBasePrc = me.reCalGljBasePrc(that.getCurrentComponent(gljComponent));
  114. if(gljBasePrc !== that.currentGlj.basePrice){
  115. that.currentGlj.basePrice = gljBasePrc;
  116. that.reshowGljBasePrc(that.currentGlj);
  117. //updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
  118. }
  119. updateArr.push(that.currentGlj);
  120. me.updateComponent(updateArr);
  121. }}
  122. }
  123. };
  124. }
  125. else{
  126. return false;
  127. }
  128. }
  129. });
  130. },
  131. gljComponentDelOpr: function () {
  132. let me = gljComponentOprObj, that = repositoryGljObj, updateArr = [], removeArr = [], isUpdate = false, updateBasePrc= [];
  133. me.workBook.commandManager().register('gljComponentDel', function () {
  134. let sels = me.workBook.getSheet(0).getSelections();
  135. if(sels.length > 0 && that.currentComponent.length > 0){
  136. let component = that.currentGlj.component;
  137. for(let i = 0; i < sels.length > 0; i++){
  138. if(sels[i].colCount === me.setting.header.length){//可删除
  139. for(let j = 0; j < sels[i].rowCount; j++){
  140. if(sels[i].row + j < that.currentComponent.length){
  141. removeArr.push(that.currentComponent[sels[i].row + j].ID);
  142. }
  143. }
  144. }
  145. else if(sels[i].col === 0){
  146. //编码不可为空
  147. alert("编码不可为空!");
  148. }
  149. else if(sels[i].col === 4){//消耗量修改为0
  150. if(sels[i].row === -1){//全修改
  151. for(let j = 0; j < that.currentComponent.length; j++){
  152. isUpdate = true;
  153. that.currentComponent[j].consumeAmt = 0;
  154. for(let k = 0; k < component.length; k++){
  155. if(component[k].ID === that.currentComponent[j].ID){
  156. component[k].consumeAmt = 0;
  157. break;
  158. }
  159. }
  160. }
  161. }
  162. else{//部分修改
  163. for(let j = 0; j < sels[i].rowCount; j++){
  164. if(sels[i].row + j < that.currentComponent.length){
  165. isUpdate = true;
  166. that.currentComponent[sels[i].row + j].consumeAmt = 0;
  167. for(let k = 0; k < component.length; k++){
  168. if(component[k].ID === that.currentComponent[sels[i].row + j].ID){
  169. component[k].consumeAmt = 0;
  170. break;
  171. }
  172. }
  173. }
  174. }
  175. }
  176. }
  177. }
  178. if(removeArr.length > 0 || isUpdate){
  179. for(let i = 0; i < removeArr.length; i++){
  180. for(let j = 0; j < that.currentComponent.length; j++){
  181. if(that.currentComponent[j].ID === removeArr[i]){
  182. that.currentComponent.splice(j--, 1);
  183. }
  184. }
  185. for(let j = 0; j < component.length; j++){
  186. if(component[j].ID === removeArr[i]){
  187. component.splice(j--, 1);
  188. }
  189. }
  190. }
  191. //重新计算工料机
  192. let gljBasePrc = me.reCalGljBasePrc(that.currentComponent);
  193. if(gljBasePrc !== that.currentGlj.basePrice){
  194. that.currentGlj.basePrice = gljBasePrc;
  195. that.reshowGljBasePrc(that.currentGlj);
  196. updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
  197. }
  198. updateArr.push(that.currentGlj);
  199. me.updateComponent(updateArr);
  200. if(updateBasePrc.length > 0){
  201. that.updateRationBasePrcRq(updateBasePrc);
  202. }
  203. }
  204. }
  205. });
  206. me.workBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.del, false, false, false, false);
  207. //me.workBook.commandManager().setShortcutKey('gljComponentDel', GC.Spread.Commands.Key.del, false, false, false, false);
  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 || !allowComponent.includes(that.currentGlj.gljType) ||
  217. (that.currentGlj.gljType === 4 && that.isComponent(that.currentGlj.ID, that.stdGljList.concat(that.complementaryGljList))) ||
  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. //编码
  231. /* if(args.col === 0 && args.editingText && args.editingText.trim().length > 0 &&args.editingText !== me.currentEditingComponent.code){
  232. let component = that.currentGlj.component, hasCode = false;
  233. for(let i = 0; i < gljList.length; i++){
  234. if(gljList[i].code === args.editingText){//有效的组成物
  235. hasCode = true;
  236. if((materialComponent.indexOf(that.currentGlj.gljType) !== -1 && gljList[i].gljType === 201)
  237. || (that.currentGlj.gljType === 301 && machineComponent.indexOf(gljList[i].gljType) !== -1 )){//普通材料
  238. //是否与原有组成物不同
  239. let isExist = false;
  240. for(let j = 0; j < component.length; j++){
  241. if(component[j].ID === gljList[i].ID){
  242. isExist = true;
  243. break;
  244. }
  245. }
  246. if(!isExist){
  247. let rObj = {};
  248. rObj.ID = gljList[i].ID;
  249. //rObj.basePrice = gljList[i].basePrice;
  250. if(typeof that.currentComponent[args.row] !== 'undefined'){
  251. rObj.consumeAmt = that.currentComponent[args.row].consumeAmt;
  252. let index;
  253. for(let j = 0; j < component.length; j++){
  254. if(component[j].ID === that.currentComponent[args.row].ID){
  255. index = j;
  256. break;
  257. }
  258. }
  259. component.splice(index, 1);
  260. component.splice(index, 0, rObj);
  261. //计算工料机单价
  262. let gljBasePrc = me.reCalGljBasePrc(that.getCurrentComponent(component));
  263. if(gljBasePrc !== that.currentGlj.basePrice){
  264. that.currentGlj.basePrice = gljBasePrc;
  265. that.reshowGljBasePrc(that.currentGlj);
  266. //工料机单价改变,重算引用了该工料机的定额单价
  267. updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
  268. }
  269. updateArr.push(that.currentGlj);
  270. }
  271. else{
  272. rObj.consumeAmt = 0;
  273. component.push(rObj);
  274. //计算工料机单价
  275. let gljBasePrc = me.reCalGljBasePrc(that.getCurrentComponent(component));
  276. if(gljBasePrc !== that.currentGlj.basePrice){
  277. that.currentGlj.basePrice = gljBasePrc;
  278. that.reshowGljBasePrc(that.currentGlj);
  279. //工料机单价改变,重算引用了该工料机的定额单价
  280. updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
  281. }
  282. updateArr.push(that.currentGlj);
  283. }
  284. break;
  285. }
  286. else{
  287. //已存在
  288. alert("已存在!");
  289. args.sheet.setValue(args.row, args.col, me.currentEditingComponent[me.setting.header[args.col].dataCode] ?
  290. me.currentEditingComponent[me.setting.header[args.col].dataCode]: '');
  291. }
  292. }
  293. else{
  294. if(materialComponent.indexOf(that.currentGlj.gljType) === 1){
  295. alert("该组成物只能是普通材料!");
  296. }
  297. else if(that.currentGlj.gljType === 301){
  298. alert("该组成物只能是机械组成物或机上人工!")
  299. }
  300. args.sheet.setValue(args.row, args.col, me.currentEditingComponent[me.setting.header[args.col].dataCode] ?
  301. me.currentEditingComponent[me.setting.header[args.col].dataCode]: '');
  302. //无效
  303. }
  304. }
  305. }
  306. if(!hasCode){
  307. alert("不存在此工料机,请先添加!");
  308. args.sheet.setValue(args.row, args.col, me.currentEditingComponent[me.setting.header[args.col].dataCode] ?
  309. me.currentEditingComponent[me.setting.header[args.col].dataCode] : '');
  310. //不存在
  311. }
  312. }*/
  313. if(args.col === 4 && me.currentEditingComponent.code && args.editingText && args.editingText.trim().length > 0){//消耗量
  314. let consumeAmt = parseFloat(args.editingText);
  315. if(!isNaN(consumeAmt) && consumeAmt !== me.currentEditingComponent.consumeAmt){
  316. let roundCons = scMathUtil.roundTo(parseFloat(consumeAmt), -3);
  317. let component = that.currentGlj.component;
  318. for(let i = 0; i < component.length; i++){
  319. if(component[i].ID === that.currentComponent[args.row].ID){
  320. component[i].consumeAmt = roundCons;
  321. }
  322. }
  323. that.currentComponent[args.row].consumeAmt = roundCons;
  324. //计算工料机单价
  325. let gljBasePrc = me.reCalGljBasePrc(that.currentComponent);
  326. if(gljBasePrc !== that.currentGlj.basePrice){
  327. that.currentGlj.basePrice = gljBasePrc;
  328. that.reshowGljBasePrc(that.currentGlj);
  329. //工料机单价改变,重算引用了该工料机的定额单价
  330. //updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
  331. }
  332. updateArr.push(that.currentGlj);
  333. }
  334. else{
  335. //只能输入数值
  336. args.sheet.setValue(args.row, args.col, me.currentEditingComponent[me.setting.header[args.col].dataCode] ?
  337. me.currentEditingComponent[me.setting.header[args.col].dataCode]: 0);
  338. }
  339. }
  340. else{
  341. args.sheet.setValue(args.row, args.col, me.currentEditingComponent.consumeAmt);
  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, that = repositoryGljObj;
  352. let maxCol = info.cellRange.col + info.cellRange.colCount - 1;
  353. //复制的列数超过正确的列数,不可复制
  354. if(info.cellRange.col !== 4 && info.cellRange.colCount > 1 || (that.currentGlj.gljType === 4 && that.isComponent(that.currentGlj.ID, that.stdGljList.concat(that.complementaryGljList)))){
  355. args.cancel = true;
  356. }
  357. },
  358. onClipboardPasted: function (sender, info) {
  359. let me = gljComponentOprObj, that = repositoryGljObj, updateArr = [] ,materialComponent = [202, 203, 204], machineComponent = [302, 303],
  360. component = that.currentGlj.component, newComponent = [], concatComponent = [], isChange = false, updateBasePrc = [];
  361. let items = sheetOpr.analyzePasteData(me.setting, info);
  362. let gljCache = that.gljList;
  363. //编码
  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. //消耗量
  426. if(info.cellRange.col === 4){
  427. let items = sheetOpr.analyzePasteData(me.setting, info);
  428. let row = info.cellRange.row;
  429. for(let i = 0; i < items.length; i++){
  430. if(row + i < that.currentComponent.length){
  431. let currentObj = that.currentComponent[row + i];
  432. if(items[i].consumeAmt.trim().length > 0 && items[i].consumeAmt !== currentObj.consumeAmt){
  433. let roundCons = scMathUtil.roundTo(parseFloat(items[i].consumeAmt), -3);
  434. isChange = true;
  435. currentObj.consumeAmt = roundCons;
  436. for(let j = 0; j < component.length; j++){
  437. if(component[j].ID === currentObj.ID){
  438. component[j].consumeAmt = currentObj.consumeAmt;
  439. break;
  440. }
  441. }
  442. }
  443. else{
  444. me.workBook.getSheet(0).setValue(row + i, info.cellRange.col, currentObj.consumeAmt);
  445. }
  446. }
  447. else{
  448. me.workBook.getSheet(0).setValue(row + i, info.cellRange.col, '');
  449. }
  450. }
  451. if(isChange){
  452. //计算工料机单价
  453. let gljBasePrc = me.reCalGljBasePrc(that.currentComponent);
  454. if(gljBasePrc !== that.currentGlj.basePrice){
  455. that.currentGlj.basePrice = gljBasePrc;
  456. that.reshowGljBasePrc(that.currentGlj);
  457. //updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
  458. }
  459. updateArr.push(that.currentGlj);
  460. }
  461. }
  462. if(updateArr.length > 0){
  463. me.updateComponent(updateArr);
  464. /* if(updateBasePrc.length > 0){
  465. that.updateRationBasePrcRq(updateBasePrc);
  466. }*/
  467. }
  468. },
  469. updateComponent: function (updateArr) {
  470. let me = gljComponentOprObj, that = repositoryGljObj;
  471. that.saveInString(updateArr);
  472. $.ajax({
  473. type: 'post',
  474. url: 'complementartGlj/api/updateComponent',
  475. data: {"userId": pageOprObj.userId, "updateArr": JSON.stringify(updateArr)},
  476. dataType: 'json',
  477. success: function (result) {
  478. if(!result.error){
  479. that.currentComponent = that.getCurrentComponent(result.data[0].component);
  480. sheetOpr.cleanData(me.workBook.getSheet(0), me.setting, -1);
  481. sheetOpr.showData(me.workBook.getSheet(0), me.setting, that.currentComponent);
  482. }
  483. else{
  484. sheetOpr.cleanData(me.workBook.getSheet(0), me.setting, -1);
  485. }
  486. $('#componentsCacnel').click();
  487. }
  488. })
  489. },
  490. round: function (v, e) {
  491. let t=1;
  492. for(;e>0;t*=10,e--);
  493. for(;e<0;t/=10,e++);
  494. return Math.round(v*t)/t;
  495. },
  496. reCalGljBasePrc: function (component) {
  497. let me = gljComponentOprObj, gljBasePrc = 0;
  498. for(let i = 0; i < component.length; i++){
  499. let roundBasePrc = scMathUtil.roundTo(parseFloat(component[i].basePrice), -2);
  500. let roundConsumeAmt = scMathUtil.roundTo(parseFloat(component[i].consumeAmt), -3);
  501. gljBasePrc = scMathUtil.roundTo(scMathUtil.roundTo(roundBasePrc * roundConsumeAmt, me.processDecimal) + gljBasePrc, me.processDecimal);
  502. }
  503. return gljBasePrc;
  504. }
  505. };