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

后台管理添加体温上报

This commit is contained in:
程序员小墨 2023-04-14 00:53:02 +08:00
parent bad6ecb111
commit fb10c7e666
22 changed files with 472 additions and 58 deletions

View File

@ -4,7 +4,8 @@ public enum FieldType {
HIDDEN("null"), HIDDEN("null"),
TEXT("plaintext"), TEXT("plaintext"),
LONG_TEXT("longtext"), LONG_TEXT("longtext"),
IMAGE("image"); IMAGE("image"),
DATETIME("time");
private final String value; private final String value;

View File

@ -3,7 +3,8 @@ package com.cxyxiaomo.epp.PageTable.enums;
public enum SearchType { public enum SearchType {
CAN_NOT_SEARCH("null"), CAN_NOT_SEARCH("null"),
INPUT("input"), INPUT("input"),
SELECT("select"); SELECT("select"),
DATETIME_INTERVAL("time-interval");
private final String value; private final String value;

View File

@ -7,6 +7,8 @@ import com.cxyxiaomo.epp.PageTable.enums.EditType;
import com.cxyxiaomo.epp.PageTable.enums.FieldType; import com.cxyxiaomo.epp.PageTable.enums.FieldType;
import com.cxyxiaomo.epp.PageTable.enums.SearchType; import com.cxyxiaomo.epp.PageTable.enums.SearchType;
import java.util.Objects;
public class FieldBuilder { public class FieldBuilder {
public final static String SEARCH_PLACEHOLDER_SAME_AS_FIELDNAME = "<SEARCH_PLACEHOLDER_SAME_AS_FIELDNAME>"; public final static String SEARCH_PLACEHOLDER_SAME_AS_FIELDNAME = "<SEARCH_PLACEHOLDER_SAME_AS_FIELDNAME>";
@ -70,7 +72,8 @@ public class FieldBuilder {
jsonObject.put("editType", editType.getValue()); jsonObject.put("editType", editType.getValue());
jsonObject.put("editPlaceholder", EDIT_PLACEHOLDER_SAME_AS_ADD_PLACEHOLDER.equals(editPlaceholder) ? addPlaceholder : editPlaceholder); 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); jsonObject.put("default", defaultValue);

View File

@ -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;
}

View File

@ -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<ReportVO> convertFrom(List<Report> reportList) {
if (reportList == null) {
return null;
}
List<ReportVO> 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;
}
}

View File

@ -1,18 +1,31 @@
package com.cxyxiaomo.epp.access.controller; 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.rpc.UserServiceFeign;
import com.cxyxiaomo.epp.access.service.ReportServiceImpl; import com.cxyxiaomo.epp.access.service.ReportServiceImpl;
import com.cxyxiaomo.epp.common.pojo.Report; import com.cxyxiaomo.epp.common.pojo.Report;
import com.cxyxiaomo.epp.common.pojo.User; 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.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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List; import java.util.List;
@Controller @Controller
@ -78,6 +91,7 @@ public class ReportController {
List<Report> records = reportService.getRecordListByUserId(user.getId()); List<Report> records = reportService.getRecordListByUserId(user.getId());
return Res.success(records); return Res.success(records);
} }
/** /**
* 获取最近一次用户填报信息 * 获取最近一次用户填报信息
* *
@ -94,4 +108,104 @@ public class ReportController {
Report records = reportService.getLatestRecordByUserId(user.getId()); Report records = reportService.getLatestRecordByUserId(user.getId());
return Res.success(records); return Res.success(records);
} }
/**
* 获取体温数据列表
*
* @return
*/
@GetMapping("/manage/getReportList")
@ResponseBody
public Res getReportList(PageQuery pageQuery, ReportQuery reportQuery) {
// 查询分页数据
PageHelper.startPage(pageQuery.getPageIndex(), pageQuery.getPageSize());
List<Report> reportList = reportService.getReportList(reportQuery);
PageInfo<Report> reportPageInfo = new PageInfo<>(reportList);
List<Report> list = reportPageInfo.getList();
List<ReportVO> 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<Object, Object> 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<Report> reportList = reportService.getReportList(reportQuery);
List<ReportVO> reportVOList = ReportVO.convertFrom(reportList);
// 当前时间
Date now = Calendar.getInstance().getTime();
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd_HHmmss");
String dateTime = format.format(now);
HashMap<String, Object> map = new HashMap<>();
map.put("list", reportVOList);
map.put("sheetName", "体温数据表-" + System.currentTimeMillis());
map.put("fileName", "体温数据表_导出时间_" + dateTime);
return Res.success(map);
}
} }

View File

@ -1,6 +1,7 @@
package com.cxyxiaomo.epp.access.dao; package com.cxyxiaomo.epp.access.dao;
import com.cxyxiaomo.epp.common.pojo.Report; import com.cxyxiaomo.epp.common.pojo.Report;
import com.cxyxiaomo.epp.common.query.ReportQuery;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
@ -14,4 +15,6 @@ public interface ReportDao {
List<Report> getReportListByUserId(Integer userId); List<Report> getReportListByUserId(Integer userId);
Report getLatestReportByUserId(Integer userId); Report getLatestReportByUserId(Integer userId);
public List<Report> getReportList(ReportQuery reportQuery);
} }

View File

@ -2,6 +2,8 @@ package com.cxyxiaomo.epp.access.service;
import com.cxyxiaomo.epp.access.dao.ReportDao; import com.cxyxiaomo.epp.access.dao.ReportDao;
import com.cxyxiaomo.epp.common.pojo.Report; 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -18,11 +20,19 @@ public class ReportServiceImpl implements ReportService {
reportDao.insert(report); reportDao.insert(report);
} }
@Override
public List<Report> getRecordListByUserId(Integer userId) { public List<Report> getRecordListByUserId(Integer userId) {
return reportDao.getReportListByUserId(userId); return reportDao.getReportListByUserId(userId);
} }
@Override
public Report getLatestRecordByUserId(Integer userId) { public Report getLatestRecordByUserId(Integer userId) {
return reportDao.getLatestReportByUserId(userId); return reportDao.getLatestReportByUserId(userId);
} }
public List<Report> getReportList(ReportQuery reportQuery) {
List<Report> reportList = reportDao.getReportList(reportQuery);
return reportList;
}
} }

View File

@ -21,3 +21,8 @@ spring:
url: jdbc:mysql://127.0.0.1:3306/epp?useUnicode=true&characterEncoding=utf8&useSSL=false url: jdbc:mysql://127.0.0.1:3306/epp?useUnicode=true&characterEncoding=utf8&useSSL=false
username: root username: root
password: root password: root
logging:
level:
org.mybatis.spring.SqlSessionFactoryBean: DEBUG
# org.mybatis.spring.SqlSessionFactoryBean: TRACE

View File

@ -18,4 +18,33 @@
order by time desc order by time desc
LIMIT 1 LIMIT 1
</select> </select>
<select id="getReportList" resultType="com.cxyxiaomo.epp.common.pojo.Report">
select *
from report
where 1 = 1
<if test="id != null">
AND id = #{id}
</if>
<if test="userId != null">
AND user_id = #{userId}
</if>
<if test="name != null &amp;&amp; name != ''">
AND name LIKE concat('%',#{name,jdbcType=VARCHAR},'%')
</if>
<!--<if test="timestamp != null">-->
<!-- AND DATE_FORMAT(time, '%Y-%m-%d %H:%i:%s') = #{time, jdbcType=TIMESTAMP}-->
<!--</if>-->
<if test="startTime != null &amp;&amp; endTime != null">
AND time BETWEEN from_unixtime(#{startTime}/1000) AND from_unixtime(#{endTime}/1000)
</if>
<if test="temperature != null">
AND temperature = #{temperature}
</if>
<if test="address != null &amp;&amp; address != ''">
AND address LIKE concat('%',#{address,jdbcType=VARCHAR},'%')
</if>
ORDER BY time desc
</select>
</mapper> </mapper>

View File

@ -9,5 +9,9 @@
<!--下划线转小驼峰--> <!--下划线转小驼峰-->
<setting name="mapUnderscoreToCamelCase" value="true"/> <setting name="mapUnderscoreToCamelCase" value="true"/>
<!-- 打印 SQL 日志 -->
<!-- 设置logImpl为STDOUT_LOGGING表示使用标准输出打印SQL日志 -->
<setting name="logImpl" value="STDOUT_LOGGING"/>
</settings> </settings>
</configuration> </configuration>

View File

@ -96,6 +96,10 @@ public class GoodService {
return goodDao.deleteGoodById(goodId); return goodDao.deleteGoodById(goodId);
} }
public boolean addGoodCategory(GoodCategory goodCategory) { public boolean addGoodCategory(GoodCategory goodCategory) {
goodCategory.setId(null); goodCategory.setId(null);
return goodCategoryDao.addCategory(goodCategory); return goodCategoryDao.addCategory(goodCategory);
@ -110,6 +114,9 @@ public class GoodService {
} }
public GoodCategory getGoodCategoryById(Long id) { public GoodCategory getGoodCategoryById(Long id) {
if (id == null) { if (id == null) {
return null; return null;

View File

@ -11,7 +11,7 @@
Target Server Version : 80012 Target Server Version : 80012
File Encoding : 65001 File Encoding : 65001
Date: 29/03/2023 17:21:45 Date: 14/04/2023 00:51:48
*/ */
SET NAMES utf8mb4; SET NAMES utf8mb4;
@ -57,7 +57,7 @@ CREATE TABLE `community_gate1` (
`name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '大门显示名称', `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '大门显示名称',
`open` tinyint(1) NOT NULL DEFAULT 1 COMMENT '大门是否开放 1为开放 2为关闭', `open` tinyint(1) NOT NULL DEFAULT 1 COMMENT '大门是否开放 1为开放 2为关闭',
PRIMARY KEY (`id`) USING BTREE 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 -- 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 '体温是否正常', `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 '地址', `address` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '地址',
PRIMARY KEY (`id`) USING BTREE 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 -- 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 (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 (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 (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 -- Table structure for role
@ -356,7 +358,7 @@ CREATE TABLE `role` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'role_id', `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', `role_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'roleName',
PRIMARY KEY (`id`) USING BTREE 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 -- Records of role
@ -402,7 +404,7 @@ CREATE TABLE `user` (
`permission_time` datetime NULL DEFAULT NULL COMMENT '进出权限失效时间', `permission_time` datetime NULL DEFAULT NULL COMMENT '进出权限失效时间',
PRIMARY KEY (`id`) USING BTREE, PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `username`(`username`) 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 -- Records of user

View File

@ -15,6 +15,7 @@ declare module '@vue/runtime-core' {
ElCard: typeof import('element-plus/es')['ElCard'] ElCard: typeof import('element-plus/es')['ElCard']
ElCheckbox: typeof import('element-plus/es')['ElCheckbox'] ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
ElCol: typeof import('element-plus/es')['ElCol'] ElCol: typeof import('element-plus/es')['ElCol']
ElDatePicker: typeof import('element-plus/es')['ElDatePicker']
ElDialog: typeof import('element-plus/es')['ElDialog'] ElDialog: typeof import('element-plus/es')['ElDialog']
ElDropdown: typeof import('element-plus/es')['ElDropdown'] ElDropdown: typeof import('element-plus/es')['ElDropdown']
ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem'] ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem']

View File

@ -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,
});
};

View File

@ -18,12 +18,17 @@
<el-option v-for="optKey in Object.keys(field.options)" :key="optKey" :label="field.options[optKey]" <el-option v-for="optKey in Object.keys(field.options)" :key="optKey" :label="field.options[optKey]"
:value="optKey"></el-option> :value="optKey"></el-option>
</el-select> </el-select>
<el-date-picker v-else-if="field.searchType == 'time-interval'" v-model="query[field.field]"
type="datetimerange" :shortcuts="dateTimePickerRangeShotcut" range-separator="至"
:start-placeholder="field.placeholder + ' 起始时间'" :end-placeholder="field.placeholder + '结束时间'"
:prefix-icon="Filter" style="width: 350px; margin-right: 10px;" />
<template v-else>{{ field }}</template> <template v-else>{{ field }}</template>
</template> </template>
<el-button type="primary" :icon="Search" @click="handleSearch">查询</el-button> <el-button type="primary" :icon="Search" @click="handleSearch">查询</el-button>
<el-button type="primary" :icon="Plus" @click="handleNew" v-permiss="props.editPermiss">新增记录</el-button> <el-button type="primary" :icon="Plus" @click="handleNew" v-permiss="props.editPermiss"
<el-button type="primary" :icon="Download" @click="exportFormVisible = true" v-if="props.addFunc">新增记录</el-button>
v-permiss="props.editPermiss">导出到文件</el-button> <el-button type="primary" :icon="Download" @click="exportFormVisible = true" v-permiss="props.editPermiss"
v-if="props.exportFunc">导出到文件</el-button>
</div> </div>
<!-- 表格 --> <!-- 表格 -->
<el-table :data="tableData" border class="table" ref="multipleTable" header-cell-class-name="table-header"> <el-table :data="tableData" border class="table" ref="multipleTable" header-cell-class-name="table-header">
@ -31,29 +36,34 @@
<el-table-column v-for="(field, index) in tableFields" :prop="field.prop" :label="field.label" :key="index" <el-table-column v-for="(field, index) in tableFields" :prop="field.prop" :label="field.label" :key="index"
align="center"> align="center">
<template #default="scope" v-if="field.type == 'image'"> <template #default="scope" v-if="field.type == 'image'">
<el-image style="width: 100%; height: 100%;" :src="scope.row.picUrl" fit="cover" /> <el-image style="width: 100%; height: 100%;" :src="scope.row[field.prop]" fit="cover" />
</template>
<template #default="scope" v-else-if="field.type == 'time'">
{{
new Date(scope.row[field.prop] + 8 * 3600 * 1000).toISOString().replace('T', ' ').substring(0,19)
}}
</template> </template>
<template #default="scope" v-else-if="field.type == 'longtext'"> <template #default="scope" v-else-if="field.type == 'longtext'">
<el-tooltip placement="top"> <el-tooltip placement="top">
<template #content> <template #content>
<p v-for="line in scope.row.detail.split(/[\r\n]/g)" style="max-width: 300px;"> <p v-for="line in scope.row[field.prop].split(/[\r\n]/g)" style="max-width: 300px;">
{{ line }} {{ line }}
</p> </p>
</template> </template>
<div class="oneLine"> <div class="oneLine">
{{scope.row.detail}} {{ scope.row[field.prop] }}
</div> </div>
</el-tooltip> </el-tooltip>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" width="220" align="center"> <el-table-column label="操作" width="220" align="center" v-if="props.editFunc || props.deleteFunc">
<template #default="scope"> <template #default="scope">
<el-button text :icon="Edit" @click="handleEdit(scope.$index, scope.row)" <el-button text :icon="Edit" @click="handleEdit(scope.$index, scope.row)"
v-permiss="props.editPermiss"> v-permiss="props.editPermiss" v-if="props.editFunc">
编辑 编辑
</el-button> </el-button>
<el-button text :icon="Delete" class="red" @click="handleDelete(scope.$index, scope.row)" <el-button text :icon="Delete" class="red" @click="handleDelete(scope.$index, scope.row)"
v-permiss="props.editPermiss"> v-permiss="props.editPermiss" v-if="props.deleteFunc">
删除 删除
</el-button> </el-button>
</template> </template>
@ -144,17 +154,17 @@ const props = defineProps({
// //
'addFunc': { 'addFunc': {
type: Function, type: Function,
required: true, required: false,
}, },
// //
'editFunc': { 'editFunc': {
type: Function, type: Function,
required: true, required: false,
}, },
// //
'deleteFunc': { 'deleteFunc': {
type: Function, type: Function,
required: true, required: false,
}, },
// //
'exportFunc': { 'exportFunc': {
@ -330,6 +340,7 @@ const getData = async () => {
// //
mockData = data.columns mockData = data.columns
.filter((field: any) => field.mockRegex)
.map((field: any) => { .map((field: any) => {
let spaceIndex = field.mockRegex.indexOf(' ') let spaceIndex = field.mockRegex.indexOf(' ')
if (spaceIndex == -1) return if (spaceIndex == -1) return
@ -577,6 +588,73 @@ const doMockData = (isEdit: boolean) => {
onMounted(() => { onMounted(() => {
getData(); 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]
},
},
]
</script> </script>
<style scoped> <style scoped>

View File

@ -1,7 +1,8 @@
<template> <template>
<div class="sidebar"> <div class="sidebar">
<el-menu class="sidebar-el-menu" :default-active="onRoutes" :collapse="sidebar.collapse" background-color="#324157" <el-menu class="sidebar-el-menu" :default-active="onRoutes" :collapse="sidebar.collapse"
text-color="#bfcbd9" active-text-color="#20a0ff" unique-opened router> :default-openeds="activeItemList" background-color="#324157" text-color="#bfcbd9" active-text-color="#20a0ff"
router>
<template v-for="item in items"> <template v-for="item in items">
<template v-if="item.subs"> <template v-if="item.subs">
<el-sub-menu :index="item.index" :key="item.index" v-permiss="item.permiss"> <el-sub-menu :index="item.index" :key="item.index" v-permiss="item.permiss">
@ -11,18 +12,9 @@
</el-icon> </el-icon>
<span>{{ item.title }}</span> <span>{{ item.title }}</span>
</template> </template>
<template v-for="subItem in item.subs"> <el-menu-item v-for="subItem in item.subs" :index="subItem.index" v-permiss="item.permiss">
<el-sub-menu v-if="subItem.subs" :index="subItem.index" :key="subItem.index" {{ subItem.title }}
v-permiss="item.permiss"> </el-menu-item>
<template #title>{{ subItem.title }}</template>
<el-menu-item v-for="(threeItem, i) in subItem.subs" :key="i" :index="threeItem.index">
{{ threeItem.title }}
</el-menu-item>
</el-sub-menu>
<el-menu-item v-else :index="subItem.index" v-permiss="item.permiss">
{{ subItem.title }}
</el-menu-item>
</template>
</el-sub-menu> </el-sub-menu>
</template> </template>
<template v-else> <template v-else>
@ -39,7 +31,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { computed } from 'vue'; import { ref, computed } from 'vue';
import { useSidebarStore } from '../store/sidebar'; import { useSidebarStore } from '../store/sidebar';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import settings from '../utils/settings'; import settings from '../utils/settings';
@ -53,20 +45,15 @@ const items = [
permiss: 'dashboard', permiss: 'dashboard',
}, },
{ {
icon: 'BellFilled', icon: 'OfficeBuilding',
index: '/warning', index: '/report',
title: '预警信息', title: '体温上报',
permiss: 'warning', permiss: 'report',
subs: [ subs: [
{ {
index: '/warning-view', index: '/report-setting',
title: '总览', title: '体温管理',
permiss: 'warning-view', permiss: 'report-setting',
},
{
index: '/warning-setting',
title: '预警设置',
permiss: 'warning-setting',
}, },
], ],
}, },
@ -109,6 +96,9 @@ const onRoutes = computed(() => {
}); });
const sidebar = useSidebarStore(); const sidebar = useSidebarStore();
//
const activeItemList = items.map((i) => i.index)
</script> </script>
<style scoped> <style scoped>

View File

@ -31,6 +31,15 @@ const routes: RouteRecordRaw[] = [
}, },
component: () => import('../views/shop-good-setting.vue'), component: () => import('../views/shop-good-setting.vue'),
}, },
{
path: '/report-setting',
name: 'report-setting',
meta: {
title: '体温管理',
permiss: 'report-setting',
},
component: () => import('../views/report-setting.vue'),
},
{ {
path: '/shop-cate-setting', path: '/shop-cate-setting',
name: 'shop-cate-setting', name: 'shop-cate-setting',

View File

@ -15,6 +15,9 @@ export const usePermissStore = defineStore('permiss', {
"dashboard", "dashboard",
"report",
"report-setting",
"shop", "shop",
"shop-good-setting", "shop-good-setting",
"shop-cate-setting", "shop-cate-setting",
@ -29,6 +32,9 @@ export const usePermissStore = defineStore('permiss', {
"dashboard", "dashboard",
"report",
"report-setting",
"shop", "shop",
"shop-good-setting", "shop-good-setting",
"shop-cate-setting", "shop-cate-setting",
@ -38,9 +44,4 @@ export const usePermissStore = defineStore('permiss', {
] ]
}; };
}, },
// actions: {
// handleSet(val: string[]) {
// this.key = val;
// }
// }
}); });

View File

@ -0,0 +1,11 @@
<template>
<div class="container">
<manageList :list-func="reportApi.getReportList" :export-func="reportApi.exportReportList"
edit-permiss="privilege-user-setting" />
</div>
</template>
<script setup lang="ts">
import manageList from '../components/manage-list.vue';
import * as reportApi from '../api/report';
</script>

View File

@ -23,6 +23,9 @@ Page({
// 是否填报过 // 是否填报过
isFilled: true, isFilled: true,
filledMsg: "", filledMsg: "",
// 是否正在提交中,用于隐藏提交按钮,避免出现多次提交
isSubmitting: false,
}, },
/** /**
@ -240,6 +243,9 @@ Page({
title: '加载中' title: '加载中'
}) })
var that = this; var that = this;
that.setData({
isSubmitting: true,
})
wx.request({ wx.request({
url: `${app.globalData.baseUrl}/access/report/submit`, url: `${app.globalData.baseUrl}/access/report/submit`,
method: "POST", method: "POST",
@ -286,6 +292,9 @@ Page({
console.log("end fail") console.log("end fail")
}, },
complete: function () { complete: function () {
that.setData({
isSubmitting: false,
})
console.log("begin complete") console.log("begin complete")
if (typeof (callback) === "function") if (typeof (callback) === "function")
callback(); callback();

View File

@ -48,7 +48,7 @@
<view style="text-align: center;"> <view style="text-align: center;">
<button class="controlBtn" size="mini" type="none" bindtap="myreport">历史填报</button> <button class="controlBtn" size="mini" type="none" bindtap="myreport">历史填报</button>
<button class="controlBtn" size="mini" type="primary" bindtap="report">提交</button> <button class="controlBtn" size="mini" type="primary" bindtap="report" disabled="{{isSubmitting}}">提交</button>
</view> </view>
</view> </view>
<view wx:else style="text-align: center;"> <view wx:else style="text-align: center;">