timerList.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. <div id="timerList" class="plg-tab-container">
  2. <div id="timer" class="grid-container-full"></div>
  3. <input id="timerId" type="hidden" />
  4. </div>
  5. <div id="timeList_mywin" style="display: none; height: 550px;">
  6. <div id="timeList_g1"></div>
  7. </div>
  8. <style type="text/css">
  9. .layui-form-label {
  10. width: 210px;
  11. }
  12. .layui-input {
  13. width: 66%;
  14. }
  15. /* .plg-btn-height-auto, .plg-btn-normal, .plg-btn-normal:hover {
  16. height: auto!important;
  17. } */
  18. /* .plg-btn-normal, .plg-btn-normal:hover {
  19. border-radius: 4px;
  20. box-shadow: 0 2px 0 rgba(0, 0, 0, 0.015);
  21. color: rgba(0, 0, 0, 0.65);
  22. background-color: #fff;
  23. border-color: #d9d9d9;
  24. }
  25. .plg-btn-normal {
  26. border: 1px solid rgb(217, 217, 217)!important;
  27. }
  28. .plg-btn-normal:hover {
  29. border: 1px solid #3da0e3!important;
  30. } */
  31. </style>
  32. <script type="text/javascript">
  33. (function () {
  34. var form = $("#timerList #form1");
  35. var TIMER_STATUS = {
  36. "0": {
  37. text: "运行中",
  38. className: "plg-timer-run"
  39. },
  40. "1": {
  41. text: "关闭",
  42. className: "plg-timer-stop"
  43. },
  44. "2": {
  45. text: "暂停",
  46. className: "plg-timer-pause"
  47. }
  48. };
  49. window.global_fun.timerList = {};
  50. // window.timerList_aclick=aclick;
  51. window.global_fun.timerList.timerList_update = update;
  52. window.global_fun.timerList.timerList_del = del;
  53. window.global_fun.timerList.timerList_log = log;
  54. function del(id) {
  55. PlgDialog.confirm(
  56. "确定删除?",
  57. {
  58. title: "删除提示",
  59. btnAlign: "c",
  60. btn: ["确定", "取消"] //可以无限个按钮
  61. },
  62. function (index, layero) {
  63. Prolog.ajax({
  64. url: "/api/service-quartz/job/" + id,
  65. type: "delete",
  66. success: function (data) {
  67. PlgDialog.close(index);
  68. timer.reload();
  69. PlgDialog.msg(data.message);
  70. }
  71. });
  72. }
  73. );
  74. }
  75. var opts = {
  76. skin: "terrace",
  77. fixedLast: true,
  78. columns: [
  79. { id: "id", name: "id", type: "txt", hidden: true },
  80. { id: "systemId", name: "系统id", type: "ro", width: 120 },
  81. { id: "name", name: "定时器名称", type: "ro", width: 250 },
  82. { id: "jobName", name: "任务名称", type: "ro", width: 250 },
  83. { id: "triggerName", name: "触发器名称", type: "ro", width: 250 },
  84. { id: "cron", name: "时间表达式", type: "ro", width: 120, hidden: true },
  85. { id: "url", name: "接口地址", type: "ro", width: 200, hidden: true },
  86. { id: "requestMethod", name: "请求方式", type: "ro", width: 100, hidden: true },
  87. { id: "params", name: "请求参数", type: "ro", width: 150, hidden: true },
  88. {
  89. id: "status",
  90. name: "状态",
  91. align: "center",
  92. type: "ro",
  93. width: 100,
  94. render: function (v, d) {
  95. return `<span class="${TIMER_STATUS[v].className}"> ${TIMER_STATUS[v].text} </span>`;
  96. }
  97. },
  98. { id: "description", name: "说明", type: "ro" },
  99. {
  100. id: "op",
  101. name: "操作",
  102. type: "button",
  103. width: "*",
  104. render: function () {
  105. return "修改^global_fun.timerList.timerList_update,删除^global_fun.timerList.timerList_del,日志^global_fun.timerList.timerList_log";
  106. }
  107. }
  108. ],
  109. toolbar: [
  110. { type: "input", name: "systemId", label: "系统id:", width: 270 },
  111. { type: "newcolumn" },
  112. { type: "button", name: "addBtn", className: "plg-toolbar-right", value: "<i class='layui-icon layui-icon-add-1'></i>添加" },
  113. { type: "newcolumn" },
  114. { type: "input", name: "name", label: "定时器名称:", offsetLeft: 10, width: 270, placeholder: "请输入定时器名称" },
  115. { type: "newcolumn" },
  116. { type: "button", name: "searchBtn", className: "", value: "查询" },
  117. { type: "newcolumn" },
  118. { type: "button", name: "all", className: "normal", value: "所有" }
  119. ],
  120. formData: [
  121. { type: "settings", inputWidth: 300, width: 400, labelWidth: 80, position: "label-left", labelAlign: "left" },
  122. { type: "hidden", name: "id", value: "" },
  123. {
  124. type: "input",
  125. name: "systemId",
  126. width: 300,
  127. label: "系统id:",
  128. validate: "NotEmpty",
  129. required: true,
  130. remote: { url: "/api/service-users/sys/getSelectSystem/v1.0", data: {}, valueField: "val", textField: "val", method: "get" }
  131. },
  132. { type: "input", name: "name", label: "定时器名称:", validate: "NotEmpty", required: true, placeholder: "请输入定时器名称" },
  133. { type: "input", name: "jobName", label: "任务名称:", validate: "NotEmpty", required: true, placeholder: "请输入英文或数字", editable: false },
  134. { type: "input", name: "triggerName", label: "触发器名称:", validate: "NotEmpty", required: true, placeholder: "请输入英文或数字", editable: false },
  135. { type: "hidden", name: "jobGroup" },
  136. { type: "hidden", name: "status" },
  137. { type: "hidden", name: "triggerGroup" },
  138. { type: "input", name: "cron", label: "时间表达式:", validate: "NotEmpty", required: true, placeholder: "例:0/5 * * * * ?" },
  139. // {type: "input", name:"jobClassName", label:"执行类:", placeholder: '例:com.prolog.framework.cs.quartz.task.Task',editable:false},
  140. { type: "input", name: "url", label: "接口地址:", validate: "NotEmpty", required: true, placeholder: "请输入接口地址" },
  141. {
  142. type: "select",
  143. name: "requestMethod",
  144. label: "请求方式:",
  145. options: [
  146. { value: "GET", text: "GET" },
  147. { value: "POST", text: "POST" }
  148. ]
  149. },
  150. { type: "input", name: "params", label: "请求参数:", placeholder: '例:{"name":"张三","sex":"男"}' },
  151. { type: "input", name: "description", label: "说明:", placeholder: "说明", rows: 2 }
  152. // {type: "block", width: 380,offsetLeft:0,blockOffset:0,list:[
  153. // {type: "label", label: "是否可用:",className:"normalfont"},{type: "newcolumn"},
  154. // {type: "radio", name: "enable", label: "是",value:0, checked: true, position:"label-right"},
  155. // {type: "newcolumn"},
  156. // {type: "radio", name: "enable", label: "否",value:1, position:"label-right"}
  157. // ]}
  158. ],
  159. pagebar: {
  160. buttons: [
  161. { text: "<i class='layui-icon layui-icon-engine '></i>启动", className: "plg-btn-normal", name: "resumeJobs" },
  162. { text: "<i class='layui-icon layui-icon-pause '></i>暂停", className: "plg-btn-normal", name: "pauseJobs" },
  163. { text: "<i class='layui-icon layui-icon-delete '></i>删除", className: "layui-btn-danger plg-btn-height-auto", name: "delete" }
  164. ]
  165. },
  166. url: "/api/service-quartz/job", //数据接口
  167. type: "get", //数据提交方式,默认为get
  168. params: { pageNum: 1, pageSize: 10 }, //查询提交参数,分页参数默认为pageNum,pageSize
  169. page: true, //是否启用分页
  170. multiselect: true, //是否支持多选
  171. totalCount: "totalCount" //总记录数字段,默认totalCount
  172. };
  173. var timer = new PlgGrid(opts);
  174. timer.renderTo("timer");
  175. timer.loadData();
  176. timer.attachToolBarEvent("onButtonClick", function (name, ids) {
  177. if (name == "searchBtn") {
  178. var fdata = timer.getToolBarForm().getFormData();
  179. timer.setParams(fdata);
  180. timer.reload();
  181. } else if (name == "all") {
  182. timer.setParams({ pageNum: 1, pageSize: 10, systemId: "", name: "" });
  183. timer.reload();
  184. } else if (name == "addBtn") {
  185. timerList_add();
  186. }
  187. });
  188. timer.attachPageBarEvent(function (name, ids) {
  189. if (name == "delete") {
  190. if (ids == "") {
  191. return;
  192. }
  193. PlgDialog.confirm(
  194. "确定删除?",
  195. {
  196. title: "删除提示",
  197. btnAlign: "c",
  198. btn: ["确定", "取消"] //可以无限个按钮
  199. },
  200. function (index, layero) {
  201. Prolog.ajax({
  202. url: "/api/service-quartz/job/del",
  203. type: "post",
  204. data: { id: ids },
  205. success: function (data) {
  206. PlgDialog.close(index);
  207. timer.reload();
  208. PlgDialog.msg(data.message);
  209. }
  210. });
  211. }
  212. );
  213. } else if (name == "pauseJobs") {
  214. timerList_pauseJobs(ids);
  215. } else if (name == "resumeJobs") {
  216. timerList_resumeJobs(ids);
  217. }
  218. });
  219. function timerList_add() {
  220. timer.showDialog(0, "添加", 450, 490, { url: "/api/service-quartz/job", type: "post", contentType: "application/json" });
  221. var g = timer.getGridForm();
  222. // g.loadComboData("systemId",{url:'/api/service-users/sys/getSelectSystem/v1.0',data:{},valueField:"val",textField:"val",method:"get"});
  223. }
  224. function update(id) {
  225. $("#timerList #id").val(id);
  226. timer.selectRowById(id);
  227. timer.showDialog(1, "编辑", 450, 490, { url: "/api/service-quartz/job", type: "put", contentType: "application/json" });
  228. var g = timer.getGridForm();
  229. // g.loadComboData("systemId",{url:'/api/service-users/sys/getSelectSystem/v1.0',data:{},valueField:"val",textField:"val",method:"get"});
  230. }
  231. function log(id, data) {
  232. var index = PlgDialog.open({
  233. type: 1,
  234. title: "日志列表",
  235. shade: 0,
  236. area: ["900px", "630px"],
  237. offset: ["20px", "150px"],
  238. skin: "layui-layer-lan",
  239. content: $("#timeList_mywin"),
  240. closeBtn: 1,
  241. btn: [],
  242. success: function (layero) {
  243. var opts1 = {
  244. columns: [
  245. { id: "id", name: "id", type: "txt", hidden: true },
  246. { id: "createTime", name: "记录时间", type: "ro", width: 150 },
  247. { id: "level", name: "日志级别", type: "ro", width: 120 },
  248. {
  249. id: "description",
  250. name: "日志描述",
  251. type: "ro",
  252. width: 220,
  253. render: function (v) {
  254. return data.jobName;
  255. }
  256. },
  257. { id: "errorMessage", name: "日志信息", type: "ro", width: "*" },
  258. { id: "uri", name: "接口地址", type: "ro", width: 150, hidden: true },
  259. { id: "params", name: "参数", type: "ro", width: 120, hidden: true },
  260. { id: "systemId", name: "系统id", type: "ro", width: 120, hidden: true }
  261. ],
  262. url: "/api/service-log/log/getLogList", //数据接口
  263. type: "get", //数据提交方式,默认为get
  264. params: { systemId: data.systemId, description: data.description, pageNum: 1, pageSize: 10 }, //查询提交参数,分页参数默认为pageNum,pageSize
  265. page: true, //是否启用分页
  266. multiselect: false, //是否支持多选
  267. totalCount: "totalCount" //总记录数字段,默认totalCount
  268. };
  269. grid1 = new PlgGrid(opts1);
  270. grid1.renderTo("timeList_g1");
  271. grid1.loadData();
  272. },
  273. end: function () {
  274. $("#timeList_mywin").hide();
  275. }
  276. });
  277. }
  278. function timerList_pauseJobs(ids) {
  279. //暂停
  280. if (ids == "") {
  281. return;
  282. }
  283. PlgDialog.confirm(
  284. "确定暂停?",
  285. {
  286. title: "提示",
  287. btnAlign: "c",
  288. btn: ["确定", "取消"]
  289. },
  290. function (index, layero) {
  291. Prolog.ajax({
  292. url: "/api/service-quartz/job/pauseJob?ids=" + ids,
  293. type: "post",
  294. success: function (data) {
  295. PlgDialog.close(index);
  296. timer.reload();
  297. PlgDialog.msg(data.message);
  298. }
  299. });
  300. }
  301. );
  302. }
  303. function timerList_resumeJobs(ids) {
  304. //启动
  305. if (ids == "") {
  306. return;
  307. }
  308. PlgDialog.confirm(
  309. "确定启动?",
  310. {
  311. title: "提示",
  312. btnAlign: "c",
  313. btn: ["确定", "取消"]
  314. },
  315. function (index, layero) {
  316. Prolog.ajax({
  317. url: "/api/service-quartz/job/resumeJob?ids=" + ids,
  318. type: "post",
  319. success: function (data) {
  320. PlgDialog.close(index);
  321. timer.reload();
  322. PlgDialog.msg(data.message);
  323. }
  324. });
  325. }
  326. );
  327. }
  328. // timer.on("onRowDblClicked",function(){
  329. // timer.showDialog(1,"编辑",450,300,{url:"/api/service-quartz/timer",type:"put",contentType:"application/json"});
  330. // });
  331. var f = timer.getToolBarForm();
  332. // f.loadComboData("systemId",{url:'/api/service-users/sys/getSelectSystem/v1.0',data:{},valueField:"val",textField:"val",method:"get"});
  333. })();
  334. </script>