1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'building/info/index' + location.search,
- add_url: 'building/info/add',
- edit_url: 'building/info/edit',
- del_url: 'building/info/del',
- multi_url: 'building/info/multi',
- import_url: 'building/info/import',
- table: 'building_info',
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: __('Id')},
- {field: 'content', title: __('Content')},
- {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
- ]
- ]
- });
- // 给上传按钮添加上传成功事件
- $("#faupload-avatar").data("upload-success", function (data) {
- var url = Backend.api.cdnurl(data.url);
- $(".profile-user-img").prop("src", url);
- Toastr.success("上传成功!");
- });
- // 给表单绑定事件
- Form.api.bindevent($("#update-form"), function () {
- $("input[name='row[password]']").val('');
- var url = Backend.api.cdnurl($("#c-avatar").val());
- top.window.$(".user-panel .image img,.user-menu > a > img,.user-header > img").prop("src", url);
- return true;
- });
- // 为表格绑定事件
- 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;
- });
|