优化:审批模块的请假、出差、外出、加班、用车等时长的计算,新的计算方式按照天计算,最小是0.5天。
注意,本次需要更新数据库: ALTER TABLE `oa_approve` ADD COLUMN `start_time_span` int(1) NOT NULL DEFAULT 0 COMMENT '开始时间时段:1上午,2下午' AFTER `start_time`; ALTER TABLE `oa_approve` ADD COLUMN `end_time_span` int(1) NOT NULL DEFAULT 0 COMMENT '结束时间时段:1上午,2下午' AFTER `end_time`;
This commit is contained in:
parent
6e41c09e1a
commit
f26a7693c0
@ -644,8 +644,11 @@ function time_trans($time, $format = 'd')
|
||||
/**
|
||||
* 计算按天数
|
||||
*/
|
||||
function countDays($a, $b = 0)
|
||||
function countDays($a=0, $b = 0)
|
||||
{
|
||||
if ($a == 0) {
|
||||
$a = date("Y-m-d");
|
||||
}
|
||||
if ($b == 0) {
|
||||
$b = date("Y-m-d");
|
||||
}
|
||||
|
@ -1197,7 +1197,9 @@ CREATE TABLE `oa_approve` (
|
||||
`remark1` varchar(500) NOT NULL DEFAULT '' COMMENT '备注1',
|
||||
`detail_time` int(11) NOT NULL DEFAULT 0 COMMENT '时间日期',
|
||||
`start_time` int(11) NOT NULL DEFAULT 0 COMMENT '开始时间',
|
||||
`start_time_span` int(1) NOT NULL DEFAULT 0 COMMENT '开始时间时段:1上午,2下午',
|
||||
`end_time` int(11) NOT NULL DEFAULT 0 COMMENT '结束时间',
|
||||
`end_time_span` int(1) NOT NULL DEFAULT 0 COMMENT '结束时间时段:1上午,2下午',
|
||||
`duration` decimal(10, 1) NOT NULL DEFAULT 0.0 COMMENT '时长',
|
||||
`admin_id` int(10) NOT NULL COMMENT '创建人ID',
|
||||
`department_id` int(10) NOT NULL COMMENT '创建人部门ID',
|
||||
|
@ -239,16 +239,12 @@ class Approve extends BaseController
|
||||
if (isset($param['end_time'])) {
|
||||
$param['end_time'] = strtotime($param['end_time']);
|
||||
if ($param['end_time'] < $param['start_time']) {
|
||||
return to_assign(1, "时间选择有误");
|
||||
return to_assign(1, "结束时间不能小于开始时间");
|
||||
}
|
||||
}
|
||||
if (isset($param['start_time_a'])) {
|
||||
$param['start_time'] = strtotime($param['start_time_a'] . '' . $param['start_time_b']);
|
||||
}
|
||||
if (isset($param['end_time_a'])) {
|
||||
$param['end_time'] = strtotime($param['end_time_a'] . '' . $param['end_time_b']);
|
||||
if ($param['end_time'] <= $param['start_time']) {
|
||||
return to_assign(1, "结束时间需要大于开始时间");
|
||||
if (isset($param['duration'])) {
|
||||
if ($param['duration'] <=0) {
|
||||
return to_assign(1, "时间区间选择错误");
|
||||
}
|
||||
}
|
||||
$flow_list = Db::name('Flow')->where('id',$param['flow_id'])->value('flow_list');
|
||||
@ -435,12 +431,15 @@ class Approve extends BaseController
|
||||
$detail = Db::name('Approve')->where('id',$param['id'])->find();
|
||||
$check_record = [];
|
||||
if($detail['start_time']>0){
|
||||
$detail['start_time'] = date('Y-m-d H:i',$detail['start_time']);
|
||||
$detail['start_time_hour'] = date('Y-m-d H:i:s',$detail['start_time']);
|
||||
$detail['start_time'] = date('Y-m-d',$detail['start_time']);
|
||||
}
|
||||
if($detail['end_time']>0){
|
||||
$detail['end_time'] = date('Y-m-d H:i',$detail['end_time']);
|
||||
$detail['end_time_hour'] = date('Y-m-d H:i:s',$detail['end_time']);
|
||||
$detail['end_time'] = date('Y-m-d',$detail['end_time']);
|
||||
}
|
||||
if($detail['detail_time']>0){
|
||||
$detail['detail_time_hour'] = date('Y-m-d H:i:s',$detail['detail_time']);
|
||||
$detail['detail_time'] = date('Y-m-d',$detail['detail_time']);
|
||||
}
|
||||
|
||||
|
@ -4,21 +4,36 @@
|
||||
{/block}
|
||||
<!-- 主体 -->
|
||||
{block name="body"}
|
||||
<form class="layui-form p-4">
|
||||
<form class="layui-form p-4" lay-filter="demo-val-filter">
|
||||
<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 class="layui-td-gray-2">开始时间<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="请选择时间">
|
||||
<div class="layui-input-inline" style="width:120px; margin-right:16px;">
|
||||
<input id="start_time" name="start_time" autocomplete="off" class="layui-input select-time" value="" readonly lay-verify="required" placeholder="请选择时间" lay-reqText="请选择时间">
|
||||
</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="start_time_span" value="1" title="上午" checked lay-filter="starttype">
|
||||
<input type="radio" name="start_time_span" value="2" title="下午" lay-filter="starttype">
|
||||
</div>
|
||||
</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="请选择时间">
|
||||
<div class="layui-input-inline" style="width:120px; margin-right:16px;">
|
||||
<input id="end_time" name="end_time" autocomplete="off" class="layui-input select-time" value="" readonly lay-verify="required" placeholder="请选择时间" lay-reqText="请选择时间">
|
||||
</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="end_time_span" value="1" title="上午" lay-filter="endtype">
|
||||
<input type="radio" name="end_time_span" value="2" title="下午" checked lay-filter="endtype">
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">出差天数</td>
|
||||
<td colspan="3"><span id="days">-</span><input type="hidden" id="duration" name="duration" value="0"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">出差地点<font>*</font></td>
|
||||
<td colspan="3"><input type="text" name="address" value="" autocomplete="off" placeholder="请输入出差地点" lay-verify="required" lay-reqText="请输入出差地点" class="layui-input"></td>
|
||||
@ -41,16 +56,31 @@
|
||||
{else/}
|
||||
<table class="layui-table layui-table-form">
|
||||
<tr>
|
||||
<td class="layui-td-gray">开始时间<font>*</font></td>
|
||||
<td class="layui-td-gray-2">开始时间<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="请选择时间">
|
||||
<div class="layui-input-inline" style="width:120px; margin-right:16px;">
|
||||
<input id="start_time" name="start_time" autocomplete="off" class="layui-input select-time" value="{$detail.start_time|date='Y-m-d'}" readonly lay-verify="required" placeholder="请选择时间" lay-reqText="请选择时间">
|
||||
</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="start_time_span" value="1" title="上午" lay-filter="starttype" {eq name="$detail.start_time_span" value="1"} checked{/eq}>
|
||||
<input type="radio" name="start_time_span" value="2" title="下午" lay-filter="starttype" {eq name="$detail.start_time_span" value="2"} checked{/eq}>
|
||||
</div>
|
||||
</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="请选择时间">
|
||||
<div class="layui-input-inline" style="width:120px; margin-right:16px;">
|
||||
<input id="end_time" name="end_time" autocomplete="off" class="layui-input select-time" value="{$detail.end_time|date='Y-m-d'}" readonly lay-verify="required" placeholder="请选择时间" lay-reqText="请选择时间">
|
||||
</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="end_time_span" value="1" title="上午" lay-filter="endtype" {eq name="$detail.end_time_span" value="1"} checked{/eq}>
|
||||
<input type="radio" name="end_time_span" value="2" title="下午" lay-filter="endtype" {eq name="$detail.end_time_span" value="2"} checked{/eq}>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">出差天数</td>
|
||||
<td colspan="3">共 <span id="days">{$detail.duration|default='-'}</span> 天<input type="hidden" id="duration" name="duration" value="{$detail.duration|default='0'}"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">出差地点<font>*</font></td>
|
||||
<td colspan="3"><input type="text" name="address" value="{$detail.address}" autocomplete="off" placeholder="请输入出差地点" lay-verify="required" lay-reqText="请输入出差地点" class="layui-input"></td>
|
||||
@ -84,30 +114,82 @@
|
||||
<!-- 脚本 -->
|
||||
{block name="script"}
|
||||
<script>
|
||||
/*
|
||||
* 时长计算
|
||||
*/
|
||||
function daysBetweenDates(date1, date2) {
|
||||
var date1 = $('#start_time').val();
|
||||
var date2 = $('#end_time').val();
|
||||
if(date1=='' || date2==''){
|
||||
return -1;
|
||||
}
|
||||
var startDate = new Date(date1);
|
||||
var endDate = new Date(date2);
|
||||
var millisecondsPerDay = 24 * 60 * 60 * 1000;
|
||||
var differenceInMilliseconds = endDate - startDate;
|
||||
var differenceInDays = differenceInMilliseconds / millisecondsPerDay;
|
||||
return Math.round(differenceInDays);
|
||||
}
|
||||
|
||||
const moduleInit = ['tool','employeepicker','oaTool'];
|
||||
function gouguInit() {
|
||||
var form = layui.form,
|
||||
tool=layui.tool,
|
||||
oaTool=layui.oaTool,
|
||||
laydate = layui.laydate;
|
||||
|
||||
oaTool.addFile({
|
||||
btn: 'upFile',
|
||||
box: 'fileList'
|
||||
});
|
||||
|
||||
if (typeof (flowStep) == "function") {
|
||||
flowStep();
|
||||
}
|
||||
|
||||
function countDuration(){
|
||||
let hours = daysBetweenDates();
|
||||
if(hours < 0){
|
||||
$('#duration').val(0);
|
||||
$('#days').html('-');
|
||||
}
|
||||
else{
|
||||
let formData = form.val('demo-val-filter');
|
||||
if(formData.start_time_span==1){
|
||||
hours=hours+1;
|
||||
}
|
||||
if(formData.start_time_span==2){
|
||||
hours=hours+0.5;
|
||||
}
|
||||
if(formData.end_time_span==1){
|
||||
hours=hours-0.5;
|
||||
}
|
||||
if(hours<0){
|
||||
hours=0;
|
||||
}
|
||||
$('#duration').val(hours);
|
||||
$('#days').html(hours);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//日期时间范围
|
||||
lay('.select-time').each(function () {
|
||||
laydate.render({
|
||||
elem: this,
|
||||
trigger: 'click',
|
||||
fullPanel:true,
|
||||
type:'datetime'
|
||||
done:function(){
|
||||
countDuration();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
oaTool.addFile({
|
||||
btn: 'upFile',
|
||||
box: 'fileList'
|
||||
form.on('radio(starttype)',function(data){
|
||||
countDuration();
|
||||
});
|
||||
form.on('radio(endtype)',function(data){
|
||||
countDuration();
|
||||
});
|
||||
|
||||
if (typeof (flowStep) == "function") {
|
||||
flowStep();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
{/block}
|
||||
|
@ -24,7 +24,6 @@
|
||||
</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>
|
||||
@ -53,7 +52,6 @@
|
||||
</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>
|
||||
|
@ -27,7 +27,6 @@
|
||||
</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>
|
||||
@ -67,7 +66,6 @@
|
||||
</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>
|
||||
|
@ -4,24 +4,35 @@
|
||||
{/block}
|
||||
<!-- 主体 -->
|
||||
{block name="body"}
|
||||
<form class="layui-form p-4">
|
||||
<form class="layui-form p-4" lay-filter="demo-val-filter">
|
||||
<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 class="layui-td-gray-2">开始时间<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="请选择时间">
|
||||
<div class="layui-input-inline" style="width:120px; margin-right:16px;">
|
||||
<input id="start_time" name="start_time" autocomplete="off" class="layui-input select-time" value="" readonly lay-verify="required" placeholder="请选择时间" lay-reqText="请选择时间">
|
||||
</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="start_time_span" value="1" title="上午" checked lay-filter="starttype">
|
||||
<input type="radio" name="start_time_span" value="2" title="下午" lay-filter="starttype">
|
||||
</div>
|
||||
</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="请选择时间">
|
||||
<div class="layui-input-inline" style="width:120px; margin-right:16px;">
|
||||
<input id="end_time" name="end_time" autocomplete="off" class="layui-input select-time" value="" readonly lay-verify="required" placeholder="请选择时间" lay-reqText="请选择时间">
|
||||
</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="end_time_span" value="1" title="上午" lay-filter="endtype">
|
||||
<input type="radio" name="end_time_span" value="2" title="下午" checked lay-filter="endtype">
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">加班时长</td>
|
||||
<td colspan="3" id="duration">-</td>
|
||||
<td class="layui-td-gray">加班天数</td>
|
||||
<td colspan="3">共 <span id="days">-</span> 天<input type="hidden" id="duration" name="duration" value="0"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">加班事由<font>*</font></td>
|
||||
@ -33,19 +44,30 @@
|
||||
{else/}
|
||||
<table class="layui-table layui-table-form">
|
||||
<tr>
|
||||
<td class="layui-td-gray">开始时间<font>*</font></td>
|
||||
<td class="layui-td-gray-2">开始时间<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="请选择时间">
|
||||
<div class="layui-input-inline" style="width:120px; margin-right:16px;">
|
||||
<input id="start_time" name="start_time" autocomplete="off" class="layui-input select-time" value="{$detail.start_time|date='Y-m-d'}" readonly lay-verify="required" placeholder="请选择时间" lay-reqText="请选择时间">
|
||||
</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="start_time_span" value="1" title="上午" lay-filter="starttype" {eq name="$detail.start_time_span" value="1"} checked{/eq}>
|
||||
<input type="radio" name="start_time_span" value="2" title="下午" lay-filter="starttype" {eq name="$detail.start_time_span" value="2"} checked{/eq}>
|
||||
</div>
|
||||
</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="请选择时间">
|
||||
<div class="layui-input-inline" style="width:120px; margin-right:16px;">
|
||||
<input id="end_time" name="end_time" autocomplete="off" class="layui-input select-time" value="{$detail.end_time|date='Y-m-d'}" readonly lay-verify="required" placeholder="请选择时间" lay-reqText="请选择时间">
|
||||
</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="end_time_span" value="1" title="上午" lay-filter="endtype" {eq name="$detail.end_time_span" value="1"} checked{/eq}>
|
||||
<input type="radio" name="end_time_span" value="2" title="下午" lay-filter="endtype" {eq name="$detail.end_time_span" value="2"} checked{/eq}>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">加班时长</td>
|
||||
<td colspan="5" id="duration">共{$detail.duration}工时</td>
|
||||
<td class="layui-td-gray">加班天数</td>
|
||||
<td colspan="3">共 <span id="days">{$detail.duration|default='-'}</span> 天<input type="hidden" id="duration" name="duration" value="{$detail.duration|default='0'}"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">请假事由<font>*</font></td>
|
||||
@ -63,55 +85,82 @@
|
||||
<!-- 脚本 -->
|
||||
{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;
|
||||
function daysBetweenDates(date1, date2) {
|
||||
var date1 = $('#start_time').val();
|
||||
var date2 = $('#end_time').val();
|
||||
if(date1=='' || date2==''){
|
||||
return -1;
|
||||
}
|
||||
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);
|
||||
var startDate = new Date(date1);
|
||||
var endDate = new Date(date2);
|
||||
var millisecondsPerDay = 24 * 60 * 60 * 1000;
|
||||
var differenceInMilliseconds = endDate - startDate;
|
||||
var differenceInDays = differenceInMilliseconds / millisecondsPerDay;
|
||||
return Math.round(differenceInDays);
|
||||
}
|
||||
|
||||
|
||||
const moduleInit = ['tool','employeepicker'];
|
||||
const moduleInit = ['tool','employeepicker','oaTool'];
|
||||
function gouguInit() {
|
||||
var form = layui.form,tool=layui.tool, employeepicker = layui.employeepicker,laydate = layui.laydate;
|
||||
|
||||
var form = layui.form,
|
||||
tool=layui.tool,
|
||||
oaTool=layui.oaTool,
|
||||
laydate = layui.laydate;
|
||||
|
||||
oaTool.addFile({
|
||||
btn: 'upFile',
|
||||
box: 'fileList'
|
||||
});
|
||||
|
||||
if (typeof (flowStep) == "function") {
|
||||
flowStep();
|
||||
}
|
||||
|
||||
function countDuration(){
|
||||
let hours = daysBetweenDates();
|
||||
if(hours < 0){
|
||||
$('#duration').val(0);
|
||||
$('#days').html('-');
|
||||
}
|
||||
else{
|
||||
let formData = form.val('demo-val-filter');
|
||||
if(formData.start_time_span==1){
|
||||
hours=hours+1;
|
||||
}
|
||||
if(formData.start_time_span==2){
|
||||
hours=hours+0.5;
|
||||
}
|
||||
if(formData.end_time_span==1){
|
||||
hours=hours-0.5;
|
||||
}
|
||||
if(hours<0){
|
||||
hours=0;
|
||||
}
|
||||
$('#duration').val(hours);
|
||||
$('#days').html(hours);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//日期时间范围
|
||||
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);
|
||||
countDuration();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
form.on('radio(starttype)',function(data){
|
||||
countDuration();
|
||||
});
|
||||
form.on('radio(endtype)',function(data){
|
||||
countDuration();
|
||||
});
|
||||
}
|
||||
</script>
|
||||
{/block}
|
||||
|
@ -4,7 +4,7 @@
|
||||
{/block}
|
||||
<!-- 主体 -->
|
||||
{block name="body"}
|
||||
<form class="layui-form p-4">
|
||||
<form class="layui-form p-4" lay-filter="demo-val-filter">
|
||||
<h3 class="pb-3">请假申请</h3>
|
||||
{eq name="$id" value="0"}
|
||||
<table class="layui-table layui-table-form">
|
||||
@ -28,18 +28,28 @@
|
||||
<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="请选择时间">
|
||||
<div class="layui-input-inline" style="width:120px; margin-right:16px;">
|
||||
<input id="start_time" name="start_time" autocomplete="off" class="layui-input select-time" value="" readonly lay-verify="required" placeholder="请选择时间" lay-reqText="请选择时间">
|
||||
</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="start_time_span" value="1" title="上午" checked lay-filter="starttype">
|
||||
<input type="radio" name="start_time_span" value="2" title="下午" lay-filter="starttype">
|
||||
</div>
|
||||
</td>
|
||||
<td class="layui-td-gray">结束时间<font>*</font></td>
|
||||
<td>
|
||||
<input id="end_time" name="end_time" autocomplete="off" class="layui-input select-time" value="" readonly lay-verify="required" placeholder="请选择时间" lay-reqText="请选择时间">
|
||||
<div class="layui-input-inline" style="width:120px; margin-right:16px;">
|
||||
<input id="end_time" name="end_time" autocomplete="off" class="layui-input select-time" value="" readonly lay-verify="required" placeholder="请选择时间" lay-reqText="请选择时间">
|
||||
</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="end_time_span" value="1" title="上午" lay-filter="endtype">
|
||||
<input type="radio" name="end_time_span" value="2" title="下午" checked lay-filter="endtype">
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">请假工时</td>
|
||||
<td><input name="duration" value="" class="layui-input" lay-verify="required|number" placeholder="请完善请假工时" lay-reqText="请完善请假工时"></td>
|
||||
<td class="layui-td-gray">请假天数</td>
|
||||
<td id="days">-</td>
|
||||
<td colspan="3"><span id="days">-</span><input type="hidden" id="duration" name="duration" value="0"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">请假事由<font>*</font></td>
|
||||
@ -78,18 +88,28 @@
|
||||
<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="请选择时间">
|
||||
<div class="layui-input-inline" style="width:120px; margin-right:16px;">
|
||||
<input id="start_time" name="start_time" autocomplete="off" class="layui-input select-time" value="{$detail.start_time|date='Y-m-d'}" readonly lay-verify="required" placeholder="请选择时间" lay-reqText="请选择时间">
|
||||
</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="start_time_span" value="1" title="上午" lay-filter="starttype" {eq name="$detail.start_time_span" value="1"} checked{/eq}>
|
||||
<input type="radio" name="start_time_span" value="2" title="下午" lay-filter="starttype" {eq name="$detail.start_time_span" value="2"} checked{/eq}>
|
||||
</div>
|
||||
</td>
|
||||
<td class="layui-td-gray">结束时间<font>*</font></td>
|
||||
<td>
|
||||
<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="请选择时间">
|
||||
<div class="layui-input-inline" style="width:120px; margin-right:16px;">
|
||||
<input id="end_time" name="end_time" autocomplete="off" class="layui-input select-time" value="{$detail.end_time|date='Y-m-d'}" readonly lay-verify="required" placeholder="请选择时间" lay-reqText="请选择时间">
|
||||
</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="end_time_span" value="1" title="上午" lay-filter="endtype" {eq name="$detail.end_time_span" value="1"} checked{/eq}>
|
||||
<input type="radio" name="end_time_span" value="2" title="下午" lay-filter="endtype" {eq name="$detail.end_time_span" value="2"} checked{/eq}>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">请假工时</td>
|
||||
<td><input name="duration" value="{$detail.duration}" class="layui-input" lay-verify="required|number" placeholder="请完善请假工时" lay-reqText="请完善请假工时"></td>
|
||||
<td class="layui-td-gray">请假天数</td>
|
||||
<td id="days">共{$detail.days}天,{$detail.hours}小时</td>
|
||||
<td colspan="3">共 <span id="days">{$detail.duration|default='-'}</span> 天<input type="hidden" id="duration" name="duration" value="{$detail.duration|default='0'}"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">请假事由<font>*</font></td>
|
||||
@ -120,63 +140,23 @@
|
||||
<!-- 脚本 -->
|
||||
{block name="script"}
|
||||
<script>
|
||||
/**
|
||||
* 工时计算
|
||||
/*
|
||||
* 时长计算
|
||||
*/
|
||||
const WORKDAY_HOURS = 8;
|
||||
const START_HOUR = 9;
|
||||
const END_HOUR = 18;
|
||||
const START_BREAK_HOUR = 12;
|
||||
const END_BREAK_HOUR = 13;
|
||||
const WEEKEND_DAYS = [0, 6];
|
||||
|
||||
function isWeekend(day) {
|
||||
return WEEKEND_DAYS.includes(day);
|
||||
function daysBetweenDates(date1, date2) {
|
||||
var date1 = $('#start_time').val();
|
||||
var date2 = $('#end_time').val();
|
||||
if(date1=='' || date2==''){
|
||||
return -1;
|
||||
}
|
||||
var startDate = new Date(date1);
|
||||
var endDate = new Date(date2);
|
||||
var millisecondsPerDay = 24 * 60 * 60 * 1000;
|
||||
var differenceInMilliseconds = endDate - startDate;
|
||||
var differenceInDays = differenceInMilliseconds / millisecondsPerDay;
|
||||
return Math.round(differenceInDays);
|
||||
}
|
||||
|
||||
function calculateWorkHours() {
|
||||
var startDate = new Date($('#start_time').val());
|
||||
var endDate = new Date($('#end_time').val());
|
||||
|
||||
const start = startDate.getTime();
|
||||
const end = endDate.getTime();
|
||||
const startDay = startDate.getDay();
|
||||
const endDay = endDate.getDay();
|
||||
|
||||
let totalHours = 0;
|
||||
|
||||
for (let time = start; time < end; time += 3600000 /* 1 hour in milliseconds */) {
|
||||
const date = new Date(time);
|
||||
const dayOfWeek = date.getDay();
|
||||
const hour = date.getHours();
|
||||
|
||||
if (!isWeekend(dayOfWeek)) {
|
||||
if (hour >= START_HOUR && hour < END_HOUR) {
|
||||
if (hour < START_BREAK_HOUR || hour >= END_BREAK_HOUR) {
|
||||
console.log(totalHours);
|
||||
totalHours += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return totalHours;
|
||||
}
|
||||
|
||||
function isNumber(str, type) {
|
||||
var t = type || 0;
|
||||
var patn = /^[0-9]+$/;
|
||||
if (t > 0) {
|
||||
patn = /^\d+(\.\d+)?$/;
|
||||
}
|
||||
if (!patn.test(str)){
|
||||
return false;
|
||||
}
|
||||
else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const moduleInit = ['tool','employeepicker','oaTool'];
|
||||
function gouguInit() {
|
||||
var form = layui.form,
|
||||
@ -191,45 +171,51 @@ const moduleInit = ['tool','employeepicker','oaTool'];
|
||||
|
||||
if (typeof (flowStep) == "function") {
|
||||
flowStep();
|
||||
}
|
||||
}
|
||||
|
||||
function countDuration(){
|
||||
let hours = daysBetweenDates();
|
||||
if(hours < 0){
|
||||
$('#duration').val(0);
|
||||
$('#days').html('-');
|
||||
}
|
||||
else{
|
||||
let formData = form.val('demo-val-filter');
|
||||
if(formData.start_time_span==1){
|
||||
hours=hours+1;
|
||||
}
|
||||
if(formData.start_time_span==2){
|
||||
hours=hours+0.5;
|
||||
}
|
||||
if(formData.end_time_span==1){
|
||||
hours=hours-0.5;
|
||||
}
|
||||
if(hours<0){
|
||||
hours=0;
|
||||
}
|
||||
$('#duration').val(hours);
|
||||
$('#days').html(hours);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//日期时间范围
|
||||
lay('.select-time').each(function () {
|
||||
laydate.render({
|
||||
elem: this,
|
||||
trigger: 'click',
|
||||
fullPanel:true,
|
||||
type:'datetime',
|
||||
done:function(){
|
||||
var hours = calculateWorkHours();
|
||||
if(hours == 0){
|
||||
$('[name="duration"]').val('');
|
||||
$('#days').html('-');
|
||||
}
|
||||
else{
|
||||
$('[name="duration"]').val(hours);
|
||||
var days = 0;
|
||||
if(hours>=8){
|
||||
days = parseInt(hours/8);
|
||||
}
|
||||
$('#days').html('共'+days+'天,'+(hours%8).toFixed(1)+'小时');
|
||||
}
|
||||
countDuration();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('[name="duration"]').on('input',function(){
|
||||
let hours = $(this).val();
|
||||
if(isNumber(hours,1) && hours>0){
|
||||
var days = 0;
|
||||
if(hours>=8){
|
||||
days = parseInt(hours/8);
|
||||
}
|
||||
$('#days').html('共'+days+'天,'+((hours%8).toFixed(1))+'小时');
|
||||
}
|
||||
else{
|
||||
$('#days').html('-');
|
||||
}
|
||||
})
|
||||
form.on('radio(starttype)',function(data){
|
||||
countDuration();
|
||||
});
|
||||
form.on('radio(endtype)',function(data){
|
||||
countDuration();
|
||||
});
|
||||
}
|
||||
</script>
|
||||
{/block}
|
||||
|
@ -4,7 +4,7 @@
|
||||
{/block}
|
||||
<!-- 主体 -->
|
||||
{block name="body"}
|
||||
<form class="layui-form p-4">
|
||||
<form class="layui-form p-4" lay-filter="demo-val-filter">
|
||||
<h3 class="pb-3">外出审批</h3>
|
||||
{eq name="$id" value="0"}
|
||||
<table class="layui-table layui-table-form">
|
||||
@ -15,18 +15,28 @@
|
||||
<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="请选择时间">
|
||||
<div class="layui-input-inline" style="width:120px; margin-right:16px;">
|
||||
<input id="start_time" name="start_time" autocomplete="off" class="layui-input select-time" value="" readonly lay-verify="required" placeholder="请选择时间" lay-reqText="请选择时间">
|
||||
</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="start_time_span" value="1" title="上午" checked lay-filter="starttype">
|
||||
<input type="radio" name="start_time_span" value="2" title="下午" lay-filter="starttype">
|
||||
</div>
|
||||
</td>
|
||||
<td class="layui-td-gray">结束时间<font>*</font></td>
|
||||
<td>
|
||||
<input id="end_time" name="end_time" autocomplete="off" class="layui-input select-time" value="" readonly lay-verify="required" placeholder="请选择时间" lay-reqText="请选择时间">
|
||||
<div class="layui-input-inline" style="width:120px; margin-right:16px;">
|
||||
<input id="end_time" name="end_time" autocomplete="off" class="layui-input select-time" value="" readonly lay-verify="required" placeholder="请选择时间" lay-reqText="请选择时间">
|
||||
</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="end_time_span" value="1" title="上午" lay-filter="endtype">
|
||||
<input type="radio" name="end_time_span" value="2" title="下午" checked lay-filter="endtype">
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">外出时长</td>
|
||||
<td><input name="duration" value="" class="layui-input" lay-verify="required|number" placeholder="请完善请外出时长" lay-reqText="请完善请外出时长"></td>
|
||||
<td class="layui-td-gray">外出天数</td>
|
||||
<td id="days">-</td>
|
||||
<td colspan="3"><span id="days">-</span><input type="hidden" id="duration" name="duration" value="0"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">外出事由<font>*</font></td>
|
||||
@ -52,19 +62,28 @@
|
||||
<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="请选择时间">
|
||||
<div class="layui-input-inline" style="width:120px; margin-right:16px;">
|
||||
<input id="start_time" name="start_time" autocomplete="off" class="layui-input select-time" value="{$detail.start_time|date='Y-m-d'}" readonly lay-verify="required" placeholder="请选择时间" lay-reqText="请选择时间">
|
||||
</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="start_time_span" value="1" title="上午" lay-filter="starttype" {eq name="$detail.start_time_span" value="1"} checked{/eq}>
|
||||
<input type="radio" name="start_time_span" value="2" title="下午" lay-filter="starttype" {eq name="$detail.start_time_span" value="2"} checked{/eq}>
|
||||
</div>
|
||||
</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="请选择时间">
|
||||
<div class="layui-input-inline" style="width:120px; margin-right:16px;">
|
||||
<input id="end_time" name="end_time" autocomplete="off" class="layui-input select-time" value="{$detail.end_time|date='Y-m-d'}" readonly lay-verify="required" placeholder="请选择时间" lay-reqText="请选择时间">
|
||||
</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="end_time_span" value="1" title="上午" lay-filter="endtype" {eq name="$detail.end_time_span" value="1"} checked{/eq}>
|
||||
<input type="radio" name="end_time_span" value="2" title="下午" lay-filter="endtype" {eq name="$detail.end_time_span" value="2"} checked{/eq}>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">外出时长</td>
|
||||
<td><input name="duration" value="{$detail.duration}" class="layui-input" lay-verify="required|number" placeholder="请完善请外出时长" lay-reqText="请完善外出时长"></td>
|
||||
<td class="layui-td-gray">外出天数</td>
|
||||
<td id="days">共{$detail.days}天,{$detail.hours}小时</td>
|
||||
<td colspan="3">共 <span id="days">{$detail.duration|default='-'}</span> 天<input type="hidden" id="duration" name="duration" value="{$detail.duration|default='0'}"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">外出事由<font>*</font></td>
|
||||
@ -95,63 +114,23 @@
|
||||
<!-- 脚本 -->
|
||||
{block name="script"}
|
||||
<script>
|
||||
/**
|
||||
* 工时计算
|
||||
/*
|
||||
* 时长计算
|
||||
*/
|
||||
const WORKDAY_HOURS = 8;
|
||||
const START_HOUR = 9;
|
||||
const END_HOUR = 18;
|
||||
const START_BREAK_HOUR = 12;
|
||||
const END_BREAK_HOUR = 13;
|
||||
const WEEKEND_DAYS = [0, 6];
|
||||
|
||||
function isWeekend(day) {
|
||||
return WEEKEND_DAYS.includes(day);
|
||||
function daysBetweenDates(date1, date2) {
|
||||
var date1 = $('#start_time').val();
|
||||
var date2 = $('#end_time').val();
|
||||
if(date1=='' || date2==''){
|
||||
return -1;
|
||||
}
|
||||
var startDate = new Date(date1);
|
||||
var endDate = new Date(date2);
|
||||
var millisecondsPerDay = 24 * 60 * 60 * 1000;
|
||||
var differenceInMilliseconds = endDate - startDate;
|
||||
var differenceInDays = differenceInMilliseconds / millisecondsPerDay;
|
||||
return Math.round(differenceInDays);
|
||||
}
|
||||
|
||||
function calculateWorkHours() {
|
||||
var startDate = new Date($('#start_time').val());
|
||||
var endDate = new Date($('#end_time').val());
|
||||
|
||||
const start = startDate.getTime();
|
||||
const end = endDate.getTime();
|
||||
const startDay = startDate.getDay();
|
||||
const endDay = endDate.getDay();
|
||||
|
||||
let totalHours = 0;
|
||||
|
||||
for (let time = start; time < end; time += 3600000 /* 1 hour in milliseconds */) {
|
||||
const date = new Date(time);
|
||||
const dayOfWeek = date.getDay();
|
||||
const hour = date.getHours();
|
||||
|
||||
if (!isWeekend(dayOfWeek)) {
|
||||
if (hour >= START_HOUR && hour < END_HOUR) {
|
||||
if (hour < START_BREAK_HOUR || hour >= END_BREAK_HOUR) {
|
||||
console.log(totalHours);
|
||||
totalHours += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return totalHours;
|
||||
}
|
||||
|
||||
function isNumber(str, type) {
|
||||
var t = type || 0;
|
||||
var patn = /^[0-9]+$/;
|
||||
if (t > 0) {
|
||||
patn = /^\d+(\.\d+)?$/;
|
||||
}
|
||||
if (!patn.test(str)){
|
||||
return false;
|
||||
}
|
||||
else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const moduleInit = ['tool','employeepicker','oaTool'];
|
||||
function gouguInit() {
|
||||
var form = layui.form,
|
||||
@ -166,45 +145,51 @@ const moduleInit = ['tool','employeepicker','oaTool'];
|
||||
|
||||
if (typeof (flowStep) == "function") {
|
||||
flowStep();
|
||||
}
|
||||
}
|
||||
|
||||
function countDuration(){
|
||||
let hours = daysBetweenDates();
|
||||
if(hours < 0){
|
||||
$('#duration').val(0);
|
||||
$('#days').html('-');
|
||||
}
|
||||
else{
|
||||
let formData = form.val('demo-val-filter');
|
||||
if(formData.start_time_span==1){
|
||||
hours=hours+1;
|
||||
}
|
||||
if(formData.start_time_span==2){
|
||||
hours=hours+0.5;
|
||||
}
|
||||
if(formData.end_time_span==1){
|
||||
hours=hours-0.5;
|
||||
}
|
||||
if(hours<0){
|
||||
hours=0;
|
||||
}
|
||||
$('#duration').val(hours);
|
||||
$('#days').html(hours);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//日期时间范围
|
||||
lay('.select-time').each(function () {
|
||||
laydate.render({
|
||||
elem: this,
|
||||
trigger: 'click',
|
||||
fullPanel:true,
|
||||
type:'datetime',
|
||||
done:function(){
|
||||
var hours = calculateWorkHours();
|
||||
if(hours == 0){
|
||||
$('[name="duration"]').val('');
|
||||
$('#days').html('-');
|
||||
}
|
||||
else{
|
||||
$('[name="duration"]').val(hours);
|
||||
var days = 0;
|
||||
if(hours>=8){
|
||||
days = parseInt(hours/8);
|
||||
}
|
||||
$('#days').html('共'+days+'天,'+(hours%8).toFixed(1)+'小时');
|
||||
}
|
||||
countDuration();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('[name="duration"]').on('input',function(){
|
||||
let hours = $(this).val();
|
||||
if(isNumber(hours,1) && hours>0){
|
||||
var days = 0;
|
||||
if(hours>=8){
|
||||
days = parseInt(hours/8);
|
||||
}
|
||||
$('#days').html('共'+days+'天,'+((hours%8).toFixed(1))+'小时');
|
||||
}
|
||||
else{
|
||||
$('#days').html('-');
|
||||
}
|
||||
})
|
||||
form.on('radio(starttype)',function(data){
|
||||
countDuration();
|
||||
});
|
||||
form.on('radio(endtype)',function(data){
|
||||
countDuration();
|
||||
});
|
||||
}
|
||||
</script>
|
||||
{/block}
|
||||
|
@ -4,24 +4,35 @@
|
||||
{/block}
|
||||
<!-- 主体 -->
|
||||
{block name="body"}
|
||||
<form class="layui-form p-4">
|
||||
<form class="layui-form p-4" lay-filter="demo-val-filter">
|
||||
<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="请选择时间">
|
||||
<div class="layui-input-inline" style="width:120px; margin-right:16px;">
|
||||
<input id="start_time" name="start_time" autocomplete="off" class="layui-input select-time" value="" readonly lay-verify="required" placeholder="请选择时间" lay-reqText="请选择时间">
|
||||
</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="start_time_span" value="1" title="上午" checked lay-filter="starttype">
|
||||
<input type="radio" name="start_time_span" value="2" title="下午" lay-filter="starttype">
|
||||
</div>
|
||||
</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="请选择时间">
|
||||
<div class="layui-input-inline" style="width:120px; margin-right:16px;">
|
||||
<input id="end_time" name="end_time" autocomplete="off" class="layui-input select-time" value="" readonly lay-verify="required" placeholder="请选择时间" lay-reqText="请选择时间">
|
||||
</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="end_time_span" value="1" title="上午" lay-filter="endtype">
|
||||
<input type="radio" name="end_time_span" value="2" title="下午" checked lay-filter="endtype">
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">用车时长</td>
|
||||
<td colspan="3" id="duration">-</td>
|
||||
<td class="layui-td-gray">用车天数</td>
|
||||
<td colspan="3"><span id="days">-</span><input type="hidden" id="duration" name="duration" value="0"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray-2">用车目的地<font>*</font></td>
|
||||
@ -48,17 +59,28 @@
|
||||
<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="请选择时间">
|
||||
<div class="layui-input-inline" style="width:120px; margin-right:16px;">
|
||||
<input id="start_time" name="start_time" autocomplete="off" class="layui-input select-time" value="{$detail.start_time|date='Y-m-d'}" readonly lay-verify="required" placeholder="请选择时间" lay-reqText="请选择时间">
|
||||
</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="start_time_span" value="1" title="上午" lay-filter="starttype" {eq name="$detail.start_time_span" value="1"} checked{/eq}>
|
||||
<input type="radio" name="start_time_span" value="2" title="下午" lay-filter="starttype" {eq name="$detail.start_time_span" value="2"} checked{/eq}>
|
||||
</div>
|
||||
</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="请选择时间">
|
||||
<div class="layui-input-inline" style="width:120px; margin-right:16px;">
|
||||
<input id="end_time" name="end_time" autocomplete="off" class="layui-input select-time" value="{$detail.end_time|date='Y-m-d'}" readonly lay-verify="required" placeholder="请选择时间" lay-reqText="请选择时间">
|
||||
</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="end_time_span" value="1" title="上午" lay-filter="endtype" {eq name="$detail.end_time_span" value="1"} checked{/eq}>
|
||||
<input type="radio" name="end_time_span" value="2" title="下午" lay-filter="endtype" {eq name="$detail.end_time_span" value="2"} checked{/eq}>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">用车时长</td>
|
||||
<td colspan="3" id="duration">共{$detail.duration}小时</td>
|
||||
<td class="layui-td-gray">用车天数</td>
|
||||
<td colspan="3">共 <span id="days">{$detail.duration|default='-'}</span> 天<input type="hidden" id="duration" name="duration" value="{$detail.duration|default='0'}"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray-2">用车目的地<font>*</font></td>
|
||||
@ -89,53 +111,82 @@
|
||||
<!-- 脚本 -->
|
||||
{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;
|
||||
function daysBetweenDates(date1, date2) {
|
||||
var date1 = $('#start_time').val();
|
||||
var date2 = $('#end_time').val();
|
||||
if(date1=='' || date2==''){
|
||||
return -1;
|
||||
}
|
||||
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);
|
||||
var startDate = new Date(date1);
|
||||
var endDate = new Date(date2);
|
||||
var millisecondsPerDay = 24 * 60 * 60 * 1000;
|
||||
var differenceInMilliseconds = endDate - startDate;
|
||||
var differenceInDays = differenceInMilliseconds / millisecondsPerDay;
|
||||
return Math.round(differenceInDays);
|
||||
}
|
||||
|
||||
const moduleInit = ['tool','employeepicker'];
|
||||
const moduleInit = ['tool','employeepicker','oaTool'];
|
||||
function gouguInit() {
|
||||
var form = layui.form,tool=layui.tool, employeepicker = layui.employeepicker,laydate = layui.laydate;
|
||||
var form = layui.form,
|
||||
tool=layui.tool,
|
||||
oaTool=layui.oaTool,
|
||||
laydate = layui.laydate;
|
||||
|
||||
oaTool.addFile({
|
||||
btn: 'upFile',
|
||||
box: 'fileList'
|
||||
});
|
||||
|
||||
if (typeof (flowStep) == "function") {
|
||||
flowStep();
|
||||
}
|
||||
}
|
||||
|
||||
function countDuration(){
|
||||
let hours = daysBetweenDates();
|
||||
if(hours < 0){
|
||||
$('#duration').val(0);
|
||||
$('#days').html('-');
|
||||
}
|
||||
else{
|
||||
let formData = form.val('demo-val-filter');
|
||||
if(formData.start_time_span==1){
|
||||
hours=hours+1;
|
||||
}
|
||||
if(formData.start_time_span==2){
|
||||
hours=hours+0.5;
|
||||
}
|
||||
if(formData.end_time_span==1){
|
||||
hours=hours-0.5;
|
||||
}
|
||||
if(hours<0){
|
||||
hours=0;
|
||||
}
|
||||
$('#duration').val(hours);
|
||||
$('#days').html(hours);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//日期时间范围
|
||||
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);
|
||||
countDuration();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
form.on('radio(starttype)',function(data){
|
||||
countDuration();
|
||||
});
|
||||
form.on('radio(endtype)',function(data){
|
||||
countDuration();
|
||||
});
|
||||
}
|
||||
</script>
|
||||
{/block}
|
||||
|
@ -9,11 +9,13 @@
|
||||
<table class="layui-table layui-table-form">
|
||||
<tr>
|
||||
<td class="layui-td-gray">出差地点</td>
|
||||
<td>{$detail.address}</td>
|
||||
<td colspan="3">{$detail.address}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">出差日期</td>
|
||||
<td>{$detail.start_time} 至 {$detail.end_time}</td>
|
||||
<td>{$detail.start_time} 的{$detail.start_time_span==1?'上午':'下午'} 至 {$detail.end_time} 的{$detail.end_time_span==1?'上午':'下午'}</td>
|
||||
<td class="layui-td-gray">出差天数</td>
|
||||
<td>共{$detail.duration}天</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">出差事由</td>
|
||||
|
@ -17,7 +17,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">预定时间</td>
|
||||
<td>{$detail.start_time} 至 {$detail.end_time}</td>
|
||||
<td>{$detail.start_time_hour} 至 {$detail.end_time_hour}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">备注</td>
|
||||
|
@ -13,7 +13,7 @@
|
||||
<td class="layui-td-gray">活动预算</td>
|
||||
<td>{$detail.amount}</td>
|
||||
<td class="layui-td-gray">活动日期</td>
|
||||
<td>{$detail.start_time} 至 {$detail.end_time}</td>
|
||||
<td>{$detail.start_time_hour} 至 {$detail.end_time_hour}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">活动说明</td>
|
||||
|
@ -9,9 +9,9 @@
|
||||
<table class="layui-table layui-table-form">
|
||||
<tr>
|
||||
<td class="layui-td-gray">加班时间</td>
|
||||
<td>{$detail.start_time} 至 {$detail.end_time}</td>
|
||||
<td class="layui-td-gray">加班时长</td>
|
||||
<td>共{$detail.duration}工时</td>
|
||||
<td>{$detail.start_time} 的{$detail.start_time_span==1?'上午':'下午'} 至 {$detail.end_time} 的{$detail.end_time_span==1?'上午':'下午'}</td>
|
||||
<td class="layui-td-gray">请假天数</td>
|
||||
<td>共{$detail.duration}天</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">加班事由</td>
|
||||
|
@ -21,22 +21,18 @@
|
||||
{eq name="$detail.detail_type" value="9"}其他{/eq}
|
||||
</td>
|
||||
<td class="layui-td-gray">请假日期</td>
|
||||
<td>{$detail.start_time} 至 {$detail.end_time}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">请假工时</td>
|
||||
<td>共{$detail.duration}工时</td>
|
||||
<td>{$detail.start_time} 的{$detail.start_time_span==1?'上午':'下午'} 至 {$detail.end_time} 的{$detail.end_time_span==1?'上午':'下午'}</td>
|
||||
<td class="layui-td-gray">请假天数</td>
|
||||
<td>共{$detail.days}天,{$detail.hours}小时</td>
|
||||
<td>共{$detail.duration}天</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">请假事由</td>
|
||||
<td colspan="3">{$detail.content}</td>
|
||||
<td colspan="5">{$detail.content}</td>
|
||||
</tr>
|
||||
{notempty name="$detail.file_ids"}
|
||||
<tr>
|
||||
<td class="layui-td-gray">相关附件</td>
|
||||
<td colspan="3" style="line-height:inherit">
|
||||
<td colspan="5" style="line-height:inherit">
|
||||
<div class="layui-row">
|
||||
{volist name="$detail.fileArray" id="vo"}
|
||||
<div class="layui-col-md4">{:file_card($vo,'view')}</div>
|
||||
|
@ -13,13 +13,9 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">外出日期</td>
|
||||
<td colspan="3">{$detail.start_time} 至 {$detail.end_time}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">外出时长</td>
|
||||
<td>共{$detail.duration}工时</td>
|
||||
<td>{$detail.start_time} 的{$detail.start_time_span==1?'上午':'下午'} 至 {$detail.end_time} 的{$detail.end_time_span==1?'上午':'下午'}</td>
|
||||
<td class="layui-td-gray">外出天数</td>
|
||||
<td>共{$detail.days}天,{$detail.hours}小时</td>
|
||||
<td>共{$detail.duration}天</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">外出事由</td>
|
||||
|
@ -9,12 +9,12 @@
|
||||
<table class="layui-table layui-table-form">
|
||||
<tr>
|
||||
<td class="layui-td-gray">用车时间</td>
|
||||
<td>{$detail.start_time} 至 {$detail.end_time}</td>
|
||||
<td class="layui-td-gray">用车时长</td>
|
||||
<td>共{$detail.duration}小时</td>
|
||||
<td>{$detail.start_time} 的{$detail.start_time_span==1?'上午':'下午'} 至 {$detail.end_time} 的{$detail.end_time_span==1?'上午':'下午'}</td>
|
||||
<td class="layui-td-gray">用车天数</td>
|
||||
<td>共{$detail.duration}天</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">用车目的地</td>
|
||||
<td class="layui-td-gray">目的地</td>
|
||||
<td>{$detail.address}</td>
|
||||
<td class="layui-td-gray">车辆</td>
|
||||
<td>
|
||||
|
Loading…
x
Reference in New Issue
Block a user