glj.js 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056
  1. /**
  2. * Created by Zhong on 2017/8/14.
  3. */
  4. let pageOprObj = {
  5. gljLibName : null,
  6. stdGljLibId: null,
  7. userId: null,
  8. compilationId: null,
  9. initPage : function(container, containerComponent, containerC) {
  10. let me = pageOprObj;
  11. me.stdGljLibId = stdGljLibId;
  12. me.userId = userId;
  13. me.compilationId = compilationId;
  14. repositoryGljObj.buildSheet(container);
  15. gljComponentOprObj.buildSheet(containerComponent);
  16. componentOprObj.buildSheet(containerC);
  17. //获得定额库中引用此工料机库中的,所有被定额所套的工料机的ID
  18. //repositoryGljObj.getRationGljIds(gljLibId);
  19. repositoryGljObj.getGljDistType(function () {
  20. repositoryGljObj.currentRepositoryId = me.stdGljLibId;
  21. repositoryGljObj.getGljTree(stdGljLibId, function () {
  22. repositoryGljObj.getGljItems(me.stdGljLibId, me.userId, me.compilationId);
  23. });
  24. sheetOpr.shieldAllCells(repositoryGljObj.workBook.getSheet(0), repositoryGljObj.setting);
  25. });
  26. }
  27. };
  28. let repositoryGljObj = {
  29. treeObj : null,
  30. workBook: null,
  31. gljCurTypeId: -1,
  32. currentRepositoryId: -1,
  33. currentCache: null,
  34. parentNodeIds: {},
  35. gljList: [],
  36. stdGljList:[],
  37. complementaryGljList: [],
  38. allowComponent: [202, 203, 204, 301],//可带组成物类型:混凝土、砂浆、配合比、机械台班
  39. componentGljType: [201, 302, 303],//可成为组成物的工料机类型: 普通材料、 机械组成物、 机上人工
  40. distTypeTree: null,//add
  41. setting: {
  42. header:[
  43. {headerName:"编码",headerWidth:140,dataCode:"code", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
  44. {headerName:"名称",headerWidth:280,dataCode:"name", dataType: "String", hAlign: "left", vAlign: "center"},
  45. {headerName:"规格型号",headerWidth:180,dataCode:"specs", dataType: "String", hAlign: "left", vAlign: "center"},
  46. {headerName:"计量单位",headerWidth:120,dataCode:"unit", dataType: "String", hAlign: "center", vAlign: "center"},
  47. {headerName:"基价单价",headerWidth:120,dataCode:"basePrice", dataType: "Number", formatter: "0.00", hAlign: "right", vAlign: "center"},
  48. {headerName:"类型",headerWidth:120,dataCode:"gljType", dataType: "String", hAlign: "center", vAlign: "center"},
  49. {headerName:"是否新增",headerWidth:80,dataCode:"isComplementary", hAlign: "center", vAlign: "center"}
  50. ],
  51. view:{
  52. comboBox:[
  53. {row:-1,col:3,rowCount:-1,colCount:1}
  54. ],
  55. lockedCells:[
  56. ]
  57. }
  58. },
  59. getComboData: function (gljDistType) {
  60. let me = this;
  61. let distType;
  62. let distTypeTree = {
  63. prefix : 'gljType',
  64. distTypes: {},
  65. comboDatas: [],
  66. distTypesArr: []
  67. };
  68. gljDistType.forEach(function (typeData) {
  69. let typeObj = {
  70. data: typeData,
  71. children: [],
  72. parent: null
  73. }
  74. distTypeTree.distTypes[distTypeTree.prefix + typeData.ID] = typeObj;
  75. distTypeTree.distTypesArr.push(typeObj);
  76. });
  77. gljDistType.forEach(function (typeData) {
  78. distType = distTypeTree.distTypes[distTypeTree.prefix + typeData.ID];
  79. let parent = distTypeTree.distTypes[distTypeTree.prefix + typeData.ParentID];
  80. if(parent){
  81. distType.parent = parent;
  82. parent.children.push(distType);
  83. }
  84. });
  85. distTypeTree.distTypesArr.forEach(function (distTypeObj) {
  86. /* if(distTypeObj.children.length === 0 && distTypeObj.data.fullName !== '普通机械' &&distTypeObj.data.fullName !== '机械组成物'
  87. && distTypeObj.data.fullName !== '机上人工'){
  88. distTypeTree.comboDatas.push({text: distTypeObj.data.fullName, value: distTypeObj.data.ID});
  89. }*/
  90. if(distTypeObj.data.fullName !== '材料' && distTypeObj.data.fullName !== '机械'){
  91. distTypeTree.comboDatas.push({text: distTypeObj.data.fullName, value: distTypeObj.data.ID});
  92. }
  93. });
  94. return distTypeTree;
  95. },
  96. getGljDistType: function (callback) {
  97. let me = this;
  98. $.ajax({
  99. type: 'post',
  100. url: "complementartGlj/api/getGljDistType",
  101. dataType: 'json',
  102. success: function (result) {
  103. if(!result.error && callback){
  104. me.distTypeTree = me.getComboData(result.data);
  105. console.log(me.distTypeTree);
  106. let combo = new GC.Spread.Sheets.CellTypes.ComboBox();
  107. combo.items(me.distTypeTree.comboDatas).editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.text);
  108. me.workBook.getSheet(0).getCell(-1, 5, GC.Spread.Sheets.SheetArea.viewport).cellType(combo).value(me.distTypeTree.comboDatas[0].text);
  109. callback();
  110. }
  111. }
  112. })
  113. },
  114. getGljTree: function(gljLibId, callback) {
  115. let me = this;
  116. $.ajax({
  117. type:"POST",
  118. url:"complementartGlj/api/getGljTree",
  119. data:{"gljLibId": gljLibId},
  120. dataType:"json",
  121. cache:false,
  122. timeout:20000,
  123. success:function(result,textStatus,status){
  124. if(status.status == 200) {
  125. zTreeHelper.createTree(result.data, gljSetting, "repositoryTree", me);
  126. zTreeHelper.createTree(result.data, componentSetting, "componentTree", componentOprObj);
  127. if (result.data && result.data.length > 0) {
  128. me.gljCurTypeId = result.data[0].ID;
  129. } else {
  130. //重新创建库?
  131. gljTypeTreeOprObj.addRootNode();
  132. }
  133. callback();
  134. }
  135. },
  136. error:function(err){
  137. alert(err.responseJSON.error);
  138. }
  139. })
  140. },
  141. getGljItems: function(stdGljLibId, userId, compilationId) {
  142. let me = this;
  143. $.ajax({
  144. type:"POST",
  145. url:"complementartGlj/api/getGljItems",
  146. data:{stdGljLibId: stdGljLibId, userId: userId, compilationId: compilationId},
  147. dataType:"json",
  148. cache:false,
  149. timeout:5000,
  150. success:function(result){
  151. if(!result.error) {
  152. me.stdGljList = result.data.stdGljs;
  153. me.complementaryGljList = result.data.complementaryGljs;
  154. me.workBook.getSheet(0).setRowCount(me.stdGljList.length);
  155. me.sortGlj(me.stdGljList);
  156. me.sortGlj(me.complementaryGljList);
  157. let rootNode = me.treeObj.getNodes()[0];
  158. if(rootNode && rootNode.isParent && rootNode.isFirstNode){
  159. componentOprObj.rootNode = rootNode;
  160. me.treeObj.selectNode(rootNode);
  161. gljTypeTreeOprObj.onClick(null, 'repositoryTree', rootNode);
  162. }
  163. }
  164. },
  165. error:function(err){
  166. alert(err.responseJSON.error);
  167. }
  168. })
  169. },
  170. showGljItems: function(data, type) {
  171. let me = repositoryGljObj;
  172. if (me.workBook) {
  173. let cacheSection = [];
  174. let pArr = me.parentNodeIds["_pNodeId_" + type];
  175. for (let i = 0; i < data.length; i++) {
  176. if (pArr && pArr.indexOf(data[i].gljClass) >= 0) {
  177. cacheSection.push(data[i]);
  178. } else if (type == data[i].gljClass) {
  179. cacheSection.push(data[i]);
  180. }
  181. }
  182. sheetOpr.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
  183. sheetOpr.showData(me.workBook.getSheet(0), me.setting, cacheSection, me.distTypeTree);
  184. cacheSection = null;
  185. }
  186. },
  187. buildSheet: function(container) {
  188. let me = repositoryGljObj;
  189. me.workBook = sheetOpr.buildSheet(container, me.setting, 30);
  190. me.repositoryGljDelOpr();
  191. me.workBook.getActiveSheet().bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
  192. me.workBook.getActiveSheet().bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
  193. me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditStarting, me.onCellEditStart);
  194. me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditEnded, me.onCellEditEnd);
  195. me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EnterCell, me.onEnterCell);
  196. me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.SelectionChanged, me.onSelectionChanged);
  197. },
  198. getCurrentComponent: function (gljComponent) {
  199. let me = repositoryGljObj, rst = [];
  200. for(let i = 0; i < gljComponent.length; i++){
  201. let obj = {};
  202. for(let j = 0; j < me.complementaryGljList.length; j++){
  203. if(gljComponent[i].ID == me.complementaryGljList[j].ID){
  204. obj.ID = me.complementaryGljList[j].ID;
  205. obj.code = me.complementaryGljList[j].code;
  206. obj.name = me.complementaryGljList[j].name;
  207. obj.unit = me.complementaryGljList[j].unit;
  208. obj.basePrice = me.complementaryGljList[j].basePrice;
  209. obj.consumeAmt = gljComponent[i].consumeAmt;
  210. rst.push(obj);
  211. }
  212. }
  213. for(let j = 0; j < me.stdGljList.length; j++){
  214. if(gljComponent[i].ID == me.stdGljList[j].ID){
  215. obj.ID = me.stdGljList[j].ID;
  216. obj.code = me.stdGljList[j].code;
  217. obj.name = me.stdGljList[j].name;
  218. obj.unit = me.stdGljList[j].unit;
  219. obj.basePrice = me.stdGljList[j].basePrice;
  220. obj.consumeAmt = gljComponent[i].consumeAmt;
  221. rst.push(obj);
  222. }
  223. }
  224. }
  225. rst.sort(function (a, b) {
  226. let r = 0;
  227. if(a.code > b.code) r = 1;
  228. else if(a.code < b.code) r = -1;
  229. return r;
  230. });
  231. return rst;
  232. },
  233. //获得引用了组成物id为componentId的工料机,和重新变化组成物数组、重新计算单价
  234. getUpdateGljs: function (rObj, isDelete) {
  235. let me = repositoryGljObj, that = gljComponentOprObj,
  236. rst = {updateArr: [], updateBasePrcArr: []};
  237. //改变单价,以便reCalGljBasePrc方法可行
  238. if(!isDelete){
  239. for(let i = 0; i < me.complementaryGljList.length; i++){
  240. if(me.complementaryGljList[i].ID === rObj.ID){
  241. me.complementaryGljList[i].basePrice = rObj.basePrice;
  242. break;
  243. }
  244. }
  245. }
  246. for(let i = 0; i < me.complementaryGljList.length; i++){
  247. let thisComponent = me.complementaryGljList[i].component, isChange = false;
  248. for(let j = 0; j < thisComponent.length; j++){
  249. if(thisComponent[j].ID === rObj.ID){
  250. //删除
  251. isChange = true;
  252. if(isDelete){
  253. thisComponent.splice(j--, 1);
  254. }
  255. else {
  256. break;
  257. }
  258. }
  259. }
  260. if(isChange){//引用了此组成物
  261. let gljBasePrc = that.reCalGljBasePrc(me.getCurrentComponent(thisComponent));
  262. if(me.complementaryGljList[i].basePrice !== gljBasePrc){
  263. me.complementaryGljList[i].basePrice = gljBasePrc;
  264. rst.updateBasePrcArr.push({gljId: me.complementaryGljList[i].ID, gljType: me.complementaryGljList[i].gljType, basePrice: me.complementaryGljList[i].basePrice});
  265. }
  266. rst.updateArr.push(me.complementaryGljList[i]);
  267. }
  268. }
  269. return rst;
  270. },
  271. reshowGljBasePrc: function (glj) {
  272. let me = repositoryGljObj;
  273. let cacheSection = me.currentCache;
  274. for(let i = 0; i < cacheSection.length; i++){
  275. if(glj.ID === cacheSection[i].ID){
  276. cacheSection[i].basePrice = glj.basePrice;
  277. me.workBook.getSheet(0).setValue(i, 4, glj.basePrice);
  278. break;
  279. }
  280. }
  281. },
  282. onSelectionChanged: function (sender, info) {
  283. let me = repositoryGljObj, that = gljComponentOprObj;
  284. //混凝土202、砂浆203、配合比204、机械3
  285. if(typeof info.oldSelections || info.oldSelections.length === 0 && info.newSelections.length > 0 || info.oldSelections[0].row !== info.newSelections[0].row){
  286. let row = info.newSelections[0].row;
  287. sheetOpr.lockCells(that.workBook.getSheet(0), that.setting);
  288. that.workBook.getSheet(0).getRange(-1, 0 , -1, 1, GC.Spread.Sheets.SheetArea.viewport).locked(true);
  289. that.workBook.getSheet(0).getRange(-1, 4 , -1, 1, GC.Spread.Sheets.SheetArea.viewport).locked(true);
  290. that.isLocked = true;
  291. //that.workBook.getSheet(0).options.isProtected = true;
  292. sheetOpr.cleanSheet(that.workBook.getSheet(0), that.setting, -1);
  293. me.workBook.focus(true);
  294. me.currentComponent = [];
  295. if(row < me.currentCache.length){
  296. //标记当前工料机
  297. me.currentGlj = me.currentCache[row];
  298. if(me.allowComponent.indexOf(me.currentCache[row].gljType) !== -1){
  299. //that.workBook.getSheet(0).getRange(-1, 0 , -1, 1, GC.Spread.Sheets.SheetArea.viewport).locked(false);
  300. that.workBook.getSheet(0).getRange(-1, 4 , -1, 1, GC.Spread.Sheets.SheetArea.viewport).locked(false);
  301. that.isLocked = false;
  302. //展示数据
  303. if(me.currentGlj.component.length > 0){
  304. me.currentComponent = me.getCurrentComponent(me.currentGlj.component);
  305. if(me.currentComponent.length > 0){
  306. sheetOpr.showData(that.workBook.getSheet(0), that.setting, me.currentComponent);
  307. }
  308. }
  309. }
  310. }
  311. else{
  312. me.currentGlj = null;
  313. }
  314. }
  315. },
  316. onEnterCell: function (sender, args) {
  317. let me = repositoryGljObj;
  318. me.cellRowIdx = args.row;
  319. let isHasData = false;
  320. if(me.addGljObj){
  321. for(let i=0; i<me.setting.header.length; i++){
  322. if(me.addGljObj[me.setting.header[i].dataCode]){
  323. isHasData = true;
  324. break;
  325. }
  326. }
  327. }
  328. if(isHasData){
  329. if(me.editingRowIdx !== me.cellRowIdx) {
  330. let isComple = true;
  331. let focusToCol;
  332. function getFocusToCol (me){
  333. if(!me.addGljObj[me.setting.header[0].dataCode]){
  334. $('#alertGljTxt').text('编号不能为空,是否取消增加工料机?');
  335. return 0;
  336. }
  337. else if(!me.addGljObj[me.setting.header[1].dataCode]){
  338. $('#alertGljTxt').text('名称不能为空,是否取消增加工料机?');
  339. return 1;
  340. }
  341. else if(!me.addGljObj[me.setting.header[3].dataCode]){
  342. $('#alertGljTxt').text('计量单位不能为空,是否取消增加工料机?');
  343. return 3;
  344. }
  345. else if(!me.addGljObj[me.setting.header[5].dataCode]){
  346. $('#alertGljTxt').text('类型不能为空,是否取消增加工料机?');
  347. return 5;
  348. }
  349. else {
  350. return -1;
  351. }
  352. }
  353. focusToCol = getFocusToCol(me);
  354. if(focusToCol === -1){
  355. }
  356. else {
  357. $('#gljAlertBtn').click();
  358. //me.workBook.getSheet(0).options.isProtected = true;
  359. sheetOpr.lockAllCells(args.sheet);
  360. $('#aleCanceBtn').click(function () {
  361. // me.workBook.getSheet(0).options.isProtected = false;
  362. sheetOpr.unLockAllCells(args.sheet);
  363. sheetOpr.reLockSomeCodes(args.sheet, 0, repositoryGljObj.currentCache.length);
  364. me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, focusToCol);
  365. });
  366. $('#gljAleClose').click(function () {
  367. // me.workBook.getSheet(0).options.isProtected = false;
  368. sheetOpr.unLockAllCells(args.sheet);
  369. sheetOpr.reLockSomeCodes(args.sheet, 0, repositoryGljObj.currentCache.length);
  370. me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, focusToCol);
  371. });
  372. $('#aleConfBtn').click(function () {
  373. // me.workBook.getSheet(0).options.isProtected = false;
  374. sheetOpr.unLockAllCells(args.sheet);
  375. sheetOpr.reLockSomeCodes(args.sheet, 0, repositoryGljObj.currentCache.length);
  376. me.addGljObj = null;
  377. for(let col=0; col<me.setting.header.length; col++){
  378. let field = me.setting.header[col].dataCode;
  379. if(field === 'gljType'){
  380. me.workBook.getSheet(0).getCell(me.editingRowIdx, col).value(
  381. me.distTypeTree.distTypes[me.distTypeTree.prefix + me.currentEditingGlj[field]].data.fullName);
  382. }
  383. else{
  384. me.workBook.getSheet(0).getCell(me.editingRowIdx, col).value(me.currentEditingGlj[me.setting.header[col].dataCode]);
  385. }
  386. }
  387. me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, 0);
  388. });
  389. }
  390. }
  391. }
  392. },
  393. onCellEditStart: function(sender, args) {
  394. let me = repositoryGljObj;
  395. let rObj = sheetOpr.combineRowData(me.workBook.getSheet(0), me.setting, args.row);
  396. me.currentEditingGlj = rObj;
  397. me.orgCode = me.workBook.getSheet(0).getValue(args.row, 0);
  398. let cacheSection = me.complementaryGljList;
  399. if (cacheSection) {
  400. for (let j = 0; j < cacheSection.length; j++) {
  401. if (cacheSection[j][me.setting.header[0].dataCode] && cacheSection[j][me.setting.header[0].dataCode] == rObj[me.setting.header[0].dataCode]) {
  402. rObj["ID"] = cacheSection[j]["ID"];
  403. rObj.gljClass = cacheSection[j].gljClass;
  404. break;
  405. }
  406. }
  407. }
  408. },
  409. onCellEditEnd: function(sender, args) {
  410. let me = repositoryGljObj, that = gljComponentOprObj,
  411. rObj = sheetOpr.combineRowData(me.workBook.getSheet(0), me.setting, args.row, me),
  412. updateArr = [], addArr = [], updateBasePrcArr = [];
  413. me.editingRowIdx = args.row;
  414. rObj.basePrice = rObj.basePrice ? rObj.basePrice : 0;
  415. //更新
  416. if (me.currentEditingGlj["ID"]) {
  417. rObj["ID"] = me.currentEditingGlj["ID"];
  418. rObj.gljClass = me.currentEditingGlj.gljClass;
  419. for(let col =0; col< me.setting.header.length; col++){
  420. if(me.currentEditingGlj[me.setting.header[col].dataCode] !== rObj[me.setting.header[col].dataCode]){
  421. me.addGljObj = rObj;
  422. if(rObj[me.setting.header[0].dataCode] && rObj[me.setting.header[1].dataCode] && rObj[me.setting.header[5].dataCode]){
  423. if(rObj.gljType !== me.currentEditingGlj.gljType){//修改了工料机类型
  424. if(me.currentGlj){
  425. me.currentGlj.component = [];
  426. }
  427. if(me.allowComponent.indexOf(rObj.gljType) !== -1){
  428. rObj.basePrice = 0;
  429. }
  430. if(me.componentGljType.indexOf(me.currentEditingGlj.gljType) !== -1 &&
  431. !(me.currentEditingGlj.gljType === 302 && rObj.gljType === 303) && !(me.currentEditingGlj.gljType === 303 && rObj.gljType === 302)){//修改了原本是组成物的工料机
  432. //寻找所有引用了此组成物的工料机,并从组成物中删去此工料机,并重算单价
  433. let updateGljs = me.getUpdateGljs(rObj);
  434. if(updateGljs.updateArr.length > 0 || updateGljs.updateBasePrcArr.length > 0){
  435. for(let i = 0; i < updateGljs.updateArr.length; i++){
  436. updateArr.push(updateGljs.updateArr[i]);
  437. }
  438. for(let i = 0; i < updateGljs.updateBasePrcArr.length; i++){
  439. updateArr.push(updateGljs.updateBasePrcArr[i]);
  440. }
  441. }
  442. }
  443. }
  444. else if(rObj.basePrice !== me.currentEditingGlj.basePrice){//修改了单价,可修改单价的必为可成为组成物的
  445. //寻找所有引用了此组成物的工料机,并从组成物中删去此工料机,并重算单价
  446. let updateGljs = me.getUpdateGljs(rObj);
  447. if(updateGljs.updateArr.length > 0 || updateGljs.updateBasePrcArr.length > 0){
  448. for(let i = 0; i < updateGljs.updateArr.length; i++){
  449. updateArr.push(updateGljs.updateArr[i]);
  450. }
  451. for(let i = 0; i < updateGljs.updateBasePrcArr.length; i++){
  452. updateArr.push(updateGljs.updateBasePrcArr[i]);
  453. }
  454. }
  455. rObj.basePrice = !isNaN(parseFloat(rObj.basePrice)) && (rObj.basePrice && typeof rObj.basePrice !== 'undefined') ? that.round(parseFloat(rObj.basePrice), 2) : 0;
  456. }
  457. rObj.component = me.currentGlj.component;
  458. updateArr.push(rObj);
  459. break;
  460. }
  461. }
  462. }
  463. //--------------------------------------
  464. if(me.currentEditingGlj.basePrice !== rObj.basePrice){
  465. //update basePrice of ration when editting basePrice of glj
  466. /* let gljType = -1;
  467. let gljTypeParent = me.distTypeTree.distTypes[me.distTypeTree.prefix + me.currentEditingGlj.gljType].parent;
  468. if(gljTypeParent && gljTypeParent.data.ID <=3){
  469. gljType = gljTypeParent.data.ID;
  470. }
  471. if(!gljTypeParent && me.currentEditingGlj.gljType <= 3){
  472. gljType = me.currentEditingGlj.gljType;
  473. }
  474. let gljBasePrcObj = {gljId: me.currentEditingGlj.ID, gljType: gljType, basePrice: rObj.basePrice};
  475. if(gljBasePrcObj.gljType !== -1){
  476. updateBasePrcArr.push(gljBasePrcObj);
  477. if(me.rationLibs.length > 0){//重算定额单价
  478. me.updateRationBasePrcRq(updateBasePrcArr);
  479. }
  480. }*/
  481. }
  482. //update basePrice of ration when editting gljType of glj
  483. if(me.currentEditingGlj.gljType !== rObj.gljType){
  484. /*let gljTypeObj = {gljId: me.currentEditingGlj.ID, gljType: rObj.gljType, basePrice: rObj.basePrice};
  485. updateBasePrcArr.push(gljTypeObj);
  486. if(me.rationLibs.length > 0){
  487. me.updateRationBasePrcRq(updateBasePrcArr);
  488. }*/
  489. }
  490. //-----------------------------------------------------------
  491. }
  492. //新增
  493. else {
  494. me.addGljObj = rObj;
  495. let isCanSav = true;
  496. if(!rObj[me.setting.header[0].dataCode] || !rObj[me.setting.header[1].dataCode] || !rObj[me.setting.header[3].dataCode] || !rObj[me.setting.header[5].dataCode]){
  497. isCanSav = false;
  498. }
  499. if(isCanSav){
  500. me.addGljObj = null;
  501. rObj.component = [];
  502. //如果类型为混凝土、砂浆、配合比、机械台班时,添加时填写的单价清空
  503. if(me.allowComponent.indexOf(rObj.gljType) !== -1){
  504. rObj.basePrice = 0;
  505. }
  506. rObj.basePrice = !isNaN(parseFloat(rObj.basePrice)) && (rObj.basePrice && typeof rObj.basePrice !== 'undefined') ? parseFloat(rObj.basePrice) : 0;
  507. addArr.push(rObj);
  508. }
  509. }
  510. if(me.gljCurTypeId !== 732){
  511. rObj.gljClass = me.gljCurTypeId;
  512. }
  513. if(updateArr.length >0 || addArr.length >0){
  514. me.currentEditingGlj = null;
  515. //me.workBook.getSheet(0).setValue(11, 5, "人工");
  516. console.log(updateArr);
  517. me.mixUpdateRequest(updateArr, addArr, []);
  518. }
  519. },
  520. repositoryGljDelOpr: function () {
  521. let me = repositoryGljObj;
  522. me.workBook.commandManager().register('repositoryGljDel', function () {
  523. let sheet = me.workBook.getSheet(0),
  524. updateArr = [], removeArr = [],
  525. tempRemoveArr= [],
  526. refGljCodes = [], //已被引用的工料机
  527. updateBasePrcArr = [],//删除基价单位后重新计算
  528. sels = sheet.getSelections(),
  529. canUpdate = false,
  530. cacheSection = me.currentCache;
  531. if(sels.length > 0 && cacheSection.length > 0){
  532. for(let i = 0; i < sels.length; i++){
  533. if(sels[i].colCount === me.setting.header.length){
  534. for(let j = 0; j < sels[i].rowCount; j++){
  535. if(sels[i].row + j < cacheSection.length){
  536. //删除了已被引用成组成物的工料机,重新计算所有引用此组成物的工料机的单价、组成物数组
  537. let updateGljs = me.getUpdateGljs(cacheSection[sels[i].row + j], true);
  538. if(updateGljs.updateArr.length > 0 || updateGljs.updateBasePrcArr.length > 0){
  539. for(let i = 0; i < updateGljs.updateArr.length; i++){
  540. updateArr.push(updateGljs.updateArr[i]);
  541. }
  542. for(let i = 0; i < updateGljs.updateBasePrcArr.length; i++){
  543. updateBasePrcArr.push(updateGljs.updateBasePrcArr[i]);
  544. }
  545. }
  546. console.log(updateArr);
  547. removeArr.push(cacheSection[sels[i].row + j].ID);
  548. //tempRemoveArr.push({ID: cacheSection[sels[i].row + j].ID, code: cacheSection[sels[i].row + j].code});
  549. //删除后重新计算引用了此工料机的定额单价
  550. updateBasePrcArr.push({gljId: cacheSection[sels[i].row + j].ID, gljType: cacheSection[sels[i].row + j].gljType, basePrice: 0, delete: 1});
  551. }
  552. }
  553. }
  554. else{
  555. let maxCol = sels[i].col + sels[i].colCount - 1;
  556. if(sels[i].col >= 2 && maxCol <= 4){
  557. for(let j = 0; j < sels[i].rowCount; j++){
  558. if(sels[i].row + j < cacheSection.length){
  559. let updateObj = cacheSection[sels[i].row + j];
  560. for(let col = sels[i].col; col <= maxCol; col++){
  561. if(me.setting.header[col].dataCode === 'basePrice'){
  562. //如果类型不为混凝土、砂浆、配合比、机械,才可删除单价 basePrice = 0
  563. if(me.allowComponent.indexOf(updateObj.gljType) === -1){
  564. canUpdate = true;
  565. updateObj[me.setting.header[col].dataCode] = 0;
  566. updateBasePrcArr.push({gljId: updateObj.ID, gljType: updateObj.gljType, basePrice: 0});
  567. }
  568. }
  569. else{
  570. canUpdate = true;
  571. updateObj[me.setting.header[col].dataCode] = '';
  572. }
  573. }
  574. if(canUpdate){
  575. updateArr.push(updateObj);
  576. }
  577. }
  578. }
  579. }
  580. //编号、名称、类型不可为空
  581. else{
  582. if(sels[i].row < cacheSection.length){
  583. let text = '', cantNullStr =['编码', '名称', '类型'];
  584. for(let col = sels[i].col; col <= sels[i].col + sels[i].colCount -1; col++){
  585. if(cantNullStr.indexOf(me.setting.header[col].headerName) !== -1){
  586. text += me.setting.header[col].headerName + " ";
  587. }
  588. }
  589. $('#alertText').text(text + "不可为空!");
  590. $('#codeAlertBtn').click();
  591. sheet.options.isProtected = true;
  592. $('#codAleConfBtn').click(function () {
  593. sheetOpr.lockSomeCodes(sheet, 0, cacheSection.length);
  594. });
  595. $('#codAleClose').click(function () {
  596. sheetOpr.lockSomeCodes(sheet, 0, cacheSection.length);
  597. });
  598. }
  599. }
  600. }
  601. }
  602. if(removeArr.length > 0 || updateArr.length > 0){
  603. //删除警告
  604. $('#alertGljTxt').text('可能已有定额引用了当前工料机,导致定额查找不到此工料机。确定要删除吗?');
  605. $('#gljAlertBtn').click();
  606. //确认
  607. $('#aleConfBtn').click(function () {
  608. me.mixUpdateRequest(updateArr, [], removeArr);
  609. if(updateBasePrcArr.length > 0 && me.rationLibs.length > 0){
  610. me.updateRationBasePrcRq(updateBasePrcArr);
  611. }
  612. });
  613. }
  614. }
  615. });
  616. me.workBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.del, false, false, false, false);
  617. me.workBook.commandManager().setShortcutKey('repositoryGljDel', GC.Spread.Commands.Key.del, false, false, false, false);
  618. },
  619. validUpdateObj: function (pasteObj, rowIdx) {
  620. let rst = {updateGlj: [], updateBasePrcArr: []}, backUpObj = {},
  621. me = repositoryGljObj,
  622. that = gljComponentOprObj,
  623. tempObj = me.currentCache[rowIdx],
  624. reCalBasePrc = false,
  625. isValid = true;
  626. //备份原始数据
  627. for(let atr in tempObj){
  628. backUpObj[atr] = tempObj[atr];
  629. }
  630. if(typeof pasteObj.code !== 'undefined'){
  631. if(pasteObj.code.trim().length !== 0){
  632. let isExist = false;
  633. for(let i = 0; i < me.stdGljList.length; i++){
  634. if(me.stdGljList[i].code === pasteObj.code){
  635. isExist = true;
  636. break;
  637. }
  638. }
  639. if(!isExist){
  640. for(let i = 0; i < me.complementaryGljList.length; i++){
  641. if(me.complementaryGljList[i].code === pasteObj.code){
  642. isExist = true;
  643. break;
  644. }
  645. }
  646. }
  647. if(!isExist){
  648. tempObj.code = pasteObj.code;
  649. }
  650. else isValid = false;
  651. }
  652. else isValid = false;
  653. }
  654. if(typeof pasteObj.name !== 'undefined'){
  655. if(pasteObj.name.trim().length === 0) isValid = false;
  656. else tempObj.name = pasteObj.name;
  657. }
  658. if(typeof pasteObj.specs !== 'undefined'){
  659. tempObj.specs = pasteObj.specs;
  660. }
  661. if(typeof pasteObj.unit !== 'undefined'){
  662. tempObj.unit = pasteObj.unit;
  663. }
  664. if(typeof pasteObj.gljType !== 'undefined'){
  665. let isExsit = false;
  666. for(let i = 0; i < me.distTypeTree.comboDatas.length; i++){
  667. if(pasteObj.gljType === me.distTypeTree.comboDatas[i].text){
  668. isExsit = true;
  669. reCalBasePrc = true;
  670. //
  671. if(me.componentGljType.indexOf(tempObj.gljType) !== -1 &&
  672. !(tempObj.gljType === 302 && pasteObj.gljType === 303) && !(tempObj.gljType === 303 && pasteObj.gljType === 302)){//修改了原本是组成物的工料机
  673. //寻找所有引用了此组成物的工料机,并从组成物中删去此工料机,并重算单价
  674. let updateGljs = me.getUpdateGljs(tempObj, true);
  675. if(updateGljs.updateArr.length > 0 || updateGljs.updateBasePrcArr.length > 0){
  676. for(let i = 0; i < updateGljs.updateArr.length; i++){
  677. rst.updateGlj.push(updateGljs.updateArr[i]);
  678. }
  679. for(let i = 0; i < updateGljs.updateBasePrcArr.length; i++){
  680. rst.updateBasePrcArr.push(updateGljs.updateBasePrcArr[i]);
  681. }
  682. }
  683. }
  684. tempObj.gljType = me.distTypeTree.comboDatas[i].value;
  685. tempObj.shortName = me.distTypeTree.distTypes[me.distTypeTree.prefix + tempObj.gljType].data.shortName;
  686. if(me.allowComponent.indexOf(tempObj.gljType) !== -1){
  687. tempObj.basePrice = 0;
  688. }
  689. break;
  690. }
  691. }
  692. if(!isExsit) isValid = false;
  693. }
  694. //
  695. pasteObj.basePrice = !isNaN(parseFloat(pasteObj.basePrice)) && (pasteObj.basePrice && typeof pasteObj.basePrice !== 'undefined') ? that.round(parseFloat(pasteObj.basePrice), 2) :
  696. me.currentCache[rowIdx].basePrice;
  697. if(pasteObj.basePrice !== me.currentCache[rowIdx].basePrice){
  698. reCalBasePrc = true;
  699. tempObj.basePrice = pasteObj.basePrice;
  700. let updateGljs = me.getUpdateGljs(tempObj, false);
  701. if(updateGljs.updateArr.length > 0 || updateGljs.updateBasePrcArr.length > 0){
  702. for(let i = 0; i < updateGljs.updateArr.length; i++){
  703. rst.updateGlj.push(updateGljs.updateArr[i]);
  704. }
  705. for(let i = 0; i < updateGljs.updateBasePrcArr.length; i++){
  706. rst.updateBasePrcArr.push(updateGljs.updateBasePrcArr[i]);
  707. }
  708. }
  709. }
  710. if(isValid){
  711. rst.updateGlj.push(tempObj);
  712. if(reCalBasePrc){
  713. //重新计算定额基价对象
  714. //rst.updateBasePrc = {gljId: tempObj.ID, gljType: tempObj.gljType, basePrice: tempObj.basePrice};
  715. let newReObj = {gljId: tempObj.ID, gljType: tempObj.gljType, basePrice: tempObj.basePrice};
  716. rst.updateBasePrcArr.push(newReObj);
  717. }
  718. }
  719. else {
  720. for(let attr in backUpObj){
  721. tempObj[attr] = backUpObj[attr];
  722. }
  723. }
  724. return rst;
  725. },
  726. //粘贴的数据是否是可添加的数据,只有含有编号,名称,类型才可添加
  727. isValidObj: function(pasteObj) {
  728. let me = repositoryGljObj;
  729. if(!(pasteObj.code && typeof pasteObj.code !== 'undefined') || !(pasteObj.name && typeof pasteObj.name !== 'undefined') ||
  730. !(pasteObj.gljType && typeof pasteObj.gljType !== 'undefined')){
  731. return false;
  732. }
  733. if(pasteObj.gljType && typeof pasteObj.gljType !== 'undefined'){
  734. let isExist = false;
  735. for(let i = 0; i < me.distTypeTree.comboDatas.length; i++){
  736. if(me.distTypeTree.comboDatas[i].text === pasteObj.gljType){
  737. isExist = true;
  738. pasteObj.gljType = me.distTypeTree.comboDatas[i].value;
  739. pasteObj.shortName = me.distTypeTree.distTypes[me.distTypeTree.prefix + pasteObj.gljType].data.shortName;
  740. break;
  741. }
  742. }
  743. if(!isExist){
  744. return false;
  745. }
  746. }
  747. if(pasteObj.code && typeof pasteObj.code !== 'undefined'){
  748. for(let i = 0; i < me.stdGljList.length; i++){
  749. if(me.stdGljList[i].code === pasteObj.code){
  750. return false;
  751. }
  752. }
  753. for(let i = 0; i < me.complementaryGljList.length; i++){
  754. if(me.complementaryGljList[i].code === pasteObj.code){
  755. return false;
  756. }
  757. }
  758. }
  759. pasteObj.basePrice = !isNaN(parseFloat(pasteObj.basePrice)) && (pasteObj.basePrice && typeof pasteObj.basePrice !== 'undefined') ? parseFloat(pasteObj.basePrice) : 0;
  760. pasteObj.gljClass = me.gljCurTypeId;
  761. return true;
  762. },
  763. onClipboardPasting: function(sender, args) {
  764. let me = repositoryGljObj;
  765. let maxCol = args.cellRange.col + args.cellRange.colCount - 1;
  766. //复制的列数超过正确的列数,不可复制
  767. if (me.gljCurTypeId < 0 || maxCol >= me.setting.header.length -1) {
  768. args.cancel = true;
  769. }
  770. },
  771. onClipboardPasted: function(e, info) {
  772. if(info.pasteData.text.trim().length > 0){
  773. let me = repositoryGljObj;
  774. let updateArr = [], addArr = [];
  775. let items = sheetOpr.analyzePasteData(me.setting, info);
  776. let beginRow = info.cellRange.row, endRow = info.cellRange.row + info.cellRange.rowCount - 1,//复制的起始行数和结束行数
  777. maxRow = me.currentCache.length - 1,//当前数据最大行数
  778. updateBasePrcArr = [] ,
  779. updateCount, resumeArr = [];
  780. if(endRow <= maxRow){
  781. //updateItems = items;
  782. for(let i = 0; i < items.length; i++){
  783. let updateObj = me.validUpdateObj(items[i], info.cellRange.row + i);
  784. if(updateObj && typeof updateObj.updateGlj !== 'undefined'){
  785. updateArr = updateObj.updateGlj;
  786. /*if(typeof updateObj.updateBasePrcArr !== 'undefined'){
  787. updateBasePrcArr = updateObj.updateBasePrcArr;
  788. }*/
  789. }
  790. else{
  791. resumeArr.push(info.cellRange.row + i);
  792. }
  793. }
  794. }
  795. else if(beginRow <= maxRow && endRow > maxRow){
  796. updateCount = maxRow - beginRow + 1;
  797. for(let i = 0; i < updateCount; i++){
  798. let updateObj = me.validUpdateObj(items[i], info.cellRange.row + i);
  799. if(updateObj && typeof updateObj.updateGlj !== 'undefined'){
  800. updateArr = updateObj.updateGlj;
  801. /* if(typeof updateObj.updateBasePrcArr !== 'undefined'){
  802. updateBasePrcArr = updateObj.updateBasePrcArr;
  803. }*/
  804. }
  805. else{
  806. resumeArr.push(info.cellRange.row + i);
  807. }
  808. }
  809. if(info.cellRange.colCount === me.setting.header.length -1){
  810. for(let i = updateCount ; i < items.length; i++){
  811. if(me.isValidObj(items[i])){
  812. items[i].component = [];
  813. //类型为混凝土、砂浆、配合比、机械时,基价只能组成物计算
  814. if(me.allowComponent.indexOf(items[i].gljType) !== -1){
  815. items[i].basePrice = 0;
  816. }
  817. addArr.push(items[i]);
  818. }
  819. else{
  820. resumeArr.push(info.cellRange.row + i);
  821. }
  822. }
  823. }
  824. else{
  825. for(let i = updateCount ; i < items.length; i++){
  826. resumeArr.push(info.cellRange.row + i);
  827. }
  828. }
  829. }
  830. else{
  831. if(info.cellRange.colCount === me.setting.header.length -1){
  832. for(let i = 0; i < items.length; i++){
  833. if(me.isValidObj(items[i])){
  834. items[i].component = [];
  835. if(me.allowComponent.indexOf(items[i].gljType) !== -1){
  836. items[i].basePrice = 0;
  837. }
  838. addArr.push(items[i]);
  839. }
  840. else{
  841. resumeArr.push(info.cellRange.row + i);
  842. }
  843. }
  844. }
  845. else{
  846. for(let i = 0; i < items.length; i++){
  847. resumeArr.push(info.cellRange.row + i);
  848. }
  849. }
  850. }
  851. //repaint
  852. if(resumeArr.length > 0){
  853. let sheet = me.workBook.getActiveSheet();
  854. sheet.suspendPaint();
  855. for(let i = 0; i < resumeArr.length ; i++){
  856. if(resumeArr[i] < me.currentCache.length){
  857. for(let col = 0; col < me.setting.header.length -1; col++){
  858. if(me.setting.header[col].dataCode === 'gljType'){
  859. let gljType = me.currentCache[resumeArr[i]][me.setting.header[col].dataCode];
  860. sheet.setValue(resumeArr[i], col, me.distTypeTree.distTypes["gljType" + gljType].data.fullName);
  861. }
  862. else{
  863. sheet.setValue(resumeArr[i], col, me.currentCache[resumeArr[i]][me.setting.header[col].dataCode]);
  864. }
  865. }
  866. }
  867. else{
  868. for(let col = 0; col < me.setting.header.length - 1; col++){
  869. sheet.setValue(resumeArr[i], col, '', GC.Spread.Sheets.SheetArea.viewport);
  870. }
  871. }
  872. }
  873. sheet.resumePaint();
  874. }
  875. if (updateArr.length > 0 || addArr.length > 0) {
  876. me.mixUpdateRequest(updateArr, addArr, []);
  877. }
  878. /*if(updateBasePrcArr.length > 0 && me.rationLibs.length > 0){
  879. me.updateRationBasePrcRq(updateBasePrcArr);
  880. }*/
  881. }
  882. else{//解决bug: 从原本的sheet复制一行数据,会两次调用粘贴事件函数..,todo:找出原因
  883. for(let i = 0, len = info.cellRange.rowCount; i < len; i++){
  884. for(let col = 0; col < 6; col++){
  885. info.sheet.setValue(info.cellRange.row + i, col, '');
  886. }
  887. }
  888. }
  889. },
  890. updateRationBasePrcRq: function (basePrcArr) {
  891. $.ajax({
  892. type: 'post',
  893. url: 'complementartGlj/api/updateRationBasePrc',
  894. data:{basePrcArr: JSON.stringify(basePrcArr)},
  895. dataType: 'json',
  896. success: function (result) {
  897. if(result.error){
  898. alert("计算定额基价失败");
  899. }
  900. }
  901. });
  902. },
  903. /* getRationGljIds: function (repId) {
  904. let me = repositoryGljObj;
  905. $.ajax({
  906. type: 'post',
  907. url: 'api/getRationGljIds',
  908. data: {data: JSON.stringify({repId: repId})},
  909. dataType: 'json',
  910. success: function(result){
  911. if(!result.error){
  912. me.rationGljIds = result.data;
  913. }
  914. }
  915. });
  916. },*/
  917. mixUpdateRequest: function(updateArr, addArr, removeIds) {
  918. let me = repositoryGljObj;
  919. $.ajax({
  920. type:"POST",
  921. url:"complementartGlj/api/mixUpdateGljItems",
  922. data:{userId: pageOprObj.userId, compilationId: pageOprObj.compilationId, updateItems: JSON.stringify(updateArr), addItems: JSON.stringify(addArr), removeIds: JSON.stringify(removeIds)},
  923. dataType:"json",
  924. cache:false,
  925. timeout:5000,
  926. success:function(result){
  927. if (result.error) {
  928. alert(result.message);
  929. me.getRationItems(me.currentRepositoryId);
  930. } else {
  931. me.updateCache(addArr, updateArr, removeIds, result);
  932. me.sortGlj(me.complementaryGljList);
  933. if(me.currentOprParent === 1){
  934. me.currentCache = me.getParentCache(me.parentNodeIds["_pNodeId_" + me.gljCurTypeId]);
  935. }
  936. else{
  937. me.currentCache = me.getCache();
  938. //sheetOpr.unLockAllCells(me.workBook.getSheet(0));
  939. sheetOpr.reLockSomeCodes(me.workBook.getSheet(0), 0, me.currentCache.length);
  940. //sheetOpr.lockSomeCodes(me.workBook.getSheet(0), 0, me.currentCache.length);
  941. }
  942. me.showGljItems(me.complementaryGljList, me.gljCurTypeId);
  943. }
  944. },
  945. error:function(err){
  946. alert("保存失败");
  947. }
  948. })
  949. },
  950. getParentCache: function (nodes) {
  951. let me = repositoryGljObj, rst = [];
  952. for(let i = 0; i < me.complementaryGljList.length; i++){
  953. if(nodes.indexOf(me.complementaryGljList[i].gljClass) !== -1){
  954. rst.push(me.complementaryGljList[i]);
  955. }
  956. }
  957. rst.sort(function (a, b) {
  958. let rst = 0;
  959. if(a.code > b.code) rst = 1;
  960. else if(a.code < b.code)rst = -1;
  961. return rst;
  962. });
  963. return rst;
  964. },
  965. getCache: function() {
  966. let me = this, rst = [];
  967. for (let i = 0; i < me.complementaryGljList.length; i++) {
  968. if (me.complementaryGljList[i].gljClass == me.gljCurTypeId) {
  969. rst.push(me.complementaryGljList[i]);
  970. }
  971. }
  972. return rst;
  973. },
  974. updateCache: function(addArr, updateArr, removeIds, result) {
  975. let me = this, cacheSection = me.complementaryGljList;
  976. if (addArr.length > 0) {
  977. me.complementaryGljList = me.complementaryGljList.concat(addArr);
  978. cacheSection = me.complementaryGljList;
  979. }
  980. for (let i = removeIds.length - 1; i >= 0; i--) {
  981. for (let j = cacheSection.length - 1; j >= 0 ; j--) {
  982. if (cacheSection[j]["ID"] == removeIds[i]) {
  983. cacheSection.splice(j,1);
  984. }
  985. }
  986. }
  987. if (result && result.data && result.data.ops && result.data.ops.length > 0) {
  988. for (let i = 0; i < result.data.ops.length; i++) {
  989. for (let j = 0; j < cacheSection.length; j++) {
  990. if (cacheSection[j][me.setting.header[0].dataCode] == result.data.ops[i][me.setting.header[0].dataCode]) {
  991. cacheSection[j]["ID"] = result.data.ops[i]["ID"];
  992. }
  993. }
  994. }
  995. }
  996. for (let i = 0; i < updateArr.length; i++) {
  997. for (let j = 0; j < cacheSection.length; j++) {
  998. if (updateArr[i]["ID"] && cacheSection[j]["ID"]) {
  999. if (cacheSection[j]["ID"] == updateArr[i]["ID"]) {
  1000. cacheSection[j] = updateArr[i];
  1001. }
  1002. } else {
  1003. if (cacheSection[j][me.setting.header[0].dataCode] == updateArr[i][me.setting.header[0].dataCode]) {
  1004. cacheSection[j] = updateArr[i];
  1005. }
  1006. }
  1007. }
  1008. }
  1009. //allgljs
  1010. },
  1011. sortGlj: function(gljList) {
  1012. let me = this;
  1013. gljList.sort(function(a, b){
  1014. let rst = 0;
  1015. if (a.code > b.code) rst = 1
  1016. else if (a.code < b.code) rst = -1;
  1017. return rst;
  1018. });
  1019. }
  1020. }
  1021. let gljTypeTreeOprObj = {
  1022. onClick: function(event,treeId,treeNode) {
  1023. let me = repositoryGljObj,
  1024. that = gljComponentOprObj,
  1025. gljTypeId = treeNode.ID;
  1026. me.gljCurTypeId = treeNode.ID;
  1027. that.isLocked = true;
  1028. //me.currentCache = me.getCache();
  1029. sheetOpr.cleanSheet(that.workBook.getSheet(0), that.setting, 5);
  1030. that.workBook.getSheet(0).getRange(-1, 0 , -1, 1, GC.Spread.Sheets.SheetArea.viewport).locked(true);
  1031. that.workBook.getSheet(0).getRange(-1, 4 , -1, 1, GC.Spread.Sheets.SheetArea.viewport).locked(true);
  1032. me.workBook.getSheet(0).getRange(-1, 6 , -1, 1, GC.Spread.Sheets.SheetArea.viewport).locked(true);
  1033. //that.workBook.getSheet(0).options.isProtected = true;
  1034. if (me.parentNodeIds["_pNodeId_" + treeNode.ID]) {
  1035. me.currentOprParent = 1;
  1036. me.currentCache = me.getParentCache(me.parentNodeIds["_pNodeId_" + treeNode.ID]);
  1037. sheetOpr.lockCodeCells(me.workBook.getSheet(0), me.currentCache.length);
  1038. me.workBook.getSheet(0).setRowCount(me.currentCache.length);
  1039. } else {
  1040. me.currentOprParent = 0;
  1041. me.currentCache = me.getCache();
  1042. sheetOpr.unLockAllCells(me.workBook.getSheet(0));
  1043. sheetOpr.reLockSomeCodes(me.workBook.getSheet(0), 0, me.currentCache.length);
  1044. }
  1045. me.showGljItems(me.complementaryGljList, gljTypeId);
  1046. }
  1047. }