1. 工作人员账号添加
2. 优化打包
3. 日志
4. 用户头像列表
This commit is contained in:
Zy
2026-10-21 08:59:48 +08:00
parent 5584ef1954
commit eeb842d278
36 changed files with 1514 additions and 602 deletions

View File

@@ -66,7 +66,7 @@
</el-table-column>
<el-table-column align="center" class-name="small-padding fixed-width" label="操作">
<template #default="scope">
<el-button v-hasPermi="['system:agreement:edit']" link type="primary"
<el-button v-hasPermiAnd="['system:agreement:edit','system:agreement:query']" link type="primary"
@click="handleUpdate(scope.row)">编辑
</el-button>
<el-button v-if="scope.row.status === '0'" v-hasPermi="['system:agreement:edit']" link type="success"

View File

@@ -27,8 +27,9 @@
<el-button
class="btn-img"
plain
:disabled="disable || uploading"
type="info"
:disabled="disable"
:loading="uploading"
@click="handleSelectImage"
>
上传图片
@@ -55,7 +56,11 @@ const props = defineProps({
type: Boolean,
default: false
},
/** 是否正在上传图片 */
uploading: {
type: Boolean,
default: false
},
/** 是否禁用输入框 */
disable: {
type: Boolean,

View File

@@ -67,6 +67,7 @@ const props = defineProps<{
messages: ChatMessage[]
userAvatar: string
loadingHistory?: boolean
latestSeq?: number
}>()
const emit = defineEmits<{
@@ -81,6 +82,7 @@ const listRef = ref<HTMLElement>()
const isAtBottom = ref(true)
let isFirstRender = true
let isLoadingMore = false
let prevScrollTop = 0
const BOTTOM_THRESHOLD = 50
const TOP_THRESHOLD = 30
@@ -105,30 +107,39 @@ const handleScroll = () => {
const el = listRef.value
if (!el) return
isAtBottom.value = checkAtBottom()
if (el.scrollTop <= TOP_THRESHOLD && !isLoadingMore) {
isLoadingMore = true
const currentTop = el.scrollTop
const scrollingUp = currentTop < prevScrollTop
prevScrollTop = currentTop
if (scrollingUp && currentTop <= TOP_THRESHOLD && !props.loadingHistory && !isLoadingMore) {
console.log('向上滚动到顶部了')
isLoadingMore = true;
setTimeout(() => {
isLoadingMore = false
}, 500)
emit('loadMore')
}
}
watch(
() => props.messages.length,
async (newLen, oldLen) => {
console.log(newLen, oldLen)
isLoadingMore = false
if (newLen === 0) return
() => props.latestSeq,
async (newSeq, oldSeq) => {
console.log(newSeq, oldSeq, isAtBottom.value)
if (newSeq === 1) return
if (isFirstRender) {
await scrollToBottom()
isFirstRender = false
isAtBottom.value = true
return
}
if (isAtBottom.value) {
await scrollToBottom()
}
await nextTick()
const el = listRef.value
if (el) prevScrollTop = el.scrollTop
},
{immediate: true}
)

View File

@@ -21,6 +21,7 @@ const csSessionStore = useCsSessionStore()
const userStore = useUserStore()
const {
state,
latestSeq,
userInfoMessage,
currentSessionId
} = storeToRefs(csSessionStore);
@@ -55,6 +56,7 @@ const onSendMsg = async (text: string) => {
}
}
let isUploadImaging = ref(false)
const onUploadImage = async (file: File) => {
const client = csSessionStore.getWs()
if (!client) {
@@ -63,7 +65,9 @@ const onUploadImage = async (file: File) => {
}
// 1. 转换成 网络图片
// 2. 发送图片消息
isUploadImaging.value = true
let res = await handleSaveAvatar(file);
isUploadImaging.value = false
if (!res) return
let sendObj = {
"type": "message",
@@ -121,18 +125,19 @@ const loadingHistory = ref(false)
function handleLoadMore() {
loadingHistory.value = true
if (!currentSessionId.value) return
console.log('加载更多历史消息')
// // 每次只能拉取 100 条消息
if (!currentSessionId.value) return loadingHistory.value = false;
// // 每次只能拉取 MAX_MESSAGES 条消息
// 1. 得到最早的seq
let seq = userInfoMessage.value[0].seq;
let seq = userInfoMessage.value[0]?.seq || 0;
if ((seq === 1 || seq === 0)) return loadingHistory.value = false;
// 2. 减去 MAX_MESSAGES 条消息
let latestSeq = Math.max(seq - MAX_MESSAGES, 0)
// 3. 拉取过往新消息
// console.log('拉取过往新消息从', latestSeq)
console.log(`拉去消息:${seq} -> ${latestSeq}`)
getDeskCsAgentHistory(currentSessionId.value, latestSeq, seq).then(res => {
csSessionStore.handleLoadMoreMessages(res.data)
console.log('加载更多历史消息', res.data.length)
}).finally(() => {
loadingHistory.value = false
})
}
@@ -227,11 +232,12 @@ function exportCsSessionStore() {
function handleRouteDeviceMain(deviceInfo: Device) {
// 跳转设备详情页
window.open(`/device/deviceMain?deviceId=${deviceInfo.deviceId}`)
window.open(`/device/deviceMain?id=${deviceInfo.deviceId}`)
}
// 保持活跃
let lastPingTime = 0
// 保持活跃的冷却时间(单位:毫秒) 10s
const PING_COOLDOWN = 10000
const floatItems = ref<{ id: number; x: number }[]>([])
let floatId = 0
@@ -377,13 +383,16 @@ async function handleRefreshList() {
</div>
</div>
<div class="content beautify_scroll">
<MessageList ref="messageList" :loading-history="loadingHistory" :messages="userInfoMessage"
<MessageList ref="messageList" :latest-seq="latestSeq" :loading-history="loadingHistory"
:messages="userInfoMessage"
:user-avatar="state.userInfoMain.customer.avatarUrl || ''"
@load-more="handleLoadMore"></MessageList>
</div>
<div class="footer">
<!-- 输入框组件 -->
<ChatInput :disable="state.userInfoMain.session.status !== '2'" :sending="csSessionStore.sending"
<ChatInput v-hasPermi="['cs:session:send']" :disable="state.userInfoMain.session.status !== '2'"
:sending="csSessionStore.sending"
:uploading="isUploadImaging"
@send="onSendMsg" @uploadImage="onUploadImage"/>
</div>
</div>

View File

@@ -8,8 +8,8 @@
<el-input v-model="queryParams.sessionNo" clearable placeholder="请输入会话编号" size="large"
style="width: 150px" @keyup.enter="handleQuery"/>
</el-form-item>
<el-form-item label="用户手机号" prop="ipaddr">
<el-input v-model="queryParams.ipaddr" clearable placeholder="请输入用户手机号" size="large"
<el-form-item label="用户手机号" prop="phonenumber">
<el-input v-model="queryParams.phonenumber" clearable placeholder="请输入用户手机号" size="large"
style="width: 150px" @keyup.enter="handleQuery"/>
</el-form-item>
<el-form-item label="会话状态" prop="status">
@@ -26,24 +26,24 @@
:value="item.value"></el-option>
</el-select>
</el-form-item>
<el-form-item label="问题类型" prop="problemType">
<el-select
v-model="queryParams.problemType"
:empty-values="[null, undefined]"
:value-on-clear="null"
clearable
placeholder="请选择问题类型"
size="large"
style="width: 150px"
>
<el-option label="在线" value="0"></el-option>
<el-option label="离线" value="1"></el-option>
</el-select>
</el-form-item>
<el-form-item label="关联设备" prop="deviceId">
<el-input v-model="queryParams.deviceId" clearable placeholder="请输入MAC/设备名称" size="large"
style="width: 190px" @keyup.enter="handleQuery"/>
</el-form-item>
<!-- <el-form-item label="问题类型" prop="problemType">-->
<!-- <el-select-->
<!-- v-model="queryParams.problemType"-->
<!-- :empty-values="[null, undefined]"-->
<!-- :value-on-clear="null"-->
<!-- clearable-->
<!-- placeholder="请选择问题类型"-->
<!-- size="large"-->
<!-- style="width: 150px"-->
<!-- >-->
<!-- <el-option label="在线" value="0"></el-option>-->
<!-- <el-option label="离线" value="1"></el-option>-->
<!-- </el-select>-->
<!-- </el-form-item>-->
<!-- <el-form-item label="关联设备" prop="deviceId">-->
<!-- <el-input v-model="queryParams.deviceId" clearable placeholder="请输入MAC/设备名称" size="large"-->
<!-- style="width: 190px" @keyup.enter="handleQuery"/>-->
<!-- </el-form-item>-->
<el-form-item label="会话创建时间" prop="startTime">
<el-date-picker
v-model="queryParams.startTime"
@@ -63,11 +63,12 @@
:empty-values="[null, undefined]"
:value-on-clear="null"
clearable
placeholder="请选择接待客服"
size="large"
style="width: 150px"
>
<el-option label="在线" value="0"></el-option>
<el-option label="离线" value="1"></el-option>
<el-option v-for="(item,index) in queryParamsOptions" :key="index" :label="item.nickName"
:value="item.userId"></el-option>
</el-select>
</el-form-item>
<el-form-item>
@@ -83,14 +84,15 @@
<div>
<el-button type="primary">
<span style="margin:0 8px;color: #fff;">全部</span>
<span style="color: #fff;font-weight: bold">1286</span>
<span style="color: #fff;font-weight: bold">{{ overViewTotal }}</span>
</el-button>
<tableTag v-for="(item,index) in overViewList" :key="index" :circle-color="colorList[index]"
:num="item.count"
:title="item.statusName"></tableTag>
</div>
<div>
<el-button plain type="info" @click="handleExport">批量导出会话记录</el-button>
<el-button v-hasPermi="['cs:session:export']" plain type="info" @click="handleExport">批量导出会话记录
</el-button>
<el-button plain type="info" @click="getList">刷新</el-button>
</div>
</div>
@@ -99,23 +101,26 @@
v-loading="loading"
:data="onlineList"
border
@select="handleSelectionChange"
class="data-table"
style="width: 100%"
>
<el-table-column align="center" type="selection"></el-table-column>
<el-table-column :show-overflow-tooltip="true" align="center" label="会话ID" prop="sessionNo"/>
<el-table-column :show-overflow-tooltip="true" align="center" label="用户信息" prop="userNickName">
<el-table-column :show-overflow-tooltip="true" align="center" label="用户信息" min-width="150"
prop="userNickName">
<template #default="scope">
<div class="userInfoBox">
<div v-if="scope.row.customer" class="userInfoBox">
<div class="nameBox">
<i class="circle"></i>
<span>{{ scope.row.customer.nickName }}</span>
</div>
<div style="color: #9CA3AF;font-size: 12px;">{{ hiddenPhone(scope.row.customer.phonenumber) }}</div>
<!-- <div style="color: #9CA3AF;font-size: 12px;">{{ hiddenPhone(scope.row.customer.phonenumber) }}</div>-->
<div style="color: #9CA3AF;font-size: 12px;">{{ scope.row.customer.phonenumber }}</div>
</div>
</template>
</el-table-column>
<el-table-column :show-overflow-tooltip="true" align="center" label="关联设备" prop="deviceId"/>
<!-- <el-table-column :show-overflow-tooltip="true" align="center" label="关联设备" prop="deviceId"/>-->
<el-table-column align="center" label="会话状态" width="100">
<template #default="scope">
<dict-tag :options="com_session_state" :value="scope.row.status"></dict-tag>
@@ -126,23 +131,24 @@
<div class="name">{{ scope.row.agentName }}</div>
</template>
</el-table-column>
<el-table-column :show-overflow-tooltip="true" align="center" label="用户问题摘要" prop="summary"/>
<el-table-column :show-overflow-tooltip="true" align="center" label="用户问题摘要" min-width="200"
prop="summary"/>
<el-table-column :show-overflow-tooltip="true" align="center" label="排队序号" prop="queueNo" width="100"/>
<el-table-column :show-overflow-tooltip="true" align="center" label="等待时长" prop="os" width="100"/>
<el-table-column :show-overflow-tooltip="true" align="center" label="最后消息时间" prop="lastMessageTime"
width="160"/>
<el-table-column align="center" class-name="small-padding fixed-width" fixed="right" label="操作"
min-width="200">
min-width="220">
<template #default="scope">
<div>
<el-button
v-hasPermi="['monitor:online:forceLogout']"
v-hasPermi="['cs:session:query']"
type="primary"
@click="handleMain(scope.row)"
>查看会话
</el-button>
<el-button
v-hasPermi="['monitor:online:forceLogout']"
v-hasPermi="['customer:user:query']"
plain
type="info"
@click="handleUserMain(scope.row)"
@@ -158,6 +164,7 @@
v-model:limit="queryParams.pageSize"
v-model:page="queryParams.pageNum"
:total="total"
@pagination="getList"
/>
</el-card>
</div>
@@ -171,6 +178,8 @@ import {hiddenPhone} from "@/utils/phone";
import {download as requestDownload} from "@/utils/request";
import {useTableSelection} from "@/hooks/table/useTableSelection";
import {CsAgentVO} from "@/api/system/cssAgent/types";
import {listUser} from "@/api/system/user";
import {UserVO} from "@/api/system/user/types";
const {com_session_state} = toRefs<any>(useDict('com_session_state'));
@@ -182,11 +191,21 @@ const total = ref(0);
const {ids, single, multiple, handleSelectionChange} = useTableSelection<CsSessionVO>(item => item.sessionId);
const queryFormRef = ref<ElFormInstance>();
const queryParamsOptions = ref<UserVO[]>([]);
function getUserOptionsByAgent() {
listUser({pageNum: 1, pageSize: undefined, roleId: "2095336076121190401",}).then((res) => {
queryParamsOptions.value = res.data?.rows || [];
})
}
getUserOptionsByAgent()
const queryParams = ref<CsSessionQuery>({
pageNum: 1,
pageSize: 10,
ipaddr: '',
userName: ''
});
/** 查询登录日志列表 */
@@ -231,11 +250,13 @@ const overViewList = ref([
"statusName": "已结束"
}
])
const overViewTotal = ref(0)
// 查看客服会话状态统计
function getOverViewSession() {
overViewCsSession().then((res) => {
overViewList.value = res.data.statuses || [];
overViewTotal.value = res.data.total || 0;
})
}
@@ -263,6 +284,10 @@ function handleMain(row: Partial<CsSessionVO>) {
/** 导出按钮操作 */
const handleExport = () => {
if (ids.value.length === 0) {
ElMessage.warning('请选择会话');
return;
}
requestDownload(
'/cs/session/exportSelected',
{
@@ -290,6 +315,7 @@ onMounted(() => {
.userInfoBox {
min-width: 120px;
.nameBox {
display: flex;

View File

@@ -38,9 +38,10 @@
<tableTag :num="overView.stoppedCount" circle-color="#ef4444" num-color="#DC2626" title="禁用"></tableTag>
</div>
<div class="toolbar-actions">
<el-button :disabled="multiple" plain size="large" type="info" @click="handleDelete()">批量删除
<el-button v-hasPermi="['cs:kb:remove']" :disabled="multiple" plain size="large" type="info"
@click="handleDelete()">批量删除
</el-button>
<el-button size="large" type="primary" @click="handleAdd">新增问题
<el-button v-hasPermi="['cs:kb:add']" size="large" type="primary" @click="handleAdd">新增问题
</el-button>
<right-toolbar v-model:show-search="showSearch" :search="false" @query-table="getList"></right-toolbar>
</div>
@@ -85,26 +86,27 @@
<span>{{ scope.row.createTime }}</span>
</template>
</el-table-column>
<el-table-column align="center" class-name="small-padding fixed-width" label="操作">
<el-table-column align="center" class-name="small-padding fixed-width" fixed="right" label="操作"
min-width="240">
<template #default="scope">
<el-button v-hasPermi="['system:cskb:edit']" :disabled="scope.$index === 0" link type="info"
<el-button :disabled="scope.$index === 0" link type="info"
@click="moveSort(scope.row,'up')">上移
</el-button>
<el-button v-hasPermi="['system:cskb:edit']" :disabled="scope.$index === csKbList.length-1" link
<el-button :disabled="scope.$index === csKbList.length-1" link
type="info"
@click="moveSort(scope.row,'down')">下移
</el-button>
<el-button v-hasPermi="['system:cskb:edit']" link type="primary"
<el-button v-hasPermi="['cs:kb:edit']" link type="primary"
@click="handleUpdate(scope.row)">编辑
</el-button>
<el-button v-if="scope.row.status === '0'" v-hasPermi="['system:cskb:edit']" link type="success"
<el-button v-if="scope.row.status === '0'" v-hasPermi="['cs:kb:edit']" link type="success"
@click="handleEnableOrUnEnable(scope.row,'1')">启用
</el-button>
<el-button v-else v-hasPermi="['system:cskb:edit']" link type="info"
<el-button v-else v-hasPermi="['cs:kb:edit']" link type="info"
@click="handleEnableOrUnEnable(scope.row,'0')">禁用
</el-button>
<el-button v-hasPermi="['system:cskb:remove']" link type="danger"
<el-button v-hasPermi="['cs:kb:remove']" link type="danger"
@click="handleDelete(scope.row)">删除
</el-button>
</template>

View File

@@ -26,17 +26,17 @@
</el-select>
</el-form-item>
<el-form-item label="所在地区" prop="userName">
<el-select
v-model="queryParams.ipaddr"
:empty-values="[null, undefined]"
:value-on-clear="null"
clearable
<el-cascader
v-model="ipaddr"
size="large"
style="width: 190px;"
>
<el-option label="在线" value="0"></el-option>
<el-option label="离线" value="1"></el-option>
</el-select>
:clearable="true"
:options="Administrative"
:props="{
label:'name',
value:'name'
}"
@change="handelChangeQuery"
/>
</el-form-item>
<el-form-item label="注册时间段" prop="createTime">
@@ -97,9 +97,9 @@
</div>
</template>
</el-table-column>
<el-table-column :show-overflow-tooltip="true" align="center" label="手机号" prop="phonenumber">
<el-table-column :show-overflow-tooltip="true" align="center" label="手机号" prop="phonenumber" width="120">
<template #default="scope">
<span>{{ hiddenPhone(scope.row.phonenumber) }}</span>
<span>{{ scope.row.phonenumber }}</span>
</template>
</el-table-column>
<el-table-column :show-overflow-tooltip="true" align="center" label="性别" prop="gender">
@@ -109,35 +109,48 @@
<span v-else style="color: #9CA3AF">未填写</span>
</template>
</el-table-column>
<el-table-column align="center" label="生日" prop="birthday"></el-table-column>
<el-table-column :show-overflow-tooltip="true" align="center" label="所在地区" prop="deptName"/>
<el-table-column :show-overflow-tooltip="true" align="center" label="绑定设备量" prop="deviceCount"/>
<el-table-column :show-overflow-tooltip="true" align="center" label="注册时间" prop="createTime"/>
<el-table-column :show-overflow-tooltip="true" align="center" label="最后登录时间" prop="loginDate"/>
<el-table-column align="center" label="生日" prop="birthday" width="120"></el-table-column>
<el-table-column :show-overflow-tooltip="true" align="center" label="所在地区" min-width="180px"
prop="deptName">
<template #default="scope">
<span>{{ scope.row.province }}</span>
<span v-if="scope.row.province && scope.row.city">/</span>
<span>{{ scope.row.city }}</span>
<span v-if="scope.row.district && scope.row.city">/</span>
<span>{{ scope.row.district }}</span>
</template>
</el-table-column>
<el-table-column :show-overflow-tooltip="true" align="center" label="绑定设备量" prop="deviceCount"
width="100"/>
<el-table-column :show-overflow-tooltip="true" align="center" label="注册时间" min-width="120"
prop="createTime"/>
<el-table-column :show-overflow-tooltip="true" align="center" label="最后登录时间" min-width="120"
prop="loginDate"/>
<el-table-column :show-overflow-tooltip="true" align="center" label="账号状态" prop="status">
<template #default="scope">
<el-tag v-if="scope.row.status === '0'" type="success">正常</el-tag>
<el-tag v-else type="danger">异常</el-tag>
<el-tag v-else type="danger">停用</el-tag>
</template>
</el-table-column>
<el-table-column align="center" class-name="small-padding fixed-width" label="操作" min-width="250">
<el-table-column align="center" class-name="small-padding fixed-width" fixed="right" label="操作"
min-width="380">
<template #default="scope">
<el-button
v-hasPermi="['monitor:online:forceLogout']"
v-hasPermi="['customer:user:query']"
plain
type="primary"
@click="handleMain(scope.row)"
>查看详情
</el-button>
<el-button
v-hasPermi="['monitor:online:forceLogout']"
v-hasPermiAnd="['customer:user:edit','customer:user:query']"
plain
type="info"
@click="handleEdit(scope.row)"
>编辑
</el-button>
<el-button
v-hasPermi="['monitor:online:forceLogout']"
v-hasPermi="['customer:user:resetPwd']"
plain
type="info"
@click="handleReboot(scope.row)"
@@ -145,7 +158,7 @@
</el-button>
<el-button
v-if="scope.row.status === '0'"
v-hasPermi="['monitor:online:forceLogout']"
v-hasPermi="['customer:user:edit']"
plain
type="warning"
@click="changeStatus(scope.row, '1')"
@@ -153,7 +166,7 @@
</el-button>
<el-button
v-if="scope.row.status === '1'"
v-hasPermi="['monitor:online:forceLogout']"
v-hasPermi="['customer:user:edit']"
plain
type="success"
@click="changeStatus(scope.row, '0')"
@@ -167,6 +180,7 @@
v-model:limit="queryParams.pageSize"
v-model:page="queryParams.pageNum"
:total="total"
@pagination="getList"
/>
</el-card>
</div>
@@ -180,8 +194,8 @@ import pageCrumb from "@/components/Pagecrumb/index.vue";
import modal from "@/plugins/modal";
import {download as requestDownload} from '@/utils/request';
import {useTableSelection} from "@/hooks/table/useTableSelection";
import {PostVO} from "@/api/system/post/types";
import defaultImag from '@/assets/images/avatar.png';
import Administrative from '@/data/Administrative.json';
const router = useRouter();
@@ -208,10 +222,19 @@ function handleChangeTime(data) {
const queryParams = ref<UserQuery>({
pageNum: 1,
pageSize: 10,
ipaddr: '',
userName: ''
});
const ipaddr = ref([])
function handelChangeQuery(code: string[]) {
queryParams.value.province = code[0] || undefined
queryParams.value.city = code[1] || undefined
queryParams.value.district = code[2] || undefined
getList()
}
/** 查询登录日志列表 */
const getList = async () => {
loading.value = true;
@@ -231,6 +254,10 @@ const resetQuery = () => {
createTime.value = []
queryParams.value.beginTime = undefined
queryParams.value.endTime = undefined
ipaddr.value = []
queryParams.value.province = undefined
queryParams.value.city = undefined
queryParams.value.district = undefined
handleQuery();
};
@@ -279,6 +306,10 @@ const handleExport = () => {
async function selectDisableUser() {
if (ids.value?.length === 0) {
modal.msgWarning('请选择要禁用的用户')
return
}
await modal.confirm('禁用账号会立即退出该用户的 APP 登录状态,确定要禁用这些选择的用户吗?')
const userIds = ids.value || [];
batchDisableUsers(userIds as string[]).then(() => {

View File

@@ -0,0 +1,617 @@
<script lang="ts" name="airPurifier" setup>
import {DeviceForm} from "@/api/system/device/types";
import {getDevice} from "@/api/system/device";
import {DeviceStatus, fanLevel, parkingShutDown, powerMode, runMode} from "@/views/system/device/devicelist/type";
const initFormData: DeviceForm = {
deviceId: undefined,
deviceNo: undefined,
name: undefined,
productId: undefined,
model: undefined,
sn: undefined,
mac: undefined,
bluetoothConnected: undefined,
status: undefined,
bindUserId: undefined,
bindTime: undefined,
homeId: undefined,
locationId: undefined,
charging: undefined,
deviceBattery: undefined,
lastReportTime: undefined,
lastOnlineTime: undefined,
remark: undefined,
createDept: undefined,
createBy: undefined,
createTime: undefined,
updateBy: undefined,
updateTime: undefined,
}
const form = ref<DeviceForm>(initFormData);
const route = useRoute();
let timer = ref<NodeJS.Timeout | null>(null);
function refresh() {
getDevice(route.query.id as string).then(res => {
Object.assign(form.value, res.data);
timer.value = setTimeout(() => {
refresh();
}, 30000)
}).catch(() => {
if (timer.value) {
clearTimeout(timer.value);
timer.value = null;
}
});
}
onUnmounted(() => {
if (timer.value) {
clearTimeout(timer.value);
}
timer.value = null;
})
function init() {
form.value = {...initFormData};
if (route.query.id) {
refresh()
}
}
init()
</script>
<template>
<div class="air-purifier">
<div class="infoBox">
<div class="info-item">
<el-image class="info_img"
src="https://ts2.tc.mm.bing.net/th/id/OIP-C.2KXRoOZ1EPBDMf6jrp6xeAHaE7?r=0&rs=1&pid=ImgDetMain&o=7&rm=3"></el-image>
<div class="info">
<div class="nav">
<div class="title">{{ form.name }}</div>
<div v-if="form.status === DeviceStatus.online" class="tag online">
<i class="circle"></i>
<span>在线</span>
</div>
<div v-else-if="form.status === DeviceStatus.offline" class="tag online offline">
<i class="circle"></i>
<span>离线</span>
</div>
<div v-else-if="form.status === DeviceStatus.unActive" class="tag online unActive">
<i class="circle"></i>
<span>未激活</span>
</div>
</div>
<div class="info-list">
<div class="info-list-item">
<div class="title">设备ID</div>
<div class="value">{{ form.deviceId }}</div>
</div>
<div class="info-list-item">
<div class="title">MAC地址</div>
<div class="value">{{ form.mac }}</div>
</div>
<div class="info-list-item">
<div class="title">所在房间</div>
<div class="value">{{ form.locationName }}</div>
</div>
<div class="info-list-item">
<div class="title">产品型号</div>
<div class="value">{{ form.model }}</div>
</div>
</div>
</div>
</div>
<div class="timeBox">
<div class="title">最后上报时间</div>
<div class="time">{{ form.updateTime }}</div>
<div class="tip">
<i class="circle"></i>
<span>每30s自动刷新</span>
</div>
</div>
</div>
<div class="baseInfo">
<cardNav subTitle="静态档案信息,如需修改请前往「编辑设备」页" title="设备基础档案"></cardNav>
<div class=" gridBox">
<div class="grid-item">
<div class="title">设备ID</div>
<div class="value">{{ form.deviceId }}</div>
</div>
<div class="grid-item">
<div class="title">设备名称</div>
<div class="value">{{ form.name }}</div>
</div>
<div class="grid-item">
<div class="title">MAC地址</div>
<div class="value">{{ form.mac }}</div>
</div>
<div class="grid-item">
<div class="title">产品型号</div>
<div class="value">{{ form.model }}</div>
</div>
<div class="grid-item">
<div class="title">所在房间</div>
<div class="value">{{ form.homeName }}</div>
</div>
<div class="grid-item">
</div>
<div class="grid-item">
<div class="title">档案创建时间</div>
<div class="value">{{ form.createTime }}</div>
</div>
<div class="grid-item">
<div class="title">档案更新时间</div>
<div class="value">{{ form.updateTime }}</div>
</div>
</div>
</div>
<div v-if="form.purifier" class="readTimeBox">
<cardNav line-color="#14b8a6" subTitle="设备蓝牙上报 · 只读 · 每 30 秒自动刷新"
title="设备实时运行状态"></cardNav>
<div class="flexBox">
<div class="flex-item">
<div class="flex-item-nav">
<i class="circle"></i>
<span>环境数据</span>
</div>
<div class="numBox">
<div class="num">{{ form.tvoc || '--' }}</div>
<div v-if="form.status === DeviceStatus.online" class="tag">
<i class="circle"></i>
<span>在线</span>
</div>
</div>
<div class="subTitle">TVOC 传感器原始读数(未换算为浓度值)</div>
<div class="footer">
<span>数据更新时间</span>
<span style="color: rgba(17, 24, 39, 1);">2026-09-30 12:50:30</span>
</div>
</div>
<div class="flex-item flex flex-col">
<div class="flex-item-nav">
<i class="circle" style="background: #2563eb"></i>
<span>运行数据</span>
</div>
<div class="flex-1 flex flex-col justify-evenly">
<div class="footer" style="margin-top: 0">
<span>运行模式</span>
<div>
<span v-if="form.runMode == runMode.dask" style="color: rgba(17, 24, 39, 1);">桌面模式</span>
<span v-else-if="form.runMode == runMode.car" style="color: rgba(17, 24, 39, 1);">车载模式</span>
<span v-else style="color: rgba(17, 24, 39, 1);">自动</span>
</div>
</div>
<div class="footer" style="margin-top: 0">
<span>风速挡位</span>
<div>
<span v-if="form.fanLevel == fanLevel.power" style="color: rgba(17, 24, 39, 1);">强力</span>
<span v-else-if="form.fanLevel == fanLevel.lower" style="color: rgba(17, 24, 39, 1);">低档</span>
<span v-else style="color: rgba(17, 24, 39, 1);">标准</span>
</div>
</div>
<div class="footer" style="margin-top: 0">
<span>供电模式</span>
<div>
<span v-if="form.powerMode == powerMode.usb" style="color: rgba(17, 24, 39, 1);">USB供电</span>
<span v-else style="color: rgba(17, 24, 39, 1);">电池供电</span>
</div>
</div>
<div class="footer" style="margin-top: 0">
<span>停车关机模式</span>
<el-tag v-if="form.parkingShutdown == parkingShutDown.open" type="success">开启</el-tag>
<el-tag v-else type="danger">关闭</el-tag>
</div>
</div>
</div>
<div class="flex-item flex flex-col ">
<div class="flex-item-nav">
<i class="circle" style="background: #f59e0b"></i>
<span>耗材与电量</span>
</div>
<div class="flex-1 flex justify-evenly">
<div v-if="form.filterLife !== null" class="ageBox">
<div class="title">滤芯寿命</div>
<div class="processInfo">
<span class="num">{{ form.filterLife }}</span>
<span class="unit">%</span>
</div>
<el-progress :percentage="form.filterLife" :show-text="false"></el-progress>
<div class="tip">
<span>预计剩余可用 {{ form.filterRemainDays || '---' }} 天</span>
</div>
</div>
<div v-if="form.deviceBattery!==null && form.filterLife !==null" class="line"></div>
<div v-if="form.deviceBattery!==null" class="ageBox BatteryBox">
<div class="title">电池电量</div>
<div class="processInfo">
<span class="num">{{ form.deviceBattery }}</span>
<span class="unit">%</span>
</div>
<el-progress :percentage="form.deviceBattery" :show-text="false" color="#22C55E"></el-progress>
<el-tag type="success">充电中</el-tag>
</div>
</div>
</div>
<div class="flex-item flex flex-col ">
<div class="flex-item-nav">
<i class="circle" style="background: #6366f1"></i>
<span>策略说明 · 停车关机模式</span>
</div>
<ul style="margin-top: 16px;">
<li class="modelLi">
<el-tag type="success">开启</el-tag>
<span class="describe">USB 外部供电断开后,电池供电继续运行 5 分钟消杀再自动关机;低电量 SOC<10% 时关闭等离子消杀;SOC<5% 整机锁机(防止过放)。</span>
</li>
<li class="modelLi">
<el-tag type="info">关闭</el-tag>
<span class="describe">不执行该套低电量策略,仅保留基础净化逻辑。</span>
</li>
</ul>
</div>
</div>
</div>
</div>
</template>
<style lang="scss" scoped>
.air-purifier {
.infoBox {
padding: 24px;
display: flex;
justify-content: space-between;
align-items: center;
max-height: 177px;
min-width: 750px;
border-radius: 16px 16px 16px 16px;
border: 1px solid rgba(238, 240, 243, 1);
margin-top: 8px;
.info-item {
display: flex;
align-items: center;
.info_img {
width: 97px;
height: 97px;
border-radius: 16px 16px 16px 16px;
}
.info {
display: flex;
flex-direction: column;
justify-content: space-between;
margin-left: 24px;
.nav {
display: flex;
align-items: end;
.title {
height: 28px;
line-height: 28px;
color: rgba(17, 24, 39, 1);
font-size: 22px;
text-align: left;
}
.tag {
margin-left: 5px;
width: 62px;
height: 28px;
border-radius: 14px;
&.online {
background-color: rgba(232, 247, 238, 1);
color: rgba(22, 163, 74, 1);
font-size: 12px;
display: flex;
align-items: center;
justify-content: center;
.circle {
margin-right: 6px;
display: block;
width: 7px;
height: 6px;
border-radius: 3px;
background-color: rgba(22, 163, 74, 1);
}
&.offline {
background-color: rgba(237, 56, 34, 0.2);
color: rgb(237 56 34);
.circle {
background-color: rgb(237 56 34);
}
}
&.unActive {
background-color: #ccc;
color: #838383;
.circle {
background-color: #838383;
}
}
}
}
}
.info-list {
display: flex;
align-items: center;
gap: 20px;
margin-top: 28px;
.info-list-item {
.title {
height: 16px;
line-height: 16px;
color: rgba(156, 163, 175, 1);
font-size: 12px;
}
.value {
height: 40px;
line-height: 20px;
color: rgba(17, 24, 39, 1);
font-size: 14px;
}
}
}
}
}
.timeBox {
.title {
text-align: right;
line-height: 16px;
color: rgba(156, 163, 175, 1);
font-size: 12px;
}
.time {
line-height: 22px;
background-color: rgba(0, 0, 0, 0);
color: rgba(17, 24, 39, 1);
font-size: 16px;
margin-top: 6px;
margin-bottom: 12px;
}
.tip {
display: flex;
align-items: center;
justify-content: end;
span {
background-color: rgba(0, 0, 0, 0);
color: rgba(37, 99, 235, 1);
font-size: 12px;
text-align: left;
}
.circle {
margin-right: 6px;
display: block;
width: 7px;
height: 6px;
border-radius: 3px;
background-color: #2563eb;
}
}
}
}
.baseInfo {
padding: 25px;
min-height: 248px;
border-radius: 16px 16px 16px 16px;
border: 1px solid rgba(238, 240, 243, 1);
margin: 16px 0;
.gridBox {
margin-top: 44px;
display: grid;
grid-template-columns: repeat(4, minmax(381px, 1fr));
gap: 20px;
@media (max-width: 1659px) {
grid-template-columns: repeat(3, minmax(381px, 1fr));
}
@media (max-width: 1250px) {
grid-template-columns: repeat(2, minmax(381px, 1fr));
}
@media (max-width: 600px) {
grid-template-columns: repeat(1, minmax(381px, 1fr));
}
.grid-item {
max-width: 381px;
.title {
height: 16px;
line-height: 16px;
color: rgba(156, 163, 175, 1);
font-size: 12px;
margin-bottom: 6px;
}
.value {
height: 20px;
line-height: 20px;
color: rgba(17, 24, 39, 1);
font-size: 14px;
text-align: left;
}
}
}
}
.readTimeBox {
padding: 25px;
border-radius: 16px 16px 16px 16px;
border: 1px solid rgba(238, 240, 243, 1);
.flexBox {
margin-top: 44px;
gap: 20px;
display: grid;
grid-template-columns: repeat(2, minmax(360px, 1fr));
@media (max-width: 900px) {
grid-template-columns: repeat(1, minmax(381px, 1fr));
}
.flex-item {
min-height: 201px;
border-radius: 12px 12px 12px 12px;
background-color: rgba(247, 249, 252, 1);
border: 1px solid rgba(238, 240, 243, 1);
padding: 21px;
.flex-item-nav {
display: flex;
align-items: center;
.circle {
margin-right: 6px;
display: block;
width: 7px;
height: 6px;
border-radius: 3px;
background-color: rgba(22, 163, 74, 1);
}
span {
font-size: 12px;
display: flex;
align-items: center;
justify-content: center;
}
}
.numBox {
display: flex;
align-items: end;
margin-top: 17px;
.num {
line-height: 43px;
color: rgba(17, 24, 39, 1);
font-size: 36px;
text-align: left;
}
.tag {
margin-left: 5px;
width: 62px;
height: 28px;
border-radius: 14px;
$backColor: rgba(232, 247, 238, 1);
$textColor: rgba(22, 163, 74, 1);
background-color: $backColor;
color: $textColor;
font-size: 12px;
display: flex;
align-items: center;
justify-content: center;
.circle {
margin-right: 6px;
display: block;
width: 7px;
height: 6px;
border-radius: 3px;
background-color: $textColor;
}
}
}
.subTitle {
margin-top: 12px;
line-height: 16px;
color: rgba(156, 163, 175, 1);
font-size: 12px;
}
.footer {
margin-top: 44px;
display: flex;
align-items: center;
justify-content: space-between;
line-height: 14px;
color: rgba(107, 114, 128, 1);
font-size: 12px;
}
// 滤芯寿命
.ageBox {
flex: 1;
margin-top: 16px;
.title {
line-height: 18px;
color: rgba(107, 114, 128, 1);
font-size: 13px;
}
.processInfo {
margin: 12px 0;
.num {
line-height: 31px;
color: rgba(17, 24, 39, 1);
font-size: 26px;
}
.unit {
line-height: 17px;
color: rgba(107, 114, 128, 1);
font-size: 14px;
margin-left: 4px;
}
}
.tip {
line-height: 16px;
color: rgba(156, 163, 175, 1);
font-size: 12px;
}
}
.line {
width: 2px;
height: 96px;
background-color: rgba(238, 240, 243, 1);
margin: 15px 24px;
}
.modelLi {
margin-bottom: 12px;
span.describe {
margin-left: 12px;
line-height: 16px;
color: rgba(75, 85, 99, 1);
font-size: 13px;
text-align: left;
}
}
}
}
}
}
</style>

View File

@@ -4,6 +4,7 @@ import FormItemTip from '@/components/FormItemTip/index.vue';
import {DeviceForm} from "@/api/system/device/types";
import {getDevice, updateDevice} from "@/api/system/device";
import modal from "@/plugins/modal";
import {airLevel, DeviceStatus} from "@/views/system/device/devicelist/type";
function submitForm() {
if (!form.value.name || form.value.name.trim() === "") {
@@ -110,10 +111,18 @@ init()
<div class="info">
<div class="nav">
<div class="title">Z2空气净化器</div>
<div class="tag online">
<div v-if="form.status === DeviceStatus.online" class="tag online">
<i class="circle"></i>
<span>在线</span>
</div>
<div v-else-if="form.status === DeviceStatus.offline" class="tag online offline">
<i class="circle"></i>
<span>离线</span>
</div>
<div v-else-if="form.status === DeviceStatus.unActive" class="tag online unActive">
<i class="circle"></i>
<span>未激活</span>
</div>
</div>
<div class="describe">DEV-2026-000138·AA:BB:CC:DD:EE:B·客厅·CZ-Z2023</div>
</div>
@@ -208,8 +217,11 @@ init()
<li class="li-item">
<div class="title">TVOC数值</div>
<div class="value">
<span class="Num">{{ form.tvoc }}</span>
<el-tag type="success">优</el-tag>
<span class="Num">{{ form.tvoc || '--' }}</span>
<el-tag v-if="form.airLevel === airLevel.Excellent" type="primary">优</el-tag>
<el-tag v-else-if="form.airLevel === airLevel.good" type="success">良</el-tag>
<el-tag v-else-if="form.airLevel === airLevel.poor" type="warning">差</el-tag>
<el-tag v-else-if="form.airLevel === airLevel.polluted" type="info">污染</el-tag>
</div>
</li>
<li class="li-item">
@@ -235,19 +247,19 @@ init()
<span v-else class="Num">电池供电</span>
</div>
</li>
<li class="li-item">
<li v-if="form.filterLife !== null" class="li-item">
<div class="title">滤芯寿命</div>
<div class="value">
<span class="Num">{{ form.filterLife }}%</span>
</div>
<div class="tip">剩余{{ form.filterRemainDays }}天</div>
<div class="tip">剩余 {{ form.filterRemainDays || '--' }} 天</div>
</li>
<li class="li-item">
<li v-if="form.deviceBattery !== null" class="li-item">
<div class="title">电池电量</div>
<div class="value">
<span class="Num">85%</span>
<span class="Num">{{ form.deviceBattery }}%</span>
</div>
<div class="tip">剩余128天</div>
<div class="tip"></div>
</li>
</ul>
@@ -331,6 +343,24 @@ init()
border-radius: 3px;
background-color: rgba(22, 163, 74, 1);
}
&.offline {
background-color: rgba(237, 56, 34, 0.2);
color: rgb(237 56 34);
.circle {
background-color: rgb(237 56 34);
}
}
&.unActive {
background-color: #ccc;
color: #838383;
.circle {
background-color: #838383;
}
}
}
}
}

View File

@@ -47,24 +47,25 @@
<el-table v-loading="loading" :data="deviceList" border class="data-table"
@selection-change="handleSelectionChange">
<el-table-column align="center" type="selection" width="55"/>
<el-table-column align="center" label="设备名称" prop="name"/>
<el-table-column align="center" label="产品型号" prop="model"/>
<el-table-column align="center" label="所在房间" prop="homeName"/>
<el-table-column align="center" label="设备名称" min-width="150" prop="name"/>
<el-table-column align="center" label="产品型号" min-width="150" prop="model"/>
<el-table-column align="center" label="所在房间" min-width="150" prop="homeName"/>
<el-table-column align="center" label="在线状态" prop="status" width="100">
<template #default="scope">
<el-tag v-if="scope.row.status === '0'" type="success">在线</el-tag>
<el-tag v-else type="danger">离线</el-tag>
<el-tag v-if="scope.row.status === DeviceStatus.online" type="success">在线</el-tag>
<el-tag v-else-if="scope.row.status === DeviceStatus.offline" type="danger">离线</el-tag>
<el-tag v-else-if="scope.row.status === DeviceStatus.unActive" type="info">未激活</el-tag>
</template>
</el-table-column>
<el-table-column align="center" label="当前TVOC" prop="tvoc">
<el-table-column align="center" label="当前TVOC" min-width="100" prop="tvoc">
<template #default="scope">
<div class="flex flex-items-center justify-center">
<div>{{ scope.row.tvoc ?? '--' }}</div>
<div>
<el-tag v-if="scope.row.airLevel == '0'" type="primary">优</el-tag>
<el-tag v-else-if="scope.row.airLevel == '1'" type="success">良</el-tag>
<el-tag v-else-if="scope.row.airLevel == '2'" type="warning">差</el-tag>
<el-tag v-else-if="scope.row.airLevel == '3'" type="danger">污染</el-tag>
<el-tag v-if="scope.row.airLevel === airLevel.Excellent" type="primary">优</el-tag>
<el-tag v-else-if="scope.row.airLevel === airLevel.good" type="success">良</el-tag>
<el-tag v-else-if="scope.row.airLevel === airLevel.poor" type="warning">差</el-tag>
<el-tag v-else-if="scope.row.airLevel === airLevel.polluted" type="danger">污染</el-tag>
</div>
</div>
</template>
@@ -76,34 +77,36 @@
}" class="defaultLife">{{ scope.row.filterLife }}%</span>
</template>
</el-table-column>
<el-table-column align="center" label="电池电量" prop="deviceBattery" width="100">
<template #default="scope">
<span :class="{
lowBattery: scope.row.filterLife < 50
}" class="defaultLife">{{ scope.row.filterLife }}%</span>
<el-table-column align="center" label="电池电量" width="100">
<template #default="{ row }">
<div v-if="row.deviceBattery" :class="{ lowBattery: row.deviceBattery < 50 }" class="defaultLife">
{{ row.deviceBattery }}%
</div>
<div v-else>---</div>
</template>
</el-table-column>
<el-table-column align="center" label="运行模式" prop="runMode" width="100">
<template #default="scope">
<span v-if="scope.row.runMode == '2'" style="color: rgba(17, 24, 39, 1);">桌面模式</span>
<span v-else-if="scope.row.runMode == '1'" style="color: rgba(17, 24, 39, 1);">车载模式</span>
<span v-if="scope.row.runMode == runMode.dask" style="color: rgba(17, 24, 39, 1);">桌面模式</span>
<span v-else-if="scope.row.runMode == runMode.car" style="color: rgba(17, 24, 39, 1);">车载模式</span>
<span v-else style="color: rgba(17, 24, 39, 1);">自动</span>
</template>
</el-table-column>
<el-table-column align="center" label="风速挡位" prop="mac" width="100">
<el-table-column align="center" label="风速挡位" prop="fanLevel" width="100">
<template #default="scope">
<span v-if="scope.row.fanLevel == '1'" style="color: rgba(17, 24, 39, 1);">强力</span>
<span v-else-if="scope.row.fanLevel == '2'" style="color: rgba(17, 24, 39, 1);">低档</span>
<span v-if="scope.row.fanLevel == fanLevel.power" style="color: rgba(17, 24, 39, 1);">强力</span>
<span v-else-if="scope.row.fanLevel == fanLevel.lower" style="color: rgba(17, 24, 39, 1);">低档</span>
<span v-else style="color: rgba(17, 24, 39, 1);">标准</span>
</template>
</el-table-column>
<el-table-column align="center" label="创建时间" prop="createTime"/>
<el-table-column align="center" class-name="small-padding fixed-width" label="操作" min-width="100">
<el-table-column align="center" label="数据更新时间" min-width="180" prop="updateTime"/>
<el-table-column align="center" class-name="small-padding fixed-width" fixed="right" label="操作"
min-width="200">
<template #default="scope">
<el-button v-hasPermi="['device:device:query']" plain type="primary"
@click="handleUpdate(scope.row)">查看详情
</el-button>
<el-button v-hasPermi="['device:device:edit']" plain type="info"
<el-button v-hasPermiAnd="['device:device:edit','device:device:query']" plain type="info"
@click="handleEdit(scope.row)">编辑
</el-button>
</template>
@@ -129,6 +132,7 @@ import {useSearchToggle} from '@/hooks/form/useSearchToggle';
import {useTableSelection} from '@/hooks/table/useTableSelection';
import modal from '@/plugins/modal';
import {download as requestDownload} from '@/utils/request';
import {airLevel, DeviceStatus, fanLevel, runMode} from "@/views/system/device/devicelist/type";
const router = useRouter();

View File

@@ -3,10 +3,12 @@ import cardNav from '@/components/cardNav/index.vue';
import {getDevice} from "@/api/system/device";
import {DeviceForm} from "@/api/system/device/types";
import {useUserStore} from "@/store/modules/user";
import {DeviceStatus, fanLevel, parkingShutDown, powerMode, runMode} from "@/views/system/device/devicelist/type";
// import airPurifier from './component/AirPurifier.vue'
const userStore = useUserStore();
const router = useRouter();
const route = useRoute();
function backList() {
router.replace({
@@ -23,32 +25,20 @@ function editDevice() {
})
}
const route = useRoute();
const initFormData: DeviceForm = {
deviceId: undefined,
deviceNo: undefined,
imei: undefined,
name: undefined,
productId: undefined,
model: undefined,
sn: undefined,
hwVersion: undefined,
swVersion: undefined,
fwVersion: undefined,
pkgVersion: undefined,
ip: undefined,
mac: undefined,
wifiSsid: undefined,
bluetoothConnected: undefined,
status: undefined,
bindUserId: undefined,
bindTime: undefined,
homeId: undefined,
locationId: undefined,
signalLevel: undefined,
lng: undefined,
lat: undefined,
address: undefined,
charging: undefined,
deviceBattery: undefined,
lastReportTime: undefined,
@@ -59,24 +49,8 @@ const initFormData: DeviceForm = {
createTime: undefined,
updateBy: undefined,
updateTime: undefined,
activeDeviceNo: undefined,
activeImei: undefined,
activeMac: undefined,
}
const form = ref();
function init() {
form.value = {...initFormData};
if (route.query.id) {
getDevice(route.query.id as string).then(res => {
Object.assign(form.value, res.data);
refresh()
});
}
}
init()
const form = ref<DeviceForm>(initFormData);
let timer = ref<NodeJS.Timeout | null>(null);
@@ -84,10 +58,16 @@ let timer = ref<NodeJS.Timeout | null>(null);
function refresh() {
getDevice(route.query.id as string).then(res => {
Object.assign(form.value, res.data);
timer.value = setTimeout(() => {
refresh();
}, 30000)
}).catch(() => {
if (timer.value) {
clearTimeout(timer.value);
timer.value = null;
}
});
timer.value = setTimeout(() => {
refresh();
}, 30000)
}
onUnmounted(() => {
@@ -96,6 +76,31 @@ onUnmounted(() => {
}
timer.value = null;
})
function init() {
form.value = {...initFormData};
if (route.query.id) {
refresh()
}
}
init()
// const compDefine = ref<any>(null)
// const compMap: Record<string, () => Promise<typeof import("*.vue")>> = {
// airPurifier: () => import('./component/AirPurifier.vue'),
// }
// const currentComp = computed(() => compDefine.value)
// const loadDevice = async () => {
// const loader = compMap['airPurifier']
// // 动态import组件
// const mod = await loader()
// compDefine.value = mod.default
// }
//
// onMounted(() => {
// loadDevice()
// })
</script>
<template>
@@ -116,10 +121,18 @@ onUnmounted(() => {
<div class="info">
<div class="nav">
<div class="title">{{ form.name }}</div>
<div class="tag online">
<div v-if="form.status === DeviceStatus.online" class="tag online">
<i class="circle"></i>
<span>在线</span>
</div>
<div v-else-if="form.status === DeviceStatus.offline" class="tag online offline">
<i class="circle"></i>
<span>离线</span>
</div>
<div v-else-if="form.status === DeviceStatus.unActive" class="tag online unActive">
<i class="circle"></i>
<span>未激活</span>
</div>
</div>
<div class="info-list">
<div class="info-list-item">
@@ -150,8 +163,6 @@ onUnmounted(() => {
</div>
</div>
</div>
<div class="baseInfo">
<cardNav subTitle="静态档案信息,如需修改请前往「编辑设备」页" title="设备基础档案"></cardNav>
<div class=" gridBox">
@@ -197,8 +208,8 @@ onUnmounted(() => {
<span>环境数据</span>
</div>
<div class="numBox">
<div class="num">{{ form.tvoc }}</div>
<div class="tag">
<div class="num">{{ form.tvoc || '--' }}</div>
<div v-if="form.status === DeviceStatus.online" class="tag">
<i class="circle"></i>
<span>在线</span>
</div>
@@ -218,29 +229,29 @@ onUnmounted(() => {
<div class="footer" style="margin-top: 0">
<span>运行模式</span>
<div>
<span v-if="form.runMode == '2'" style="color: rgba(17, 24, 39, 1);">桌面模式</span>
<span v-else-if="form.runMode == '1'" style="color: rgba(17, 24, 39, 1);">车载模式</span>
<span v-if="form.runMode == runMode.dask" style="color: rgba(17, 24, 39, 1);">桌面模式</span>
<span v-else-if="form.runMode == runMode.car" style="color: rgba(17, 24, 39, 1);">车载模式</span>
<span v-else style="color: rgba(17, 24, 39, 1);">自动</span>
</div>
</div>
<div class="footer" style="margin-top: 0">
<span>风速挡位</span>
<div>
<span v-if="form.fanLevel == '1'" style="color: rgba(17, 24, 39, 1);">强力</span>
<span v-else-if="form.fanLevel == '2'" style="color: rgba(17, 24, 39, 1);">低档</span>
<span v-if="form.fanLevel == fanLevel.power" style="color: rgba(17, 24, 39, 1);">强力</span>
<span v-else-if="form.fanLevel == fanLevel.lower" style="color: rgba(17, 24, 39, 1);">低档</span>
<span v-else style="color: rgba(17, 24, 39, 1);">标准</span>
</div>
</div>
<div class="footer" style="margin-top: 0">
<span>供电模式</span>
<div>
<span v-if="form.powerMode == '0'" style="color: rgba(17, 24, 39, 1);">USB供电</span>
<span v-if="form.powerMode == powerMode.usb" style="color: rgba(17, 24, 39, 1);">USB供电</span>
<span v-else style="color: rgba(17, 24, 39, 1);">电池供电</span>
</div>
</div>
<div class="footer" style="margin-top: 0">
<span>停车关机模式</span>
<el-tag v-if="form.parkingShutdown == '1'" type="success">开启</el-tag>
<el-tag v-if="form.parkingShutdown == parkingShutDown.open" type="success">开启</el-tag>
<el-tag v-else type="danger">关闭</el-tag>
</div>
</div>
@@ -251,7 +262,7 @@ onUnmounted(() => {
<span>耗材与电量</span>
</div>
<div class="flex-1 flex justify-evenly">
<div class="ageBox">
<div v-if="form.filterLife !== null" class="ageBox">
<div class="title">滤芯寿命</div>
<div class="processInfo">
<span class="num">{{ form.filterLife }}</span>
@@ -259,17 +270,17 @@ onUnmounted(() => {
</div>
<el-progress :percentage="form.filterLife" :show-text="false"></el-progress>
<div class="tip">
<span>预计剩余可用{{ form.filterRemainDays }}天</span>
<span>预计剩余可用 {{ form.filterRemainDays || '---' }} 天</span>
</div>
</div>
<div class="line"></div>
<div class="ageBox BatteryBox">
<div v-if="form.deviceBattery!==null && form.filterLife !==null" class="line"></div>
<div v-if="form.deviceBattery!==null" class="ageBox BatteryBox">
<div class="title">电池电量</div>
<div class="processInfo">
<span class="num">76</span>
<span class="num">{{ form.deviceBattery }}</span>
<span class="unit">%</span>
</div>
<el-progress :percentage="30" :show-text="false" color="#22C55E"></el-progress>
<el-progress :percentage="form.deviceBattery" :show-text="false" color="#22C55E"></el-progress>
<el-tag type="success">充电中</el-tag>
</div>
</div>
@@ -292,6 +303,10 @@ onUnmounted(() => {
</div>
</div>
</div>
<!-- <component-->
<!-- :is="currentComp"-->
<!-- v-if="currentComp"-->
<!-- />-->
</div>
</template>
@@ -364,6 +379,25 @@ onUnmounted(() => {
border-radius: 3px;
background-color: rgba(22, 163, 74, 1);
}
&.offline {
background-color: rgba(237, 56, 34, 0.2);
color: rgb(237 56 34);
.circle {
background-color: rgb(237 56 34);
}
}
&.unActive {
background-color: #ccc;
color: #838383;
.circle {
background-color: #838383;
}
}
}
}
}

View File

@@ -1,5 +1,5 @@
/**设备状态*/
enum Status {
export enum DeviceStatus {
/**未激活*/
unActive = '0',
/**在线*/
@@ -9,57 +9,57 @@ enum Status {
}
/**运行模式*/
enum runMode {
export enum runMode {
/**自动*/
auto = 0,
auto = '0',
/**车载模式*/
car = 1,
car = '1',
/**桌面模式*/
dask = 2
dask = '2'
}
/**
* 风速
* */
enum fanLevel {
export enum fanLevel {
/**
* 标准
*/
normal = 0,
normal = '0',
/**
* 强力
* */
power = 1,
power = '1',
/**
* 低档
* */
lower = 2
lower = '2'
}
/**
* 空气质量
* */
enum airLevel {
export enum airLevel {
/**优*/
Excellent,
Excellent = '0',
/**良*/
good,
good = '1',
/**差*/
poor,
poor = '2',
/**污染*/
polluted
polluted = '3'
}
/**供电方式*/
enum powerMode {
export enum powerMode {
/**USB*/
USB,
usb = '0',
/**电池*/
Battery
battery = '1'
}
/**蓝牙连接情况*/
enum bluetoothConnected {
export enum bluetoothConnected {
/**未连接*/
unConnected = 0,
/**已连接*/
@@ -69,9 +69,9 @@ enum bluetoothConnected {
/**
* @enum {number}
* */
enum parkingShutDown {
export enum parkingShutDown {
/**开*/
open,
open = '1',
/**关*/
close
close = '0'
}

View File

@@ -120,6 +120,7 @@
v-if="previewListResource && checkFileSuffix(scope.row.fileSuffix)"
:width="100"
:height="100"
:lazy="true"
:src="scope.row.url"
:preview-src-list="[scope.row.url]"
/>

View File

@@ -38,7 +38,8 @@
<h3>已授权用户</h3>
</div>
<div class="toolbar-actions">
<el-button v-hasPermi="['system:role:add']" type="primary" plain icon="Plus" @click="openSelectUser">
<el-button v-hasPermiAnd="['system:role:add','system:user:list']" icon="Plus" plain type="primary"
@click="openSelectUser">
添加用户
</el-button>
<el-button
@@ -63,14 +64,14 @@
:data="userList"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="用户名称" prop="userName" :show-overflow-tooltip="true" />
<el-table-column label="用户昵称" prop="nickName" :show-overflow-tooltip="true" />
<el-table-column label="邮箱" prop="email" :show-overflow-tooltip="true" />
<el-table-column label="手机" prop="phoneNumber" :show-overflow-tooltip="true" />
<el-table-column align="center" type="selection" width="55"/>
<el-table-column :show-overflow-tooltip="true" label="用户名称" prop="userName"/>
<el-table-column :show-overflow-tooltip="true" label="用户昵称" prop="nickName"/>
<el-table-column :show-overflow-tooltip="true" label="邮箱" prop="email"/>
<el-table-column :show-overflow-tooltip="true" label="手机" prop="phoneNumber"/>
<el-table-column label="状态" align="center" prop="status">
<template #default="scope">
<dict-tag :options="sys_normal_disable" :value="scope.row.status" />
<dict-tag :options="sys_normal_disable" :value="scope.row.status"/>
</template>
</el-table-column>
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
@@ -100,31 +101,31 @@
:total="total"
@pagination="getList"
/>
<select-user ref="selectRef" :role-id="queryParams.roleId" @ok="handleQuery" />
<select-user ref="selectRef" :role-id="queryParams.roleId" @ok="handleQuery"/>
</el-card>
</div>
</template>
<script setup name="AuthUser" lang="ts">
import { RouteLocationNormalized } from 'vue-router';
import { allocatedUserList, authUserCancel, authUserCancelAll } from '@/api/system/role';
import { UserQuery } from '@/api/system/user/types';
import { UserVO } from '@/api/system/user/types';
import { useLoading } from '@/hooks/async/useLoading';
import { useSearchReset } from '@/hooks/form/useSearchReset';
import { useSearchToggle } from '@/hooks/form/useSearchToggle';
import { useTableSelection } from '@/hooks/table/useTableSelection';
import {RouteLocationNormalized} from 'vue-router';
import {allocatedUserList, authUserCancel, authUserCancelAll} from '@/api/system/role';
import {UserQuery} from '@/api/system/user/types';
import {UserVO} from '@/api/system/user/types';
import {useLoading} from '@/hooks/async/useLoading';
import {useSearchReset} from '@/hooks/form/useSearchReset';
import {useSearchToggle} from '@/hooks/form/useSearchToggle';
import {useTableSelection} from '@/hooks/table/useTableSelection';
import modal from '@/plugins/modal';
import tab from '@/plugins/tab';
import { useDict } from '@/utils/dict';
import {useDict} from '@/utils/dict';
import SelectUser from './selectUser.vue';
const route = useRoute();
const { sys_normal_disable } = toRefs<any>(useDict('sys_normal_disable'));
const {sys_normal_disable} = toRefs<any>(useDict('sys_normal_disable'));
const userList = ref<UserVO[]>([]);
const { loading, withLoading } = useLoading(true);
const { showSearch } = useSearchToggle();
const {loading, withLoading} = useLoading(true);
const {showSearch} = useSearchToggle();
const total = ref(0);
const queryFormRef = ref<ElFormInstance>();
@@ -137,7 +138,7 @@ const queryParams = reactive<UserQuery>({
userName: undefined,
phoneNumber: undefined
});
const { ids: userIds, multiple, handleSelectionChange } = useTableSelection<UserVO>(item => item.userId);
const {ids: userIds, multiple, handleSelectionChange} = useTableSelection<UserVO>(item => item.userId);
/** 查询授权用户列表 */
const getList = async () => {
@@ -147,6 +148,7 @@ const getList = async () => {
total.value = res.data?.total;
});
};
const router = useRouter();
// 返回按钮
const handleClose = () => {
const obj: RouteLocationNormalized = {
@@ -161,13 +163,14 @@ const handleClose = () => {
redirectedFrom: undefined
};
tab.closeOpenPage(obj as any);
router.back()
};
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.pageNum = 1;
getList();
};
const { resetQuery } = useSearchReset({
const {resetQuery} = useSearchReset({
queryFormRef,
afterReset: () => {
handleQuery();
@@ -180,7 +183,7 @@ const openSelectUser = () => {
/** 取消授权按钮操作 */
const cancelAuthUser = async (row: Partial<UserVO>) => {
await modal.confirm('确认要取消该用户"' + row.userName + '"角色吗?');
await authUserCancel({ userId: row.userId, roleId: queryParams.roleId });
await authUserCancel({userId: row.userId, roleId: queryParams.roleId});
await getList();
modal.msgSuccess('取消授权成功');
};
@@ -189,7 +192,7 @@ const cancelAuthUserAll = async () => {
const roleId = queryParams.roleId;
const uIds = userIds.value.join(',');
await modal.confirm('是否取消选中用户授权数据项?');
await authUserCancelAll({ roleId: roleId, userIds: uIds });
await authUserCancelAll({roleId: roleId, userIds: uIds});
await getList();
modal.msgSuccess('取消授权成功');
};

View File

@@ -27,18 +27,6 @@
<el-option v-for="dict in sys_normal_disable" :key="dict.value" :label="dict.label" :value="dict.value"/>
</el-select>
</el-form-item>
<el-form-item label="创建时间" style="width: 308px">
<el-date-picker
v-model="dateRange"
value-format="YYYY-MM-DD HH:mm:ss"
type="daterange"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="[new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 1, 1, 23, 59, 59)]"
></el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
@@ -59,26 +47,6 @@
<el-button v-hasPermi="['system:role:add']" type="primary" plain icon="Plus" @click="handleAdd()">
新增
</el-button>
<el-button
v-hasPermi="['system:role:edit']"
type="success"
plain
:disabled="single"
icon="Edit"
@click="handleUpdate()"
>
修改
</el-button>
<el-button
v-hasPermi="['system:role:remove']"
type="danger"
plain
:disabled="ids.length === 0"
icon="Delete"
@click="handleDelete()"
>
删除
</el-button>
<el-button v-hasPermi="['system:role:export']" type="warning" plain icon="Download" @click="handleExport">
导出
</el-button>
@@ -282,40 +250,40 @@
</el-tree>
</div>
</el-tab-pane>
<el-tab-pane label="数据权限" name="data">
<el-form-item label="权限范围">
<el-select v-model="form.dataScope" @change="dataScopeSelectChange">
<el-option
v-for="item in dataScopeOptions"
:key="item.value"
:label="item.label"
:value="item.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item v-show="form.dataScope === '2'" label="数据权限">
<el-checkbox v-model="deptExpand" @change="handleCheckedTreeExpand($event, 'dept')">
展开/折叠
</el-checkbox>
<el-checkbox v-model="deptNodeAll" @change="handleCheckedTreeNodeAll($event, 'dept')">
全选/全不选
</el-checkbox>
<el-checkbox v-model="form.deptCheckStrictly" @change="handleCheckedTreeConnect($event, 'dept')">
父子联动
</el-checkbox>
<el-tree
ref="deptRef"
class="tree-border"
:data="deptOptions"
show-checkbox
default-expand-all
node-key="id"
:check-strictly="!form.deptCheckStrictly"
empty-text="加载中,请稍候"
:props="{ label: 'label', children: 'children' }"
></el-tree>
</el-form-item>
</el-tab-pane>
<!-- <el-tab-pane label="数据权限" name="data">-->
<!-- <el-form-item label="权限范围">-->
<!-- <el-select v-model="form.dataScope" @change="dataScopeSelectChange">-->
<!-- <el-option-->
<!-- v-for="item in dataScopeOptions"-->
<!-- :key="item.value"-->
<!-- :label="item.label"-->
<!-- :value="item.value"-->
<!-- ></el-option>-->
<!-- </el-select>-->
<!-- </el-form-item>-->
<!-- <el-form-item v-show="form.dataScope === '2'" label="数据权限">-->
<!-- <el-checkbox v-model="deptExpand" @change="handleCheckedTreeExpand($event, 'dept')">-->
<!-- 展开/折叠-->
<!-- </el-checkbox>-->
<!-- <el-checkbox v-model="deptNodeAll" @change="handleCheckedTreeNodeAll($event, 'dept')">-->
<!-- 全选/全不选-->
<!-- </el-checkbox>-->
<!-- <el-checkbox v-model="form.deptCheckStrictly" @change="handleCheckedTreeConnect($event, 'dept')">-->
<!-- 父子联动-->
<!-- </el-checkbox>-->
<!-- <el-tree-->
<!-- ref="deptRef"-->
<!-- class="tree-border"-->
<!-- :data="deptOptions"-->
<!-- show-checkbox-->
<!-- default-expand-all-->
<!-- node-key="id"-->
<!-- :check-strictly="!form.deptCheckStrictly"-->
<!-- empty-text="加载中,请稍候"-->
<!-- :props="{ label: 'label', children: 'children' }"-->
<!-- ></el-tree>-->
<!-- </el-form-item>-->
<!-- </el-tab-pane>-->
</el-tabs>
</el-form>
<template #footer>

View File

@@ -58,7 +58,7 @@ const rules = {
nickName: [{required: true, message: '用户昵称不能为空', trigger: 'blur'}],
password: [
{required: true, message: '用户密码不能为空', trigger: 'blur'},
{min: 5, max: 20, message: '用户密码长度必须介于 5 和 20 之间', trigger: 'blur'},
{min: 8, max: 20, message: '用户密码长度必须介于 8 和 20 之间', trigger: 'blur'},
{pattern: /^[^<>"'|\\]+$/, message: '不能包含非法字符:< > " \' \\ |', trigger: 'blur'}
],
phoneNumber: [
@@ -71,6 +71,7 @@ const rules = {
],
confirmPassword: [
{required: true, message: '确认密码不能为空', trigger: 'blur'},
{min: 8, max: 20, message: '确认密码长度必须介于 8 和 20 之间', trigger: 'blur'},
{
validator: (rule, value, callback) => {
if (value !== form.value.password) {
@@ -95,6 +96,7 @@ function getRoleList() {
function reset() {
form.value = {...initForm};
formRef.value?.resetFields();
router.back();
}
function addRoleAction() {

View File

@@ -36,13 +36,13 @@
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="角色" prop="status">
<el-select v-model="queryParams.status" clearable placeholder="用户角色" size="large">
<el-form-item label="角色" prop="roleId">
<el-select v-model="queryParams.roleId" clearable placeholder="用户角色" size="large">
<el-option
v-for="dict in sys_normal_disable"
:key="dict.value"
:label="dict.label"
:value="dict.value"
v-for="dict in rolesOptions"
:key="dict.roleId"
:label="dict.roleName"
:value="dict.roleId"
/>
</el-select>
</el-form-item>
@@ -74,7 +74,6 @@
<div class="toolbar-actions">
<right-toolbar
v-model:show-search="showSearch"
:columns="columns"
:search="false"
storage-key="sys_user_column_visible"
@query-table="getList"
@@ -141,7 +140,7 @@
</el-table-column>
<el-table-column align="center" class-name="small-padding fixed-width" fixed="right" label="操作"
width="220">
width="250">
<template #default="scope">
<div v-if="scope.row.userId !== '1761100000000000001'">
<el-button
@@ -402,6 +401,7 @@ import {globalHeaders} from '@/utils/request';
import {download as requestDownload} from '@/utils/request';
import UserViewDrawer from './view.vue';
import {hiddenPhone} from "@/utils/phone";
import {listRole} from "@/api/system/role";
const router = useRouter();
const {sys_normal_disable, sys_user_gender} = toRefs<any>(useDict('sys_normal_disable', 'sys_user_gender'));
@@ -416,6 +416,18 @@ const enabledDeptOptions = ref<DeptTreeVO[]>([]);
const initPassword = ref<string>('');
const postOptions = ref<PostVO[]>([]);
const roleOptions = ref<RoleVO[]>([]);
const rolesOptions = ref<RoleVO[]>([]);
function getRolesOptions() {
listRole({pageNum: 1, pageSize: undefined}).then(res => {
rolesOptions.value = res.data.rows;
})
}
getRolesOptions()
/*** 用户导入参数 */
const upload = reactive<ImportOption>({
// 是否显示弹出层(用户导入)
@@ -433,7 +445,7 @@ const upload = reactive<ImportOption>({
});
// 列显隐信息
const columns = ref<FieldOption[]>([
{key: 0, label: `用户编号`, visible: false, children: []},
// {key: 0, label: `用户编号`, visible: false, children: []},
{key: 1, label: `用户名称`, visible: true, children: []},
{key: 2, label: `用户昵称`, visible: true, children: []},
{key: 3, label: `部门`, visible: true, children: []},