|
@@ -0,0 +1,162 @@
|
|
|
|
+define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
|
|
|
+
|
|
|
|
+ var Controller = {
|
|
|
|
+ index: function () {
|
|
|
|
+ // 初始化表格参数配置
|
|
|
|
+ Table.api.init({
|
|
|
|
+ extend: {
|
|
|
|
+ index_url: 'coupon/index' + location.search,
|
|
|
|
+ add_url: 'coupon/add',
|
|
|
|
+ // edit_url: 'coupon/edit',
|
|
|
|
+ // del_url: 'coupon/del',
|
|
|
|
+ multi_url: 'coupon/multi',
|
|
|
|
+ import_url: 'coupon/import',
|
|
|
|
+ table: 'coupon',
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ var table = $("#table");
|
|
|
|
+
|
|
|
|
+ // 初始化表格
|
|
|
|
+ table.bootstrapTable({
|
|
|
|
+ url: $.fn.bootstrapTable.defaults.extend.index_url,
|
|
|
|
+ pk: 'id',
|
|
|
|
+ sortName: 'weigh',
|
|
|
|
+ fixedColumns: true,
|
|
|
|
+ fixedRightNumber: 1,
|
|
|
|
+ columns: [
|
|
|
|
+ [
|
|
|
|
+ {checkbox: true},
|
|
|
|
+ {field: 'id', title: __('Id')},
|
|
|
|
+ {field: 'title', title: __('Title'), operate: 'LIKE'},
|
|
|
|
+ {field: 'desc', title: __('Desc'), operate: 'LIKE'},
|
|
|
|
+ {field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2')}, formatter: Table.api.formatter.normal},
|
|
|
|
+ {field: 'money', title: __('Money')},
|
|
|
|
+ {field: 'minmoney', title: __('Minmoney')},
|
|
|
|
+ {field: 'purpose', title: __('Purpose'), searchList: {"0":__('Purpose 0'),"1":__('Purpose 1'),"2":__('Purpose 2'),"3":__('Purpose 3'),"4":__('Purpose 4'),"5":__('Purpose 5')}, formatter: Table.api.formatter.normal},
|
|
|
|
+ {field: 'effectiveday', title: __('Effectiveday')},
|
|
|
|
+ {field: 'weigh', title: __('Weigh'), operate: false},
|
|
|
|
+ {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.status},
|
|
|
|
+ {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
|
|
|
|
+ {field: 'updatetime', title: __('Updatetime'), 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: 'chanagestatus',
|
|
|
|
+ text: '发布',
|
|
|
|
+ title: __('发布'),
|
|
|
|
+ extend: 'data-area=\'["85%", "85%"]\'',
|
|
|
|
+ classname: 'btn btn-xs btn-success btn-ajax',
|
|
|
|
+ icon: 'fa fa-pencil',
|
|
|
|
+ confirm: '确认发布?',
|
|
|
|
+ url: 'coupon/chanagestatus/status/1',
|
|
|
|
+ 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;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ name: 'chanagestatus',
|
|
|
|
+ text: '下架',
|
|
|
|
+ title: __('下架'),
|
|
|
|
+ extend: 'data-area=\'["85%", "85%"]\'',
|
|
|
|
+ classname: 'btn btn-xs btn-danger btn-ajax',
|
|
|
|
+ icon: 'fa fa-pencil',
|
|
|
|
+ confirm: '确认下架?',
|
|
|
|
+ url: 'coupon/chanagestatus/status/2',
|
|
|
|
+ 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 == 1) {
|
|
|
|
+ return true;
|
|
|
|
+ } else {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ name: 'delcoupon',
|
|
|
|
+ text: '删除',
|
|
|
|
+ title: __('删除'),
|
|
|
|
+ extend: 'data-area=\'["85%", "85%"]\'',
|
|
|
|
+ classname: 'btn btn-xs btn-danger btn-ajax',
|
|
|
|
+ icon: 'fa fa-trash',
|
|
|
|
+ confirm: '确认删除?',
|
|
|
|
+ url: 'coupon/delcoupon',
|
|
|
|
+ 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 == 2) {
|
|
|
|
+ return true;
|
|
|
|
+ } else {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ ]
|
|
|
|
+ }
|
|
|
|
+ ]
|
|
|
|
+ ]
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // 为表格绑定事件
|
|
|
|
+ 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;
|
|
|
|
+});
|