define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { var Controller = { index: function () { // 初始化表格参数配置 Table.api.init(); this.table.first(); this.table.second(); //绑定 $('#bind').click(function (e) { var ids = $('#table1').bootstrapTable('getSelections')[0]['id']; $.get('qcode_product/bind',{'ids':ids},function (data) { if(data.code==1){ Toastr.success(data.msg) $('#table2').bootstrapTable('refresh'); }else{ Toastr.error(data.msg) } },'json'); // layer.confirm('确定提交选中的 1 项?!', { // btn: ['确定', '取消'], // cancel: function(index, layero) { // } // },function (index) { // $.get('qcode_product/bind',{'ids':ids},function (data) { // if(data.code==1){ // Toastr.success(data.msg) // table2.bootstrapTable('refresh'); // }else{ // Toastr.error(data.msg) // } // },'json'); // Layer.close(index); // // },function (){}) }) //绑定 $('#unbind').click(function (e) { layer.confirm('确定提交选中的 1 项?!', { btn: ['确定', '取消'], cancel: function(index, layero) { } },function (index) { var ids = $('#table2').bootstrapTable('getSelections')[0]['id']; $.get('qcode_product/unbind',{'ids':ids},function (data) { if(data.code==1){ Toastr.success(data.msg) $('#table2').bootstrapTable('refresh'); }else{ Toastr.error(data.msg) } },'json'); Layer.close(index); },function (){}) }) }, table: { first: function () { // 表格1 var table1 = $("#table1"); table1.bootstrapTable({ url: 'qcode_product/table1', extend: { index_url: 'qcode_product/table1' + location.search, add_url: 'qcode_product/add', edit_url: 'qcode_product/edit', del_url: 'qcode_product/del', table: 'qcode_product', }, toolbar: '#toolbar1', pk: 'id', sortName: 'id', pageSize: 8, pageList: [8, 20, 50, 'All'], search: false, singleSelect: true, columns: [ [ {checkbox: true}, {field: 'product_code', title: __('Product_code'), operate: 'LIKE'}, {field: 'product_name', title: __('Product_name'), operate: 'LIKE'}, {field: 'temple', title: __('Temple'), operate: 'LIKE'}, {field: 'main_unit', title: __('Main_unit'), operate: 'LIKE'}, {field: 'sec_unit', title: __('Sec_unit'), operate: 'LIKE'}, {field: 'proportion', title: __('Proportion'), operate: 'LIKE'}, // {field: 'notes', title: __('Notes')}, // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ] }); // 为表格1绑定事件 Table.api.bindevent(table1); }, second: function () { // 表格2 var table2 = $("#table2"); table2.bootstrapTable({ url: 'qcode_product/table2', extend: { index_url: '', add_url: '', edit_url: '', del_url: '', multi_url: '', table: '', }, toolbar: '#toolbar2', pk: 'id', sortName: 'id', pageSize: 8, pageList: [8, 20, 50, 'All'], search: false, singleSelect: true, columns: [ [ {checkbox: true}, {field: 'product_code', title: __('Product_code'), operate: 'LIKE'}, {field: 'product_name', title: __('Product_name'), operate: 'LIKE'}, {field: 'temple', title: __('Temple'), operate: 'LIKE'}, {field: 'main_unit', title: __('Main_unit'), operate: 'LIKE'}, {field: 'sec_unit', title: __('Sec_unit'), operate: 'LIKE'}, {field: 'proportion', title: __('Proportion'), operate: 'LIKE'}, // {field: 'notes', title: __('Notes')}, // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ] }); // 为表格2绑定事件 Table.api.bindevent(table2); } }, /*recyclebin: function () { // 初始化表格参数配置 Table.api.init({ extend: { 'dragsort_url': '' } }); var table = $("#table"); // 初始化表格 table.bootstrapTable({ url: 'qcode_product/recyclebin' + location.search, pk: 'id', sortName: 'id', columns: [ [ {checkbox: true}, {field: 'id', title: __('Id')}, {field: 'name', title: __('Name'), align: 'left'}, { field: 'deletetime', title: __('Deletetime'), operate: 'RANGE', addclass: 'datetimerange', formatter: Table.api.formatter.datetime }, { field: 'operate', width: '140px', title: __('Operate'), table: table, events: Table.api.events.operate, buttons: [ { name: 'Restore', text: __('Restore'), classname: 'btn btn-xs btn-info btn-ajax btn-restoreit', icon: 'fa fa-rotate-left', url: 'qcode_product/restore', refresh: true }, { name: 'Destroy', text: __('Destroy'), classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit', icon: 'fa fa-times', url: 'qcode_product/destroy', refresh: true } ], formatter: Table.api.formatter.operate } ] ] }); // 为表格绑定事件 Table.api.bindevent(table); },*/ add: function () { Controller.api.bindevent(); }, edit: function () { Controller.api.bindevent(); }, api: { bindevent: function () { Form.api.bindevent($("form[role=form]")); } } }; return Controller; });