1
This commit is contained in:
@@ -10,11 +10,14 @@ const app = AdminFramework.createApp({
|
|||||||
title: '我的管理系统',
|
title: '我的管理系统',
|
||||||
apiUrl: config.apiUrl,
|
apiUrl: config.apiUrl,
|
||||||
componentMap: componentMap,
|
componentMap: componentMap,
|
||||||
HomePage: CustomHomePage, // 可选:自定义首页组件,覆盖整个首页
|
HomePage: CustomHomePage // 可选:自定义首页组件,覆盖整个首页
|
||||||
storeModules: {
|
|
||||||
device: deviceModule // 注册设备选择模块
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 手动注册 store 模块(如果框架不支持 storeModules 参数)
|
||||||
|
if (app.$store && !app.$store.hasModule(['device'])) {
|
||||||
|
app.$store.registerModule('device', deviceModule)
|
||||||
|
}
|
||||||
|
|
||||||
// 挂载应用
|
// 挂载应用
|
||||||
app.$mount('#app')
|
app.$mount('#app')
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="home-statistics">
|
<div class="home-statistics">
|
||||||
<!-- 设备选择器 -->
|
<!-- 设备选择器 -->
|
||||||
<Card style="margin-bottom: 16px;">
|
<Card class="home-card" style="margin-bottom: 16px;">
|
||||||
<p slot="title">设备选择</p>
|
<p slot="title">设备选择</p>
|
||||||
<Select
|
<Select
|
||||||
v-model="selectedDeviceSn"
|
v-model="selectedDeviceSn"
|
||||||
@@ -137,7 +137,7 @@
|
|||||||
<!-- 统计卡片 -->
|
<!-- 统计卡片 -->
|
||||||
<Row :gutter="16" style="margin-bottom: 16px;">
|
<Row :gutter="16" style="margin-bottom: 16px;">
|
||||||
<Col span="6">
|
<Col span="6">
|
||||||
<Card>
|
<Card class="home-card">
|
||||||
<div class="statistic-item">
|
<div class="statistic-item">
|
||||||
<div class="statistic-title">今日投递</div>
|
<div class="statistic-title">今日投递</div>
|
||||||
<div class="statistic-value">{{ todayStats.applyCount }}</div>
|
<div class="statistic-value">{{ todayStats.applyCount }}</div>
|
||||||
@@ -145,7 +145,7 @@
|
|||||||
</Card>
|
</Card>
|
||||||
</Col>
|
</Col>
|
||||||
<Col span="6">
|
<Col span="6">
|
||||||
<Card>
|
<Card class="home-card">
|
||||||
<div class="statistic-item">
|
<div class="statistic-item">
|
||||||
<div class="statistic-title">今日找工作</div>
|
<div class="statistic-title">今日找工作</div>
|
||||||
<div class="statistic-value">{{ todayStats.jobSearchCount }}</div>
|
<div class="statistic-value">{{ todayStats.jobSearchCount }}</div>
|
||||||
@@ -153,7 +153,7 @@
|
|||||||
</Card>
|
</Card>
|
||||||
</Col>
|
</Col>
|
||||||
<Col span="6">
|
<Col span="6">
|
||||||
<Card>
|
<Card class="home-card">
|
||||||
<div class="statistic-item">
|
<div class="statistic-item">
|
||||||
<div class="statistic-title">今日沟通</div>
|
<div class="statistic-title">今日沟通</div>
|
||||||
<div class="statistic-value">{{ todayStats.chatCount }}</div>
|
<div class="statistic-value">{{ todayStats.chatCount }}</div>
|
||||||
@@ -161,7 +161,7 @@
|
|||||||
</Card>
|
</Card>
|
||||||
</Col>
|
</Col>
|
||||||
<Col span="6">
|
<Col span="6">
|
||||||
<Card>
|
<Card class="home-card">
|
||||||
<div class="statistic-item">
|
<div class="statistic-item">
|
||||||
<div class="statistic-title">执行中任务</div>
|
<div class="statistic-title">执行中任务</div>
|
||||||
<div class="statistic-value">{{ todayStats.runningTaskCount }}</div>
|
<div class="statistic-value">{{ todayStats.runningTaskCount }}</div>
|
||||||
@@ -171,7 +171,7 @@
|
|||||||
</Row>
|
</Row>
|
||||||
|
|
||||||
<!-- 当前执行任务的命令区块(指令列表) -->
|
<!-- 当前执行任务的命令区块(指令列表) -->
|
||||||
<Card style="margin-bottom: 16px;">
|
<Card class="home-card" style="margin-bottom: 16px;">
|
||||||
<p slot="title">当前执行中的任务</p>
|
<p slot="title">当前执行中的任务</p>
|
||||||
<Table
|
<Table
|
||||||
v-if="runningTasks.length > 0"
|
v-if="runningTasks.length > 0"
|
||||||
@@ -190,7 +190,7 @@
|
|||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
<!-- 趋势图表(7天趋势) -->
|
<!-- 趋势图表(7天趋势) -->
|
||||||
<Card>
|
<Card class="home-card">
|
||||||
<p slot="title">近7天统计趋势</p>
|
<p slot="title">近7天统计趋势</p>
|
||||||
<div ref="chartContainer" style="height: 400px;"></div>
|
<div ref="chartContainer" style="height: 400px;"></div>
|
||||||
</Card>
|
</Card>
|
||||||
@@ -716,6 +716,8 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
console.log('加载账户信息,设备SN:', this.selectedDeviceSn)
|
||||||
|
|
||||||
// 根据 sn_code 查询账户信息
|
// 根据 sn_code 查询账户信息
|
||||||
const res = await PlaAccountServer.page({
|
const res = await PlaAccountServer.page({
|
||||||
seachOption: {
|
seachOption: {
|
||||||
@@ -728,13 +730,20 @@ export default {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
if (res.code === 0 && res.data && res.data.rows && res.data.rows.length > 0) {
|
console.log('账户信息接口返回:', res)
|
||||||
const accountData = res.data.rows[0]
|
|
||||||
|
// 支持多种数据格式
|
||||||
|
const accountList = res.data?.rows || res.data?.list || res.data?.data || []
|
||||||
|
|
||||||
|
if (accountList.length > 0) {
|
||||||
|
const accountData = accountList[0]
|
||||||
|
console.log('找到账户信息:', accountData)
|
||||||
|
|
||||||
// 如果接口没有返回设备状态,则单独查询
|
// 如果接口没有返回设备状态,则单独查询
|
||||||
if (accountData.is_online === undefined || accountData.is_logged_in === undefined) {
|
if (accountData.is_online === undefined || accountData.is_logged_in === undefined) {
|
||||||
try {
|
try {
|
||||||
const deviceRes = await DeviceStatusServer.getById(this.selectedDeviceSn)
|
const deviceRes = await DeviceStatusServer.getById(this.selectedDeviceSn)
|
||||||
|
console.log('设备状态接口返回:', deviceRes)
|
||||||
if (deviceRes.code === 0 && deviceRes.data) {
|
if (deviceRes.code === 0 && deviceRes.data) {
|
||||||
accountData.is_online = deviceRes.data.isOnline || false
|
accountData.is_online = deviceRes.data.isOnline || false
|
||||||
accountData.is_logged_in = deviceRes.data.isLoggedIn || false
|
accountData.is_logged_in = deviceRes.data.isLoggedIn || false
|
||||||
@@ -756,7 +765,9 @@ export default {
|
|||||||
accountData.auto_active = accountData.auto_active !== undefined ? accountData.auto_active : 0
|
accountData.auto_active = accountData.auto_active !== undefined ? accountData.auto_active : 0
|
||||||
|
|
||||||
this.accountInfo = accountData
|
this.accountInfo = accountData
|
||||||
|
console.log('设置账户信息:', this.accountInfo)
|
||||||
} else {
|
} else {
|
||||||
|
console.warn('未找到账户信息,设备SN:', this.selectedDeviceSn)
|
||||||
this.accountInfo = {}
|
this.accountInfo = {}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -863,6 +874,8 @@ export default {
|
|||||||
<style scoped>
|
<style scoped>
|
||||||
.home-statistics {
|
.home-statistics {
|
||||||
padding: 16px;
|
padding: 16px;
|
||||||
|
background: #f7f8fa;
|
||||||
|
min-height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.statistic-item {
|
.statistic-item {
|
||||||
@@ -883,12 +896,24 @@ export default {
|
|||||||
|
|
||||||
.account-info-card {
|
.account-info-card {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
background: #fff !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.account-info-card:hover {
|
.account-info-card:hover {
|
||||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 所有卡片背景色 */
|
||||||
|
.home-card {
|
||||||
|
background: #fff !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.home-card >>> .ivu-card,
|
||||||
|
.home-card /deep/ .ivu-card,
|
||||||
|
.home-card ::v-deep .ivu-card {
|
||||||
|
background: #fff !important;
|
||||||
|
}
|
||||||
|
|
||||||
.account-info-item {
|
.account-info-item {
|
||||||
padding: 8px 0;
|
padding: 8px 0;
|
||||||
}
|
}
|
||||||
@@ -919,4 +944,49 @@ export default {
|
|||||||
margin-bottom: 8px;
|
margin-bottom: 8px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 确保卡片样式正常 */
|
||||||
|
.home-statistics >>> .ivu-card,
|
||||||
|
.home-statistics /deep/ .ivu-card,
|
||||||
|
.home-statistics ::v-deep .ivu-card {
|
||||||
|
background: #fff !important;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.home-statistics >>> .ivu-card-head,
|
||||||
|
.home-statistics /deep/ .ivu-card-head,
|
||||||
|
.home-statistics ::v-deep .ivu-card-head {
|
||||||
|
border-bottom: 1px solid #e8eaec;
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.home-statistics >>> .ivu-card-body,
|
||||||
|
.home-statistics /deep/ .ivu-card-body,
|
||||||
|
.home-statistics ::v-deep .ivu-card-body {
|
||||||
|
padding: 16px;
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 确保表格样式正常 */
|
||||||
|
.home-statistics >>> .ivu-table {
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.home-statistics >>> .ivu-table th {
|
||||||
|
background: #f8f8f9;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.home-statistics >>> .ivu-table-stripe .ivu-table-body tr:nth-child(2n) td {
|
||||||
|
background-color: #fafafa;
|
||||||
|
}
|
||||||
|
|
||||||
|
.home-statistics >>> .ivu-table td {
|
||||||
|
padding: 12px 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 确保图表容器样式正常 */
|
||||||
|
.home-statistics >>> .ivu-card-body {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -36,6 +36,64 @@ module.exports = {
|
|||||||
* 200:
|
* 200:
|
||||||
* description: 获取成功
|
* description: 获取成功
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
* @swagger
|
||||||
|
* /admin_api/device/detail:
|
||||||
|
* post:
|
||||||
|
* summary: 获取设备详情
|
||||||
|
* description: 根据设备SN码获取设备详细信息
|
||||||
|
* tags: [后台-设备管理]
|
||||||
|
* requestBody:
|
||||||
|
* required: true
|
||||||
|
* content:
|
||||||
|
* application/json:
|
||||||
|
* schema:
|
||||||
|
* type: object
|
||||||
|
* required:
|
||||||
|
* - deviceSn
|
||||||
|
* properties:
|
||||||
|
* deviceSn:
|
||||||
|
* type: string
|
||||||
|
* description: 设备SN码
|
||||||
|
* responses:
|
||||||
|
* 200:
|
||||||
|
* description: 获取成功
|
||||||
|
*/
|
||||||
|
'POST /device/detail': async (ctx) => {
|
||||||
|
const models = Framework.getModels();
|
||||||
|
const { device_status } = models;
|
||||||
|
const body = ctx.getBody();
|
||||||
|
const { deviceSn } = body;
|
||||||
|
|
||||||
|
if (!deviceSn) {
|
||||||
|
return ctx.fail('设备SN码不能为空');
|
||||||
|
}
|
||||||
|
|
||||||
|
const device = await device_status.findOne({
|
||||||
|
where: { sn_code: deviceSn }
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!device) {
|
||||||
|
return ctx.fail('设备不存在');
|
||||||
|
}
|
||||||
|
|
||||||
|
const deviceData = device.toJSON();
|
||||||
|
|
||||||
|
// 处理 JSON 字段
|
||||||
|
if (deviceData.config) {
|
||||||
|
try {
|
||||||
|
deviceData.config = typeof deviceData.config === 'string'
|
||||||
|
? JSON.parse(deviceData.config)
|
||||||
|
: deviceData.config;
|
||||||
|
} catch (e) {
|
||||||
|
console.error('解析设备配置失败:', e);
|
||||||
|
deviceData.config = {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ctx.success(deviceData);
|
||||||
|
},
|
||||||
|
|
||||||
'POST /device/list': async (ctx) => {
|
'POST /device/list': async (ctx) => {
|
||||||
const models = Framework.getModels();
|
const models = Framework.getModels();
|
||||||
const { device_status, op } = models;
|
const { device_status, op } = models;
|
||||||
|
|||||||
@@ -56,8 +56,22 @@ module.exports = {
|
|||||||
*/
|
*/
|
||||||
'POST /account/list': async (ctx) => {
|
'POST /account/list': async (ctx) => {
|
||||||
const body = ctx.getBody();
|
const body = ctx.getBody();
|
||||||
const { key, value, platform_type, is_online } = body;
|
|
||||||
const { limit, offset } = ctx.getPageSize();
|
// 支持两种参数格式:直接传参或通过 seachOption 传递
|
||||||
|
const seachOption = body.seachOption || {};
|
||||||
|
const pageOption = body.pageOption || {};
|
||||||
|
|
||||||
|
// 获取搜索参数(优先使用 seachOption,兼容直接传参)
|
||||||
|
const key = seachOption.key || body.key;
|
||||||
|
const value = seachOption.value || body.value;
|
||||||
|
const platform_type = seachOption.platform_type || body.platform_type;
|
||||||
|
const is_online = seachOption.is_online !== undefined ? seachOption.is_online : body.is_online;
|
||||||
|
|
||||||
|
// 获取分页参数
|
||||||
|
const page = pageOption.page || body.page || 1;
|
||||||
|
const pageSize = pageOption.pageSize || body.pageSize || 20;
|
||||||
|
const limit = pageSize;
|
||||||
|
const offset = (page - 1) * pageSize;
|
||||||
|
|
||||||
const result = await plaAccountService.getAccountList({
|
const result = await plaAccountService.getAccountList({
|
||||||
key,
|
key,
|
||||||
|
|||||||
@@ -53,8 +53,13 @@ class PlaAccountService {
|
|||||||
|
|
||||||
// 搜索条件
|
// 搜索条件
|
||||||
if (key && value) {
|
if (key && value) {
|
||||||
|
// 对于 sn_code 使用精确匹配,其他字段使用模糊匹配
|
||||||
|
if (key === 'sn_code') {
|
||||||
|
where[key] = value;
|
||||||
|
} else {
|
||||||
where[key] = { [op.like]: `%${value}%` };
|
where[key] = { [op.like]: `%${value}%` };
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 平台筛选
|
// 平台筛选
|
||||||
if (platform_type) {
|
if (platform_type) {
|
||||||
|
|||||||
Reference in New Issue
Block a user