1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'privatebookpage/index',
- add_url: 'privatebookpage/add',
- edit_url: 'privatebookpage/edit',
- del_url: 'privatebookpage/del',
- table: 'private_book_page',
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: __('Id')},
- {field: 'title', title: __('Title'),operate:false},
- {field: 'url', title: __('页面地址'),operate:false, formatter: function (value, row, index) {
- return '/index/recharge/singlepage?page_id='+ row.id;
- }},
- {field: 'status', title: __('状态'), operate:false, formatter: function (value, row, index) {
- if (value == '0') {
- return "隐藏";
- }
- return "正常";
- }},
- {field: 'end_time', title: __('结束时间'), operate:false,formatter:Table.api.formatter.datetime},
- {field: 'createtime', title: __('创建时间'), operate:false,formatter:Table.api.formatter.datetime},
- {field: 'updatetime', title: __('更新时间'), operate:false,formatter:Table.api.formatter.datetime},
- {field: 'id', title: __('资源列表'),formatter: Controller.api.formatter.id},
- {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,formatter:function (value,row) {
- var html = '';
- html += '<a href="javascript:;" data-id="'+row.id+'" class="btn btn-xs btn-default clean-cache" >清除缓存 </a> ';
- html += '<a href="/admin/privatebookpage/edit/ids/"'+row.id+' class="btn btn-xs btn-success btn-editone"><i class="fa fa-pencil"></i></a> ';
- html+='<a href="javascript:;" class="btn btn-xs btn-danger btn-delone" ><i class="fa fa-trash"></i></a>';
- return html;
- }}
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- //btn-collect
- $(document).on('click','.clean-cache',function () {
- var id = $(this).attr('data-id');
- $.post('Privatebookpage/cleancache/id/'+id,function(res){
- console.log(res);
- if(res.code == 1){
- layer.alert('操作成功');
- }else{
- layer.alert('操作失败');
- }
- });
- });
- },
- add: function () {
- Controller.api.bindevent();
- },
- edit: function () {
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- },
- formatter: {
- id: function (value, row, index) {
- //这里手动构造URL
- url = "privatebookpageresource/index?page_id="+row.id;
- return '<a href="' + url + '" class="label label-success addtabsit" title="' + __("Search %s", value) + '">资源列表</a>';
- }
- }
- }
- };
- return Controller;
- });
|