area.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. searchFormVisible:true,
  21. columns: [
  22. [
  23. {checkbox: true},
  24. {field: 'id', title: __('地区ID'), operate: '=',
  25. searchList: function (column) {
  26. return Template('sourcetpl', {})
  27. }},
  28. {field: 'name', title: __('Name'), operate: false},
  29. {field: 'first_air_amount', title: __('出港费'), operate:false,formatter(a,b){
  30. if(!b.first_air_amount){
  31. return '未设置'
  32. }
  33. return b.first_air_amount
  34. }},
  35. {field: 'second_air_amount', title: __('Second_air_amount'), operate:false,formatter(a,b){
  36. if(!b.second_air_amount){
  37. return '未设置'
  38. }
  39. return b.second_air_amount
  40. }},
  41. {field: 'latitude', title: __('机场坐标'), operate:false,formatter: function (a, b, c) {
  42. let str=''
  43. if(b.air_longitude){
  44. str+=b.air_longitude
  45. }
  46. if(b.air_latitude){
  47. str=str+","+b.air_latitude
  48. }
  49. if(str===''){
  50. return "未设置"
  51. }
  52. return str;
  53. }},
  54. {
  55. field: 'operate',
  56. title: __('Operate'),
  57. table: table,
  58. events: Table.api.events.operate,
  59. formatter: Table.api.formatter.buttons,
  60. buttons:[
  61. {
  62. name: 'detail',
  63. text: __('设置机场位置'),
  64. title: __('设置机场位置'),
  65. classname: 'btn btn-xs btn-info btn-dialog set-ll',
  66. icon: 'fa',
  67. url: 'area/air_set',
  68. callback: function (data) {
  69. //Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
  70. $('.btn-refresh').trigger('click')
  71. },
  72. visible: function (row) {
  73. //返回true时按钮显示,返回false隐藏
  74. return true;
  75. }
  76. },
  77. {
  78. name: 'detail',
  79. text: __('编辑'),
  80. title: __('编辑'),
  81. classname: 'btn btn-xs btn-primary btn-dialog',
  82. icon: 'fa',
  83. url: 'area/edit',
  84. callback: function (data) {
  85. //Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
  86. $('.btn-refresh').trigger('click')
  87. },
  88. visible: function (row) {
  89. //返回true时按钮显示,返回false隐藏
  90. return true;
  91. }
  92. }
  93. ],
  94. },
  95. ]
  96. ],
  97. onLoadSuccess(){
  98. $(".set-ll").data("area", ['500px','100%']);
  99. $(".set-ll").data("shade", [0.5,"#000"]);
  100. }
  101. });
  102. // 为表格绑定事件
  103. Table.api.bindevent(table);
  104. $('.btn-multi-coordinate').click(function(){
  105. let a=$(this)
  106. let ids=[]
  107. $('#table').bootstrapTable('getSelections').forEach(item=>{
  108. ids.push(item.id)
  109. })
  110. Fast.api.open(`${a.data('href')}/ids/${ids.join(',')}`,a.text(),{
  111. area:['500px','100%'],
  112. callback(){
  113. $('.btn-refresh').trigger('click')
  114. }
  115. })
  116. })
  117. $('.btn-multi-price').click(function(){
  118. let a=$(this)
  119. let ids=[]
  120. $('#table').bootstrapTable('getSelections').forEach(item=>{
  121. ids.push(item.id)
  122. })
  123. Fast.api.open(`${a.data('href')}/ids/${ids.join(',')}`,a.text(),{
  124. area:['500px','100%'],
  125. callback(){
  126. $('.btn-refresh').trigger('click')
  127. }
  128. })
  129. })
  130. },
  131. add: function () {
  132. Controller.api.bindevent();
  133. },
  134. edit: function () {
  135. Controller.api.bindevent();
  136. },
  137. air_set: function () {
  138. Controller.api.bindevent();
  139. },
  140. api: {
  141. bindevent: function () {
  142. Form.api.bindevent($("form[role=form]"));
  143. }
  144. }
  145. };
  146. return Controller;
  147. });