1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'goods/index',
- add_url: 'goods/add',
- edit_url: 'goods/edit',
- del_url: 'goods/del',
- multi_url: 'goods/multi',
- table: 'goods',
- },
- showToggle:false,
- showColumns:false,
- showExport:false,
- searchFormVisible: true,
- });
- //绑定事件
- // $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
- // var panel = $($(this).attr("href"));
- // console.log('goods?category_id='+$(this).attr("href"));
- // if (panel.size() > 0) {
- // Controller.table[panel.attr("id")].call(this);
- // $(this).on('click', function (e) {
- // $('goods?category_id='+$(this).attr("href")).trigger("click");
- // });
- // }
- // //移除绑定的事件
- // // $(this).unbind('shown.bs.tab');
- // });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'weigh',
- columns: [
- [
- {checkbox: true},
- {field: 'title', title: __('Title'),operate:false},
- {field: 'category_id', title: __('Category_name'),searchList: $.getJSON('goods/categorylist'),formatter: Controller.api.formatter.category_name},
- {field: 'money', title: __('Money'),operate:false},
- {field: 'first_description', title: __('First_description'),operate:false},
- {field: 'second_description', title: __('Second_description'),operate:false},
- {field: 'type_text', title: __('Type'), operate:false},
- {field: 'kandian', title: __('Kandian'),operate:false},
- {field: 'free_kandian', title: __('Free_kandian'),operate:false},
- {field: 'day', title: __('Day'),operate:false},
- {field: 'icon', title: __('Icon'),operate:false},
- {field: 'show_type_text', title: __('Show_type'), operate:false},
- {field: 'weigh', title: __('Weigh'),operate:false},
- {field: 'updatetime', title: __('Updatetime'), formatter: Table.api.formatter.datetime,operate:false},
- {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- Controller.api.bindevent();
- },
- add: function () {
- Controller.api.bindevent();
- },
- edit: function () {
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- $(document).on("click", ".resource_type", function () {
- var type = $("input[name='row[type]']:checked").val();
- if(type==2){
- $('.day').removeAttr('style');
- $('.kandian').css('display','none');
- }
- if(type==1){
- $('.kandian').removeAttr('style');
- $('.day').css('display','none');
- }
- });
- },
- formatter: {
- category_name:function (value, row, index) {
- return row.category.name;
- }
- }
- }
- };
- return Controller;
- });
|