gljComponent.js 28 KB

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