123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'selectpage'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'subscrip/activity/index',
- add_url: 'subscrip/activity/add',
- edit_url: 'subscrip/activity/edit',
- del_url: 'subscrip/activity/del',
- multi_url: 'subscrip/activity/multi',
- table: 'subscrip_activity',
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: __('Id'),operate:false},
- {field: 'title', title: __('Title')},
- {field: 'old_price', title: __('Old_price'), operate:false},
- {field: 'price', title: __('Price'), operate:false},
- {field: 'created_at', title: __('创建时间'),operate:false,formatter:Table.api.formatter.datetime},
- {field: 'days', title: __('活动周期(天)'),operate:false},
- {field: 'begin_date', title: __('Begin_date'),operate:false},
- {field: 'pop_space', title: __('弹窗位置'),operate:false},
- // {field: 'pop_img', title: __('Pop_img'),operate:false},
- {field: 'state', title: __("状态"),searchList: {"1":__('有效'),"2":__('失效')},formatter:function(value,row){
- if (row.state == 1){
- return '有效';
- }else{
- return '失效';
- }
- }},
- {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: function (value,row) {
- var html = '';
- if (row.is_begin == 0){
- if (row.state == 2) {
- html += '<a href="javascript:;" data-id="' + row.id + '" data-status="' + row.state + '" class="btn btn-xs btn-danger btn-lapse">有效</a> ';
- } else {
- html += '<a href="javascript:;" data-id="' + row.id + '" data-status="' + row.state + '" class="btn btn-xs btn-primary btn-lapse">失效</a> ';
- }
- html += '<a href="javascript:;" class="btn btn-dialog btn-xs btn-success btn-editone book_but">修改</a> ';
- html += '<a href="javascript:;" data-id="'+row.id+'" data-date="'+row.begin_date+'" class="btn btn-xs btn-success upload-user" title="" data-table-id="table">关联用户</a> ';
- }
- html += '<a href="javascript:;" data-id="'+row.id+'" class="btn btn-info btn-xs btn-detail">详情</a> ';
- html += '<a href="javascript:;" data-id="'+row.id+'" class="btn btn-success btn-collect btn-xs">数据统计</a> ';
- return html;
- }}
- ]
- ]
- });
- $(document).on('click','.upload-user',function () {
- var aid = $(this).data('id');
- var date = $(this).data('date');
- Fast.api.open('subscrip/activity/upload/aid/'+aid+'/date/'+date,'关联用户', {callback: function (data) {
- }});
- });
- $(document).on('click','.btn-collect',function () {
- var aid = $(this).data('id');
- Fast.api.open('subscrip/activecollect/index/aid/'+aid,'活动统计', {callback: function (data) {
- }});
- });
- $(document).on('click','.btn-detail',function () {
- var id = $(this).data('id');
- Fast.api.open('subscrip/activity/detail/id/'+id,'活动详情', {callback: function (data) {
- }});
- });
- // 失效 | 有效
- $(document).on('click','.btn-lapse',function(){
- var id = $(this).data('id');
- var state = $(this).data('status');
- var status_text = '确定要失效处理吗?';
- if(state == 2){
- status_text = '确定要设置为有效吗?';
- }
- Layer.confirm(status_text, function (idx) {
- $.post(
- 'subscrip/activity/ajaxLapse',
- {
- 'id': id,
- 'state': state
- },
- function (data) {
- layer.alert(data.msg);
- }
- );
- });
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- add: function () {
- Controller.api.bindevent();
- $(document).on('change', '#c-goods', function () {
- $('#c-price').val($(this).children('option:selected').data('money') );
- });
- },
- edit: function () {
- Controller.api.bindevent();
- },
- upload: function () {
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- $('#c-book').selectPage({
- eSelect : function(d){
- $('#c-book_book_name').val(d.name);
- $('#select_book_id').val(d.id);
- $('#c-chapter_text').val('');
- $('#c-chapter').val('');
- $('#select_chapter_id').val('');
- },
- params: function(){
- return {'custom':{state:'1'}}
- }
- });
- $('#c-chapter').selectPage({
- eSelect : function(d){
- $('#c-chapter_name').val(d.name);
- $('#select_chapter_id').val(d.id);
- },
- params: function(){
- return {'filter':'{"id":"'+$('#select_book_id').val()+'"}'}
- }
- });
- $('#c-chapter_text').val($('#c-chapter').val());
- Form.api.bindevent($("form[role=form]"));
- }
- }
- };
- return Controller;
- });
|