123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348 |
- <div id="timerList" class="plg-tab-container">
- <div id="timer" class="grid-container-full"></div>
- <input id="timerId" type="hidden" />
- </div>
- <div id="timeList_mywin" style="display: none; height: 550px;">
- <div id="timeList_g1"></div>
- </div>
- <style type="text/css">
- .layui-form-label {
- width: 210px;
- }
- .layui-input {
- width: 66%;
- }
- /* .plg-btn-height-auto, .plg-btn-normal, .plg-btn-normal:hover {
- height: auto!important;
- } */
- /* .plg-btn-normal, .plg-btn-normal:hover {
- border-radius: 4px;
- box-shadow: 0 2px 0 rgba(0, 0, 0, 0.015);
- color: rgba(0, 0, 0, 0.65);
- background-color: #fff;
- border-color: #d9d9d9;
- }
- .plg-btn-normal {
- border: 1px solid rgb(217, 217, 217)!important;
- }
- .plg-btn-normal:hover {
- border: 1px solid #3da0e3!important;
- } */
- </style>
- <script type="text/javascript">
- (function () {
- var form = $("#timerList #form1");
- var TIMER_STATUS = {
- "0": {
- text: "运行中",
- className: "plg-timer-run"
- },
- "1": {
- text: "关闭",
- className: "plg-timer-stop"
- },
- "2": {
- text: "暂停",
- className: "plg-timer-pause"
- }
- };
- window.global_fun.timerList = {};
- // window.timerList_aclick=aclick;
- window.global_fun.timerList.timerList_update = update;
- window.global_fun.timerList.timerList_del = del;
- window.global_fun.timerList.timerList_log = log;
- function del(id) {
- PlgDialog.confirm(
- "确定删除?",
- {
- title: "删除提示",
- btnAlign: "c",
- btn: ["确定", "取消"] //可以无限个按钮
- },
- function (index, layero) {
- Prolog.ajax({
- url: "/api/service-quartz/job/" + id,
- type: "delete",
- success: function (data) {
- PlgDialog.close(index);
- timer.reload();
- PlgDialog.msg(data.message);
- }
- });
- }
- );
- }
- var opts = {
- skin: "terrace",
- fixedLast: true,
- columns: [
- { id: "id", name: "id", type: "txt", hidden: true },
- { id: "systemId", name: "系统id", type: "ro", width: 120 },
- { id: "name", name: "定时器名称", type: "ro", width: 250 },
- { id: "jobName", name: "任务名称", type: "ro", width: 250 },
- { id: "triggerName", name: "触发器名称", type: "ro", width: 250 },
- { id: "cron", name: "时间表达式", type: "ro", width: 120, hidden: true },
- { id: "url", name: "接口地址", type: "ro", width: 200, hidden: true },
- { id: "requestMethod", name: "请求方式", type: "ro", width: 100, hidden: true },
- { id: "params", name: "请求参数", type: "ro", width: 150, hidden: true },
- {
- id: "status",
- name: "状态",
- align: "center",
- type: "ro",
- width: 100,
- render: function (v, d) {
- return `<span class="${TIMER_STATUS[v].className}"> ${TIMER_STATUS[v].text} </span>`;
- }
- },
- { id: "description", name: "说明", type: "ro" },
- {
- id: "op",
- name: "操作",
- type: "button",
- width: "*",
- render: function () {
- return "修改^global_fun.timerList.timerList_update,删除^global_fun.timerList.timerList_del,日志^global_fun.timerList.timerList_log";
- }
- }
- ],
- toolbar: [
- { type: "input", name: "systemId", label: "系统id:", width: 270 },
- { type: "newcolumn" },
- { type: "button", name: "addBtn", className: "plg-toolbar-right", value: "<i class='layui-icon layui-icon-add-1'></i>添加" },
- { type: "newcolumn" },
- { type: "input", name: "name", label: "定时器名称:", offsetLeft: 10, width: 270, placeholder: "请输入定时器名称" },
- { type: "newcolumn" },
- { type: "button", name: "searchBtn", className: "", value: "查询" },
- { type: "newcolumn" },
- { type: "button", name: "all", className: "normal", value: "所有" }
- ],
- formData: [
- { type: "settings", inputWidth: 300, width: 400, labelWidth: 80, position: "label-left", labelAlign: "left" },
- { type: "hidden", name: "id", value: "" },
- {
- type: "input",
- name: "systemId",
- width: 300,
- label: "系统id:",
- validate: "NotEmpty",
- required: true,
- remote: { url: "/api/service-users/sys/getSelectSystem/v1.0", data: {}, valueField: "val", textField: "val", method: "get" }
- },
- { type: "input", name: "name", label: "定时器名称:", validate: "NotEmpty", required: true, placeholder: "请输入定时器名称" },
- { type: "input", name: "jobName", label: "任务名称:", validate: "NotEmpty", required: true, placeholder: "请输入英文或数字", editable: false },
- { type: "input", name: "triggerName", label: "触发器名称:", validate: "NotEmpty", required: true, placeholder: "请输入英文或数字", editable: false },
- { type: "hidden", name: "jobGroup" },
- { type: "hidden", name: "status" },
- { type: "hidden", name: "triggerGroup" },
- { type: "input", name: "cron", label: "时间表达式:", validate: "NotEmpty", required: true, placeholder: "例:0/5 * * * * ?" },
- // {type: "input", name:"jobClassName", label:"执行类:", placeholder: '例:com.prolog.framework.cs.quartz.task.Task',editable:false},
- { type: "input", name: "url", label: "接口地址:", validate: "NotEmpty", required: true, placeholder: "请输入接口地址" },
- {
- type: "select",
- name: "requestMethod",
- label: "请求方式:",
- options: [
- { value: "GET", text: "GET" },
- { value: "POST", text: "POST" }
- ]
- },
- { type: "input", name: "params", label: "请求参数:", placeholder: '例:{"name":"张三","sex":"男"}' },
- { type: "input", name: "description", label: "说明:", placeholder: "说明", rows: 2 }
- // {type: "block", width: 380,offsetLeft:0,blockOffset:0,list:[
- // {type: "label", label: "是否可用:",className:"normalfont"},{type: "newcolumn"},
- // {type: "radio", name: "enable", label: "是",value:0, checked: true, position:"label-right"},
- // {type: "newcolumn"},
- // {type: "radio", name: "enable", label: "否",value:1, position:"label-right"}
- // ]}
- ],
- pagebar: {
- buttons: [
- { text: "<i class='layui-icon layui-icon-engine '></i>启动", className: "plg-btn-normal", name: "resumeJobs" },
- { text: "<i class='layui-icon layui-icon-pause '></i>暂停", className: "plg-btn-normal", name: "pauseJobs" },
- { text: "<i class='layui-icon layui-icon-delete '></i>删除", className: "layui-btn-danger plg-btn-height-auto", name: "delete" }
- ]
- },
- url: "/api/service-quartz/job", //数据接口
- type: "get", //数据提交方式,默认为get
- params: { pageNum: 1, pageSize: 10 }, //查询提交参数,分页参数默认为pageNum,pageSize
- page: true, //是否启用分页
- multiselect: true, //是否支持多选
- totalCount: "totalCount" //总记录数字段,默认totalCount
- };
- var timer = new PlgGrid(opts);
- timer.renderTo("timer");
- timer.loadData();
- timer.attachToolBarEvent("onButtonClick", function (name, ids) {
- if (name == "searchBtn") {
- var fdata = timer.getToolBarForm().getFormData();
- timer.setParams(fdata);
- timer.reload();
- } else if (name == "all") {
- timer.setParams({ pageNum: 1, pageSize: 10, systemId: "", name: "" });
- timer.reload();
- } else if (name == "addBtn") {
- timerList_add();
- }
- });
- timer.attachPageBarEvent(function (name, ids) {
- if (name == "delete") {
- if (ids == "") {
- return;
- }
- PlgDialog.confirm(
- "确定删除?",
- {
- title: "删除提示",
- btnAlign: "c",
- btn: ["确定", "取消"] //可以无限个按钮
- },
- function (index, layero) {
- Prolog.ajax({
- url: "/api/service-quartz/job/del",
- type: "post",
- data: { id: ids },
- success: function (data) {
- PlgDialog.close(index);
- timer.reload();
- PlgDialog.msg(data.message);
- }
- });
- }
- );
- } else if (name == "pauseJobs") {
- timerList_pauseJobs(ids);
- } else if (name == "resumeJobs") {
- timerList_resumeJobs(ids);
- }
- });
- function timerList_add() {
- timer.showDialog(0, "添加", 450, 490, { url: "/api/service-quartz/job", type: "post", contentType: "application/json" });
- var g = timer.getGridForm();
- // g.loadComboData("systemId",{url:'/api/service-users/sys/getSelectSystem/v1.0',data:{},valueField:"val",textField:"val",method:"get"});
- }
- function update(id) {
- $("#timerList #id").val(id);
- timer.selectRowById(id);
- timer.showDialog(1, "编辑", 450, 490, { url: "/api/service-quartz/job", type: "put", contentType: "application/json" });
- var g = timer.getGridForm();
- // g.loadComboData("systemId",{url:'/api/service-users/sys/getSelectSystem/v1.0',data:{},valueField:"val",textField:"val",method:"get"});
- }
- function log(id, data) {
- var index = PlgDialog.open({
- type: 1,
- title: "日志列表",
- shade: 0,
- area: ["900px", "630px"],
- offset: ["20px", "150px"],
- skin: "layui-layer-lan",
- content: $("#timeList_mywin"),
- closeBtn: 1,
- btn: [],
- success: function (layero) {
- var opts1 = {
- columns: [
- { id: "id", name: "id", type: "txt", hidden: true },
- { id: "createTime", name: "记录时间", type: "ro", width: 150 },
- { id: "level", name: "日志级别", type: "ro", width: 120 },
- {
- id: "description",
- name: "日志描述",
- type: "ro",
- width: 220,
- render: function (v) {
- return data.jobName;
- }
- },
- { id: "errorMessage", name: "日志信息", type: "ro", width: "*" },
- { id: "uri", name: "接口地址", type: "ro", width: 150, hidden: true },
- { id: "params", name: "参数", type: "ro", width: 120, hidden: true },
- { id: "systemId", name: "系统id", type: "ro", width: 120, hidden: true }
- ],
- url: "/api/service-log/log/getLogList", //数据接口
- type: "get", //数据提交方式,默认为get
- params: { systemId: data.systemId, description: data.description, pageNum: 1, pageSize: 10 }, //查询提交参数,分页参数默认为pageNum,pageSize
- page: true, //是否启用分页
- multiselect: false, //是否支持多选
- totalCount: "totalCount" //总记录数字段,默认totalCount
- };
- grid1 = new PlgGrid(opts1);
- grid1.renderTo("timeList_g1");
- grid1.loadData();
- },
- end: function () {
- $("#timeList_mywin").hide();
- }
- });
- }
- function timerList_pauseJobs(ids) {
- //暂停
- if (ids == "") {
- return;
- }
- PlgDialog.confirm(
- "确定暂停?",
- {
- title: "提示",
- btnAlign: "c",
- btn: ["确定", "取消"]
- },
- function (index, layero) {
- Prolog.ajax({
- url: "/api/service-quartz/job/pauseJob?ids=" + ids,
- type: "post",
- success: function (data) {
- PlgDialog.close(index);
- timer.reload();
- PlgDialog.msg(data.message);
- }
- });
- }
- );
- }
- function timerList_resumeJobs(ids) {
- //启动
- if (ids == "") {
- return;
- }
- PlgDialog.confirm(
- "确定启动?",
- {
- title: "提示",
- btnAlign: "c",
- btn: ["确定", "取消"]
- },
- function (index, layero) {
- Prolog.ajax({
- url: "/api/service-quartz/job/resumeJob?ids=" + ids,
- type: "post",
- success: function (data) {
- PlgDialog.close(index);
- timer.reload();
- PlgDialog.msg(data.message);
- }
- });
- }
- );
- }
- // timer.on("onRowDblClicked",function(){
- // timer.showDialog(1,"编辑",450,300,{url:"/api/service-quartz/timer",type:"put",contentType:"application/json"});
- // });
- var f = timer.getToolBarForm();
- // f.loadComboData("systemId",{url:'/api/service-users/sys/getSelectSystem/v1.0',data:{},valueField:"val",textField:"val",method:"get"});
- })();
- </script>
|