Browse Source

个人打卡前端页面完成,后端数据传输出问题

ry
loser 1 year ago
parent
commit
e3822ec635
  1. 51
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/CheckController.java
  2. 6
      ruoyi-admin/src/main/resources/static/ajax/libs/validate/jquery.validate.extend.js
  3. 193
      ruoyi-admin/src/main/resources/templates/individual/check/check.html
  4. 1
      ruoyi-admin/src/main/resources/templates/system/post/add.html
  5. 7
      ruoyi-system/src/main/java/com/ruoyi/system/domain/Check.java
  6. 29
      ruoyi-system/src/main/java/com/ruoyi/system/mapper/CheckMapper.java
  7. 31
      ruoyi-system/src/main/java/com/ruoyi/system/service/ICheckService.java
  8. 58
      ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CheckServiceImpl.java
  9. 68
      ruoyi-system/src/main/resources/mapper/CheckMapper.xml

51
ruoyi-admin/src/main/java/com/ruoyi/web/controller/CheckController.java

@ -5,6 +5,7 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
@ -55,20 +56,6 @@ public class CheckController extends BaseController
}
/**
* 导出个人打卡列表
*/
@RequiresPermissions("individual:check:export")
@Log(title = "个人打卡", businessType = BusinessType.EXPORT)
@PostMapping("/export")
@ResponseBody
public AjaxResult export(Check check)
{
List<Check> list = checkService.selectCheckList(check);
ExcelUtil<Check> util = new ExcelUtil<Check>(Check.class);
return util.exportExcel(list, "个人打卡数据");
}
/**
* 新增个人打卡
*/
@GetMapping("/add")
@ -84,44 +71,10 @@ public class CheckController extends BaseController
@Log(title = "个人打卡", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(Check check)
public AjaxResult addSave(@Validated Check check)
{
return toAjax(checkService.insertCheck(check));
}
/**
* 修改个人打卡
*/
@RequiresPermissions("individual:check:edit")
@GetMapping("/edit/{checkId}")
public String edit(@PathVariable("checkId") Long checkId, ModelMap mmap)
{
Check check = checkService.selectCheckByCheckId(checkId);
mmap.put("check", check);
return prefix + "/edit";
}
/**
* 修改保存个人打卡
*/
@RequiresPermissions("individual:check:edit")
@Log(title = "个人打卡", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(Check check)
{
return toAjax(checkService.updateCheck(check));
}
/**
* 删除个人打卡
*/
@RequiresPermissions("individual:check:remove")
@Log(title = "个人打卡", businessType = BusinessType.DELETE)
@PostMapping( "/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
return toAjax(checkService.deleteCheckByCheckIds(ids));
}
}

6
ruoyi-admin/src/main/resources/static/ajax/libs/validate/jquery.validate.extend.js

@ -26,7 +26,11 @@ $(document).ready(function(){
var userName=/^[a-zA-Z0-9]{2,13}$/;
return this.optional(element) || (userName).test(value);
},'请输入数字或者字母,不包含特殊字符');
//校验体温
jQuery.validator.addMethod("isTemperature",function(value,element){
var userName=/^[.0-9]{2,13}$/;
return this.optional(element) || (userName).test(value);
},'请输入数字,可使用"."号');
//校验身份证
jQuery.validator.addMethod("isIdentity",function(value,element){
var id= /^(\d{15}$|^\d{18}$|^\d{17}(\d|X))$/;

193
ruoyi-admin/src/main/resources/templates/individual/check/check.html

@ -4,88 +4,136 @@
<th:block th:include="include :: header('个人打卡列表')" />
</head>
<body class="gray-bg">
<div class="main-content" >
<form class="form-horizontal" id="form-check">
<div class="container-div">
<h4 class="form-header h4">打卡信息提交</h4>
<div class="row">
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table">
<div class="tab-content">
<div class="ibox-content">
<ul class="nav nav-tabs">
<li class="active"><a href="#individual_check" data-toggle="tab" aria-expanded="true">今日打卡</a></li>
</ul>
</div>
<div class="col-sm-6">
<div class="form-group">
<div class="row data-type">
<label class="col-sm-4 control-label is-required">姓名:</label>
<div class="col-sm-8">
<input name="checkName" placeholder="请输入姓名" class="form-control" type="text" maxlength="30" >
<div class="col-md-2 title">姓名</div>
<div class="col-md-4 data">
<input type="text" class="form-control" name="name"
placeholder="姓名" value="">
</div>
<div class="col-md-2 title">目前位置</div>
<div class="col-md-4 data" style="display: flex">
<input type="button" class="btn bg-olive" value="点击获取位置" onclick="clickToGetAddress()"></input>
<input type="text" class="form-control" name="currentPosition" id="currentPosition"
placeholder="目前位置" value="">
</div>
<div class="col-md-2 title">健康状况</div>
<div class="col-md-4 data">
<input type="text" class="form-control" name="healthState"
placeholder="健康状况" value="">
</div>
<div class="col-md-2 title">体温</div>
<div class="col-md-4 data">
<input type="text" class="form-control" name="bodyTemperature"
placeholder="体温" value="">
</div>
<div class="col-md-2 title">打卡时间</div>
<div class="col-md-4 data">
<input type="date" class="form-control" name="checkOutDate"
placeholder="打卡时间" value="">
</div>
<div class="col-md-2 title">是否到过高、中风险地区</div>
<div class="col-md-4 data">
<input type="text" class="form-control" name="isToHighArea"
placeholder="是否到达" value="">
</div>
<div class="col-md-2 title">是否接触过疑似或者确诊</div>
<div class="col-md-4 data">
<input type="text" class="form-control" name="isTouch"
placeholder="是否接触" value="">
</div>
<div class="col-md-2 title">备注</div>
<div class="col-md-4 data">
<input type="text" class="form-control" name="remarks"
placeholder="" value="">
</div>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label class="col-sm-4 control-label">目前位置:</label>
<div class="col-sm-8">
<div class="input-group" style="display: flex">
<input class="btn bg-olive" type="button" value="点击获取位置" onclick="clickToGetAddress()" ></input>
<input type="text" class="form-control" name="currentPosition" id="currentPosition" placeholder="目前位置" value="">
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label class="col-sm-4 control-label">健康状况:</label>
<div class="col-sm-8">
<div class="input-group">
<input name="state" placeholder="健康状况" class="form-control" type="text">
<span class="input-group-addon"><i class="fa fa-user"></i></span>
</div>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label class="col-sm-4 control-label">打卡时间:</label>
<div class="col-sm-8">
<div class="input-group">
<input name="checkDatetime" class="form-control " type="date" placeholder="打卡时间">
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label class="col-sm-4 control-label is-required">体温:</label>
<div class="col-sm-8">
<input name="temperature" class="form-control" type="text" placeholder="体温"/>
</div>
</div>
</div>
</table>
<div class="col-sm-6" >
<div class="form-group" style="display: flex">
<label class="col-sm-5 control-label">是否接触密接:</label>
<div class="col-sm-2">
<label class="toggle-switch switch-solid">
<input type="checkbox" id="isTouch">
<span></span>
</label>
</div>
<label class="col-sm-4 control-label">是否去过高风险:</label>
<div class="col-sm-2">
<label class="toggle-switch switch-solid">
<input type="checkbox" id="isHigh">
<span></span>
</label>
</div>
</div>
</div>
<h4 class="form-header h4">其他信息</h4>
<div class="row">
<div class="col-sm-12">
<div class="form-group">
<label class="col-xs-2 control-label">备注:</label>
<div class="col-xs-10">
<textarea name="description" maxlength="500" class="form-control" rows="3" placeholder="个人状况描述"></textarea>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-offset-5 col-sm-10">
<button type="button" class="btn btn-sm btn-primary" onclick="submitCheck()"><i class="fa fa-check"></i>保 存</button>&nbsp;
<button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
</div>
</div>
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer" />
<script src="http://api.map.baidu.com/api?v=1.4" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
// 选择框
$(".select2").select2();
<script >
var prefix = ctx + "individual/check";
$("#form-check").validate({
//首字母默认大写
onkeyup: false,
rules:{
checkName:{
isUserName:true,
},
currentPosition:{
},
state:{
},
checkDatetime:{
},
temperature:{
isTemperature:true
},
},
description: {
},
// WYSIHTML5编辑器
$(".textarea").wysihtml5({
locale : 'zh-CN'
});
});
// 设置激活菜单
function setSidebarActive(tagUri) {
var liObj = $("#" + tagUri);
if (liObj.length > 0) {
liObj.parent().parent().addClass("active");
liObj.addClass("active");
function submitCheck () {
if ($.validate.form()) {
var data = $("#form-check").serializeArray();
var isTouch = $("input[id='isTouch']").is(':checked') == true ? 0 : 1;
var isHigh = $("input[id='isHigh']").is(':checked') == true ? 0 : 1;
data.push({"checkName": "isTouch", "value": isTouch});
data.push({"checkName": "isHigh", "value": isHigh});
$.operate.saveTab(prefix+"/add", data);
}
}
@ -98,14 +146,7 @@
});
});
$(document).ready(function() {
// 激活导航位置
setSidebarActive("order-manage");
$("#datepicker-a3").datetimepicker({
format : "yyyy-mm-dd hh:ii",
});
});
//获取位置
function getLocation() {
var options = {
enableHighAccuracy : true,
@ -156,6 +197,8 @@
}
// 这里后面可以写你的后续操作了
}
//获取地理位置
const clickToGetAddress = () => {
getLocation();
}

1
ruoyi-admin/src/main/resources/templates/system/post/add.html

@ -42,6 +42,7 @@
</form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: select2-js" />
<script type="text/javascript">
var prefix = ctx + "system/post";

7
ruoyi-system/src/main/java/com/ruoyi/system/domain/Check.java

@ -2,11 +2,14 @@ package com.ruoyi.system.domain;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.xss.Xss;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import javax.validation.constraints.Size;
/**
* 个人打卡对象 check
*
@ -66,7 +69,8 @@ public class Check extends BaseEntity
{
this.checkName = checkName;
}
@Xss(message = "用户昵称不能包含脚本字符")
@Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
public String getCheckName()
{
return checkName;
@ -76,6 +80,7 @@ public class Check extends BaseEntity
this.temperature = temperature;
}
@Size(min = 2, message = "体温只能为数字")
public String getTemperature()
{
return temperature;

29
ruoyi-system/src/main/java/com/ruoyi/system/mapper/CheckMapper.java

@ -11,13 +11,6 @@ import com.ruoyi.system.domain.Check;
*/
public interface CheckMapper
{
/**
* 查询个人打卡
*
* @param checkId 个人打卡主键
* @return 个人打卡
*/
public Check selectCheckByCheckId(Long checkId);
/**
* 查询个人打卡列表
@ -35,27 +28,5 @@ public interface CheckMapper
*/
public int insertCheck(Check check);
/**
* 修改个人打卡
*
* @param check 个人打卡
* @return 结果
*/
public int updateCheck(Check check);
/**
* 删除个人打卡
*
* @param checkId 个人打卡主键
* @return 结果
*/
public int deleteCheckByCheckId(Long checkId);
/**
* 批量删除个人打卡
*
* @param checkIds 需要删除的数据主键集合
* @return 结果
*/
public int deleteCheckByCheckIds(String[] checkIds);
}

31
ruoyi-system/src/main/java/com/ruoyi/system/service/ICheckService.java

@ -12,14 +12,6 @@ import com.ruoyi.system.domain.Check;
public interface ICheckService
{
/**
* 查询个人打卡
*
* @param checkId 个人打卡主键
* @return 个人打卡
*/
public Check selectCheckByCheckId(Long checkId);
/**
* 查询个人打卡列表
*
* @param check 个人打卡
@ -35,27 +27,4 @@ public interface ICheckService
*/
public int insertCheck(Check check);
/**
* 修改个人打卡
*
* @param check 个人打卡
* @return 结果
*/
public int updateCheck(Check check);
/**
* 批量删除个人打卡
*
* @param checkIds 需要删除的个人打卡主键集合
* @return 结果
*/
public int deleteCheckByCheckIds(String checkIds);
/**
* 删除个人打卡信息
*
* @param checkId 个人打卡主键
* @return 结果
*/
public int deleteCheckByCheckId(Long checkId);
}

58
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CheckServiceImpl.java

@ -6,7 +6,7 @@ import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.CheckMapper;
import com.ruoyi.system.domain.Check;
import com.ruoyi.system.service.ICheckService;
import com.ruoyi.common.core.text.Convert;
/**
* 个人打卡Service业务层处理
@ -15,22 +15,10 @@ import com.ruoyi.common.core.text.Convert;
* @date 2023-04-22
*/
@Service
public class CheckServiceImpl implements ICheckService
{
public class CheckServiceImpl implements ICheckService {
@Autowired
private CheckMapper checkMapper;
/**
* 查询个人打卡
*
* @param checkId 个人打卡主键
* @return 个人打卡
*/
@Override
public Check selectCheckByCheckId(Long checkId)
{
return checkMapper.selectCheckByCheckId(checkId);
}
/**
* 查询个人打卡列表
@ -39,8 +27,7 @@ public class CheckServiceImpl implements ICheckService
* @return 个人打卡
*/
@Override
public List<Check> selectCheckList(Check check)
{
public List<Check> selectCheckList(Check check) {
return checkMapper.selectCheckList(check);
}
@ -51,44 +38,7 @@ public class CheckServiceImpl implements ICheckService
* @return 结果
*/
@Override
public int insertCheck(Check check)
{
public int insertCheck(Check check) {
return checkMapper.insertCheck(check);
}
/**
* 修改个人打卡
*
* @param check 个人打卡
* @return 结果
*/
@Override
public int updateCheck(Check check)
{
return checkMapper.updateCheck(check);
}
/**
* 批量删除个人打卡
*
* @param checkIds 需要删除的个人打卡主键
* @return 结果
*/
@Override
public int deleteCheckByCheckIds(String checkIds)
{
return checkMapper.deleteCheckByCheckIds(Convert.toStrArray(checkIds));
}
/**
* 删除个人打卡信息
*
* @param checkId 个人打卡主键
* @return 结果
*/
@Override
public int deleteCheckByCheckId(Long checkId)
{
return checkMapper.deleteCheckByCheckId(checkId);
}
}

68
ruoyi-system/src/main/resources/mapper/CheckMapper.xml

@ -34,59 +34,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
</select>
<select id="selectCheckByCheckId" parameterType="Long" resultMap="CheckResult">
<include refid="selectCheckVo"/>
where check_id = #{checkId}
</select>
<insert id="insertCheck" parameterType="Check" useGeneratedKeys="true" keyProperty="checkId">
insert into check
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="checkName != null">check_name,</if>
<if test="temperature != null">temperature,</if>
<if test="state != null">state,</if>
insert into check(
<if test="checkId != null and checkId != ''">check_id,</if>
<if test="checkName != null and checkName != ''">check_name,</if>
<if test="temperature != null and temperature != ''">temperature,</if>
<if test="state != null and state != ''">state,</if>
<if test="description != null and description != ''">description,</if>
<if test="isHigh != null ">is_high,</if>
<if test="isTouch != null ">is_touch,</if>
<if test="description != null">description,</if>
<if test="checkDatetime != null">check_datetime,</if>
<if test="currentPosition != null">current_position,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="checkName != null">#{checkName},</if>
<if test="temperature != null">#{temperature},</if>
<if test="state != null">#{state},</if>
<if test="isHigh != null">#{isHigh},</if>
<if test="isTouch != null">#{isTouch},</if>
<if test="description != null">#{description},</if>
<if test="checkDatetime != null">#{checkDatetime},</if>
<if test="currentPosition != null">#{currentPosition},</if>
</trim>
<if test="currentPosition != null and currentPosition != ''">current_position,</if>
<if test="checkDatetime != null and checkDatetime != ''">check_datetime</if>
)values(
<if test="checkId != null and checkId != ''">#{checkId},</if>
<if test="checkName != null and checkName != ''">#{checkName},</if>
<if test="temperature != null and temperature != ''">#{temperature},</if>
<if test="state != null and state != ''">#{state},</if>
<if test="description != null and description != ''">#{description},</if>
<if test="isHigh != null and isHigh != ''">#{isHigh},</if>
<if test="isTouch != null and isTouch != ''">#{isTouch},</if>
<if test="currentPosition != null and currentPosition != ''">#{currentPosition},</if>
<if test="checkDatetime != null and checkDatetime != ''">#{check_datetime}</if>
)
</insert>
<update id="updateCheck" parameterType="Check">
update check
<trim prefix="SET" suffixOverrides=",">
<if test="checkName != null">check_name = #{checkName},</if>
<if test="temperature != null">temperature = #{temperature},</if>
<if test="state != null">state = #{state},</if>
<if test="isHigh != null">is_high = #{isHigh},</if>
<if test="isTouch != null">is_touch = #{isTouch},</if>
<if test="description != null">description = #{description},</if>
<if test="checkDatetime != null">check_datetime = #{checkDatetime},</if>
<if test="currentPosition != null">current_position = #{currentPosition},</if>
</trim>
where check_id = #{checkId}
</update>
<delete id="deleteCheckByCheckId" parameterType="Long">
delete from check where check_id = #{checkId}
</delete>
<delete id="deleteCheckByCheckIds" parameterType="String">
delete from check where check_id in
<foreach item="checkId" collection="array" open="(" separator="," close=")">
#{checkId}
</foreach>
</delete>
</mapper>
Loading…
Cancel
Save