locate_view.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. initSubSheet:function () {
  76. this.subSheet = this.subSpread .getSheet(0);
  77. sheetCommonObj.initSheet( this.subSheet, this.ration_setting);
  78. this.subSheet.setRowCount(0);
  79. //this.spread.bind(GC.Spread.Sheets.Events.ButtonClicked, this.onReplaceButtonClick);
  80. this.subSheet.name('locate_sub');
  81. },
  82. showMainData:function () {
  83. let datas = [];
  84. //sheetCommonObj.showData(this.mainSheet,this.mainSettiong,datas);
  85. this.mainSpread.getActiveSheet().setRowCount(datas.length);
  86. },
  87. init:function () {
  88. let me = this;
  89. let options = $("input[name='content_type']:checked").val();
  90. let callback = function () {
  91. let mainHeight = $(window).height()-$(".header").height()-$(".toolsbar").height()-$("#searchPanel").height();
  92. let subHeight = 0;
  93. if(options == "ration_glj"){
  94. subHeight = mainHeight*0.4;
  95. mainHeight = mainHeight*0.6;
  96. }
  97. console.log(mainHeight);
  98. $('#locate_result').height(mainHeight);
  99. $('#locate_sub').height(subHeight - 7);
  100. me.initMainSpread();
  101. me.initSubSpread();
  102. me.showMainData();
  103. };
  104. options == "bills"?$("#outstandingOptions").show(0,callback):$("#outstandingOptions").hide(0,callback);
  105. },
  106. findRecodes:function () {
  107. },
  108. onshow:function () {
  109. locateObject.init();
  110. }
  111. }
  112. $("#locate_btn").click(function () {
  113. locateObject.findRecodes();
  114. });
  115. $("input[name='content_type']").each(function(){
  116. $(this).click(function(){
  117. let optins = $(this).val();
  118. switch (optins){
  119. case "bills":
  120. locateObject.mainSpread.setActiveSheetIndex(0);
  121. break;
  122. case "ration":
  123. locateObject.mainSpread.setActiveSheetIndex(1);
  124. break;
  125. case "ration_glj":
  126. locateObject.mainSpread.setActiveSheetIndex(2);
  127. break;
  128. }
  129. locateObject.init();
  130. });
  131. });