| | |
| | | * 管理初始化 |
| | | */ |
| | | var UserActivity = { |
| | | id: "UserActivityTable", //表格id |
| | | seItem: null, //选中的条目 |
| | | table: null, |
| | | layerIndex: -1 |
| | | id: "UserActivityTable", //表格id |
| | | seItem: null, //选中的条目 |
| | | table: null, |
| | | layerIndex: -1 |
| | | }; |
| | | |
| | | /** |
| | | * 初始化表格的列 |
| | | */ |
| | | UserActivity.initColumn = function () { |
| | | return [ |
| | | {field: 'selectItem', radio: true}, |
| | | {title: '', field: 'id', visible: false, align: 'center', valign: 'middle'}, |
| | | {title: '添加时间', field: 'insertTime', visible: true, align: 'center', valign: 'middle'}, |
| | | {title: '活动名称', field: 'name', visible: true, align: 'center', valign: 'middle'}, |
| | | {title: '开始时间', field: 'startTime', visible: true, align: 'center', valign: 'middle'}, |
| | | {title: '结束时间', field: 'endTime', visible: true, align: 'center', valign: 'middle'}, |
| | | {title: '参与人次', field: 'number', visible: true, align: 'center', valign: 'middle'}, |
| | | {title: '备注', field: 'remark', visible: true, align: 'center', valign: 'middle'}, |
| | | {title: '状态', field: 'status', visible: true, align: 'center', valign: 'middle', |
| | | formatter: function (value, row) { |
| | | if(value==1){ |
| | | return "待审核"; |
| | | }else if(value==2){ |
| | | return "已驳回"; |
| | | }else if(value==3){ |
| | | if(new Date()<new Date(row.startTime.replace(/-/g,"/"))){ |
| | | return "未开始"; |
| | | }else if(new Date()>new Date(row.endTime.replace(/-/g,"/"))){ |
| | | return "已结束"; |
| | | }else{ |
| | | return "进行中"; |
| | | } |
| | | }else if(value==4){ |
| | | return "已暂停"; |
| | | } |
| | | } |
| | | } |
| | | ]; |
| | | return [ |
| | | {field: 'selectItem', radio: true}, |
| | | {title: '', field: 'id', visible: false, align: 'center', valign: 'middle'}, |
| | | {title: '添加时间', field: 'insertTime', visible: true, align: 'center', valign: 'middle'}, |
| | | {title: '活动名称', field: 'name', visible: true, align: 'center', valign: 'middle'}, |
| | | {title: '开始时间', field: 'startTime', visible: true, align: 'center', valign: 'middle'}, |
| | | {title: '结束时间', field: 'endTime', visible: true, align: 'center', valign: 'middle'}, |
| | | {title: '参与人次', field: 'number', visible: true, align: 'center', valign: 'middle'}, |
| | | {title: '备注', field: 'remark', visible: true, align: 'center', valign: 'middle'}, |
| | | { |
| | | title: '状态', field: 'status', visible: true, align: 'center', valign: 'middle', |
| | | formatter: function (value, row) { |
| | | if (value == 1) { |
| | | return "待审核"; |
| | | } else if (value == 2) { |
| | | return "已驳回"; |
| | | } else if (value == 3) { |
| | | // if(new Date()<new Date(row.startTime.replace(/-/g,"/"))){ |
| | | // return "未开始"; |
| | | // }else if(new Date()>new Date(row.endTime.replace(/-/g,"/"))){ |
| | | // return "已结束"; |
| | | // }else{ |
| | | // return "进行中"; |
| | | // } |
| | | } else if (value == 4) { |
| | | return "已暂停"; |
| | | } else if (value == 5) { |
| | | return "未开始"; |
| | | } else if (value == 6) { |
| | | return "进行中"; |
| | | } else if (value == 7) { |
| | | return "已结束"; |
| | | } |
| | | } |
| | | } |
| | | ]; |
| | | }; |
| | | |
| | | /** |
| | | * 检查是否选中 |
| | | */ |
| | | UserActivity.check = function (type) { |
| | | var selected = $('#' + this.id).bootstrapTable('getSelections'); |
| | | if(selected.length == 0){ |
| | | Feng.info("请先选中表格中的某一记录!"); |
| | | return false; |
| | | }else{ |
| | | |
| | | //验证类型null删除,1=审核,2=编辑,3=启动/暂停 |
| | | if(type==null){ |
| | | UserActivity.seItem = selected[0]; |
| | | return true; |
| | | }else if(type==3 && selected[0].status!=3 && selected[0].status!=4){ |
| | | Feng.info("当前状态不能暂停/启动!"); |
| | | return false; |
| | | }else if(type==3 && selected[0].status==3 && (selected[0].startTime>new Date() || new Date()>selected[0].endTime)){ |
| | | Feng.info("当前状态不能暂停/启动!"); |
| | | return false; |
| | | }else if(type==1 && selected[0].status!=1){ |
| | | Feng.info("当前状态不能审核!"); |
| | | return false; |
| | | }else if(type==2 && selected[0].status!=2){ |
| | | Feng.info("当前状态不能编辑!"); |
| | | return false; |
| | | } |
| | | UserActivity.seItem = selected[0]; |
| | | return true; |
| | | } |
| | | var selected = $('#' + this.id).bootstrapTable('getSelections'); |
| | | if (selected.length == 0) { |
| | | Feng.info("请先选中表格中的某一记录!"); |
| | | return false; |
| | | } else { |
| | | |
| | | //验证类型null删除,1=审核,2=编辑,3=启动/暂停 |
| | | if (type == null) { |
| | | UserActivity.seItem = selected[0]; |
| | | return true; |
| | | } else if (type == 3 && selected[0].status != 4 && selected[0].status != 5 && selected[0].status != 6) { |
| | | Feng.info("当前状态不能暂停/启动!"); |
| | | return false; |
| | | } else if (type == 3 && (selected[0].status != 4 || selected[0].status != 5 || selected[0].status != 6) && (selected[0].startTime > new Date() || new Date() > selected[0].endTime)) { |
| | | Feng.info("当前状态不能暂停/启动!"); |
| | | return false; |
| | | } else if (type == 1 && selected[0].status != 1) { |
| | | Feng.info("当前状态不能审核!"); |
| | | return false; |
| | | } else if (type == 2 && ((selected[0].status != 1 && selected[0].status != 2) || new Date() >= new Date(selected[0].startTime.replace(/-/g, "/")))) { |
| | | Feng.info("当前状态不能编辑!"); |
| | | return false; |
| | | } |
| | | UserActivity.seItem = selected[0]; |
| | | return true; |
| | | } |
| | | }; |
| | | |
| | | /** |
| | | * 点击添加 |
| | | */ |
| | | UserActivity.openAddUserActivity = function () { |
| | | var index = layer.open({ |
| | | type: 2, |
| | | title: '添加', |
| | | area: ['100%', '100%'], //宽高 |
| | | fix: false, //不固定 |
| | | maxmin: true, |
| | | content: Feng.ctxPath + '/userActivity/userActivity_add' |
| | | }); |
| | | this.layerIndex = index; |
| | | var index = layer.open({ |
| | | type: 2, |
| | | title: '添加', |
| | | area: ['100%', '100%'], //宽高 |
| | | fix: false, //不固定 |
| | | maxmin: true, |
| | | content: Feng.ctxPath + '/userActivity/userActivity_add' |
| | | }); |
| | | this.layerIndex = index; |
| | | }; |
| | | |
| | | /** |
| | | * 打开查看详情 |
| | | */ |
| | | UserActivity.openUserActivityDetail = function () { |
| | | if (this.check()) { |
| | | var index = layer.open({ |
| | | type: 2, |
| | | title: '详情', |
| | | area: ['100%', '100%'], //宽高 |
| | | fix: false, //不固定 |
| | | maxmin: true, |
| | | content: Feng.ctxPath + '/userActivity/userActivity_detail/' + UserActivity.seItem.id |
| | | }); |
| | | this.layerIndex = index; |
| | | } |
| | | if (this.check()) { |
| | | var index = layer.open({ |
| | | type: 2, |
| | | title: '详情', |
| | | area: ['100%', '100%'], //宽高 |
| | | fix: false, //不固定 |
| | | maxmin: true, |
| | | content: Feng.ctxPath + '/userActivity/userActivity_detail/' + UserActivity.seItem.id |
| | | }); |
| | | this.layerIndex = index; |
| | | } |
| | | }; |
| | | /** |
| | | * 打开编辑 |
| | | */ |
| | | UserActivity.openUpdateUserActivity = function () { |
| | | if (this.check(2)) { |
| | | var index = layer.open({ |
| | | type: 2, |
| | | title: '编辑', |
| | | area: ['100%', '100%'], //宽高 |
| | | fix: false, //不固定 |
| | | maxmin: true, |
| | | content: Feng.ctxPath + '/userActivity/userActivity_update/' + UserActivity.seItem.id |
| | | }); |
| | | this.layerIndex = index; |
| | | } |
| | | if (this.check(2)) { |
| | | var index = layer.open({ |
| | | type: 2, |
| | | title: '编辑', |
| | | area: ['100%', '100%'], //宽高 |
| | | fix: false, //不固定 |
| | | maxmin: true, |
| | | content: Feng.ctxPath + '/userActivity/userActivity_update/' + UserActivity.seItem.id |
| | | }); |
| | | this.layerIndex = index; |
| | | } |
| | | }; |
| | | /** |
| | | * 删除 |
| | | */ |
| | | UserActivity.delete = function () { |
| | | if (this.check()) { |
| | | var ajax = new $ax(Feng.ctxPath + "/userActivity/delete", function (data) { |
| | | Feng.success("删除成功!"); |
| | | UserActivity.table.refresh(); |
| | | }, function (data) { |
| | | Feng.error("删除失败!" + data.responseJSON.message + "!"); |
| | | }); |
| | | ajax.set("userActivityId",this.seItem.id); |
| | | ajax.start(); |
| | | } |
| | | if (this.check()) { |
| | | var ajax = new $ax(Feng.ctxPath + "/userActivity/delete", function (data) { |
| | | Feng.success("删除成功!"); |
| | | UserActivity.table.refresh(); |
| | | }, function (data) { |
| | | Feng.error("删除失败!" + data.responseJSON.message + "!"); |
| | | }); |
| | | ajax.set("userActivityId", this.seItem.id); |
| | | ajax.start(); |
| | | } |
| | | }; |
| | | /** |
| | | * 启动/暂停 |
| | | */ |
| | | UserActivity.updateStatus = function () { |
| | | if (this.check(3)) { |
| | | var ajax = new $ax(Feng.ctxPath + "/userActivity/updateStatus", function (data) { |
| | | Feng.success("启动/暂停成功!"); |
| | | UserActivity.table.refresh(); |
| | | }, function (data) { |
| | | Feng.error("动/暂停失败!" + data.responseJSON.message + "!"); |
| | | }); |
| | | ajax.set("id",this.seItem.id); |
| | | ajax.set("status",this.seItem.status==3?4:3); |
| | | ajax.start(); |
| | | } |
| | | if (this.check(3)) { |
| | | var ajax = new $ax(Feng.ctxPath + "/userActivity/updateStatus", function (data) { |
| | | Feng.success("启动/暂停成功!"); |
| | | UserActivity.table.refresh(); |
| | | }, function (data) { |
| | | Feng.error("动/暂停失败!" + data.responseJSON.message + "!"); |
| | | }); |
| | | ajax.set("id", this.seItem.id); |
| | | ajax.set("status", this.seItem.status == 6 ? 4 : 3); |
| | | ajax.start(); |
| | | } |
| | | }; |
| | | /** |
| | | * 打开立即处理页面 |
| | | */ |
| | | UserActivity.immediately = function () { |
| | | if (this.check(1)) { |
| | | var index = layer.open({ |
| | | type: 2, |
| | | title: '审核', |
| | | area: ['800px', '420px'], //宽高 |
| | | fix: false, //不固定 |
| | | maxmin: true, |
| | | content: Feng.ctxPath + '/userActivity/userActivity_immediately/' + this.seItem.id |
| | | }); |
| | | this.layerIndex = index; |
| | | } |
| | | if (this.check(1)) { |
| | | var index = layer.open({ |
| | | type: 2, |
| | | title: '审核', |
| | | area: ['800px', '420px'], //宽高 |
| | | fix: false, //不固定 |
| | | maxmin: true, |
| | | content: Feng.ctxPath + '/userActivity/userActivity_immediately/' + this.seItem.id |
| | | }); |
| | | this.layerIndex = index; |
| | | } |
| | | }; |
| | | /** |
| | | * 领取记录 |
| | | */ |
| | | UserActivity.receiveRecord= function () { |
| | | if (this.check()) { |
| | | var index = layer.open({ |
| | | type: 2, |
| | | title: '领取记录', |
| | | area: ['100%', '100%'], //宽高 |
| | | fix: false, //不固定 |
| | | maxmin: true, |
| | | content: Feng.ctxPath + '/userActivity/receiveRecord?activityId='+ UserActivity.seItem.id |
| | | }); |
| | | this.layerIndex = index; |
| | | } |
| | | UserActivity.receiveRecord = function () { |
| | | if (this.check()) { |
| | | var index = layer.open({ |
| | | type: 2, |
| | | title: '领取记录', |
| | | area: ['100%', '100%'], //宽高 |
| | | fix: false, //不固定 |
| | | maxmin: true, |
| | | content: Feng.ctxPath + '/userActivity/receiveRecord?activityId=' + UserActivity.seItem.id |
| | | }); |
| | | this.layerIndex = index; |
| | | } |
| | | }; |
| | | /** |
| | | * 查询列表 |
| | | */ |
| | | UserActivity.search = function () { |
| | | var queryData = {}; |
| | | queryData['createTime'] = $("#createTime").val(); |
| | | queryData['name'] = $("#name").val(); |
| | | queryData['status'] = $("#status").val(); |
| | | UserActivity.table.refresh({query: queryData}); |
| | | var queryData = {}; |
| | | queryData['createTime'] = $("#createTime").val(); |
| | | queryData['name'] = $("#name").val(); |
| | | queryData['status'] = $("#status").val(); |
| | | UserActivity.table.refresh({query: queryData}); |
| | | }; |
| | | UserActivity.resetSearch = function () { |
| | | $("#createTime").val(""); |
| | | $("#name").val(""); |
| | | $("#status").val(""); |
| | | DriverActivity.search(); |
| | | $("#createTime").val(""); |
| | | $("#name").val(""); |
| | | $("#status").val(""); |
| | | DriverActivity.search(); |
| | | }; |
| | | $(function () { |
| | | var defaultColunms = UserActivity.initColumn(); |
| | | var table = new BSTable(UserActivity.id, "/userActivity/list", defaultColunms); |
| | | table.setPaginationType("server"); |
| | | UserActivity.table = table.init(); |
| | | var defaultColunms = UserActivity.initColumn(); |
| | | var table = new BSTable(UserActivity.id, "/userActivity/list", defaultColunms); |
| | | table.setPaginationType("server"); |
| | | UserActivity.table = table.init(); |
| | | }); |