| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218 |
- 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;
- });
|