define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { var Controller = { index: function () { // 初始化表格参数配置 Table.api.init({ extend: { index_url: 'customqrcode/index', add_url: 'customqrcode/add', edit_url: 'customqrcode/edit', del_url: 'customqrcode/del', multi_url: 'customqrcode/multi', table: 'custom_qrcode', } }); var table = $("#table"); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', sortName: 'id', columns: [ [ {checkbox: true}, {field: 'title', title: __('Title')}, {field: 'url', title: __('Url'),operate: false, formatter: Table.api.formatter.url}, {field: 'uv', title: __('UV'),operate: false}, {field: 'type', title: __('type'),searchList: {"0":__('Type0'),"1":__('Type1'),"2":__('Type2')},formatter: Controller.api.formatter.type_text}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: function (value, row, index) { var that = $.extend({}, this); var table = $(that.table).clone(true); if (row.type == 2) $(table).data("operate-edit", null); that.table = table; return Table.api.formatter.operate.call(that, value, row, index); }} ] ] }); // 为表格绑定事件 Table.api.bindevent(table); }, add: function () { Controller.api.bindevent(); }, edit: function () { Controller.api.bindevent(); }, api: { bindevent: function () { Form.api.bindevent($("form[role=form]")); var refreshkey = function (data) { $("input[name='row[eventkey]']").val(data.eventkey).trigger("change"); Layer.closeAll(); var keytitle = data.title; var cont = $(".clickbox .create-click:first"); $(".keytitle", cont).remove(); if (keytitle) { cont.append('
' + __('Event key') + ':' + keytitle + '
'); } }; $(document).on('click', "#select-resources", function () { var key = $("input[name='row[eventkey]']").val(); parent.Backend.api.open($(this).attr("href") + "?key=" + key, __('Select'), {callback: refreshkey}); return false; }); $(document).on('click', "#add-resources", function () { parent.Backend.api.open($(this).attr("href") + "?key=", __('Add'), {callback: refreshkey}); return false; }); }, formatter:{ type_text: function(value,row,index){return row.type_text;}, } } }; return Controller; });