YM
2025-03-28 3bd8985e73fa326454ed8b8e1b1b60245caff89b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
layui.define(['tool'], function (exports) {
    const tool = layui.tool;
    const obj = {
        load: function (box,name, action_id) {
            let page=1;
            let callback = function (res) {
                if (res.code == 0 && res.data.length > 0) {
                    let itemLog = '',log_time='';
                    $.each(res.data, function (index, item) {
                        let detail = "";
                        if(log_time != item.create_time){
                            if(log_time==''){
                                itemLog+='<dl><dt><span class="date-second-point"></span>'+item.create_time+'</dt>'
                            }
                            else{
                                itemLog+='</dl><dl><dt><span class="date-second-point"></span>'+item.create_time+'</dt>'
                            }
                            log_time =     item.create_time;            
                        }
                        detail= `
                            <span class="log-content gray">将<strong>${item.field_name}</strong>从 <span class="green">${item.old_content}</span> ${item.action}为 <span class="blue">${item.new_content}</span><span class="ml-4 gray" title="${item.create_time}">${item.times}</span></span>
                        `;
                        itemLog+= `
                            <dd><img src="${item.thumb}" class="log-thumb" /><span class="log-name">${item.admin_name}</span>${detail}</dd>
                        `;
                    });
                    itemLog+='</dl>';
                    if(res.data.length>19){
                        itemLog+='<div class="py-3 log-more"><button class="layui-btn layui-btn-normal layui-btn-sm" type="button">查看更多</button></div>';
                    }
                    $("#"+box).html(itemLog);
                }
                else{
                    if(page ==1){
                        $("#"+box).html('<div class="layui-data-none">暂无记录</div>');
                    }
                }
            }
            tool.get("/api/index/load_log", {name:name,action_id:action_id,page:page}, callback);
            $("#"+box).on('click','.log-more',function(){
                page++;
                tool.get("/api/index/load_log", {name:name,action_id:action_id,page:page}, callback);
            });
        }
    };
    exports('oaLog', obj);
});