1
This commit is contained in:
@@ -19,6 +19,121 @@
|
||||
</Select>
|
||||
</Card>
|
||||
|
||||
<!-- 账户信息卡片 -->
|
||||
<Card v-if="accountInfo.id" style="margin-bottom: 16px;" class="account-info-card">
|
||||
<div slot="title" style="display: flex; align-items: center; justify-content: space-between;">
|
||||
<span>账户信息</span>
|
||||
<Button type="primary" size="small" @click="viewAccountDetail">查看详情</Button>
|
||||
</div>
|
||||
<Row :gutter="16" style="margin-bottom: 16px;">
|
||||
<Col span="6">
|
||||
<div class="account-info-item">
|
||||
<div class="info-label">账户名</div>
|
||||
<div class="info-value">{{ accountInfo.name || '-' }}</div>
|
||||
</div>
|
||||
</Col>
|
||||
<Col span="6">
|
||||
<div class="account-info-item">
|
||||
<div class="info-label">平台</div>
|
||||
<div class="info-value">
|
||||
<Tag :color="getPlatformColor(accountInfo.platform_type)">
|
||||
{{ getPlatformText(accountInfo.platform_type) }}
|
||||
</Tag>
|
||||
</div>
|
||||
</div>
|
||||
</Col>
|
||||
<Col span="6">
|
||||
<div class="account-info-item">
|
||||
<div class="info-label">登录名</div>
|
||||
<div class="info-value">{{ accountInfo.login_name || '-' }}</div>
|
||||
</div>
|
||||
</Col>
|
||||
<Col span="6">
|
||||
<div class="account-info-item">
|
||||
<div class="info-label">设备SN码</div>
|
||||
<div class="info-value">{{ accountInfo.sn_code || '-' }}</div>
|
||||
</div>
|
||||
</Col>
|
||||
</Row>
|
||||
<Divider style="margin: 12px 0;"></Divider>
|
||||
<Row :gutter="16">
|
||||
<Col span="4">
|
||||
<div class="account-switch-item">
|
||||
<div class="switch-label">是否启用</div>
|
||||
<i-switch
|
||||
v-model="accountInfo.is_enabled"
|
||||
:true-value="1"
|
||||
:false-value="0"
|
||||
@on-change="handleSwitchChange('is_enabled', $event)"
|
||||
:loading="switchLoading.is_enabled"
|
||||
></i-switch>
|
||||
</div>
|
||||
</Col>
|
||||
<Col span="4">
|
||||
<div class="account-switch-item">
|
||||
<div class="switch-label">是否在线</div>
|
||||
<i-switch
|
||||
v-model="accountInfo.is_online"
|
||||
:true-value="true"
|
||||
:false-value="false"
|
||||
@on-change="handleSwitchChange('is_online', $event)"
|
||||
:loading="switchLoading.is_online"
|
||||
:disabled="true"
|
||||
></i-switch>
|
||||
</div>
|
||||
</Col>
|
||||
<Col span="4">
|
||||
<div class="account-switch-item">
|
||||
<div class="switch-label">是否登录</div>
|
||||
<i-switch
|
||||
v-model="accountInfo.is_logged_in"
|
||||
:true-value="true"
|
||||
:false-value="false"
|
||||
@on-change="handleSwitchChange('is_logged_in', $event)"
|
||||
:loading="switchLoading.is_logged_in"
|
||||
:disabled="true"
|
||||
></i-switch>
|
||||
</div>
|
||||
</Col>
|
||||
<Col span="4">
|
||||
<div class="account-switch-item">
|
||||
<div class="switch-label">自动投递</div>
|
||||
<i-switch
|
||||
v-model="accountInfo.auto_deliver"
|
||||
:true-value="1"
|
||||
:false-value="0"
|
||||
@on-change="handleSwitchChange('auto_deliver', $event)"
|
||||
:loading="switchLoading.auto_deliver"
|
||||
></i-switch>
|
||||
</div>
|
||||
</Col>
|
||||
<Col span="4">
|
||||
<div class="account-switch-item">
|
||||
<div class="switch-label">自动沟通</div>
|
||||
<i-switch
|
||||
v-model="accountInfo.auto_chat"
|
||||
:true-value="1"
|
||||
:false-value="0"
|
||||
@on-change="handleSwitchChange('auto_chat', $event)"
|
||||
:loading="switchLoading.auto_chat"
|
||||
></i-switch>
|
||||
</div>
|
||||
</Col>
|
||||
<Col span="4">
|
||||
<div class="account-switch-item">
|
||||
<div class="switch-label">自动活跃</div>
|
||||
<i-switch
|
||||
v-model="accountInfo.auto_active"
|
||||
:true-value="1"
|
||||
:false-value="0"
|
||||
@on-change="handleSwitchChange('auto_active', $event)"
|
||||
:loading="switchLoading.auto_active"
|
||||
></i-switch>
|
||||
</div>
|
||||
</Col>
|
||||
</Row>
|
||||
</Card>
|
||||
|
||||
<!-- 统计卡片 -->
|
||||
<Row :gutter="16" style="margin-bottom: 16px;">
|
||||
<Col span="6">
|
||||
@@ -56,9 +171,22 @@
|
||||
</Row>
|
||||
|
||||
<!-- 当前执行任务的命令区块(指令列表) -->
|
||||
<Card v-if="runningTasks.length > 0" style="margin-bottom: 16px;">
|
||||
<Card style="margin-bottom: 16px;">
|
||||
<p slot="title">当前执行中的任务</p>
|
||||
<Table :columns="taskColumns" :data="commandTableData" :loading="taskLoading"></Table>
|
||||
<Table
|
||||
v-if="runningTasks.length > 0"
|
||||
:columns="taskColumns"
|
||||
:data="commandTableData"
|
||||
:loading="taskLoading"
|
||||
></Table>
|
||||
<div v-else-if="!taskLoading" style="text-align: center; padding: 40px; color: #999;">
|
||||
<Icon type="ios-list-outline" size="48" />
|
||||
<p style="margin-top: 16px; font-size: 14px;">暂无执行中的任务</p>
|
||||
</div>
|
||||
<div v-else style="text-align: center; padding: 40px;">
|
||||
<Spin size="large"></Spin>
|
||||
<p style="margin-top: 16px; color: #999;">加载中...</p>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
<!-- 趋势图表(7天趋势) -->
|
||||
@@ -73,6 +201,7 @@
|
||||
import * as echarts from 'echarts'
|
||||
import DeviceStatusServer from '../../api/device/device_status_server.js'
|
||||
import StatisticsServer from '../../api/statistics/statistics_server.js'
|
||||
import PlaAccountServer from '../../api/profile/pla_account_server.js'
|
||||
|
||||
export default {
|
||||
name: 'HomePage',
|
||||
@@ -98,7 +227,16 @@ export default {
|
||||
taskLoading: false,
|
||||
chartInstance: null, // ECharts实例
|
||||
taskColumns: [],
|
||||
refreshTimer: null
|
||||
refreshTimer: null,
|
||||
accountInfo: {}, // 账户信息
|
||||
switchLoading: {
|
||||
is_enabled: false,
|
||||
is_online: false,
|
||||
is_logged_in: false,
|
||||
auto_deliver: false,
|
||||
auto_chat: false,
|
||||
auto_active: false
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -220,7 +358,8 @@ export default {
|
||||
await Promise.all([
|
||||
this.loadTodayStats(),
|
||||
this.loadChartData(),
|
||||
this.loadRunningTasks()
|
||||
this.loadRunningTasks(),
|
||||
this.loadAccountInfo()
|
||||
])
|
||||
},
|
||||
|
||||
@@ -567,6 +706,155 @@ export default {
|
||||
// 计算进度百分比
|
||||
const progress = Math.round((completedCount / commands.length) * 100)
|
||||
return progress
|
||||
},
|
||||
|
||||
// 加载账户信息
|
||||
async loadAccountInfo() {
|
||||
if (!this.selectedDeviceSn) {
|
||||
this.accountInfo = {}
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
// 根据 sn_code 查询账户信息
|
||||
const res = await PlaAccountServer.page({
|
||||
seachOption: {
|
||||
key: 'sn_code',
|
||||
value: this.selectedDeviceSn
|
||||
},
|
||||
pageOption: {
|
||||
page: 1,
|
||||
pageSize: 1
|
||||
}
|
||||
})
|
||||
|
||||
if (res.code === 0 && res.data && res.data.rows && res.data.rows.length > 0) {
|
||||
const accountData = res.data.rows[0]
|
||||
|
||||
// 如果接口没有返回设备状态,则单独查询
|
||||
if (accountData.is_online === undefined || accountData.is_logged_in === undefined) {
|
||||
try {
|
||||
const deviceRes = await DeviceStatusServer.getById(this.selectedDeviceSn)
|
||||
if (deviceRes.code === 0 && deviceRes.data) {
|
||||
accountData.is_online = deviceRes.data.isOnline || false
|
||||
accountData.is_logged_in = deviceRes.data.isLoggedIn || false
|
||||
} else {
|
||||
accountData.is_online = false
|
||||
accountData.is_logged_in = false
|
||||
}
|
||||
} catch (deviceError) {
|
||||
console.error('获取设备状态失败:', deviceError)
|
||||
accountData.is_online = false
|
||||
accountData.is_logged_in = false
|
||||
}
|
||||
}
|
||||
|
||||
// 确保布尔值字段正确初始化
|
||||
accountData.is_enabled = accountData.is_enabled !== undefined ? accountData.is_enabled : 1
|
||||
accountData.auto_deliver = accountData.auto_deliver !== undefined ? accountData.auto_deliver : 0
|
||||
accountData.auto_chat = accountData.auto_chat !== undefined ? accountData.auto_chat : 0
|
||||
accountData.auto_active = accountData.auto_active !== undefined ? accountData.auto_active : 0
|
||||
|
||||
this.accountInfo = accountData
|
||||
} else {
|
||||
this.accountInfo = {}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载账户信息失败:', error)
|
||||
this.accountInfo = {}
|
||||
}
|
||||
},
|
||||
|
||||
// 处理开关变化
|
||||
async handleSwitchChange(field, value) {
|
||||
if (!this.accountInfo.id) {
|
||||
this.$Message.warning('账户信息不存在')
|
||||
return
|
||||
}
|
||||
|
||||
// is_online 和 is_logged_in 是只读的,不应该被修改
|
||||
if (field === 'is_online' || field === 'is_logged_in') {
|
||||
this.$Message.warning('该状态由设备状态决定,无法手动修改')
|
||||
// 恢复原值
|
||||
this.$nextTick(() => {
|
||||
if (field === 'is_online') {
|
||||
this.accountInfo.is_online = !value
|
||||
} else {
|
||||
this.accountInfo.is_logged_in = !value
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 设置加载状态
|
||||
this.switchLoading[field] = true
|
||||
|
||||
try {
|
||||
// 确保 value 是数字类型(0 或 1)
|
||||
const numericValue = value ? 1 : 0
|
||||
|
||||
// 构建更新数据,确保是纯对象,只包含基本类型
|
||||
const updateData = {
|
||||
id: Number(this.accountInfo.id),
|
||||
[field]: numericValue
|
||||
}
|
||||
|
||||
// 调用更新接口
|
||||
await PlaAccountServer.update(updateData)
|
||||
|
||||
// 更新本地数据
|
||||
this.accountInfo[field] = numericValue
|
||||
|
||||
this.$Message.success('更新成功')
|
||||
} catch (error) {
|
||||
console.error(`更新${field}失败:`, error)
|
||||
const errorMsg = error.response?.data?.message || error.message || '请稍后重试'
|
||||
this.$Message.error('更新失败:' + errorMsg)
|
||||
|
||||
// 恢复原值
|
||||
this.$nextTick(() => {
|
||||
const oldValue = this.accountInfo[field]
|
||||
if (field === 'is_enabled') {
|
||||
this.accountInfo.is_enabled = oldValue === 1 ? 0 : 1
|
||||
} else if (field === 'auto_deliver') {
|
||||
this.accountInfo.auto_deliver = oldValue === 1 ? 0 : 1
|
||||
} else if (field === 'auto_chat') {
|
||||
this.accountInfo.auto_chat = oldValue === 1 ? 0 : 1
|
||||
} else if (field === 'auto_active') {
|
||||
this.accountInfo.auto_active = oldValue === 1 ? 0 : 1
|
||||
}
|
||||
})
|
||||
} finally {
|
||||
this.switchLoading[field] = false
|
||||
}
|
||||
},
|
||||
|
||||
// 查看账户详情
|
||||
viewAccountDetail() {
|
||||
if (this.accountInfo.id) {
|
||||
this.$router.push({
|
||||
path: '/pla_account/pla_account_detail',
|
||||
query: { id: this.accountInfo.id }
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
// 获取平台颜色
|
||||
getPlatformColor(platformType) {
|
||||
const colorMap = {
|
||||
'1': 'blue',
|
||||
'2': 'green'
|
||||
}
|
||||
return colorMap[platformType] || 'default'
|
||||
},
|
||||
|
||||
// 获取平台文本
|
||||
getPlatformText(platformType) {
|
||||
const textMap = {
|
||||
'1': 'Boss直聘',
|
||||
'2': '猎聘'
|
||||
}
|
||||
return textMap[platformType] || platformType || '-'
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -592,4 +880,43 @@ export default {
|
||||
font-weight: bold;
|
||||
color: #2d8cf0;
|
||||
}
|
||||
|
||||
.account-info-card {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.account-info-card:hover {
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.account-info-item {
|
||||
padding: 8px 0;
|
||||
}
|
||||
|
||||
.info-label {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.info-value {
|
||||
font-size: 14px;
|
||||
color: #333;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.account-switch-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 8px 0;
|
||||
}
|
||||
|
||||
.switch-label {
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
margin-bottom: 8px;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user