lyg
2025-03-04 72bbec1590f85974d369ce7aeaa05be8905672a0
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
{extend name="../../base/view/common/base" /}
{block name="style"}
<style>
.layui-unselect dl {max-height:200px;}
</style>
{/block}
<!-- 主体 -->
{block name="body"}
<div class="p-page">
    <form class="layui-form gg-form-bar border-x border-t" lay-filter="barsearchform">
        <div class="layui-input-inline" style="width:180px">
            <input type="text"  name="diff_time" class="layui-input tool-time" data-range="~" placeholder="选择时间区间" readonly>
        </div>
        {gt name="is_leader" value="0"}
        <div class="layui-input-inline" style="width:120px;">
            <input type="text" name="username" placeholder="请选择下属员工" class="layui-input picker-sub" readonly />
            <input type="text" name="uid" value="" style="display:none" />    
        </div>
        {/gt}
        <div class="layui-input-inline" style="width:130px;">
            <select name="cid">
                <option value="">选择工作类别</option>
                {volist name=":get_base_data('WorkCate')" id="vo"}
                <option value="{$vo.id}">{$vo.title}</option>
                {/volist}
            </select>
        </div>
        <div class="layui-input-inline" style="width:130px;">
            <select name="labor_type">
                <option value="">选择工作类型</option>
                <option value="1">案头工作</option>
                <option value="2">外勤工作</option>
            </select>
        </div>
        <div class="layui-input-inline" style="width:220px;">
            <input type="text" name="keywords"  placeholder="输入关键字,工作内容" class="layui-input"/>
        </div>    
        <div class="layui-input-inline" style="width:150px;">
            <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="table-search"><i class="layui-icon layui-icon-search mr-1"></i>搜索</button>
            <button type="reset" class="layui-btn layui-btn-reset" lay-filter="table-reset">清空</button>
        </div>
    </form> 
    <div>
        <table class="layui-hide" id="test" lay-filter="test"></table>
    </div>
</div>
<script type="text/html" id="toolbarDemo">
  <div class="layui-btn-container">
      <button class="layui-btn layui-btn-sm addLoan" type="button">+ 新增工作记录</button>
  </div>
</script>
{/block}
<!-- /主体 -->
 
<!-- 脚本 -->
{block name="script"}
    <script>
    const is_leader = '{$is_leader}';
    const role_auth = '{$role_auth}';
    const hour_auth = '{$hour_auth}';
    const moduleInit = ['tool','tablePlus','oaPicker','oaSchedule'];
    function gouguInit() {
        var form = layui.form,table = layui.tablePlus,tool=layui.tool, laydate = layui.laydate,work = layui.oaSchedule;      
        //日期范围
        laydate.render({
            elem: '#barDate',
            range: ['#start_time', '#end_time']
        });
 
        layui.scheduleTable = table.render({
            elem: '#test'
            ,toolbar: '#toolbarDemo'
            ,title:'工作记录列表'
            ,url: "/oa/schedule/datalist"
            ,cellMinWidth: 80
            ,height: 'full-112'
            ,cols: [[ //表头
                {field: 'id', title: '序号',fixed: 'left', width:80, align:'center'}
                ,{field: 'labor_type_string', title: '工作类型', align:'center',width:100,templet:function(d){
                    var html='';
                    if(d.labor_type==0){
                        html='<span class="layui-color-'+d.labor_type+'">-</span>';
                    }
                    else if(d.labor_type == 1){
                        html='<span class="layui-color-'+d.labor_type+'">『案头工作』</span>';
                    }
                    else if(d.labor_type == 2){
                        html='<span class="layui-color-'+d.labor_type+'">『外勤工作』</span>';
                    }
                    return html;
                }}
                ,{field: 'work_cate', title: '工作类别', align:'center',width:100}
                ,{field: 'start_time', title: '工作时间范围', align:'center',width:186,templet:function(d){
                    var html=d.start_time+'至'+d.end_time;
                    return html;
                }}
                ,{field: 'name', title: '执行人', align:'center',width:80}
                ,{field: 'labor_time', title: '工时', align:'center',width:80}
                ,{field: 'title', title: '工作内容'}
                ,{field: 'create_time', title: '记录时间', align:'center',width:150}
                ,{field: 'right', title: '操作',fixed:'right', width:150, align:'center',templet:function(d){
                    var html='<div class="layui-btn-group">';
                    if(hour_auth==2 && d.admin_id==login_admin){
                        //开放员工自己调整
                        html+='<button class="layui-btn layui-btn-xs layui-btn-danger" lay-event="time">调整工时</button>';
                    }
                    if(hour_auth==3 && is_leader > 0){
                        //开放部门负责人调整
                        html+='<button class="layui-btn layui-btn-xs layui-btn-danger" lay-event="time">调整工时</button>';
                    }
                    if(hour_auth==4 && role_auth > 0){
                        //开放日常办公数据管理员调整
                        html+='<button class="layui-btn layui-btn-xs layui-btn-danger" lay-event="time">调整工时</button>';
                    }
                    if(d.admin_id==login_admin){
                        html+='<button class="layui-btn layui-btn-xs" lay-event="edit">编辑</button>';
                    }
                    html+='<button class="layui-btn layui-btn-xs layui-btn-normal" lay-event="view">查看</button>';
                    html+='</div>';
                    return html;
                }}
            ]]
        });
 
        //更改工时
        table.on('tool(test)', function(obj){
            var data = obj.data;
            if(obj.event === 'time'){
              var content='<form class="layui-form" style="width:666px">\
                            <table class="layui-table" style="margin:12px 12px 0;">\
                                <tr>\
                                    <td class="layui-td-gray-2">工作时间范围<font>*</font></td>\
                                    <td>\
                                        <input id="start_time_a" name="start_time_a" style="width:150px; display:inline-block;" autocomplete="off" class="layui-input" value="" readonly lay-verify="required" lay-reqText="请选择"><div style="display: inline-block; margin-left:5px; width: 90px;"><select lay-filter="start_time_b" id="start_time_b"></select></div> 至 <input id="end_time_a" name="end_time_a" style="width:150px; display:inline-block;" autocomplete="off" class="layui-input" value="" readonly lay-verify="required" lay-reqText="请选择"><div style="display: inline-block; margin-left:5px; width: 90px;"><select lay-filter="end_time_b" id="end_time_b"></select></div>\
                                    </td>\
                                </tr>\
                            </table>\
                        </form>';
                layer.open({
                    type:1,
                    title:'调整工时',
                    area:['692px','398px'],
                    content:content,
                    success:function(){
                        //日期时间范围
                        laydate.render({
                            elem: '#start_time_a',
                            type: 'date',
                            max:0,
                            format: 'yyyy-MM-dd',
                            showBottom: false,
                            done:function(a,b,c){
                                $('#end_time_a').val(a);
                            }
                        });
 
                        //日期时间范围
                        laydate.render({
                            elem: '#end_time_a',
                            type: 'date',
                            max:0,
                            format: 'yyyy-MM-dd',
                            showBottom: false,
                            done:function(a,b,c){
                                $('#start_time_a').val(a);
                            }
                        });
                        $('#start_time_b,#end_time_b').empty();
                        
                        var hourArray=[];
                        for(var h=0;h<24;h++){
                            var t=h<10?'0'+h:h
                            var t_1=t+':00',t_2=t+':15',t_3=t+':30',t_4=t+':45';
                            hourArray.push(t_1,t_2,t_3,t_4);
                        }
                        
                        var html_1='', html_2='',def_h1='09:00',def_h2='09:30';
                        for(var s=0;s<hourArray.length;s++){
                            var check_1='',check_2='';
                            if(hourArray[s]==def_h1){
                                check_1='selected';
                            }
                            if(hourArray[s]==def_h2){
                                check_2='selected';
                            }
                            html_1 += '<option value="'+hourArray[s]+'" '+check_1+'>'+hourArray[s]+'</option>';
                            html_2 += '<option value="'+hourArray[s]+'" '+check_2+'>'+hourArray[s]+'</option>';
                        }
                        
                        $('#start_time_b').append(html_1);
                        $('#end_time_b').append(html_2);
                        form.render();
                    
                    },
                    btn: ['确定提交'],
                    btnAlign: 'c',
                    yes: function(idx){
                        let start_time_a = $('#start_time_a').val();
                        let end_time_a = $('#end_time_a').val();
                        let start_time_b = $('#start_time_b').val();
                        let end_time_b = $('#end_time_b').val();
                        if(start_time_a=='' || end_time_a==''){
                            layer.msg('请选择工作时间范围');
                            return;
                        }
                        $.ajax({
                            url: "/oa/api/update_schedule",
                            type:'post',
                            data:{
                                id:data.id,
                                admin_id:data.admin_id,
                                start_time_a:start_time_a,
                                end_time_a:end_time_a,
                                start_time_b:start_time_b,
                                end_time_b:end_time_b
                            },
                            success:function(e){
                                layer.msg(e.msg);
                                if(e.code==0){                                
                                    layer.close(idx);                                
                                    layui.scheduleTable.reload();
                                }
                            }
                        })            
                    }
                })
            }
            else if(obj.event === 'edit'){
                work.add(0, obj.data);    
            }
            else if(obj.event === 'view'){
                work.view(obj.data);                
            }
        });
          
        $('body').on('click','.addLoan',function(){
            work.add(0,{'id':0});    
        });      
    }
        
    </script>
{/block}
<!-- /脚本 -->