|
@ -0,0 +1,236 @@
|
|
|
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8" %>
|
|
|
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
|
|
|
<script>
|
|
|
(function ($, win) {
|
|
|
$(function () {
|
|
|
/* ************************** 变量定义 ******************************** */
|
|
|
// 通用工具类库
|
|
|
var Util = $.Util;
|
|
|
var task = null;
|
|
|
var master = null;
|
|
|
var isFirstPage = false;
|
|
|
/* *************************** 函数定义 ******************************* */
|
|
|
function pageInit() {
|
|
|
task.init();
|
|
|
master.init();
|
|
|
}
|
|
|
|
|
|
function reloadGrid(params) {
|
|
|
if (isFirstPage) {
|
|
|
this.grid.options.newPage = 1;
|
|
|
}
|
|
|
this.grid.setOptions({parms: params});
|
|
|
this.grid.loadData(true);
|
|
|
}
|
|
|
|
|
|
/* *************************** 模块初始化 ***************************** */
|
|
|
|
|
|
task = {
|
|
|
$element: $('.m-task-area'),
|
|
|
$searchBtn: $('#btn_search'),
|
|
|
$addBtn: $('#btn_add'),
|
|
|
|
|
|
$title: $("#inp_title"),//任务标题
|
|
|
$type: $("#inp_type"),//任务类型
|
|
|
$period: $("#inp_period"),//周期
|
|
|
$status: $("#inp_status"),//状态
|
|
|
init: function () {
|
|
|
this.$element.show();
|
|
|
this.$element.attrScan();
|
|
|
window.form = this.$element;
|
|
|
this.$title.ligerTextBox({width: 200});
|
|
|
this.typeBox = this.$type.ligerComboBox({
|
|
|
width: 200,
|
|
|
data: [
|
|
|
{text: '普通任务', id: 'NORMAL_TASK'},
|
|
|
{text: '活动任务', id: 'ACTIVITY_TASK'},
|
|
|
{text: '规则任务', id: 'RULE_TASK'},
|
|
|
]
|
|
|
});
|
|
|
this.periodBox =this.$period.ligerComboBox({
|
|
|
width: 200,
|
|
|
data: [
|
|
|
{text: '一次性', id: '1'},
|
|
|
{text: '每天', id: '0'},
|
|
|
]
|
|
|
});
|
|
|
this.statusBox = this.$status.ligerComboBox({
|
|
|
width: 200,
|
|
|
data: [
|
|
|
{text: '有效', id: '1'},
|
|
|
{text: '失效', id: '0'},
|
|
|
]
|
|
|
});
|
|
|
this.bindEvents();
|
|
|
},
|
|
|
bindEvents: function () {
|
|
|
var self = this;
|
|
|
self.$searchBtn.click(function () {
|
|
|
master.grid.options.newPage = 1;
|
|
|
master.reloadGrid();
|
|
|
});
|
|
|
self.$addBtn.click(function () {
|
|
|
$.publish("task:info:create", [0]);
|
|
|
});
|
|
|
|
|
|
}
|
|
|
};
|
|
|
master = {
|
|
|
taskInfoDialog: null,
|
|
|
grid: null,
|
|
|
init: function () {
|
|
|
this.grid = $("#div_task_list").ligerGrid($.LigerGridEx.config({
|
|
|
url: ctx + '/admin/task/list',
|
|
|
parms: {"task": JSON.stringify(task.$element.Fields.getValues())},
|
|
|
ajaxHeader: ajaxHeaderName,
|
|
|
ajaxHeaderValue: ajaxHeaderValue,
|
|
|
columns: [
|
|
|
{display: 'id', name: 'id', hide: true},
|
|
|
{display: '任务标题', name: 'title', width: '10%', align: "left"},
|
|
|
{display: '任务说明', name: 'content', width: '10%', align: "left"},
|
|
|
{display: '任务编码', name: 'taskCode', width: '10%', align: "left"},
|
|
|
{
|
|
|
display: '任务类型', name: 'type', width: '10%', align: "left",
|
|
|
render: function (row) {
|
|
|
if (row.type == "NORMAL_TASK") {
|
|
|
return "普通任务"
|
|
|
}
|
|
|
if (row.type == "ACTIVITY_TASK") {
|
|
|
return "活动任务"
|
|
|
}
|
|
|
if (row.type == "RULE_TASK") {
|
|
|
return "规则任务"
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
// {display: '业务Id', name: 'startTime', width: '10%', align: "left"},
|
|
|
{
|
|
|
display: '周期', name: 'period', width: '10%', align: "left",
|
|
|
render: function (row) {
|
|
|
if (row.period == 1) {
|
|
|
return "一次性"
|
|
|
}
|
|
|
if (row.period == 0) {
|
|
|
return "每天"
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
{display: '开始时间', name: 'startTime', width: '10%', align: "left"},
|
|
|
{display: '结束时间', name: 'endTime', width: '10%', align: "left"},
|
|
|
{
|
|
|
display: '状态', name: 'status', width: '10%', align: "left",
|
|
|
render: function (row) {
|
|
|
if (row.status == 1) {
|
|
|
return "有效"
|
|
|
}
|
|
|
if (row.status == 0) {
|
|
|
return "失效"
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
{
|
|
|
display: '操作', name: 'operator', width: '10%', align: "center", isSort: false,
|
|
|
render: function (row) {
|
|
|
var html = '';
|
|
|
html += '<a style="margin-left:10px;"href="javascript:void(0)" onclick="javascript:' + Util.format("$.publish('{0}',['{1}'])", "task:info:view", row.id) + '">查看</a>';
|
|
|
<sec:authorize url="/admin/task/update">
|
|
|
html += '<a style="margin-left:10px;"href="javascript:void(0)" onclick="javascript:' + Util.format("$.publish('{0}',['{1}'])", "task:info:edit", row.id) + '">编辑</a>';
|
|
|
</sec:authorize>
|
|
|
<%--<sec:authorize url="/admin/task/delete">
|
|
|
html += '<a style="margin-left:10px;"href="javascript:void(0)" onclick="javascript:' + Util.format("$.publish('{0}',['{1}'])", "task:info:del", row.id) + '">删除</a>';
|
|
|
</sec:authorize>--%>
|
|
|
return html;
|
|
|
}
|
|
|
}
|
|
|
],
|
|
|
}));
|
|
|
// 自适应宽度
|
|
|
this.grid.adjustToWidth();
|
|
|
this.bindEvents();
|
|
|
},
|
|
|
reloadGrid: function (msg) {
|
|
|
task.$element.attrScan();
|
|
|
var values = task.$element.Fields.getValues();
|
|
|
values.type = task.typeBox.getValue();
|
|
|
values.period = task.periodBox.getValue();
|
|
|
values.status = task.statusBox.getValue();
|
|
|
reloadGrid.call(this,{"task":JSON.stringify(values)});
|
|
|
},
|
|
|
delRecord: function (id, code) {
|
|
|
var self = this;
|
|
|
$.ajax({
|
|
|
url: ctx + "/admin/task/delete",
|
|
|
data: {"id": id},
|
|
|
method: "post",
|
|
|
dataType: "json",
|
|
|
success: function (result) {
|
|
|
if (result.status == '200') {
|
|
|
window.reloadMasterGrid(result.msg);
|
|
|
} else {
|
|
|
$.Notice.error(result.msg);
|
|
|
}
|
|
|
},
|
|
|
error: function (data) {
|
|
|
$.Notice.error("系统异常,请联系管理员!");
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
bindEvents: function () {
|
|
|
var self = this;
|
|
|
$.subscribe('task:info:view', function (event, id) {
|
|
|
var title = '查看信息';
|
|
|
self.deviceInfoDialog = $.ligerDialog.open({
|
|
|
height: 600,
|
|
|
width: 560,
|
|
|
urlParms: {"id": id, "type": "view"},
|
|
|
title: title,
|
|
|
url: ctx + '/admin/task/infoInit'
|
|
|
})
|
|
|
});
|
|
|
$.subscribe('task:info:edit', function (event, id) {
|
|
|
var title = '编辑信息';
|
|
|
self.taskInfoDialog = $.ligerDialog.open({
|
|
|
height: 600,
|
|
|
width: 560,
|
|
|
urlParms: {"id": id, "type": "edit"},
|
|
|
title: title,
|
|
|
url: ctx + '/admin/task/infoInit'
|
|
|
})
|
|
|
});
|
|
|
|
|
|
$.subscribe('task:info:create', function (event) {
|
|
|
var title = '新增活动';
|
|
|
self.taskInfoDialog = $.ligerDialog.open({
|
|
|
height: 600,
|
|
|
width: 560,
|
|
|
urlParms: {"type": "create"},
|
|
|
title: title,
|
|
|
url: ctx + '/admin/task/init'
|
|
|
})
|
|
|
});
|
|
|
|
|
|
$.subscribe('task:info:del', function (event, id, code) {
|
|
|
$.ligerDialog.confirm('确认删除该行信息?<br>如果是请点击确认按钮,否则请点击取消。', function (yes) {
|
|
|
if (yes) {
|
|
|
self.delRecord(id, code);
|
|
|
}
|
|
|
});
|
|
|
})
|
|
|
}
|
|
|
};
|
|
|
/* ************************* Dialog页面回调接口 ************************** */
|
|
|
win.reloadMasterGrid = function (msg) {
|
|
|
if (isNoEmpty(msg)) {
|
|
|
$.Notice.success(msg);
|
|
|
}
|
|
|
master.reloadGrid(msg);
|
|
|
};
|
|
|
win.closetaskInfoDialog = function () {
|
|
|
master.taskInfoDialog.close();
|
|
|
};
|
|
|
/* *************************** 页面初始化 **************************** */
|
|
|
pageInit();
|
|
|
});
|
|
|
})(jQuery, window);
|
|
|
|
|
|
</script>
|