lihai-oa/app/oa/view/approve/add_jiaban.html

118 lines
3.7 KiB
HTML
Raw Permalink Normal View History

2023-10-24 15:17:16 +08:00
{extend name="../../base/view/common/base" /}
{block name="style"}
{include file="/approve/add_style" /}
{/block}
<!-- 主体 -->
{block name="body"}
<form class="layui-form p-4">
<h3 class="pb-3">加班申请审批</h3>
{eq name="$id" value="0"}
<table class="layui-table layui-table-form">
<tr>
<td class="layui-td-gray">开始时间<font>*</font></td>
<td>
<input id="start_time" name="start_time" autocomplete="off" class="layui-input select-time" value="" readonly lay-verify="required" placeholder="请选择时间" lay-reqText="请选择时间">
</td>
<td class="layui-td-gray">结束时间<font>*</font></td>
<td>
<input type="hidden" name="duration" value="">
<input id="end_time" name="end_time" autocomplete="off" class="layui-input select-time" value="" readonly lay-verify="required" placeholder="请选择时间" lay-reqText="请选择时间">
</td>
</tr>
<tr>
<td class="layui-td-gray">加班时长</td>
<td colspan="3" id="duration">-</td>
</tr>
<tr>
<td class="layui-td-gray">加班事由<font>*</font></td>
<td colspan="3">
<textarea name="content" placeholder="请输入加班事由" class="layui-textarea" lay-verify="required" lay-reqText="请输入加班事由"></textarea>
</td>
</tr>
</table>
{else/}
<table class="layui-table layui-table-form">
<tr>
<td class="layui-td-gray">开始时间<font>*</font></td>
<td>
<input id="start_time" name="start_time" autocomplete="off" class="layui-input select-time" value="{$detail.start_time|date='Y-m-d H:i:s'}" readonly lay-verify="required" placeholder="请选择时间" lay-reqText="请选择时间">
</td>
<td class="layui-td-gray">结束时间<font>*</font></td>
<td>
<input type="hidden" name="duration" value="">
<input id="end_time" name="end_time" autocomplete="off" class="layui-input select-time" value="{$detail.end_time|date='Y-m-d H:i:s'}" readonly lay-verify="required" placeholder="请选择时间" lay-reqText="请选择时间">
</td>
</tr>
<tr>
<td class="layui-td-gray">加班时长</td>
<td colspan="5" id="duration">共{$detail.duration}工时</td>
</tr>
<tr>
<td class="layui-td-gray">请假事由<font>*</font></td>
<td colspan="5">
<textarea name="content" placeholder="请输入请假理由" class="layui-textarea" lay-verify="required" lay-reqText="请输入请假理由">{$detail.content}</textarea>
</td>
</tr>
</table>
{/eq}
{include file="/approve/add_flow" /}
</form>
{/block}
<!-- /主体 -->
<!-- 脚本 -->
{block name="script"}
<script>
/**
* 工时计算
*/
function leaveTime() {
var start_date = $('#start_time').val();
var end_date = $('#end_time').val();
if(start_date=='' || end_date==''){
return 0;
}
var start = new Date(start_date.replace(/-/g,'/'));
var end = new Date(end_date.replace(/-/g,'/'));
var diff=end.getTime() - start.getTime();//时间差的毫秒数
if(diff<0){
return 0;
}
//计算出小时数
var hours=diff/(3600*1000);
console.log(hours);
return hours.toFixed(1);
}
const moduleInit = ['tool','employeepicker'];
function gouguInit() {
var form = layui.form,tool=layui.tool, employeepicker = layui.employeepicker,laydate = layui.laydate;
if (typeof (flowStep) == "function") {
flowStep();
}
//日期时间范围
lay('.select-time').each(function () {
laydate.render({
elem: this,
trigger: 'click',
fullPanel:true,
type:'datetime',
done:function(){
var hours = leaveTime();
if(hours == 0){
$('#duration').html('-');
}
else{
$('#duration').html('共'+hours+'小时');
}
$('[name="duration"]').val(hours);
}
});
});
}
</script>
{/block}
<!-- /脚本 -->