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'); }) //解绑 $('#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/products', extend: { index_url: 'qcode_product/products' + 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', sortOrder: 'asc', pageSize: 8, pageList: [8, 20, 50, 'All'], search: false, showToggle: false, showColumns: false, showExport: false, singleSelect: true, searchFormVisible: true, searchFormTemplate: 'customformtpl', columns: [ [ {checkbox: true}, {field: 'product_code', title: __('Product_code'), operate: 'LIKE'}, {field: 'product_name', title: __('Product_name'), operate: 'LIKE'}, {field: 'temple', title: __('Temple')}, {field: 'main_unit', title: __('Main_unit')}, {field: 'sec_unit', title: __('Sec_unit')}, {field: 'proportion', title: __('Proportion')}, {field: 'code', title: __('存货分类编码'), visible:false}, // {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/product', extend: { index_url: '', add_url: '', edit_url: '', del_url: '', multi_url: '', table: '', }, toolbar: '#toolbar2', pk: 'id', sortName: 'id', sortOrder: 'asc', pageSize: 8, pageList: [8, 20, 50, 'All'], search: false, showToggle: false, showColumns: false, showExport: 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: false}, {field: 'main_unit', title: __('Main_unit'), operate: false}, {field: 'sec_unit', title: __('Sec_unit'), operate: false}, {field: 'proportion', title: __('Proportion'), operate: false}, // {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); } }, add: function () { Controller.api.bindevent(); }, edit: function () { Controller.api.bindevent(); }, api: { bindevent: function () { Form.api.bindevent($("form[role=form]")); } } }; return Controller; });