| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 |
- 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/index',
- extend: {
- index_url: 'qcode_product/index' + location.search,
- table: '工单_基本资料',
- add_url: 'qcode_product/add',
- },
- toolbar: '#toolbar1',
- pk: 'Uniqid',
- sortName: 'Uniqid',
- sortOrder: 'desc',
- pageSize: 8,
- pageList: [8, 20, 50, 'All'],
- search: true,
- showToggle: false,
- showColumns: false,
- showExport: false,
- singleSelect: false,
- columns: [
- [
- {checkbox: true},
- {field: 'Gd_gdbh', title: '工单编号', operate: 'LIKE'},
- {field: 'Gd_cpdh', title: __('产品代号'), operate: 'LIKE'},
- {field: 'Gd_cpmc', title: '产品名称', operate: 'LIKE'}
- ]
- ]
- });
- // 为表格1绑定事件
- Table.api.bindevent(table1);
- // 绑定自定义按钮点击事件
- $(".btn-operate").click(function() {
- var ids = Table.api.selectedids(table1);
- if (ids.length == 0) {
- Toastr.error("请至少选择一条记录");
- return false;
- }
- console.log(ids);
- $.ajax({
- url: 'qcode_product/bind',
- type: 'GET',
- dataType: 'json',
- data: {
- ids: ids
- },
- success: function(response) {
- },
- });
- });
- },
- 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: 'Gd_gdbh', title: '工单编号', operate: 'LIKE'},
- {field: 'Gd_cpdh', title: __('产品代号'), operate: 'LIKE'},
- {field: 'Gd_cpmc', title: '产品名称', 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);
- }
- // 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: 'Gd_gdbh', title: '工单编号', 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;
- });
|