进出日志后台查询;小程序端进门;导出表格时日期转换
This commit is contained in:
41
frontend/src/api/access-log.js
Normal file
41
frontend/src/api/access-log.js
Normal file
@@ -0,0 +1,41 @@
|
||||
import send_request from '../utils/send_request';
|
||||
|
||||
/**
|
||||
* 获取进出记录列表
|
||||
* @returns
|
||||
*/
|
||||
export function getAccessLogList(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/access-log/manage/getAccessLogList',
|
||||
method: 'GET',
|
||||
params: paramsCopy,
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 导出进出记录列表
|
||||
* @returns
|
||||
*/
|
||||
export function exportAccessLogList(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/access-log/manage/exportAccessLogList',
|
||||
method: 'GET',
|
||||
params: paramsCopy,
|
||||
});
|
||||
};
|
@@ -487,7 +487,7 @@ const handleExport = async () => {
|
||||
// 如果选择仅导出满肚条件的数据,那么这里就填上查询参数
|
||||
if (exportConfig.value.withFilter) {
|
||||
params = JSON.parse(JSON.stringify(query))
|
||||
// 去除分页参数
|
||||
// 去除分页参数
|
||||
delete params["pageIndex"]
|
||||
delete params["pageSize"]
|
||||
}
|
||||
@@ -514,6 +514,17 @@ const handleExport = async () => {
|
||||
}
|
||||
console.log("dataList", dataList)
|
||||
|
||||
// 日期转换
|
||||
let timeField = tableFields.value.filter((field: any) => field.type == "time")
|
||||
console.log("timeField", timeField)
|
||||
for (let field of timeField) {
|
||||
console.log("field.prop", field.prop)
|
||||
dataList = dataList.map((row: any) => {
|
||||
row[field.prop] = new Date(row[field.prop] + 8 * 3600 * 1000).toISOString().replace('T', ' ').substring(0, 19)
|
||||
return row
|
||||
})
|
||||
}
|
||||
|
||||
// 所有列的 field
|
||||
let fieldNameList = exportFields.map((f: any) => f.field)
|
||||
fieldNameList.unshift(idFieldName)
|
||||
|
@@ -1,11 +1,11 @@
|
||||
<template>
|
||||
<div class="container">
|
||||
<manageList :list-func="reportApi.getReportList" :export-func="reportApi.exportReportList"
|
||||
<manageList :list-func="accessLogApi.getAccessLogList" :export-func="accessLogApi.exportAccessLogList"
|
||||
edit-permiss="access-log" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import manageList from '../components/manage-list.vue';
|
||||
import * as reportApi from '../api/report';
|
||||
import * as accessLogApi from '../api/access-log';
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user