123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'area/index' + location.search,
- edit_url: 'area/edit',
- multi_url: 'area/multi',
- import_url: 'area/import',
- table: 'area',
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- searchFormVisible:true,
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: __('地区ID'), operate: '=',
- searchList: function (column) {
- return Template('sourcetpl', {})
- }},
- {field: 'name', title: __('Name'), operate: false},
- {field: 'first_air_amount', title: __('出港费'), operate:false,formatter(a,b){
- if(!b.first_air_amount){
- return '未设置'
- }
- return b.first_air_amount
- }},
- {field: 'second_air_amount', title: __('Second_air_amount'), operate:false,formatter(a,b){
- if(!b.second_air_amount){
- return '未设置'
- }
- return b.second_air_amount
- }},
- {field: 'latitude', title: __('机场坐标'), operate:false,formatter: function (a, b, c) {
- let str=''
- if(b.air_longitude){
- str+=b.air_longitude
- }
- if(b.air_latitude){
- str=str+","+b.air_latitude
- }
- if(str===''){
- return "未设置"
- }
- return str;
- }},
- {
- field: 'operate',
- title: __('Operate'),
- table: table,
- events: Table.api.events.operate,
- formatter: Table.api.formatter.buttons,
- buttons:[
- {
- name: 'detail',
- text: __('设置机场位置'),
- title: __('设置机场位置'),
- classname: 'btn btn-xs btn-info btn-dialog set-ll',
- icon: 'fa',
- url: 'area/air_set',
- callback: function (data) {
- //Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
- $('.btn-refresh').trigger('click')
- },
- visible: function (row) {
- //返回true时按钮显示,返回false隐藏
- return true;
- }
- },
- {
- name: 'detail',
- text: __('编辑'),
- title: __('编辑'),
- classname: 'btn btn-xs btn-primary btn-dialog',
- icon: 'fa',
- url: 'area/edit',
- callback: function (data) {
- //Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
- $('.btn-refresh').trigger('click')
- },
- visible: function (row) {
- //返回true时按钮显示,返回false隐藏
- return true;
- }
- }
- ],
- },
- ]
- ],
- onLoadSuccess(){
- $(".set-ll").data("area", ['500px','100%']);
- $(".set-ll").data("shade", [0.5,"#000"]);
- }
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- $('.btn-multi-coordinate').click(function(){
- let a=$(this)
- let ids=[]
- $('#table').bootstrapTable('getSelections').forEach(item=>{
- ids.push(item.id)
- })
- Fast.api.open(`${a.data('href')}/ids/${ids.join(',')}`,a.text(),{
- area:['500px','100%'],
- callback(){
- $('.btn-refresh').trigger('click')
- }
- })
- })
- $('.btn-multi-price').click(function(){
- let a=$(this)
- let ids=[]
- $('#table').bootstrapTable('getSelections').forEach(item=>{
- ids.push(item.id)
- })
- Fast.api.open(`${a.data('href')}/ids/${ids.join(',')}`,a.text(),{
- area:['500px','100%'],
- callback(){
- $('.btn-refresh').trigger('click')
- }
- })
- })
- },
- add: function () {
- Controller.api.bindevent();
- },
- edit: function () {
- Controller.api.bindevent();
- },
- air_set: function () {
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- }
- }
- };
- return Controller;
- });
|