gljComponent.js 28 KB

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