From fb10c7e6660c4baa87768e02b2710a63622f2677 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=91=98=E5=B0=8F=E5=A2=A8?= <2291200076@qq.com> Date: Fri, 14 Apr 2023 00:53:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8E=E5=8F=B0=E7=AE=A1=E7=90=86=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E4=BD=93=E6=B8=A9=E4=B8=8A=E6=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epp/PageTable/enums/FieldType.java | 3 +- .../epp/PageTable/enums/SearchType.java | 3 +- .../epp/PageTable/utils/FieldBuilder.java | 5 +- .../epp/common/query/ReportQuery.java | 28 ++++ .../com/cxyxiaomo/epp/common/vo/ReportVO.java | 67 ++++++++++ .../access/controller/ReportController.java | 122 +++++++++++++++++- .../cxyxiaomo/epp/access/dao/ReportDao.java | 3 + .../epp/access/service/ReportServiceImpl.java | 10 ++ .../src/main/resources/application.yml | 5 + .../resources/mybatis/mapper/ReportDao.xml | 29 +++++ .../main/resources/mybatis/mybatis-config.xml | 4 + .../epp/shop/service/GoodService.java | 7 + database/epp.sql | 12 +- frontend/components.d.ts | 1 + frontend/src/api/report.js | 41 ++++++ frontend/src/components/manage-list.vue | 104 +++++++++++++-- frontend/src/components/sidebar.vue | 44 +++---- frontend/src/router/index.ts | 9 ++ frontend/src/store/permiss.ts | 11 +- frontend/src/views/report-setting.vue | 11 ++ weixin-miniprogram/pages/residents/report.js | 9 ++ .../pages/residents/report.wxml | 2 +- 22 files changed, 472 insertions(+), 58 deletions(-) create mode 100644 backend/microservice-common/src/main/java/com/cxyxiaomo/epp/common/query/ReportQuery.java create mode 100644 backend/microservice-common/src/main/java/com/cxyxiaomo/epp/common/vo/ReportVO.java create mode 100644 frontend/src/api/report.js create mode 100644 frontend/src/views/report-setting.vue diff --git a/backend/microservice-common/src/main/java/com/cxyxiaomo/epp/PageTable/enums/FieldType.java b/backend/microservice-common/src/main/java/com/cxyxiaomo/epp/PageTable/enums/FieldType.java index 8a6582b..28ad251 100644 --- a/backend/microservice-common/src/main/java/com/cxyxiaomo/epp/PageTable/enums/FieldType.java +++ b/backend/microservice-common/src/main/java/com/cxyxiaomo/epp/PageTable/enums/FieldType.java @@ -4,7 +4,8 @@ public enum FieldType { HIDDEN("null"), TEXT("plaintext"), LONG_TEXT("longtext"), - IMAGE("image"); + IMAGE("image"), + DATETIME("time"); private final String value; diff --git a/backend/microservice-common/src/main/java/com/cxyxiaomo/epp/PageTable/enums/SearchType.java b/backend/microservice-common/src/main/java/com/cxyxiaomo/epp/PageTable/enums/SearchType.java index a9a84b7..6edc920 100644 --- a/backend/microservice-common/src/main/java/com/cxyxiaomo/epp/PageTable/enums/SearchType.java +++ b/backend/microservice-common/src/main/java/com/cxyxiaomo/epp/PageTable/enums/SearchType.java @@ -3,7 +3,8 @@ package com.cxyxiaomo.epp.PageTable.enums; public enum SearchType { CAN_NOT_SEARCH("null"), INPUT("input"), - SELECT("select"); + SELECT("select"), + DATETIME_INTERVAL("time-interval"); private final String value; diff --git a/backend/microservice-common/src/main/java/com/cxyxiaomo/epp/PageTable/utils/FieldBuilder.java b/backend/microservice-common/src/main/java/com/cxyxiaomo/epp/PageTable/utils/FieldBuilder.java index ea24775..58b12b0 100644 --- a/backend/microservice-common/src/main/java/com/cxyxiaomo/epp/PageTable/utils/FieldBuilder.java +++ b/backend/microservice-common/src/main/java/com/cxyxiaomo/epp/PageTable/utils/FieldBuilder.java @@ -7,6 +7,8 @@ import com.cxyxiaomo.epp.PageTable.enums.EditType; import com.cxyxiaomo.epp.PageTable.enums.FieldType; import com.cxyxiaomo.epp.PageTable.enums.SearchType; +import java.util.Objects; + public class FieldBuilder { public final static String SEARCH_PLACEHOLDER_SAME_AS_FIELDNAME = ""; @@ -70,7 +72,8 @@ public class FieldBuilder { jsonObject.put("editType", editType.getValue()); jsonObject.put("editPlaceholder", EDIT_PLACEHOLDER_SAME_AS_ADD_PLACEHOLDER.equals(editPlaceholder) ? addPlaceholder : editPlaceholder); // 新增/修改时的前端表单验证 - jsonObject.put("validateRules", fieldRuleListBuilder.build()); + jsonObject.put("validateRules", Objects.nonNull(fieldRuleListBuilder) + ? fieldRuleListBuilder.build() : new JSONArray()); // 新增弹窗 字段默认值 jsonObject.put("default", defaultValue); diff --git a/backend/microservice-common/src/main/java/com/cxyxiaomo/epp/common/query/ReportQuery.java b/backend/microservice-common/src/main/java/com/cxyxiaomo/epp/common/query/ReportQuery.java new file mode 100644 index 0000000..01159cb --- /dev/null +++ b/backend/microservice-common/src/main/java/com/cxyxiaomo/epp/common/query/ReportQuery.java @@ -0,0 +1,28 @@ +package com.cxyxiaomo.epp.common.query; + +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +// 数据库关系映射 + +@Data +@NoArgsConstructor +@Accessors(chain = true) // 链式写法 +// 微服务必须要实现Serializable +public class ReportQuery implements Serializable { + + private Integer id; + + private Integer userId; + + private String name; + + private String address; + + private Long startTime, endTime; + + private Integer temperature; +} diff --git a/backend/microservice-common/src/main/java/com/cxyxiaomo/epp/common/vo/ReportVO.java b/backend/microservice-common/src/main/java/com/cxyxiaomo/epp/common/vo/ReportVO.java new file mode 100644 index 0000000..42e1d71 --- /dev/null +++ b/backend/microservice-common/src/main/java/com/cxyxiaomo/epp/common/vo/ReportVO.java @@ -0,0 +1,67 @@ +package com.cxyxiaomo.epp.common.vo; + +import com.cxyxiaomo.epp.common.pojo.Report; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; +import org.springframework.beans.BeanUtils; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +// 数据库关系映射 + +@Data +@NoArgsConstructor +@Accessors(chain = true) // 链式写法 +// 微服务必须要实现Serializable +public class ReportVO implements Serializable { + + private Integer id; + + private Integer userId; + + private String name; + + private String address; + + private Long timestamp; + + private Integer temperature; + + public static ReportVO convertFrom(Report report) { + if (report == null) { + return null; + } + ReportVO reportVO = new ReportVO(); + BeanUtils.copyProperties(report, reportVO); + Date time = report.getTime(); + reportVO.setTimestamp(time.getTime()); + return reportVO; + } + + public static List convertFrom(List reportList) { + if (reportList == null) { + return null; + } + List reportVOList = reportList.stream() + .map(ReportVO::convertFrom).collect(Collectors.toList()); + return reportVOList; + } + + public static Report convertTo(ReportVO reportVO) { + if (reportVO == null) { + return null; + } + Report report = new Report(); + BeanUtils.copyProperties(reportVO, report); + Long timestamp = reportVO.getTimestamp(); + if (timestamp != null) { + Date date = new Date(timestamp); + report.setTime(date); + } + return report; + } +} 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 430a1f0..7cf3ef9 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 @@ -1,18 +1,31 @@ package com.cxyxiaomo.epp.access.controller; +import com.alibaba.fastjson2.JSONArray; +import com.alibaba.fastjson2.JSONObject; +import com.cxyxiaomo.epp.PageTable.enums.AddType; +import com.cxyxiaomo.epp.PageTable.enums.EditType; +import com.cxyxiaomo.epp.PageTable.enums.FieldType; +import com.cxyxiaomo.epp.PageTable.enums.SearchType; +import com.cxyxiaomo.epp.PageTable.query.PageQuery; +import com.cxyxiaomo.epp.PageTable.utils.FieldBuilder; +import com.cxyxiaomo.epp.PageTable.utils.FieldMapperBuilder; import com.cxyxiaomo.epp.access.rpc.UserServiceFeign; import com.cxyxiaomo.epp.access.service.ReportServiceImpl; import com.cxyxiaomo.epp.common.pojo.Report; import com.cxyxiaomo.epp.common.pojo.User; +import com.cxyxiaomo.epp.common.query.ReportQuery; import com.cxyxiaomo.epp.common.response.Res; +import com.cxyxiaomo.epp.common.vo.ReportVO; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.*; +import java.text.SimpleDateFormat; import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; import java.util.List; @Controller @@ -78,6 +91,7 @@ public class ReportController { List records = reportService.getRecordListByUserId(user.getId()); return Res.success(records); } + /** * 获取最近一次用户填报信息 * @@ -94,4 +108,104 @@ public class ReportController { Report records = reportService.getLatestRecordByUserId(user.getId()); return Res.success(records); } + + + /** + * 获取体温数据列表 + * + * @return + */ + @GetMapping("/manage/getReportList") + @ResponseBody + public Res getReportList(PageQuery pageQuery, ReportQuery reportQuery) { + // 查询分页数据 + PageHelper.startPage(pageQuery.getPageIndex(), pageQuery.getPageSize()); + List reportList = reportService.getReportList(reportQuery); + PageInfo reportPageInfo = new PageInfo<>(reportList); + List list = reportPageInfo.getList(); + List voList = ReportVO.convertFrom(list); + + // id列 字段名(区分大小写;以VO中的变量名为准) + // 新增、修改弹窗时,使用该列作为主键列进行操作 + String idFieldName = "id"; + + // 当前管理页面 + String pageName = "体温上报管理"; + + // 指定前端表格显示列 + JSONArray columns = FieldBuilder.create() + .add("timestamp", "timestamp", "打卡时间", "", + FieldType.DATETIME, SearchType.DATETIME_INTERVAL, AddType.CAN_NOT_ADD, EditType.CAN_NOT_EDIT, + FieldBuilder.SEARCH_PLACEHOLDER_SAME_AS_FIELDNAME, + null, null, null, null + ) + .add("userId", "userId", "用户id", "", + FieldType.TEXT, SearchType.INPUT, AddType.CAN_NOT_ADD, EditType.CAN_NOT_EDIT, + FieldBuilder.SEARCH_PLACEHOLDER_SAME_AS_FIELDNAME, + null, null, null, null + ) + .add("name", "name", "用户姓名", "", + FieldType.TEXT, SearchType.INPUT, AddType.CAN_NOT_ADD, EditType.CAN_NOT_EDIT, + FieldBuilder.SEARCH_PLACEHOLDER_SAME_AS_FIELDNAME, + null, null, null, null + ) + .add("temperature", "displayTemperature", "状态", "", + FieldType.TEXT, SearchType.SELECT, AddType.CAN_NOT_ADD, EditType.CAN_NOT_EDIT, + FieldBuilder.SEARCH_PLACEHOLDER_SAME_AS_FIELDNAME, + null, null, null, null + ) + .add("address", "address", "地址", "", + FieldType.LONG_TEXT, SearchType.INPUT, AddType.CAN_NOT_ADD, EditType.CAN_NOT_EDIT, + FieldBuilder.SEARCH_PLACEHOLDER_SAME_AS_FIELDNAME, + null, null, null, null + ) + .build(); + + // 指定需要翻译的字段 + HashMap stateMap = new HashMap<>(2); + stateMap.put("0", "正常"); + stateMap.put("1", "异常(≥37.3℃)"); + // build + JSONArray fieldMapper = FieldMapperBuilder.create() + .add("temperature", "displayTemperature", stateMap) + .build(); + + // 拼装返回结果 + JSONObject map = new JSONObject(6); + map.put("total", reportPageInfo.getTotal()); + map.put("list", voList); + map.put("columns", columns); + map.put("fieldMapper", fieldMapper); + map.put("idFieldName", idFieldName); + map.put("pageName", pageName); + + map.put("pawQuery", pageName); + + // 返回结果 + return Res.success(map); + } + + /** + * 导出商品列表 + * + * @return + */ + @GetMapping("/manage/exportReportList") + @ResponseBody + public Res exportReportList(ReportQuery reportQuery) { + List reportList = reportService.getReportList(reportQuery); + List reportVOList = ReportVO.convertFrom(reportList); + + // 当前时间 + Date now = Calendar.getInstance().getTime(); + SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd_HHmmss"); + String dateTime = format.format(now); + + HashMap map = new HashMap<>(); + map.put("list", reportVOList); + map.put("sheetName", "体温数据表-" + System.currentTimeMillis()); + map.put("fileName", "体温数据表_导出时间_" + dateTime); + + return Res.success(map); + } } 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 5192ba3..ae6b641 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 @@ -1,6 +1,7 @@ package com.cxyxiaomo.epp.access.dao; import com.cxyxiaomo.epp.common.pojo.Report; +import com.cxyxiaomo.epp.common.query.ReportQuery; import org.apache.ibatis.annotations.Mapper; import org.springframework.stereotype.Repository; @@ -14,4 +15,6 @@ public interface ReportDao { List getReportListByUserId(Integer userId); Report getLatestReportByUserId(Integer userId); + + public List getReportList(ReportQuery reportQuery); } 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 e3aa527..b981bd1 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 @@ -2,6 +2,8 @@ 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; @@ -18,11 +20,19 @@ public class ReportServiceImpl implements ReportService { reportDao.insert(report); } + @Override public List getRecordListByUserId(Integer userId) { return reportDao.getReportListByUserId(userId); } + @Override public Report getLatestRecordByUserId(Integer userId) { return reportDao.getLatestReportByUserId(userId); } + + + public List getReportList(ReportQuery reportQuery) { + List reportList = reportDao.getReportList(reportQuery); + return reportList; + } } diff --git a/backend/microservice-provider-access-8002/src/main/resources/application.yml b/backend/microservice-provider-access-8002/src/main/resources/application.yml index 3ca973b..6901488 100644 --- a/backend/microservice-provider-access-8002/src/main/resources/application.yml +++ b/backend/microservice-provider-access-8002/src/main/resources/application.yml @@ -21,3 +21,8 @@ spring: url: jdbc:mysql://127.0.0.1:3306/epp?useUnicode=true&characterEncoding=utf8&useSSL=false username: root password: root + +logging: + level: + org.mybatis.spring.SqlSessionFactoryBean: DEBUG + # org.mybatis.spring.SqlSessionFactoryBean: TRACE 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 3d97654..45fe566 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 @@ -18,4 +18,33 @@ order by time desc LIMIT 1 + + + diff --git a/backend/microservice-provider-access-8002/src/main/resources/mybatis/mybatis-config.xml b/backend/microservice-provider-access-8002/src/main/resources/mybatis/mybatis-config.xml index a7de5d4..1942ddc 100644 --- a/backend/microservice-provider-access-8002/src/main/resources/mybatis/mybatis-config.xml +++ b/backend/microservice-provider-access-8002/src/main/resources/mybatis/mybatis-config.xml @@ -9,5 +9,9 @@ + + + + diff --git a/backend/microservice-provider-shop-8003/src/main/java/com/cxyxiaomo/epp/shop/service/GoodService.java b/backend/microservice-provider-shop-8003/src/main/java/com/cxyxiaomo/epp/shop/service/GoodService.java index 4f22c98..1c2e471 100644 --- a/backend/microservice-provider-shop-8003/src/main/java/com/cxyxiaomo/epp/shop/service/GoodService.java +++ b/backend/microservice-provider-shop-8003/src/main/java/com/cxyxiaomo/epp/shop/service/GoodService.java @@ -96,6 +96,10 @@ public class GoodService { return goodDao.deleteGoodById(goodId); } + + + + public boolean addGoodCategory(GoodCategory goodCategory) { goodCategory.setId(null); return goodCategoryDao.addCategory(goodCategory); @@ -110,6 +114,9 @@ public class GoodService { } + + + public GoodCategory getGoodCategoryById(Long id) { if (id == null) { return null; diff --git a/database/epp.sql b/database/epp.sql index 25f8f93..8e14cd0 100644 --- a/database/epp.sql +++ b/database/epp.sql @@ -11,7 +11,7 @@ Target Server Version : 80012 File Encoding : 65001 - Date: 29/03/2023 17:21:45 + Date: 14/04/2023 00:51:48 */ SET NAMES utf8mb4; @@ -57,7 +57,7 @@ CREATE TABLE `community_gate1` ( `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '大门显示名称', `open` tinyint(1) NOT NULL DEFAULT 1 COMMENT '大门是否开放 1为开放 2为关闭', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '社区大门' ROW_FORMAT = DYNAMIC; +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '社区大门' ROW_FORMAT = DYNAMIC; -- ---------------------------- -- Records of community_gate1 @@ -335,7 +335,7 @@ CREATE TABLE `report` ( `temperature` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '体温是否正常', `address` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '地址', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 62 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC; +) ENGINE = InnoDB AUTO_INCREMENT = 71 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC; -- ---------------------------- -- Records of report @@ -347,6 +347,8 @@ INSERT INTO `report` VALUES (58, 3, '用户 密码user', '2022-12-29 18:20:00', INSERT INTO `report` VALUES (59, 3, '用户 密码user', '2023-03-17 00:27:21', '0', '湖北省武汉市洪山区雄楚大道珞狮南路南湖雅园F-4-106'); INSERT INTO `report` VALUES (60, 3, '用户 密码user', '2023-03-20 00:47:22', '0', '湖北省武汉市武昌区武车路'); INSERT INTO `report` VALUES (61, 3, '用户 密码user', '2023-03-23 22:24:14', '0', '湖北省武汉市武昌区修远路'); +INSERT INTO `report` VALUES (62, 3, '用户 密码user', '2023-03-13 22:54:12', '0', '湖北省武汉市洪山区文治街102-4号'); +INSERT INTO `report` VALUES (70, 3, '用户 密码user', '2023-04-14 00:36:55', '0', '湖北省武汉市洪山区文治街102-4号'); -- ---------------------------- -- Table structure for role @@ -356,7 +358,7 @@ CREATE TABLE `role` ( `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'role_id', `role_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'roleName', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic; +) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC; -- ---------------------------- -- Records of role @@ -402,7 +404,7 @@ CREATE TABLE `user` ( `permission_time` datetime NULL DEFAULT NULL COMMENT '进出权限失效时间', PRIMARY KEY (`id`) USING BTREE, UNIQUE INDEX `username`(`username`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 13 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC; +) ENGINE = InnoDB AUTO_INCREMENT = 22 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC; -- ---------------------------- -- Records of user diff --git a/frontend/components.d.ts b/frontend/components.d.ts index ff12975..371420d 100644 --- a/frontend/components.d.ts +++ b/frontend/components.d.ts @@ -15,6 +15,7 @@ declare module '@vue/runtime-core' { ElCard: typeof import('element-plus/es')['ElCard'] ElCheckbox: typeof import('element-plus/es')['ElCheckbox'] ElCol: typeof import('element-plus/es')['ElCol'] + ElDatePicker: typeof import('element-plus/es')['ElDatePicker'] ElDialog: typeof import('element-plus/es')['ElDialog'] ElDropdown: typeof import('element-plus/es')['ElDropdown'] ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem'] diff --git a/frontend/src/api/report.js b/frontend/src/api/report.js new file mode 100644 index 0000000..5a41402 --- /dev/null +++ b/frontend/src/api/report.js @@ -0,0 +1,41 @@ +import send_request from '../utils/send_request'; + +/** + * 获取体温列表 + * @returns + */ +export function getReportList(params) { + // 深拷贝一份,避免 删除 timestamp 时页面上的输入框也清空了 + // 但是 Date 类型的对象无法拷贝,所以还是获取深拷贝之间的 + let paramsCopy = JSON.parse(JSON.stringify(params)) + delete paramsCopy.timestamp + if (Array.isArray(params.timestamp) && params.timestamp.length == 2) { + paramsCopy.startTime = params.timestamp[0]?.getTime() + paramsCopy.endTime = params.timestamp[1]?.getTime() + } + return send_request({ + url: '/access/report/manage/getReportList', + method: 'GET', + params: paramsCopy, + }); +}; + +/** + * 导出体温列表 + * @returns + */ +export function exportReportList(params) { + // 深拷贝一份,避免 删除 timestamp 时页面上的输入框也清空了 + // 但是 Date 类型的对象无法拷贝,所以还是获取深拷贝之间的 + let paramsCopy = JSON.parse(JSON.stringify(params)) + delete paramsCopy.timestamp + if (Array.isArray(params.timestamp) && params.timestamp.length == 2) { + paramsCopy.startTime = params.timestamp[0]?.getTime() + paramsCopy.endTime = params.timestamp[1]?.getTime() + } + return send_request({ + url: '/access/report/manage/exportReportList', + method: 'GET', + params: paramsCopy, + }); +}; diff --git a/frontend/src/components/manage-list.vue b/frontend/src/components/manage-list.vue index 7ff5fc8..827b67b 100644 --- a/frontend/src/components/manage-list.vue +++ b/frontend/src/components/manage-list.vue @@ -18,12 +18,17 @@ + 查询 - 新增记录 - 导出到文件 + 新增记录 + 导出到文件 @@ -31,29 +36,34 @@ + - + @@ -144,17 +154,17 @@ const props = defineProps({ // 新增 接口函数 'addFunc': { type: Function, - required: true, + required: false, }, // 修改 接口函数 'editFunc': { type: Function, - required: true, + required: false, }, - // 修改 接口函数 + // 删除 接口函数 'deleteFunc': { type: Function, - required: true, + required: false, }, // 导出 接口函数 'exportFunc': { @@ -330,6 +340,7 @@ const getData = async () => { // 测试数据 mockData = data.columns + .filter((field: any) => field.mockRegex) .map((field: any) => { let spaceIndex = field.mockRegex.indexOf(' ') if (spaceIndex == -1) return @@ -577,6 +588,73 @@ const doMockData = (isEdit: boolean) => { onMounted(() => { getData(); }); + + + +// 附加内容 +const dateTimePickerRangeShotcut = [ + { + text: '今天', + value: () => { + const start = new Date() + start.setHours(0) + start.setMinutes(0) + start.setSeconds(0) + start.setMilliseconds(0) + const end = new Date(start.getTime() + 24 * 3600 * 1000) + return [start, end] + }, + }, + { + text: '昨天', + value: () => { + const end = new Date() + end.setHours(0) + end.setMinutes(0) + end.setSeconds(0) + end.setMilliseconds(0) + const start = new Date(end.getTime() - 24 * 3600 * 1000) + return [start, end] + }, + }, + { + text: '过去24小时', + value: () => { + const end = new Date() + const start = new Date() + start.setTime(start.getTime() - 3600 * 1000 * 24 * 1) + return [start, end] + }, + }, + { + text: '过去7天', + value: () => { + const end = new Date() + const start = new Date() + start.setTime(start.getTime() - 3600 * 1000 * 24 * 7) + return [start, end] + }, + }, + { + text: '过去30天', + value: () => { + const end = new Date() + const start = new Date() + start.setTime(start.getTime() - 3600 * 1000 * 24 * 30) + return [start, end] + }, + }, + { + text: '过去90天', + value: () => { + const end = new Date() + const start = new Date() + start.setTime(start.getTime() - 3600 * 1000 * 24 * 90) + return [start, end] + }, + }, +] +