feeRate.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /**
  2. * Created by CSL on 2017-03-23.
  3. */
  4. function loadLibFiles(region) {
  5. $('#inlineFormCustomSelect').empty();
  6. $.ajax({
  7. type: "POST",
  8. url: '/fees/getLibFiles',
  9. data: {"region": region},
  10. success: function (result) {
  11. if (result.data) {
  12. for (var i = 0; i < result.data.length; i++) {
  13. $("#inlineFormCustomSelect").append("<option value=" + result.data[i].fileID + '>' +
  14. result.data[i].fileName + "</option>");
  15. }
  16. $("#inlineFormCustomSelect").get(0).selectedIndex = 0;
  17. var fileID = $("#inlineFormCustomSelect").val();
  18. loadLibFees(fileID);
  19. }
  20. },
  21. error: function (result) {
  22. alert('内部程序错误!');
  23. }
  24. });
  25. }
  26. function loadLibFees(fileID) {
  27. $.ajax({
  28. type: "POST",
  29. url: '/fees/getLibFees',
  30. data: {"fileID": fileID},
  31. success: function (result) {
  32. if (result.data) {
  33. createSpreadView(result.data[0].fees);
  34. }
  35. },
  36. error: function (result) {
  37. alert('内部程序错误!');
  38. }
  39. });
  40. }
  41. function createSpreadView(data) {
  42. // 创建前先销毁旧树表。
  43. //$('#divFee').empty(); // 清空不行,浏览器跟踪显示错误数狂飚:TypeError: G is null
  44. $('#divFee').remove();
  45. $('#content').append($('<div class="grid" id="divFee"></div>'));
  46. var columns = [
  47. {
  48. id: 'name',
  49. caption: '名称',
  50. dataField: 'name',
  51. width: 250
  52. },
  53. {
  54. id: 'fee',
  55. caption: '费率',
  56. dataField: 'fee',
  57. format: '0.000',
  58. width: 80,
  59. minWidth: 50
  60. },
  61. {
  62. id: 'memo',
  63. caption: '说明',
  64. dataField: 'memo',
  65. width: 200,
  66. minWidth: 120
  67. },
  68. {
  69. id: 'ID',
  70. caption: 'ID',
  71. dataField: 'ID',
  72. width: 80,
  73. visible: false
  74. },
  75. {
  76. id: 'ParentID',
  77. caption: '父结点ID',
  78. dataField: 'ParentID',
  79. width: 80,
  80. visible: false
  81. }
  82. ];
  83. var option = {
  84. allowSorting: false,
  85. showRowHeader: true,
  86. colMinWidth: 80,
  87. colHeaderHeight: 35,
  88. rowHeight: 30,
  89. allowEditing: true,
  90. hierarchy: {
  91. keyField: 'ID',
  92. parentField: 'ParentID',
  93. collapsed: false,
  94. column: 'name'
  95. }
  96. };
  97. var dataView = new GC.Spread.Views.DataView(document.getElementById('divFee'),
  98. data, columns, new GC.Spread.Views.Plugins.GridLayout(option));
  99. var opts = dataView.layoutEngine.options;
  100. opts.editMode = 'inline';
  101. opts.editUnit = 'cell';
  102. opts.selectionUnit = 'cell';
  103. dataView.invalidate();
  104. document.querySelector('#divFee').focus();
  105. }