gljComponent.js 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  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)) || (that.currentGlj.gljType === 4 && that.isComponent(that.currentGlj.ID, that.stdGljList.concat(that.complementaryGljList)))){
  82. insertDis = true;
  83. }
  84. if(!that.currentGlj || typeof that.currentComponent === 'undefined' || (typeof that.currentComponent !== 'undefined' && target.row >= that.currentComponent.length)){//右键定位在有组成物的行,删除键才显示可用
  85. delDis = true;
  86. }
  87. return {
  88. callback: function(){},
  89. items: {
  90. "insert": {name: "插入", disabled: insertDis, icon: "fa-sign-in", callback: function (key, opt) {
  91. //默认radio所有工料机
  92. co.initRadio();
  93. co.gljCurTypeId = null;
  94. //默认点击树根节点
  95. co.initClassTree('std', gljClassTreeObj.treeData.std);
  96. //弹出窗口
  97. $('#component').modal('show');
  98. }},
  99. "delete": {name: "删除", disabled: delDis, icon: "fa-remove", callback: function (key, opt) {
  100. //删除
  101. let deleteObj = that.currentComponent[target.row];
  102. let gljComponent = that.currentGlj.component;
  103. let updateArr = [];
  104. //更新当前工料机的组成物列表
  105. for(let i = 0, len = gljComponent.length; i < len; i++){
  106. if(gljComponent[i].ID === deleteObj.ID){
  107. gljComponent.splice(i, 1);
  108. break;
  109. }
  110. }
  111. //重新计算工料机
  112. let gljBasePrc = me.reCalGljBasePrc(that.getCurrentComponent(gljComponent));
  113. if(gljBasePrc !== that.currentGlj.basePrice){
  114. that.currentGlj.basePrice = gljBasePrc;
  115. that.reshowGljBasePrc(that.currentGlj);
  116. //updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
  117. }
  118. updateArr.push(that.currentGlj);
  119. me.updateComponent(updateArr);
  120. }}
  121. }
  122. };
  123. }
  124. else{
  125. return false;
  126. }
  127. }
  128. });
  129. },
  130. gljComponentDelOpr: function () {
  131. let me = gljComponentOprObj, that = repositoryGljObj, updateArr = [], removeArr = [], isUpdate = false, updateBasePrc= [];
  132. me.workBook.commandManager().register('gljComponentDel', function () {
  133. let sels = me.workBook.getSheet(0).getSelections();
  134. if(sels.length > 0 && that.currentComponent.length > 0){
  135. let component = that.currentGlj.component;
  136. for(let i = 0; i < sels.length > 0; i++){
  137. if(sels[i].colCount === me.setting.header.length){//可删除
  138. for(let j = 0; j < sels[i].rowCount; j++){
  139. if(sels[i].row + j < that.currentComponent.length){
  140. removeArr.push(that.currentComponent[sels[i].row + j].ID);
  141. }
  142. }
  143. }
  144. else if(sels[i].col === 0){
  145. //编码不可为空
  146. alert("编码不可为空!");
  147. }
  148. else if(sels[i].col === 4){//消耗量修改为0
  149. if(sels[i].row === -1){//全修改
  150. for(let j = 0; j < that.currentComponent.length; j++){
  151. isUpdate = true;
  152. that.currentComponent[j].consumeAmt = 0;
  153. for(let k = 0; k < component.length; k++){
  154. if(component[k].ID === that.currentComponent[j].ID){
  155. component[k].consumeAmt = 0;
  156. break;
  157. }
  158. }
  159. }
  160. }
  161. else{//部分修改
  162. for(let j = 0; j < sels[i].rowCount; j++){
  163. if(sels[i].row + j < that.currentComponent.length){
  164. isUpdate = true;
  165. that.currentComponent[sels[i].row + j].consumeAmt = 0;
  166. for(let k = 0; k < component.length; k++){
  167. if(component[k].ID === that.currentComponent[sels[i].row + j].ID){
  168. component[k].consumeAmt = 0;
  169. break;
  170. }
  171. }
  172. }
  173. }
  174. }
  175. }
  176. }
  177. if(removeArr.length > 0 || isUpdate){
  178. for(let i = 0; i < removeArr.length; i++){
  179. for(let j = 0; j < that.currentComponent.length; j++){
  180. if(that.currentComponent[j].ID === removeArr[i]){
  181. that.currentComponent.splice(j--, 1);
  182. }
  183. }
  184. for(let j = 0; j < component.length; j++){
  185. if(component[j].ID === removeArr[i]){
  186. component.splice(j--, 1);
  187. }
  188. }
  189. }
  190. //重新计算工料机
  191. let gljBasePrc = me.reCalGljBasePrc(that.currentComponent);
  192. if(gljBasePrc !== that.currentGlj.basePrice){
  193. that.currentGlj.basePrice = gljBasePrc;
  194. that.reshowGljBasePrc(that.currentGlj);
  195. updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
  196. }
  197. updateArr.push(that.currentGlj);
  198. me.updateComponent(updateArr);
  199. if(updateBasePrc.length > 0){
  200. that.updateRationBasePrcRq(updateBasePrc);
  201. }
  202. }
  203. }
  204. });
  205. me.workBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.del, false, false, false, false);
  206. //me.workBook.commandManager().setShortcutKey('gljComponentDel', GC.Spread.Commands.Key.del, false, false, false, false);
  207. },
  208. onCellEditStart: function(sender, args) {
  209. let me = gljComponentOprObj, that = repositoryGljObj;
  210. let rObj = me.getRowData(args.sheet, args.row, me.setting);
  211. me.currentEditingComponent = rObj;
  212. let thatRow = that.workBook.getSheet(0).getSelections()[0].row;
  213. if(thatRow < that.currentCache.length){
  214. that.currentGlj = that.currentCache[thatRow];
  215. if(me.setting.view.lockedCols.indexOf(args.col) !== -1 || !allowComponent.includes(that.currentGlj.gljType) ||
  216. (that.currentGlj.gljType === 4 && that.isComponent(that.currentGlj.ID, that.stdGljList.concat(that.complementaryGljList))) ||
  217. (args.col === 4 && (!that.currentComponent|| args.row >= that.currentComponent.length))){
  218. args.cancel = true;
  219. }
  220. }
  221. else {
  222. args.cancel = true;
  223. }
  224. },
  225. onCellEditEnd: function (sender, args) {
  226. let me = gljComponentOprObj, that = repositoryGljObj, updateBasePrc = [];
  227. let gljList = that.gljList, updateArr = [], materialComponent = [202, 203, 204], machineComponent = [302, 303];
  228. // if(args.editingText !== me.currentEditingComponent.code){
  229. //编码
  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. 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.consumeAmt);
  341. }
  342. if(updateArr.length > 0){
  343. me.updateComponent(updateArr);
  344. /*if(updateBasePrc.length > 0){
  345. that.updateRationBasePrcRq(updateBasePrc)
  346. }*/
  347. }
  348. },
  349. onClipboardPasting: function (sender, info) {
  350. let me = gljComponentOprObj, that = repositoryGljObj;
  351. let maxCol = info.cellRange.col + info.cellRange.colCount - 1;
  352. //复制的列数超过正确的列数,不可复制
  353. if(info.cellRange.col !== 4 && info.cellRange.colCount > 1 || (that.currentGlj.gljType === 4 && that.isComponent(that.currentGlj.ID, that.stdGljList.concat(that.complementaryGljList)))){
  354. args.cancel = true;
  355. }
  356. },
  357. onClipboardPasted: function (sender, info) {
  358. let me = gljComponentOprObj, that = repositoryGljObj, updateArr = [] ,materialComponent = [202, 203, 204], machineComponent = [302, 303],
  359. component = that.currentGlj.component, newComponent = [], concatComponent = [], isChange = false, updateBasePrc = [];
  360. let items = sheetOpr.analyzePasteData(me.setting, info);
  361. let gljCache = that.gljList;
  362. //编码
  363. /* if(info.cellRange.col === 0){
  364. for(let i = 0; i < items.length; i++){
  365. for(let j = 0; j < gljCache.length; j++){
  366. if(items[i].code === gljCache[j].code){
  367. if((materialComponent.indexOf(that.currentGlj.gljType) !== -1 && gljCache[j].gljType === 201)
  368. || (that.currentGlj.gljType === 301 && machineComponent.indexOf(gljCache[j].gljType) !== -1 )){
  369. //是否与原有组成物不同
  370. let isExist = false;
  371. for(let k = 0; k < component.length; k++){
  372. if(component[k].ID === gljCache[j].ID){
  373. isExist = true;
  374. me.workBook.getSheet(0).setValue(info.cellRange.row + i, info.cellRange.col,
  375. typeof that.currentComponent[info.cellRange.row + i] !== 'undefined'? that.currentComponent[info.cellRange.row + i].code : '');
  376. break;
  377. }
  378. }
  379. if(!isExist){
  380. isChange = true;
  381. let obj = {};
  382. obj.ID = gljCache[j].ID;
  383. if(typeof that.currentComponent[info.cellRange.row + i] !== 'undefined'){//更新
  384. obj.consumeAmt = that.currentComponent[info.cellRange.row + i].consumeAmt;
  385. let index;
  386. for(let k = 0; k < component.length; k++){
  387. if(that.currentComponent[info.cellRange.row + i].ID === component[k].ID){
  388. index = k;
  389. break;
  390. }
  391. }
  392. component.splice(index, 1);
  393. component.splice(index, 0, obj);
  394. }
  395. else{//新增
  396. obj.consumeAmt = 0;
  397. component.push(obj);
  398. }
  399. break;
  400. }
  401. }
  402. else{
  403. me.workBook.getSheet(0).setValue(info.cellRange.row + i, info.cellRange.col,
  404. typeof that.currentComponent[info.cellRange.row + i] !== 'undefined'? that.currentComponent[info.cellRange.row + i].code : '');
  405. }
  406. }
  407. else{
  408. me.workBook.getSheet(0).setValue(info.cellRange.row + i, info.cellRange.col,
  409. typeof that.currentComponent[info.cellRange.row + i] !== 'undefined'? that.currentComponent[info.cellRange.row + i].code : '');
  410. }
  411. }
  412. }
  413. if(isChange){
  414. //计算工料机单价
  415. let gljBasePrc = me.reCalGljBasePrc(that.getCurrentComponent(component));
  416. if(gljBasePrc !== that.currentGlj.basePrice){
  417. that.currentGlj.basePrice = gljBasePrc;
  418. that.reshowGljBasePrc(that.currentGlj);
  419. updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
  420. }
  421. updateArr.push(that.currentGlj);
  422. }
  423. }*/
  424. //消耗量
  425. if(info.cellRange.col === 4){
  426. let items = sheetOpr.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. that.saveInString(updateArr);
  471. $.ajax({
  472. type: 'post',
  473. url: 'complementartGlj/api/updateComponent',
  474. data: {"userId": pageOprObj.userId, "updateArr": JSON.stringify(updateArr)},
  475. dataType: 'json',
  476. success: function (result) {
  477. if(!result.error){
  478. that.currentComponent = that.getCurrentComponent(result.data[0].component);
  479. sheetOpr.cleanData(me.workBook.getSheet(0), me.setting, -1);
  480. sheetOpr.showData(me.workBook.getSheet(0), me.setting, that.currentComponent);
  481. }
  482. else{
  483. sheetOpr.cleanData(me.workBook.getSheet(0), me.setting, -1);
  484. }
  485. $('#componentsCacnel').click();
  486. }
  487. })
  488. },
  489. round: function (v, e) {
  490. let t=1;
  491. for(;e>0;t*=10,e--);
  492. for(;e<0;t/=10,e++);
  493. return Math.round(v*t)/t;
  494. },
  495. reCalGljBasePrc: function (component) {
  496. let me = gljComponentOprObj, gljBasePrc = 0;
  497. for(let i = 0; i < component.length; i++){
  498. let roundBasePrc = scMathUtil.roundTo(parseFloat(component[i].basePrice), -2);
  499. let roundConsumeAmt = scMathUtil.roundTo(parseFloat(component[i].consumeAmt), -3);
  500. gljBasePrc = scMathUtil.roundTo(scMathUtil.roundTo(roundBasePrc * roundConsumeAmt, me.processDecimal) + gljBasePrc, me.processDecimal);
  501. }
  502. return gljBasePrc;
  503. }
  504. };