$(function(){ ua.table.render({ init: init, cols: [[ {type: 'checkbox'}, {field: 'id', title: 'ID', width: 80}, {field: 'task_name', title: '任务名称', minWidth: 160}, {field: 'run_type', search: 'select', selectList: ua.getDataBrage('select_list_run_type'), title: '运行类型', width: 130, templet: function(d){ var map = ua.getDataBrage('select_list_run_type'); return map[d.run_type] || d.run_type; }}, {field: 'status', search: 'select', selectList: ua.getDataBrage('select_list_status'), title: '状态', width: 100, templet: ua.table.switch}, {field: 'is_synced', search: 'select', selectList: ua.getDataBrage('select_list_is_synced'), title: '同步状态', width: 100, templet: function(d){ if(d.is_synced == 1){ return '已同步'; } return '未同步'; }}, {field: 'last_execute_node', title: '最后执行节点', width: 140}, {field: 'last_execute_time', title: '最后执行时间', width: 170, templet: function(d){ if(!d.last_execute_time || d.last_execute_time == 0){ return '暂无'; } var date = new Date(d.last_execute_time * 1000); var Y = date.getFullYear(); var m = ('0' + (date.getMonth()+1)).slice(-2); var day = ('0' + date.getDate()).slice(-2); var H = ('0' + date.getHours()).slice(-2); var i = ('0' + date.getMinutes()).slice(-2); var s = ('0' + date.getSeconds()).slice(-2); return Y+'-'+m+'-'+day+' '+H+':'+i+':'+s; }}, { width: 200, title: '操作', templet: ua.table.tool, fixed: 'right', operat: [ [{ class: 'layui-btn layui-btn-primary layui-btn-xs', method: 'tab', field: 'id', text: '详情', title: '查看详情', auth: 'read', url: init.readUrl, icon: '' }], 'edit', [{ class: 'layui-btn layui-btn-warm layui-btn-xs', method: 'request', field: 'id', text: '触发', title: '手动触发', auth: 'trigger', url: init.triggerUrl, icon: '', extend: '', callback: function(o){ // 只对 manual 类型显示,通过 CSS 控制显隐 } }] ] }, ]], }); // 控制触发按钮显隐:只有 run_type=manual 时显示 ua.listen(); // 监听表格渲染完成后处理触发按钮显隐 $(document).on('renderComplete', function(){ $('table tbody tr').each(function(){ var runType = $(this).find('td[data-field="run_type"] .layui-table-cell').text().trim(); if(runType !== 'manual'){ $(this).find('.layui-btn[title="手动触发"]').hide(); } }); }); })