123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'books/books_level/index' + location.search,
- add_url: 'books/books_level/add',
- edit_url: 'books/books_level/edit',
- del_url: 'books/books_level/del',
- multi_url: 'books/books_level/multi',
- import_url: 'books/books_level/import',
- table: 'books_level',
- }
- });
- 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: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
- // {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
- {field: 'is_deleted', title: __('是否已删除'), searchList: {"0":__('是'),"1":__('否')}, formatter: Table.api.formatter.normal},
- {field: 'sort', title: __('Sort')},
- {field: 'status', title: __('状态'), searchList: {"0":__('正常'),"1":__('禁用')}, formatter: Table.api.formatter.status},
- {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
- {
- field: 'operate',
- title: __('Operate'),
- table: table,
- events: Table.api.events.operate,
- formatter: Table.api.formatter.operate,
- buttons: [{
- name: 'click',
- text:'启用',
- title: __('启用'),
- classname: 'btn btn-xs btn-info btn-click',
- url: 'books.books_level/edit?ids/{id}',
- data: {status:0},
- // icon: 'fa fa-leaf',
- click: function (data,row) {
- var temp=table.bootstrapTable('getSelections');
- var id = row.id;
- console.log(row);
- return $.ajax({
- // url:'http://up.kuman.cn/settle/cancel',
- url:'books.books_level/update_status?ids='+id,
- type:'post',
- // dataType:'json',
- data:{status:0},
- success:function(data){
- if(data.code === 1){
- layer.msg('操作成功');
- window.location.reload();
- }else{
- layer.msg(data.msg);
- }
- }
- });
- // Layer.alert("点击按钮执行的事件");
- },
- visible: function (row) {
- console.log(row)
- if (row.status === "1"){
- return true;
- }
- return false;
- },
- refresh:true,
- },
- {
- name: 'click',
- text:'禁用',
- title: __('禁用'),
- classname: 'btn btn-xs btn-danger btn-click',
- url: 'books.books_level/edit?ids/{id}',
- data: {status:1},
- // icon: 'fa fa-leaf',
- click: function (data,row) {
- var temp=table.bootstrapTable('getSelections');
- var id = row.id;
- console.log(row);
- return $.ajax({
- // url:'http://up.kuman.cn/settle/cancel',
- url:'books.books_level/update_status?ids='+id,
- type:'post',
- // dataType:'json',
- data:{status:1},
- success:function(data){
- if(data.code === 1){
- layer.msg('操作成功');
- window.location.reload();
- }else{
- layer.alert(data.msg);
- }
- }
- });
- // Layer.alert("点击按钮执行的事件");
- },
- visible: function (row) {
- // console.log(row)
- if (row.status === "0"){
- return true;
- }
- return false;
- },
- refresh: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;
- });
|