diff --git a/src/api/device/index.ts b/src/api/device/index.ts index a8676b94..d93efb8b 100644 --- a/src/api/device/index.ts +++ b/src/api/device/index.ts @@ -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>({ + url: `${DEVICE_BASE_URL}/${sn}/sms_log/page`, + method: "get", + params: queryParams, + }); + }, + + /** + * 获取设备通话/短信记录采集开关 + * 对应后端 GET /{sn}/record_setting + * + * @param sn 设备SN号 + */ + getRecordSetting(sn: string) { + return request({ + url: `${DEVICE_BASE_URL}/${sn}/record_setting`, + method: "get", + }); + }, }; export default DeviceAPI; diff --git a/src/api/device/types.ts b/src/api/device/types.ts index fe60e0f6..436066b6 100644 --- a/src/api/device/types.ts +++ b/src/api/device/types.ts @@ -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; +} diff --git a/src/views/devices/sn/components/DeviceSnDetail.vue b/src/views/devices/sn/components/DeviceSnDetail.vue index 39258ff5..01da4fa7 100644 --- a/src/views/devices/sn/components/DeviceSnDetail.vue +++ b/src/views/devices/sn/components/DeviceSnDetail.vue @@ -733,6 +733,98 @@ + +
+
+ + + + + + + 查询 + + 刷新 + +
+ + 短信采集:{{ smsSetting ? (smsSetting.smsLogEnabled ? "开" : "关") : "—" }} + + + 通话采集:{{ smsSetting ? (smsSetting.callLogEnabled ? "开" : "关") : "—" }} + +
+
+ + + + + + + + + + + + + + + +
+
+
@@ -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([]); /** 应用信息是否已加载(懒加载,仅首次进入 tab 时拉取) */ const apkLoaded = ref(false); +/** 短信记录列表(仅元数据) */ +const smsList = ref([]); +/** 短信记录总数 */ +const smsTotal = ref(0); +/** 短信记录加载中 */ +const smsLoading = ref(false); +/** 短信记录是否已加载(懒加载) */ +const smsLoaded = ref(false); +/** 短信记录查询条件 */ +const smsQuery = reactive({ + 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(null); + /** 设备策略信息(开关值 0/1) */ const policyState = reactive>({}); /** 策略信息加载中 */ @@ -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;