area.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. Table.api.init({
  6. extend: {
  7. index_url: 'area/index' + location.search,
  8. edit_url: 'area/edit',
  9. multi_url: 'area/multi',
  10. import_url: 'area/import',
  11. table: 'area',
  12. }
  13. });
  14. var table = $("#table");
  15. // 初始化表格
  16. table.bootstrapTable({
  17. url: $.fn.bootstrapTable.defaults.extend.index_url,
  18. pk: 'id',
  19. sortName: 'id',
  20. columns: [
  21. [
  22. //{checkbox: true},
  23. {field: 'id', title: __('地区ID'), operate: '='},
  24. {field: 'name', title: __('Name'), operate: 'LIKE'},
  25. {field: 'first_air_amount', title: __('First_air_amount'), operate:'BETWEEN',formatter(a,b){
  26. if(!b.first_air_amount){
  27. return '未设置'
  28. }
  29. return b.first_air_amount
  30. }},
  31. {field: 'second_air_amount', title: __('Second_air_amount'), operate:'BETWEEN',formatter(a,b){
  32. if(!b.second_air_amount){
  33. return '未设置'
  34. }
  35. return b.second_air_amount
  36. }},
  37. {field: 'latitude', title: __('机场坐标'), operate:false,formatter: function (a, b, c) {
  38. let str=''
  39. if(b.air_longitude){
  40. str+=b.air_longitude
  41. }
  42. if(b.air_latitude){
  43. str=str+","+b.air_latitude
  44. }
  45. if(str===''){
  46. return "未设置"
  47. }
  48. return str;
  49. }},
  50. {
  51. field: 'operate',
  52. title: __('Operate'),
  53. table: table,
  54. events: Table.api.events.operate,
  55. formatter: Table.api.formatter.buttons,
  56. buttons:[
  57. {
  58. name: 'detail',
  59. text: __('设置机场位置'),
  60. title: __('设置机场位置'),
  61. classname: 'btn btn-xs btn-info btn-dialog set-ll',
  62. icon: 'fa',
  63. url: 'area/air_set',
  64. callback: function (data) {
  65. //Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
  66. $('.btn-refresh').trigger('click')
  67. },
  68. visible: function (row) {
  69. //返回true时按钮显示,返回false隐藏
  70. return true;
  71. }
  72. },
  73. {
  74. name: 'detail',
  75. text: __('编辑'),
  76. title: __('编辑'),
  77. classname: 'btn btn-xs btn-primary btn-dialog',
  78. icon: 'fa',
  79. url: 'area/edit',
  80. callback: function (data) {
  81. //Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
  82. $('.btn-refresh').trigger('click')
  83. },
  84. visible: function (row) {
  85. //返回true时按钮显示,返回false隐藏
  86. return true;
  87. }
  88. }
  89. ],
  90. },
  91. ]
  92. ],
  93. onLoadSuccess(){
  94. $(".set-ll").data("area", ['500px','100%']);
  95. $(".set-ll").data("shade", [0.5,"#000"]);
  96. }
  97. });
  98. // 为表格绑定事件
  99. Table.api.bindevent(table);
  100. },
  101. add: function () {
  102. Controller.api.bindevent();
  103. },
  104. edit: function () {
  105. Controller.api.bindevent();
  106. },
  107. air_set: function () {
  108. Controller.api.bindevent();
  109. },
  110. api: {
  111. bindevent: function () {
  112. Form.api.bindevent($("form[role=form]"));
  113. }
  114. }
  115. };
  116. return Controller;
  117. });