/** * 活动管理初始化 */ var Activity = { id: "ActivityTable", //表格id seItem: null, //选中的条目 table: null, layerIndex: -1 }; /** * 初始化表格的列 */ Activity.initColumn = function () { return [ {field: 'selectItem', radio: true}, {title: 'id', field: 'id', align: 'center', valign: 'middle',width:'50px'}, {title: '所属分公司', field: 'branchOfficeName', align: 'center', valign: 'middle', sortable: true}, {title: '活动名称', field: 'activityName', align: 'center', valign: 'middle', sortable: true}, {title: '开始时间', field: 'startTime', align: 'center', valign: 'middle', sortable: true}, {title: '结束时间', field: 'endTime', align: 'center', valign: 'middle', sortable: true}, {title: '活动区域', field: 'activityArea', align: 'center', valign: 'middle', sortable: true}, {title: '活动优惠券', field: 'activityCoupon', align: 'center', valign: 'middle', sortable: true}, {title: '活动状态', field: 'statusStr', align: 'center', valign: 'middle', sortable: true, }, {title: '创建时间', field: 'createTime', align: 'center', valign: 'middle', sortable: true}, {title: '创建人', field: 'createBy', align: 'center', valign: 'middle', sortable: true}, {title: '操作', visible: true, align: 'center', valign: 'middle',width:150, formatter: function (value, row) { if (row.status == 1 && row.roleType==1) { return '审核' } else { return '详情' + '    ' + '编辑' + '    ' + '删除' } } } ]; }; /** * 检查是否选中 */ Activity.check = function () { var selected = $('#' + this.id).bootstrapTreeTable('getSelections'); if(selected.length == 0){ Feng.info("请先选中表格中的某一记录!"); return false; }else{ Activity.seItem = selected[0]; return true; } }; /** * 点击添加活动 */ Activity.openAddActivity = function () { var index = layer.open({ type: 2, title: '创建活动', area: ['100%', '100%'], //宽高 fix: false, //不固定 maxmin: true, content: Feng.ctxPath + '/activity/activity_add' }); this.layerIndex = index; }; /** * 点击添加活动 */ Activity.openDetail = function (id) { var index = layer.open({ type: 2, title: '活动详情', area: ['100%', '100%'], //宽高 fix: false, //不固定 maxmin: true, content: Feng.ctxPath + '/activity/openDetail/' + id }); this.layerIndex = index; }; /** * 点击添加活动 */ Activity.openAuditDetail = function (id) { var index = layer.open({ type: 2, title: '审核活动', area: ['80%', '80%'], //宽高 fix: false, //不固定 maxmin: true, content: Feng.ctxPath + '/activity/openAuditDetail/' + id }); this.layerIndex = index; }; /** * 点击添加活动 */ Activity.openUpdateDetail = function (id) { var index = layer.open({ type: 2, title: '编辑活动', area: ['100%', '100%'], //宽高 fix: false, //不固定 maxmin: true, content: Feng.ctxPath + '/activity/activity_update/' + id }); this.layerIndex = index; }; /** * 打开查看活动详情 */ Activity.openActivityDetail = function () { if (this.check()) { var index = layer.open({ type: 2, title: '活动详情', area: ['100%', '100%'], //宽高 fix: false, //不固定 maxmin: true, content: Feng.ctxPath + '/activity/activity_update/' + Activity.seItem.id }); this.layerIndex = index; } }; /** * 打开查看活动详情 */ Activity.changeCoupon = function () { var index = layer.open({ type: 2, title: '选择优惠券', area: ['80%', '80%'], //宽高 fix: false, //不固定 maxmin: true, content: Feng.ctxPath + '/activity/changeCoupon' }); this.layerIndex = index; }; /** * 删除活动 */ Activity.delete = function (id) { var operation = function(){ var ajax = new $ax(Feng.ctxPath + "/activity/delete", function () { Feng.success("删除成功!"); Activity.table.refresh(); }, function (data) { Feng.error("删除失败!" + data.responseJSON.message + "!"); }); ajax.set("activityId",id); ajax.start(); }; Feng.confirm("是否刪除该活动?", operation); }; /** * 查询活动列表 */ Activity.search = function () { var queryData = {}; queryData['createTime'] = $("#createTime").val(); queryData['branchOfficeName'] = $("#branchOfficeName").val(); queryData['activityName'] = $("#activityName").val(); queryData['activityAreaCode'] = $("#activityAreaCode").val(); queryData['status'] = $("#status").val(); Activity.table.refresh({query: queryData}); }; /** * 重置 */ Activity.resetSearch = function (){ $("#createTime").val(''); $("#branchOfficeName").val(''); $("#activityName").val(''); $("#activityAreaCode").val(''); $("#status").val(''); Activity.search(); } $(function () { var defaultColunms = Activity.initColumn(); var table = new BSTable(Activity.id, "/activity/list", defaultColunms); table.setPaginationType("server"); Activity.table = table.init(); });