diff --git a/TODOs.md b/TODOs.md index ac84600..2190064 100644 --- a/TODOs.md +++ b/TODOs.md @@ -2,10 +2,6 @@ 小程序提审要做的: -订单发货小程序端显示发货详情 - -体温上报添加一个按钮 可以删除当日填报 - 小程序扫门禁码之后门禁开门(扫码 websocket 推到门禁端),小程序端显示开门成功 项目部署到服务器 diff --git a/backend/microservice-provider-access-8002/src/main/java/com/cxyxiaomo/epp/access/controller/ReportController.java b/backend/microservice-provider-access-8002/src/main/java/com/cxyxiaomo/epp/access/controller/ReportController.java index 7cf3ef9..560fac4 100644 --- a/backend/microservice-provider-access-8002/src/main/java/com/cxyxiaomo/epp/access/controller/ReportController.java +++ b/backend/microservice-provider-access-8002/src/main/java/com/cxyxiaomo/epp/access/controller/ReportController.java @@ -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); + } + /** * 获取体温数据列表 diff --git a/backend/microservice-provider-access-8002/src/main/java/com/cxyxiaomo/epp/access/dao/ReportDao.java b/backend/microservice-provider-access-8002/src/main/java/com/cxyxiaomo/epp/access/dao/ReportDao.java index ae6b641..ee5aca7 100644 --- a/backend/microservice-provider-access-8002/src/main/java/com/cxyxiaomo/epp/access/dao/ReportDao.java +++ b/backend/microservice-provider-access-8002/src/main/java/com/cxyxiaomo/epp/access/dao/ReportDao.java @@ -17,4 +17,6 @@ public interface ReportDao { Report getLatestReportByUserId(Integer userId); public List getReportList(ReportQuery reportQuery); + + public void remove(Integer id); } diff --git a/backend/microservice-provider-access-8002/src/main/java/com/cxyxiaomo/epp/access/service/ReportServiceImpl.java b/backend/microservice-provider-access-8002/src/main/java/com/cxyxiaomo/epp/access/service/ReportServiceImpl.java index b981bd1..303dff5 100644 --- a/backend/microservice-provider-access-8002/src/main/java/com/cxyxiaomo/epp/access/service/ReportServiceImpl.java +++ b/backend/microservice-provider-access-8002/src/main/java/com/cxyxiaomo/epp/access/service/ReportServiceImpl.java @@ -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 getRecordListByUserId(Integer userId) { return reportDao.getReportListByUserId(userId); diff --git a/backend/microservice-provider-access-8002/src/main/resources/mybatis/mapper/ReportDao.xml b/backend/microservice-provider-access-8002/src/main/resources/mybatis/mapper/ReportDao.xml index 45fe566..46ce9e5 100644 --- a/backend/microservice-provider-access-8002/src/main/resources/mybatis/mapper/ReportDao.xml +++ b/backend/microservice-provider-access-8002/src/main/resources/mybatis/mapper/ReportDao.xml @@ -47,4 +47,9 @@ ORDER BY time desc + + DELETE + FROM report + WHERE id = #{id} + diff --git a/weixin-miniprogram/pages/residents/report.js b/weixin-miniprogram/pages/residents/report.js index 418be60..076e189 100644 --- a/weixin-miniprogram/pages/residents/report.js +++ b/weixin-miniprogram/pages/residents/report.js @@ -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") + } + }) } }) diff --git a/weixin-miniprogram/pages/residents/report.wxml b/weixin-miniprogram/pages/residents/report.wxml index 8f0b606..cc91082 100644 --- a/weixin-miniprogram/pages/residents/report.wxml +++ b/weixin-miniprogram/pages/residents/report.wxml @@ -55,5 +55,6 @@ {{ filledMsg }} + \ No newline at end of file diff --git a/weixin-miniprogram/pages/residents/reportHistory.wxss b/weixin-miniprogram/pages/residents/reportHistory.wxss index ac45398..c64f00e 100644 --- a/weixin-miniprogram/pages/residents/reportHistory.wxss +++ b/weixin-miniprogram/pages/residents/reportHistory.wxss @@ -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; +}