1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'category/index',
- add_url: 'category/add',
- edit_url: 'category/edit',
- del_url: 'category/del',
- multi_url: 'category/multi',
- dragsort_url: '',
- table: 'category',
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- escape: false,
- pk: 'id',
- sortName: 'weigh',
- pagination: false,
- commonSearch: false,
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: __('Id')},
- {field: 'type', title: __('Type')},
- {field: 'name', title: __('Name'), align: 'left'},
- {field: 'nickname', title: __('Nickname')},
- {field: 'flag', title: __('Flag'), operate: false, formatter: Table.api.formatter.flag},
- {field: 'image', title: __('Image'), operate: false, formatter: Table.api.formatter.image},
- {field: 'weigh', title: __('Weigh')},
- {field: 'status', title: __('Status'), operate: false, formatter: Table.api.formatter.status},
- {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- add: function () {
- $(document).on('change', '#c-channel_id', function () {
- Fast.api.ajax({url: 'goods/get_channel_fields', data: {channel_id: $(this).val()}}, function (data) {
- $("#extend").html(data.html);
- Form.api.bindevent($("#extend"));
- return false;
- });
- });
- $("#c-channel_id").trigger("change");
- Controller.api.bindevent();
- },
- edit: function () {
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- $(document).on("change", "#c-type", function () {
- $("#c-pid option[data-type='all']").prop("selected", true);
- $("#c-pid option").removeClass("hide");
- $("#c-pid option[data-type!='" + $(this).val() + "'][data-type!='all']").addClass("hide");
- $("#c-pid").selectpicker("refresh");
- });
- Form.api.bindevent($("form[role=form]"));
- }
- }
- };
- return Controller;
- });
|