locate_view.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /**
  2. * Created by zhang on 2018/11/16.
  3. */
  4. let locateObject={
  5. bills_setting:{
  6. header:[
  7. {headerName: "编码", headerWidth: 120, dataCode: "code", dataType: "String"},
  8. {headerName: "项目名称", headerWidth: 100, dataCode: "name", dataType: "String"},
  9. {headerName: "单位", headerWidth: 50, dataCode: "unit", dataType: "String",hAlign: "center"},
  10. {headerName: "工程量", headerWidth: 65, dataCode: "quantity", dataType: "Number", hAlign: "right"},
  11. {headerName: "综合单价", headerWidth: 65, dataCode: "unitPrice", dataType: "Number", hAlign: "right"},
  12. {headerName: "综合合价", headerWidth: 65, dataCode: "totalPrice", dataType: "Number", hAlign: "right"}
  13. ],
  14. view: {
  15. lockColumns: [0,1,2,3,4,5],
  16. colHeaderHeight:30
  17. }
  18. },
  19. ration_setting:{
  20. header:[
  21. {headerName: "定额编码", headerWidth: 100, dataCode: "code", dataType: "String"},
  22. {headerName: "定额名称", headerWidth: 180, dataCode: "name", dataType: "String"},
  23. {headerName: "单位", headerWidth: 50, dataCode: "unit", dataType: "String",hAlign: "center"},
  24. {headerName: "工程量", headerWidth: 65, dataCode: "quantity", dataType: "Number", hAlign: "right",decimalField: "ration.quantity"}
  25. ],
  26. view: {
  27. lockColumns: [0,1,2,3],
  28. colHeaderHeight:30
  29. }
  30. },
  31. ration_glj_setting:{
  32. header:[
  33. {headerName: "编码", headerWidth: 120, dataCode: "code", dataType: "String"},
  34. {headerName: "名称", headerWidth: 80, dataCode: "name", dataType: "String"},
  35. {headerName: "规格型号", headerWidth: 80, dataCode: "code", dataType: "String"},
  36. {headerName: "单位", headerWidth: 50, dataCode: "unit", dataType: "String",hAlign: "center"},
  37. {headerName: "市场价", headerWidth: 65, dataCode: "marketPrice", dataType: "Number", hAlign: "right"}
  38. ],
  39. view: {
  40. lockColumns: [0,1,2,3,4],
  41. colHeaderHeight:30
  42. }
  43. },
  44. initMainSpread:function(){
  45. if(!this.mainSpread){
  46. this.mainSpread = SheetDataHelper.createNewSpread($("#locate_result")[0],3);
  47. sheetCommonObj.spreadDefaultStyle(this.mainSpread);
  48. this.initMainSheet();
  49. }else {
  50. this.mainSpread.refresh();
  51. }
  52. },
  53. initMainSheet:function () {
  54. // this.mainSheet = this.mainSpread .getSheet(0);
  55. //this.spread.bind(GC.Spread.Sheets.Events.ButtonClicked, this.onReplaceButtonClick);
  56. //初始化清单表格
  57. sheetCommonObj.initSheet(this.mainSpread .getSheet(0),this.bills_setting);
  58. this.mainSpread .getSheet(0).setRowCount(0);
  59. //初始化定额表格
  60. sheetCommonObj.initSheet(this.mainSpread .getSheet(1),this.ration_setting);
  61. this.mainSpread .getSheet(1).setRowCount(0);
  62. //初始化人材机表格
  63. sheetCommonObj.initSheet(this.mainSpread.getSheet(2),this.ration_glj_setting);
  64. this.mainSpread .getSheet(2).setRowCount(0);
  65. },
  66. initSubSpread:function () {
  67. if(!this.subSpread){
  68. this.subSpread = SheetDataHelper.createNewSpread($("#locate_sub")[0]);
  69. sheetCommonObj.spreadDefaultStyle(this.subSpread);
  70. this.initSubSheet();
  71. }else {
  72. this.subSpread.refresh();
  73. }
  74. },
  75. refreshWorkBook: function () {
  76. if (this.mainSpread) {
  77. this.mainSpread.refresh();
  78. }
  79. if (this.subSpread) {
  80. this.subSpread.refresh();
  81. }
  82. },
  83. initSubSheet:function () {
  84. this.subSheet = this.subSpread .getSheet(0);
  85. sheetCommonObj.initSheet( this.subSheet, this.ration_setting);
  86. this.subSheet.setRowCount(0);
  87. //this.spread.bind(GC.Spread.Sheets.Events.ButtonClicked, this.onReplaceButtonClick);
  88. this.subSheet.name('locate_sub');
  89. },
  90. showMainData:function () {
  91. let datas = [];
  92. //sheetCommonObj.showData(this.mainSheet,this.mainSettiong,datas);
  93. this.mainSpread.getActiveSheet().setRowCount(datas.length);
  94. },
  95. refreshView: function (options, refreshWorkBook) {
  96. let me = this;
  97. let mainHeight = $(window).height()-$(".header").height()-$(".toolsbar").height()-$("#searchPanel").height();
  98. let subHeight = 0;
  99. $('#locateTopDiv').height(mainHeight);
  100. $('#locate_result').height(mainHeight);
  101. $('#locateBottomDiv').height(subHeight);
  102. $('#locate_sub').height(subHeight - 7);
  103. if(options == "ration_glj"){
  104. let locateLibResize = getLocateLibResize();
  105. SlideResize.loadVerticalHeight(locateLibResize.eleObj.module, locateLibResize.eleObj, locateLibResize.limit, function () {
  106. locateObject.refreshWorkBook();
  107. });
  108. }
  109. if (refreshWorkBook) {
  110. me.refreshWorkBook();
  111. }
  112. },
  113. init:function () {
  114. let me = this;
  115. let options = $("input[name='content_type']:checked").val();
  116. let callback = function () {
  117. me.refreshView(options, false);
  118. me.initMainSpread();
  119. me.initSubSpread();
  120. me.showMainData();
  121. };
  122. options == "bills"?$("#outstandingOptions").show(0,callback):$("#outstandingOptions").hide(0,callback);
  123. },
  124. findRecodes:function () {
  125. },
  126. onshow:function () {
  127. locateObject.init();
  128. }
  129. }
  130. $("#locate_btn").click(function () {
  131. locateObject.findRecodes();
  132. });
  133. $("input[name='content_type']").each(function(){
  134. $(this).click(function(){
  135. let optins = $(this).val();
  136. switch (optins){
  137. case "bills":
  138. locateObject.mainSpread.setActiveSheetIndex(0);
  139. break;
  140. case "ration":
  141. locateObject.mainSpread.setActiveSheetIndex(1);
  142. break;
  143. case "ration_glj":
  144. locateObject.mainSpread.setActiveSheetIndex(2);
  145. break;
  146. }
  147. locateObject.init();
  148. });
  149. });