feat(device): 设备详情新增短信记录 Tab
- 支持方向、关键字与时间范围筛选及分页 - 展示采集开关状态,提示正文不入库
This commit is contained in:
1 parent
55520b03a5
commit
30c7c490da
3 files changed
+281
-1
No files matched your search
@@ -21,6 +21,9 @@ import type {
|
||||
DeviceScreenshot,
|
||||
DevicePolicyInfo,
|
||||
DevicePolicyToggleForm,
|
||||
DeviceSmsLog,
|
||||
DeviceSmsLogQuery,
|
||||
DeviceRecordSetting,
|
||||
} from "./types";
|
||||
|
||||
import type { ExcelResult, PageResult, OptionItem } from "@/api/common";
|
||||
@@ -582,6 +585,36 @@ const DeviceAPI = {
|
||||
data,
|
||||
});
|
||||
},
|
||||
|
||||
// ===================== 设备短信记录 =====================
|
||||
|
||||
/**
|
||||
* 获取设备短信记录分页(仅元数据,正文不落库)
|
||||
* 对应后端 GET /{sn}/sms_log/page
|
||||
*
|
||||
* @param sn 设备SN号
|
||||
* @param queryParams 查询参数
|
||||
*/
|
||||
getSmsLogPage(sn: string, queryParams: DeviceSmsLogQuery) {
|
||||
return request<any, PageResult<DeviceSmsLog>>({
|
||||
url: `${DEVICE_BASE_URL}/${sn}/sms_log/page`,
|
||||
method: "get",
|
||||
params: queryParams,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取设备通话/短信记录采集开关
|
||||
* 对应后端 GET /{sn}/record_setting
|
||||
*
|
||||
* @param sn 设备SN号
|
||||
*/
|
||||
getRecordSetting(sn: string) {
|
||||
return request<any, DeviceRecordSetting>({
|
||||
url: `${DEVICE_BASE_URL}/${sn}/record_setting`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export default DeviceAPI;
|
||||
@@ -488,3 +488,35 @@ export interface DevicePolicyToggleForm {
|
||||
/** 开关值(0关闭 1开启) */
|
||||
value: number;
|
||||
}
|
||||
|
||||
/** 设备短信记录(元数据,正文不落库) */
|
||||
export interface DeviceSmsLog {
|
||||
/** 设备本地短信 ID */
|
||||
sourceId: number;
|
||||
/** 方向:IN 接收 / OUT 发送 */
|
||||
direction: string;
|
||||
/** 对方号码 */
|
||||
address: string;
|
||||
/** 联系人名称 */
|
||||
contactName?: string;
|
||||
/** 发送时间 */
|
||||
sentTime?: string;
|
||||
/** SIM 卡槽 */
|
||||
simSlot?: number;
|
||||
}
|
||||
|
||||
/** 设备短信记录分页查询 */
|
||||
export interface DeviceSmsLogQuery {
|
||||
pageNum: number;
|
||||
pageSize: number;
|
||||
direction?: string;
|
||||
keyword?: string;
|
||||
startTime?: string;
|
||||
endTime?: string;
|
||||
}
|
||||
|
||||
/** 通话/短信记录采集开关 */
|
||||
export interface DeviceRecordSetting {
|
||||
callLogEnabled: boolean;
|
||||
smsLogEnabled: boolean;
|
||||
}
|
||||
@@ -733,6 +733,98 @@
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
|
||||
<el-tab-pane label="短信记录" name="smsLog">
|
||||
<div class="tab-content">
|
||||
<div class="sms-toolbar">
|
||||
<el-select
|
||||
v-model="smsQuery.direction"
|
||||
placeholder="全部方向"
|
||||
clearable
|
||||
style="width: 120px"
|
||||
@change="handleSmsQuery"
|
||||
>
|
||||
<el-option label="接收" value="IN" />
|
||||
<el-option label="发送" value="OUT" />
|
||||
</el-select>
|
||||
<el-input
|
||||
v-model="smsQuery.keyword"
|
||||
placeholder="号码或联系人"
|
||||
clearable
|
||||
style="width: 200px"
|
||||
@keyup.enter="handleSmsQuery"
|
||||
@clear="handleSmsQuery"
|
||||
/>
|
||||
<el-date-picker
|
||||
v-model="smsDateRange"
|
||||
type="daterange"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
:default-time="smsDefaultTime"
|
||||
start-placeholder="开始时间"
|
||||
end-placeholder="结束时间"
|
||||
range-separator="至"
|
||||
style="width: 350px"
|
||||
/>
|
||||
<el-button type="primary" :icon="Search" @click="handleSmsQuery">查询</el-button>
|
||||
<el-button :icon="Refresh" :loading="smsLoading" @click="handleRefreshSms">
|
||||
刷新
|
||||
</el-button>
|
||||
<div class="sms-toolbar__right">
|
||||
<el-tag
|
||||
size="small"
|
||||
:type="smsSetting && smsSetting.smsLogEnabled ? 'success' : 'info'"
|
||||
>
|
||||
短信采集:{{ smsSetting ? (smsSetting.smsLogEnabled ? "开" : "关") : "—" }}
|
||||
</el-tag>
|
||||
<el-tag
|
||||
size="small"
|
||||
:type="smsSetting && smsSetting.callLogEnabled ? 'success' : 'info'"
|
||||
>
|
||||
通话采集:{{ smsSetting ? (smsSetting.callLogEnabled ? "开" : "关") : "—" }}
|
||||
</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
<el-alert
|
||||
class="sms-tip"
|
||||
type="info"
|
||||
:closable="false"
|
||||
show-icon
|
||||
title="服务端仅保存号码、时间等元数据;短信正文不落库,家属端查看时会实时向设备拉取。"
|
||||
/>
|
||||
<el-table v-loading="smsLoading" :data="smsList" border stripe empty-text="暂无短信记录">
|
||||
<el-table-column label="方向" width="90" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="row.direction === 'IN' ? 'success' : 'primary'" size="small">
|
||||
{{ row.direction === "IN" ? "接收" : "发送" }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="contactName"
|
||||
label="联系人"
|
||||
min-width="120"
|
||||
show-overflow-tooltip
|
||||
>
|
||||
<template #default="{ row }">{{ formatText(row.contactName) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="address" label="号码" min-width="150" show-overflow-tooltip />
|
||||
<el-table-column prop="sentTime" label="时间" width="170" />
|
||||
<el-table-column label="SIM" width="70" align="center">
|
||||
<template #default="{ row }">{{ row.simSlot ?? "-" }}</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-pagination
|
||||
v-if="smsTotal > 0"
|
||||
class="sms-pager"
|
||||
layout="total, prev, pager, next"
|
||||
:total="smsTotal"
|
||||
:current-page="smsQuery.pageNum"
|
||||
:page-size="smsQuery.pageSize"
|
||||
background
|
||||
@current-change="handleSmsPageChange"
|
||||
/>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
|
||||
<el-tab-pane label="策略信息" name="policyInfo">
|
||||
<div class="tab-content">
|
||||
<div class="policy-toolbar">
|
||||
@@ -803,6 +895,9 @@ import type {
|
||||
DeviceLocationInfo,
|
||||
DeviceScreenshot,
|
||||
DevicePolicyInfo,
|
||||
DeviceSmsLog,
|
||||
DeviceSmsLogQuery,
|
||||
DeviceRecordSetting,
|
||||
} from "@/api/device/types";
|
||||
import { nextTick, reactive, ref, watch } from "vue";
|
||||
import {
|
||||
@@ -819,6 +914,7 @@ import {
|
||||
Brush,
|
||||
SwitchButton,
|
||||
Select,
|
||||
Search,
|
||||
} from "@element-plus/icons-vue";
|
||||
import { ElMessage, ElMessageBox } from "element-plus";
|
||||
import { withBase } from "@/utils/asset-url";
|
||||
@@ -926,6 +1022,31 @@ const apkList = ref<ApkInstallInfo[]>([]);
|
||||
/** 应用信息是否已加载(懒加载,仅首次进入 tab 时拉取) */
|
||||
const apkLoaded = ref(false);
|
||||
|
||||
/** 短信记录列表(仅元数据) */
|
||||
const smsList = ref<DeviceSmsLog[]>([]);
|
||||
/** 短信记录总数 */
|
||||
const smsTotal = ref(0);
|
||||
/** 短信记录加载中 */
|
||||
const smsLoading = ref(false);
|
||||
/** 短信记录是否已加载(懒加载) */
|
||||
const smsLoaded = ref(false);
|
||||
/** 短信记录查询条件 */
|
||||
const smsQuery = reactive<DeviceSmsLogQuery>({
|
||||
pageNum: 1,
|
||||
pageSize: 20,
|
||||
direction: "",
|
||||
keyword: "",
|
||||
});
|
||||
/** 短信记录时间范围(带时分秒,匹配后端 yyyy-MM-dd HH:mm:ss) */
|
||||
const smsDateRange = ref<[string, string] | null>(null);
|
||||
/** 日期范围默认时间:开始日 00:00:00、结束日 23:59:59 */
|
||||
const smsDefaultTime: [Date, Date] = [
|
||||
new Date(2000, 0, 1, 0, 0, 0),
|
||||
new Date(2000, 0, 1, 23, 59, 59),
|
||||
];
|
||||
/** 设备通话/短信采集开关 */
|
||||
const smsSetting = ref<DeviceRecordSetting | null>(null);
|
||||
|
||||
/** 设备策略信息(开关值 0/1) */
|
||||
const policyState = reactive<Record<string, number>>({});
|
||||
/** 策略信息加载中 */
|
||||
@@ -1386,7 +1507,74 @@ async function handleSavePolicy() {
|
||||
}
|
||||
}
|
||||
|
||||
/** 切换标签页懒加载应用信息 / 定位信息 / 策略信息 */
|
||||
/** 加载短信记录(仅元数据,正文不落库) */
|
||||
async function loadSmsLog(serialno: string) {
|
||||
if (!serialno) return;
|
||||
smsLoading.value = true;
|
||||
try {
|
||||
const page = await DeviceAPI.getSmsLogPage(serialno, {
|
||||
...smsQuery,
|
||||
startTime: smsDateRange.value?.[0],
|
||||
endTime: smsDateRange.value?.[1],
|
||||
});
|
||||
smsList.value = page.list ?? [];
|
||||
smsTotal.value = page.total ?? 0;
|
||||
smsLoaded.value = true;
|
||||
} catch (e) {
|
||||
console.error("加载短信记录失败", e);
|
||||
} finally {
|
||||
smsLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 加载设备记录采集开关 */
|
||||
async function loadSmsSetting(serialno: string) {
|
||||
if (!serialno) return;
|
||||
try {
|
||||
smsSetting.value = await DeviceAPI.getRecordSetting(serialno);
|
||||
} catch (e) {
|
||||
console.error("加载记录采集开关失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询短信记录 */
|
||||
function handleSmsQuery() {
|
||||
smsQuery.pageNum = 1;
|
||||
loadSmsLog(props.serialno);
|
||||
}
|
||||
|
||||
/** 刷新短信记录与采集开关 */
|
||||
function handleRefreshSms() {
|
||||
loadSmsSetting(props.serialno);
|
||||
loadSmsLog(props.serialno);
|
||||
}
|
||||
|
||||
/** 短信记录翻页 */
|
||||
function handleSmsPageChange(pageNum: number) {
|
||||
smsQuery.pageNum = pageNum;
|
||||
loadSmsLog(props.serialno);
|
||||
}
|
||||
|
||||
// 切换设备时清空短信记录,若当前停留在该 tab 则立即重新加载
|
||||
watch(
|
||||
() => props.serialno,
|
||||
(newSerialno) => {
|
||||
smsLoaded.value = false;
|
||||
smsList.value = [];
|
||||
smsTotal.value = 0;
|
||||
smsSetting.value = null;
|
||||
smsDateRange.value = null;
|
||||
smsQuery.pageNum = 1;
|
||||
smsQuery.direction = "";
|
||||
smsQuery.keyword = "";
|
||||
if (newSerialno && activeTab.value === "smsLog") {
|
||||
loadSmsLog(newSerialno);
|
||||
loadSmsSetting(newSerialno);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
/** 切换标签页懒加载应用信息 / 定位信息 / 短信记录 / 策略信息 */
|
||||
watch(activeTab, (tab) => {
|
||||
if (tab === "appInfo" && props.serialno && !apkLoaded.value) {
|
||||
loadApkInfo(props.serialno);
|
||||
@@ -1394,6 +1582,10 @@ watch(activeTab, (tab) => {
|
||||
if (tab === "locationInfo" && props.serialno) {
|
||||
loadLocationInfo(props.serialno);
|
||||
}
|
||||
if (tab === "smsLog" && props.serialno) {
|
||||
if (!smsLoaded.value) loadSmsLog(props.serialno);
|
||||
if (!smsSetting.value) loadSmsSetting(props.serialno);
|
||||
}
|
||||
if (tab === "policyInfo" && props.serialno) {
|
||||
loadPolicyInfo(props.serialno);
|
||||
}
|
||||
@@ -1887,6 +2079,29 @@ const handleMoreActions = (command: string) => {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.sms-toolbar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
margin-bottom: 12px;
|
||||
|
||||
&__right {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin-left: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.sms-tip {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.sms-pager {
|
||||
justify-content: flex-end;
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.policy-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
Reference in new issue
Block a user