123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'couponuser/index/coupon_id/' + Config.coupon_id + location.search,
- // add_url: 'couponuser/add',
- // edit_url: 'couponuser/edit',
- // del_url: 'couponuser/del',
- // multi_url: 'couponuser/multi',
- // import_url: 'couponuser/import',
- table: 'user',
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- fixedColumns: true,
- fixedRightNumber: 1,
- showToggle: false,
- showColumns: false,
- showExport: false,
- columns: [
- [
- {field: 'state', checkbox: true},
- {field: 'id', title: __('Id')},
- {field: 'username', title: __('Username'), operate: 'LIKE'},
- {field: 'nickname', title: __('Nickname'), operate: 'LIKE'},
- {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
- {field: 'avatar', title: __('Avatar'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
- {field: 'money', title: __('Money'), operate: 'LIKE'},
- {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.status,
- custom: {1:'success',2:'danger'}},
- {field: 'realname', title: __('Realname'), operate: 'LIKE'},
- {field: 'gender', title: __('Gender'), searchList: {"1":__('Gender 1'),"2":__('Gender 2')}, formatter: Table.api.formatter.normal},
- {field: 'birthday', title: __('Birthday'),formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
- {field: 'idcard', title: __('Idcard'), operate: 'LIKE'},
- {field: 'passport', title: __('Passport'), operate: 'LIKE'},
- {field: 'emergencycontact', title: __('Emergencycontact'), operate: 'LIKE'},
- {field: 'contactmobile', title: __('Contactmobile'), operate: 'LIKE'},
- {field: 'outdoorduration', title: __('Outdoorduration'), operate: 'LIKE'},
- {field: 'invite_no', title: __('Invite_no'), operate: 'LIKE'},
- {field: 'growthvalue', title: __('Growthvalue')},
- {field: 'growthlevel', title: __('Growthlevel')},
- {field: 'experiencelevel', title: __('Experiencelevel')},
- {field: 'experiencetime', title: __('Experiencetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
- {field: 'maxlevel', title: __('Maxlevel')},
- {field: 'freenumber', title: __('Freenumber')},
- {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,
- buttons: [
- {
- name: 'giveout',
- text: '发放',
- title: __('发放'),
- extend: 'data-area=\'["85%", "85%"]\'',
- classname: 'btn btn-xs btn-success btn-ajax',
- icon: 'fa fa-pencil',
- confirm: '确认发放?',
- url: 'couponuser/giveout/coupon_id/' + Config.coupon_id,
- // refresh: true,
- // success: function (data, ret) {
- // // Layer.alert(ret.msg + ",返回数据:" + JSON.stringify(data));
- // Layer.alert(ret.msg);
- // //如果需要阻止成功提示,则必须使用return false;
- // return false;
- // },
- // error: function (data, ret) {
- // // console.log(data, ret);
- // Layer.alert(ret.msg);
- // return false;
- // },
- // callback: function (data) {
- // Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
- // },
- // visible: function (row) {
- // if (row.status == 0) {
- // return true;
- // } else {
- // return false;
- // }
- // }
- }
- ]
- }
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- // 获取选中项
- $(document).on("click", ".btn-selected", function () {
- var that = this;
- var ids = Table.api.selectedids(table);
- Layer.confirm('确认发放?', function (index) {
- // Layer.alert(JSON.stringify(Table.api.selectedids(table)));
- Table.api.multi('couponuser/giveout/coupon_id/' + Config.coupon_id, ids.join(","), table, that);
- Layer.close(index);
- });
- });
- },
- add: function () {
- Controller.api.bindevent();
- },
- edit: function () {
- Controller.api.bindevent();
- },
- selected: function () {
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- }
- }
- };
- return Controller;
- });
|