1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee

小程序端添加 删除今日填表

This commit is contained in:
程序员小墨 2023-04-17 23:35:39 +08:00
parent 918917868f
commit 7a425c6241
8 changed files with 143 additions and 39 deletions

View File

@ -2,10 +2,6 @@
小程序提审要做的:
订单发货小程序端显示发货详情
体温上报添加一个按钮 可以删除当日填报
小程序扫门禁码之后门禁开门(扫码 websocket 推到门禁端),小程序端显示开门成功
项目部署到服务器

View File

@ -109,6 +109,26 @@ public class ReportController {
return Res.success(records);
}
/**
* 删除最近一次用户填报信息
*
* @param userId
* @return
*/
@PostMapping("/withdraw")
@ResponseBody
public Res withdrawLatestRecord(@RequestParam("userId") Integer userId) {
User user = userService.getUserById(userId);
if (user == null) {
return Res.error("用户不存在");
}
Report records = reportService.getLatestRecordByUserId(user.getId());
if (records != null) {
reportService.removeRecord(records.getId());
}
return Res.success(records);
}
/**
* 获取体温数据列表

View File

@ -17,4 +17,6 @@ public interface ReportDao {
Report getLatestReportByUserId(Integer userId);
public List<Report> getReportList(ReportQuery reportQuery);
public void remove(Integer id);
}

View File

@ -3,7 +3,6 @@ package com.cxyxiaomo.epp.access.service;
import com.cxyxiaomo.epp.access.dao.ReportDao;
import com.cxyxiaomo.epp.common.pojo.Report;
import com.cxyxiaomo.epp.common.query.ReportQuery;
import com.cxyxiaomo.epp.common.vo.ReportVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -20,6 +19,12 @@ public class ReportServiceImpl implements ReportService {
reportDao.insert(report);
}
public void removeRecord(Integer id) {
if (id != null) {
reportDao.remove(id);
}
}
@Override
public List<Report> getRecordListByUserId(Integer userId) {
return reportDao.getReportListByUserId(userId);

View File

@ -47,4 +47,9 @@
</if>
ORDER BY time desc
</select>
<delete id="remove">
DELETE
FROM report
WHERE id = #{id}
</delete>
</mapper>

View File

@ -170,7 +170,7 @@ Page({
updateTime() {
let timestamp = Date.now()
this.setData({
this && this.setData({
"formData.timestamp": timestamp,
"formData.time": utils.formatTime(new Date(timestamp))
})
@ -312,5 +312,80 @@ Page({
wx.navigateTo({
url: "/pages/residents/reportHistory"
})
},
// 删除今日填表
withdrawReport() {
wx.showLoading({
title: '加载中'
})
var that = this;
that.setData({
isSubmitting: true,
})
wx.request({
url: `${app.globalData.baseUrl}/access/report/withdraw`,
method: "POST",
header: {
"Content-Type": "application/x-www-form-urlencoded" //用于post
},
data: {
userId: this.data.userInfo.id
},
success: function (d) {
console.log("begin success")
wx.hideLoading()
let result = d.data;
if (result.success) {
// 填报完成
that.setData({
isFilled: false,
filledMsg: "",
"formData.address": '',
})
console.log("result.data", result.data);
wx.showToast({
title: "删除成功",
icon: 'success',
duration: 2000,
})
// wx.showModal({
// title: '删除成功',
// content: '',
// showCancel: false,
// complete: (res) => {
// }
// })
} else {
wx.showToast({
title: result.msg || "出错啦",
icon: 'error',
duration: 2000
})
}
that.isShow = ''
console.log("end success")
},
fail: function () {
console.log("begin fail")
wx.hideLoading()
wx.showToast({
title: "请求失败",
icon: 'error',
duration: 2000
})
console.log("end fail")
},
complete: function () {
that.setData({
isSubmitting: false,
})
console.log("begin complete")
if (typeof (callback) === "function")
callback();
wx.hideNavigationBarLoading();
console.log("end complete")
}
})
}
})

View File

@ -55,5 +55,6 @@
<!-- -->
<view style="margin: 40px 0;">{{ filledMsg }}</view>
<button class="controlBtn" size="mini" type="none" bindtap="myreport">历史填报</button>
<button class="controlBtn" size="mini" type="warn" bindtap="withdrawReport" disabled="{{isSubmitting}}">删除今日填报</button>
</view>
</view>

View File

@ -1,33 +1,33 @@
/* pages/residents/reportHistory.wxss */
.item {
/* background-color: #dedede; */
border-radius: 8px;
margin: 12px 20px;
padding: 18px;
display: grid;
grid-template-columns: 1fr auto;
place-items: center;
color: white;
}
.item.normal {
background-color: green;
}
.item.abnormal {
background-color: red;
}
.record_time {
font-size: 17px;
}
.record_address {
font-size: 15px;
}
.statusText {
font-size: large;
font-weight: bold;
padding: 0 20px;
}
/* pages/residents/reportHistory.wxss */
.item {
/* background-color: #dedede; */
border-radius: 8px;
margin: 12px 20px;
padding: 18px;
display: grid;
grid-template-columns: 1fr auto;
place-items: center left;
color: white;
}
.item.normal {
background-color: green;
}
.item.abnormal {
background-color: red;
}
.record_time {
font-size: 17px;
}
.record_address {
font-size: 15px;
}
.statusText {
font-size: large;
font-weight: bold;
padding: 0 20px;
}