diff --git a/class/core/crontab_api.py b/class/core/crontab_api.py index 65ef2f459..fbf8fd84b 100755 --- a/class/core/crontab_api.py +++ b/class/core/crontab_api.py @@ -21,8 +21,47 @@ class crontab_api: def listApi(self): _list = public.M('crontab').where('', ()).field('id,name,type,where1,where_hour,where_minute,echo,addtime,status,save,backup_to,stype,sname,sbody,urladdress').limit( '0,5').order('id desc').select() + + data = [] + for i in range(len(_list)): + tmp = _list[i] + if _list[i]['type'] == "day": + tmp['type'] = '每天' + tmp['cycle'] = public.getInfo('每天, {1}点{2}分 执行', (str( + _list[i]['where_hour']), str(_list[i]['where_minute']))) + elif _list[i]['type'] == "day-n": + tmp['type'] = public.getInfo( + '每{1}天', (str(_list[i]['where1']),)) + tmp['cycle'] = public.getInfo('每隔{1}天, {2}点{3}分 执行', (str( + _list[i]['where1']), str(_list[i]['where_hour']), str(_list[i]['where_minute']))) + elif _list[i]['type'] == "hour": + tmp['type'] = '每小时' + tmp['cycle'] = public.getInfo( + '每小时, 第{1}分钟 执行', (str(_list[i]['where_minute']),)) + elif _list[i]['type'] == "hour-n": + tmp['type'] = public.getInfo( + '每{1}小时', (str(_list[i]['where1']),)) + tmp['cycle'] = public.getInfo('每{1}小时, 第{2}分钟 执行', (str( + _list[i]['where1']), str(_list[i]['where_minute']))) + elif _list[i]['type'] == "minute-n": + tmp['type'] = public.getInfo( + '每{1}分钟', (str(_list[i]['where1']),)) + tmp['cycle'] = public.getInfo( + '每隔{1}分钟执行', (str(_list[i]['where1']),)) + elif _list[i]['type'] == "week": + tmp['type'] = '每周' + if not _list[i]['where1']: + _list[i]['where1'] = '0' + tmp['cycle'] = public.getInfo('每周{1}, {2}点{3}分执行', (self.toWeek(int( + _list[i]['where1'])), str(_list[i]['where_hour']), str(_list[i]['where_minute']))) + elif _list[i]['type'] == "month": + tmp['type'] = '每月' + tmp['cycle'] = public.getInfo('每月, {1}日 {2}点{3}分执行', (str(_list[i]['where1']), str( + _list[i]['where_hour']), str(_list[i]['where_minute']))) + data.append(tmp) + _ret = {} - _ret['data'] = _list + _ret['data'] = data count = public.M('crontab').where('', ()).count() _page = {} @@ -32,6 +71,9 @@ class crontab_api: _ret['page'] = public.getPage(_page) return public.getJson(_ret) + def logsApi(self): + return public.returnJson(False, '添加失败') + def addApi(self): name = request.form.get('name', '') type = request.form.get('type', '') @@ -44,6 +86,7 @@ class crontab_api: sName = request.form.get('sName', '') sBody = request.form.get('sBody', '') urladdress = request.form.get('urladdress', '') + if len(name) < 1: return public.returnJson(False, '任务名称不能为空!') @@ -62,3 +105,19 @@ class crontab_api: except Exception as e: return public.returnJson(False, '删除失败') ##### ----- start ----- ### + + # 转换大写星期 + def toWeek(self, num): + wheres = { + 0: '日', + 1: '一', + 2: '二', + 3: '三', + 4: '四', + 5: '五', + 6: '六' + } + try: + return wheres[num] + except: + return '' diff --git a/route/static/app/crontab.js b/route/static/app/crontab.js index 202326418..8a0273fee 100755 --- a/route/static/app/crontab.js +++ b/route/static/app/crontab.js @@ -1,9 +1,9 @@ var num = 0; //查看任务日志 function getLogs(id){ - layer.msg(lan.public.the_get,{icon:16,time:0,shade: [0.3, '#000']}); - var data='&id='+id - $.post('/crontab?action=GetLogs',data,function(rdata){ + layer.msg('正在获取,请稍候...',{icon:16,time:0,shade: [0.3, '#000']}); + var data='&id='+id; + $.post('/crontab/logs', data, function(rdata){ layer.closeAll(); if(!rdata.status) { layer.msg(rdata.msg,{icon:2}); @@ -18,39 +18,45 @@ function getLogs(id){ content:'