123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'selectpage'], function ($, undefined, Backend, Table, Form,Selectpage) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'bookchargesetting/index',
- add_url: 'bookchargesetting/add',
- edit_url: 'bookchargesetting/edit',
- del_url: 'bookchargesetting/del',
- multi_url: 'bookchargesetting/multi',
- table: 'book_charge_setting',
- },
- search: false
- });
- $(document).on('click','.layer-open',function () {
- Fast.api.open($(this).attr('href'), $(this).data('title')?$(this).data('title'):'配置公共信息', {});
- return false;
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: __('Id'), operate: false},
- {field: 'chapter_charge_start', title: __('Chapter_charge_start'), operate: false},
- {field: 'chapter_kandian', title: __('Chapter_kandian'), operate: false},
- {field: 'book_id', title: __('Book_id')},
- {field: 'name', title: '书籍名称', operate: false},
- {
- field: 'status',
- title: __('Status'),
- visible: false,
- searchList: {"normal": __('status normal'), "hide": __('status hide')}
- },
- {field: 'status_text', title: __('Status'), operate: false},
- {
- field: 'createtime',
- title: __('Createtime'),
- operate: false,
- formatter: Table.api.formatter.datetime
- },
- {
- field: 'updatetime',
- title: __('Updatetime'),
- operate: false,
- formatter: Table.api.formatter.datetime
- },
- {
- field: 'operate',
- title: __('Operate'),
- table: table,
- events: Table.api.events.operate,
- formatter: Table.api.formatter.operate
- }
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- add: function () {
- var selectdata = '';
- $('#c-book_book_name').selectPage({
- eAjaxSuccess : function(d){
- if(selectdata && JSON.stringify(selectdata) != JSON.stringify(d)){
- $('#c-book_id').val('');
- }
- selectdata = d;
- return d ? d : '';
- },
- eSelect : function(d){
- selectdata = '';
- $('#c-book_book_name').val(d.name);
- $('#c-book_id').val(d.id);
- },
- eClear : function(){
- $('#c-book_id').val('');
- }
- });
- Controller.api.bindevent();
- },
- edit: function () {
- var selectdata = '';
- $('#c-book_book_name').selectPage({
- eAjaxSuccess : function(d){
- if(selectdata && JSON.stringify(selectdata) != JSON.stringify(d)){
- $('#c-book_id').val('');
- }
- selectdata = d;
- return d ? d : '';
- },
- eSelect : function(d){
- selectdata = '';
- $('#c-book_book_name').val(d.name);
- $('#c-book_id').val(d.id);
- },
- eClear : function(){
- $('#c-book_id').val('');
- }
- });
- if(Config.bnotin.length>0){
- if(Config.bnotin.indexOf(parseInt($('#c-book_id').val())) != -1){
- $('#c-book_id').val('');
- $('#c-book_book_name').val('');
- }
- }
- Controller.api.bindevent();
- },
- setting: function () {
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- }
- }
- };
- return Controller;
- });
|