10/23
1. 设备详情拆分 2. 修改bug 3. 处理未读消息 4. 处理退出销毁ws 5. 限制输入内容 6. 限制修改用户名称 长度 7. 会话列表中 添加等待时间变化
This commit is contained in:
@@ -10,12 +10,13 @@ VITE_APP_BASE_API='/dev-api'
|
||||
# 本机环境
|
||||
VITE_LOCALHOST=false
|
||||
# 本地开发环境
|
||||
VITE_BASE_API='http://192.168.0.212:8082'
|
||||
VITE_BASE_API='http://192.168.0.212:8083'
|
||||
#VITE_BASE_API='http://192.168.0.212:8082'
|
||||
VITE_WS_URL='ws://192.168.0.212:8082/cs/chat'
|
||||
VITE_WS_URL='192.168.0.212:8083/cs/chat'
|
||||
|
||||
# 默认头像
|
||||
VITE_DEFAULT_USER_IMAGE='https://ts3.tc.mm.bing.net/th?id=ORMS.48a27ca8353fa47bf0dc8df38854d0e1&pid=Wdp&w=312&h=172&qlt=90&c=1&rs=1&dpr=1&p=0'
|
||||
#VITE_DEFAULT_USER_IMAGE='https://ts3.tc.mm.bing.net/th?id=ORMS.48a27ca8353fa47bf0dc8df38854d0e1&pid=Wdp&w=312&h=172&qlt=90&c=1&rs=1&dpr=1&p=0'
|
||||
VITE_DEFAULT_USER_IMAGE='https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png'
|
||||
|
||||
# 应用访问路径 例如使用前缀 /admin/
|
||||
VITE_APP_CONTEXT_PATH='/'
|
||||
|
||||
@@ -133,3 +133,13 @@ export const resetPwdUser = (userId: string, password: string) => {
|
||||
}
|
||||
});
|
||||
};
|
||||
/**
|
||||
* 重置App用户密码
|
||||
* @param userId
|
||||
*/
|
||||
export const getUserMainDevices = (userId: string) => {
|
||||
return request({
|
||||
url: `/customer/user/${userId}/devices`,
|
||||
method: 'get',
|
||||
});
|
||||
};
|
||||
|
||||
@@ -62,3 +62,22 @@ export const delDevice = (deviceId: string | number | Array<string | number>) =>
|
||||
method: 'delete'
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取设备 可选 位置
|
||||
* @param deviceId
|
||||
*/
|
||||
export const getLocationListOptions = (deviceId: string): AxiosPromise<{
|
||||
locationId: string;
|
||||
locationName: string;
|
||||
homeName: string;
|
||||
homeId: string;
|
||||
}[]> => {
|
||||
return request({
|
||||
url: '/device/device/locationOptions',
|
||||
method: 'get',
|
||||
params: {
|
||||
deviceId,
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
39
src/components/AwaitTime/index.vue
Normal file
39
src/components/AwaitTime/index.vue
Normal file
@@ -0,0 +1,39 @@
|
||||
<template>
|
||||
<span class="awaitTime">{{ display }}</span>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {ref, watch, onUnmounted, inject} from 'vue'
|
||||
|
||||
const props = defineProps({
|
||||
rowId: {type: [String, Number], required: true},
|
||||
startTime: {type: Number, default: 0},
|
||||
status: {type: String, default: ''}
|
||||
})
|
||||
|
||||
const display = ref('--')
|
||||
const timerManager = inject('timerManager')
|
||||
|
||||
watch(
|
||||
() => [props.status, props.startTime],
|
||||
() => {
|
||||
if (props.status === '1' && props.startTime) {
|
||||
timerManager.register(props.rowId, new Date(props.startTime).getTime(), display)
|
||||
} else {
|
||||
timerManager.unregister(props.rowId)
|
||||
display.value = '--'
|
||||
}
|
||||
},
|
||||
{immediate: true}
|
||||
)
|
||||
|
||||
onUnmounted(() => {
|
||||
timerManager.unregister(props.rowId)
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.awaitTime {
|
||||
color: #EA580C;
|
||||
}
|
||||
</style>
|
||||
64
src/components/AwaitTime/useWaitTimerManager.ts
Normal file
64
src/components/AwaitTime/useWaitTimerManager.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
import {ref, type Ref} from 'vue'
|
||||
|
||||
type TimerItem = {
|
||||
id: string | number
|
||||
startTime: number
|
||||
display: Ref<string>
|
||||
}
|
||||
|
||||
// 页面级管理器,不要全局单例!多个页面同时打开表格会互相干扰
|
||||
export function useWaitTimerManager() {
|
||||
const activeMap = new Map<string | number, TimerItem>()
|
||||
let rafId: number | null = null
|
||||
let lastUpdate = 0
|
||||
|
||||
const formatSeconds = (seconds: number) => {
|
||||
const h = Math.floor(seconds / 3600)
|
||||
const m = Math.floor((seconds % 3600) / 60)
|
||||
const s = Math.floor(seconds % 60)
|
||||
return [h, m, s].map(v => String(v).padStart(2, '0')).join(':')
|
||||
}
|
||||
|
||||
function tick(ts: number) {
|
||||
rafId = requestAnimationFrame(tick)
|
||||
// 1s 更新一次即可
|
||||
if (ts - lastUpdate < 1000) return
|
||||
lastUpdate = ts
|
||||
|
||||
const now = Date.now()
|
||||
for (const item of activeMap.values()) {
|
||||
const sec = Math.floor((now - item.startTime) / 1000)
|
||||
item.display.value = formatSeconds(sec)
|
||||
}
|
||||
}
|
||||
|
||||
function start() {
|
||||
if (!rafId) {
|
||||
rafId = requestAnimationFrame(tick)
|
||||
}
|
||||
}
|
||||
|
||||
function stop() {
|
||||
if (rafId) {
|
||||
cancelAnimationFrame(rafId)
|
||||
rafId = null
|
||||
}
|
||||
}
|
||||
|
||||
// 组件进来注册
|
||||
function register(id: string | number, startTime: number, display: Ref<string>) {
|
||||
activeMap.set(id, {id, startTime, display})
|
||||
start()
|
||||
}
|
||||
|
||||
// 组件注销(状态变了 / 组件销毁)
|
||||
function unregister(id: string | number) {
|
||||
activeMap.delete(id)
|
||||
// 没有任务了就停掉raf,省资源
|
||||
if (activeMap.size === 0) {
|
||||
stop()
|
||||
}
|
||||
}
|
||||
|
||||
return {register, unregister}
|
||||
}
|
||||
@@ -16,7 +16,7 @@
|
||||
@onCreated="handleCreated"
|
||||
/>
|
||||
</div>
|
||||
<!-- 底部提示、示例、字数统计 -->
|
||||
<div class="editor-footer">
|
||||
<div v-if="simpleToolbar" class="editor-tip">
|
||||
<p>请输入标准回复话术,可使用「有序步骤」插入分步指引,例如:</p>
|
||||
<div class="demo-box">
|
||||
@@ -29,6 +29,26 @@
|
||||
<p>以上为示例格式</p>
|
||||
<p>支持插入图片与链接;回复中可引用设备型号,帮助用户快速对号入座</p>
|
||||
</div>
|
||||
<div class="counter-bar">
|
||||
<span
|
||||
:class="{ warn: textCount >= props.maxTextLength, danger: textCount > props.maxTextLength }"
|
||||
>
|
||||
纯文本 {{ textCount }}/{{ props.maxTextLength }}
|
||||
</span>
|
||||
<span class="divider">|</span>
|
||||
<span
|
||||
:class="{ warn: imageCount >= props.maxImageCount, danger: imageCount > props.maxImageCount }"
|
||||
>
|
||||
图片 {{ imageCount }}/{{ props.maxImageCount }}
|
||||
</span>
|
||||
<span class="divider">|</span>
|
||||
<span
|
||||
:class="{ warn: linkCount >= props.maxLinkCount, danger: linkCount > props.maxLinkCount }"
|
||||
>
|
||||
链接 {{ linkCount }}/{{ props.maxLinkCount }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -39,32 +59,34 @@ import {Editor as WangEditor, Toolbar as EditorToolbar} from '@wangeditor-next/e
|
||||
import modal from '@/plugins/modal';
|
||||
import {propTypes} from '@/utils/propTypes';
|
||||
import {globalHeaders} from '@/utils/request';
|
||||
import {html2Text} from '@/utils';
|
||||
import {shallowRef, ref, computed, watch, onBeforeUnmount} from 'vue';
|
||||
|
||||
const props = defineProps({
|
||||
/* 编辑器的内容 */
|
||||
modelValue: propTypes.string,
|
||||
/* 高度 */
|
||||
height: propTypes.number.def(400),
|
||||
/* 最小高度 */
|
||||
minHeight: propTypes.number.def(400),
|
||||
/* 只读 */
|
||||
readOnly: propTypes.bool.def(false),
|
||||
/* 图片上传文件大小限制(MB) */
|
||||
fileSize: propTypes.number.def(5),
|
||||
/* 视频上传文件大小限制(MB) */
|
||||
videoSize: propTypes.number.def(100),
|
||||
/* 类型(base64格式、url格式) */
|
||||
type: propTypes.string.def('url'),
|
||||
/* 精简工具栏(仅加粗/有序步骤/图片/链接/清除格式) */
|
||||
simpleToolbar: propTypes.bool.def(false)
|
||||
simpleToolbar: propTypes.bool.def(false),
|
||||
maxTextLength: propTypes.number.def(1000),
|
||||
maxImageCount: propTypes.number.def(3),
|
||||
maxLinkCount: propTypes.number.def(5)
|
||||
});
|
||||
|
||||
const emit = defineEmits(['update:modelValue']);
|
||||
const emit = defineEmits(['update:modelValue', 'countChange']);
|
||||
|
||||
const editorRef = shallowRef<IDomEditor>();
|
||||
const content = ref('');
|
||||
const wordCount = ref(0);
|
||||
const textCount = ref(0);
|
||||
const imageCount = ref(0);
|
||||
const linkCount = ref(0);
|
||||
const lastValidHtml = ref('');
|
||||
|
||||
const IMG_REGEX = /<img\b[^>]*>/gi;
|
||||
const A_TAG_REGEX = /<a\b[^>]*>.*?<\/a>/gi;
|
||||
|
||||
const baseUrl = import.meta.env.VITE_APP_BASE_API;
|
||||
const uploadOssUrl = baseUrl + '/resource/oss/upload';
|
||||
@@ -102,6 +124,19 @@ const toolbarConfig = computed<Partial<IToolbarConfig>>(() => {
|
||||
}
|
||||
});
|
||||
|
||||
/* ==================== 内容度量 ==================== */
|
||||
|
||||
function measureHtml(html: string) {
|
||||
const textLen = html2Text(html).length;
|
||||
const imgMatch = html.match(IMG_REGEX);
|
||||
const linkMatch = html.match(A_TAG_REGEX);
|
||||
return {
|
||||
textLen,
|
||||
imgNum: imgMatch ? imgMatch.length : 0,
|
||||
linkNum: linkMatch ? linkMatch.length : 0
|
||||
};
|
||||
}
|
||||
|
||||
/* ==================== OSS 上传 ==================== */
|
||||
|
||||
const uploadToOss = async (file: File): Promise<{ url: string; fileName: string }> => {
|
||||
@@ -161,12 +196,24 @@ const validateVideoFile = (file: File) => {
|
||||
|
||||
/* ==================== wangeditor 菜单配置 ==================== */
|
||||
|
||||
function checkImageQuotaBeforeUpload(): boolean {
|
||||
if (!editorRef.value) return false;
|
||||
const html = editorRef.value.getHtml();
|
||||
const {imgNum} = measureHtml(html);
|
||||
if (imgNum >= props.maxImageCount) {
|
||||
modal.msgError(`图片数量不能超过 ${props.maxImageCount} 张,请先删除已插入的图片`);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
const getUploadImageMenuConfig = () => {
|
||||
if (props.type === 'base64') {
|
||||
return {
|
||||
allowedFileTypes: ['image/jpeg', 'image/jpg', 'image/png', 'image/svg+xml'],
|
||||
customUpload(file: File, insertFn: (url: string, alt?: string, href?: string) => void) {
|
||||
if (!validateImageFile(file)) return;
|
||||
if (!checkImageQuotaBeforeUpload()) return;
|
||||
|
||||
modal.loading('正在上传图片,请稍候...');
|
||||
const reader = new FileReader();
|
||||
@@ -190,11 +237,12 @@ const getUploadImageMenuConfig = () => {
|
||||
allowedFileTypes: ['image/jpeg', 'image/jpg', 'image/png', 'image/svg+xml'],
|
||||
async customUpload(file: File, insertFn: (url: string, alt?: string, href?: string) => void) {
|
||||
if (!validateImageFile(file)) return;
|
||||
if (!checkImageQuotaBeforeUpload()) return;
|
||||
|
||||
modal.loading('正在上传图片,请稍候...');
|
||||
try {
|
||||
const result = await uploadToOss(file);
|
||||
insertFn(result.url, file.name, result.url);
|
||||
insertFn(result.url, file.name);
|
||||
} catch {
|
||||
modal.msgError('图片上传失败');
|
||||
} finally {
|
||||
@@ -224,7 +272,6 @@ const getUploadVideoMenuConfig = () => ({
|
||||
const editorConfig = computed<Partial<IEditorConfig>>(() => ({
|
||||
placeholder: props.simpleToolbar ? '请输入标准回复话术...' : '请输入内容',
|
||||
autoFocus: false,
|
||||
maxLength: 2000,
|
||||
MENU_CONF: {
|
||||
uploadImage: getUploadImageMenuConfig() as any,
|
||||
uploadVideo: getUploadVideoMenuConfig() as any
|
||||
@@ -239,9 +286,37 @@ const editorConfig = computed<Partial<IEditorConfig>>(() => ({
|
||||
|
||||
/* ==================== 事件处理 ==================== */
|
||||
|
||||
function updateCounts(html: string) {
|
||||
const {textLen, imgNum, linkNum} = measureHtml(html);
|
||||
textCount.value = textLen;
|
||||
imageCount.value = imgNum;
|
||||
linkCount.value = linkNum;
|
||||
emit('countChange', {textLength: textLen, imageCount: imgNum, linkCount: linkNum, htmlLength: html.length});
|
||||
}
|
||||
|
||||
const handleChange = () => {
|
||||
if (!editorRef.value) return;
|
||||
wordCount.value = editorRef.value.getText().length;
|
||||
const html = editorRef.value.getHtml();
|
||||
console.log(html)
|
||||
const {textLen, imgNum, linkNum} = measureHtml(html);
|
||||
updateCounts(html);
|
||||
|
||||
const textOver = textLen > props.maxTextLength;
|
||||
const imgOver = imgNum > props.maxImageCount;
|
||||
const linkOver = linkNum > props.maxLinkCount;
|
||||
|
||||
if (textOver || imgOver || linkOver) {
|
||||
const msgs: string[] = [];
|
||||
if (textOver) msgs.push(`纯文本超过 ${props.maxTextLength} 字`);
|
||||
if (imgOver) msgs.push(`图片超过 ${props.maxImageCount} 张`);
|
||||
if (linkOver) msgs.push(`链接超过 ${props.maxLinkCount} 条`);
|
||||
modal.msgError(msgs.join(';') + ',已自动恢复');
|
||||
editorRef.value.setHtml(lastValidHtml.value);
|
||||
updateCounts(lastValidHtml.value);
|
||||
return;
|
||||
}
|
||||
|
||||
lastValidHtml.value = html;
|
||||
};
|
||||
|
||||
const syncReadOnly = () => {
|
||||
@@ -258,7 +333,9 @@ const syncReadOnly = () => {
|
||||
const handleCreated = (editor: IDomEditor) => {
|
||||
editorRef.value = editor;
|
||||
syncReadOnly();
|
||||
wordCount.value = editor.getText().length;
|
||||
const html = editor.getHtml();
|
||||
updateCounts(html);
|
||||
lastValidHtml.value = html;
|
||||
};
|
||||
|
||||
/* ==================== 双向数据绑定(直接透传HTML) ==================== */
|
||||
@@ -324,6 +401,11 @@ onBeforeUnmount(() => {
|
||||
min-height: inherit;
|
||||
}
|
||||
|
||||
.editor-footer {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.editor-tip {
|
||||
padding: 12px 16px;
|
||||
font-size: 13px;
|
||||
@@ -338,8 +420,27 @@ onBeforeUnmount(() => {
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.word-count {
|
||||
text-align: right;
|
||||
margin-top: 4px;
|
||||
.counter-bar {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 6px 12px;
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
border-top: 1px solid var(--el-border-color);
|
||||
background: #fafafa;
|
||||
}
|
||||
|
||||
.counter-bar .warn {
|
||||
color: #e6a23c;
|
||||
}
|
||||
|
||||
.counter-bar .danger {
|
||||
color: #f56c6c;
|
||||
}
|
||||
|
||||
.counter-bar .divider {
|
||||
color: #dcdfe6;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -116,12 +116,16 @@
|
||||
@update:model-value="$emit('update:modelValue', $event)"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in radioOptions"
|
||||
v-for="(item, idx) in radioOptions"
|
||||
:key="item[valueKey]"
|
||||
:disabled="isOptionDisabled(item)"
|
||||
:label="item[labelKey]"
|
||||
:value="item[valueKey]"
|
||||
/>
|
||||
>
|
||||
<slot :index="idx" :item="item" name="option">
|
||||
{{ item[labelKey] }}
|
||||
</slot>
|
||||
</el-option>
|
||||
</el-select>
|
||||
|
||||
<!-- 多选-->
|
||||
@@ -182,6 +186,7 @@ import {ref} from 'vue'
|
||||
import {genFileId} from 'element-plus'
|
||||
import type {UploadInstance, UploadProps, UploadRawFile} from 'element-plus'
|
||||
|
||||
import defaultImage from '@/assets/images/default.png'
|
||||
|
||||
defineOptions({inheritAttrs: false})
|
||||
|
||||
@@ -252,7 +257,8 @@ const isOptionDisabled = (item: Record<string, any>) => {
|
||||
|
||||
const showPassword = ref(false)
|
||||
const upload = ref<UploadInstance>()
|
||||
const defaultImag = import.meta.env.VITE_DEFAULT_USER_IMAGE;
|
||||
|
||||
const defaultImag = defaultImage || import.meta.env.VITE_DEFAULT_USER_IMAGE;
|
||||
const imageUrl = ref('')
|
||||
|
||||
watch(
|
||||
|
||||
@@ -123,13 +123,10 @@ const logout = async () => {
|
||||
type: 'warning'
|
||||
} as ElMessageBoxOptions);
|
||||
userStore.logout().then(() => {
|
||||
csSessionStore.destroyWs()
|
||||
router.replace({
|
||||
path: '/login',
|
||||
query: {
|
||||
redirect: encodeURIComponent(router.currentRoute.value.fullPath || '/')
|
||||
}
|
||||
});
|
||||
csSessionStore.destroyWs()
|
||||
tab.closeAllPage();
|
||||
});
|
||||
};
|
||||
|
||||
@@ -45,7 +45,23 @@ type CsQueueType = {
|
||||
},
|
||||
type: 'cs:queue'
|
||||
}
|
||||
|
||||
type CsMessageType = {
|
||||
data: {
|
||||
"clientMsgId": string,
|
||||
"content": string,
|
||||
"createTime": string,
|
||||
"messageId": string,
|
||||
"msgType": string,
|
||||
"ossId": null,
|
||||
"senderId": string,
|
||||
"senderType": string,
|
||||
"seq": number,
|
||||
"sessionId": string,
|
||||
"url": string
|
||||
},
|
||||
type: 'cs:message'
|
||||
}
|
||||
type CsMessageDataType = CsMessageType['data']
|
||||
|
||||
/** ws 消息 → 业务侧消费的消息结构(与 chat UI 对齐) */
|
||||
export interface ChatMessage {
|
||||
@@ -119,7 +135,7 @@ export const useCsSessionStore = defineStore('csSession', () => {
|
||||
}
|
||||
|
||||
// 设置客服负责所有用户的消息
|
||||
function setAllUsersMessages(sessionId: string, data) {
|
||||
function setAllUsersMessages(sessionId: string, data: CsMessageDataType) {
|
||||
allUsersMessages[sessionId] = [
|
||||
...(allUsersMessages[sessionId] || []),
|
||||
data
|
||||
@@ -140,6 +156,8 @@ export const useCsSessionStore = defineStore('csSession', () => {
|
||||
// 消息会话 不是 当前会话,且是 指定会话id 时,才增加未读消息数量
|
||||
if (currentSessionId.value !== item.sessionId) {
|
||||
item.unreadCount = (item.unreadCount || 0) + 1
|
||||
} else {
|
||||
item.unreadCount = 0
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -219,7 +237,7 @@ export const useCsSessionStore = defineStore('csSession', () => {
|
||||
url: wsUrl,
|
||||
heartbeatInterval: 15_000,
|
||||
maxReconnectAttempts: 10,
|
||||
debug: true,
|
||||
debug: import.meta.env.VITE_APP_ENV === 'development',
|
||||
});
|
||||
|
||||
// ── 业务消息 handler:收到什么类型就做什么事 ──
|
||||
@@ -257,7 +275,7 @@ export const useCsSessionStore = defineStore('csSession', () => {
|
||||
getRightUserList();
|
||||
});
|
||||
// cs:message 接受消息
|
||||
ws.registerHandler('cs:message', (pkt) => {
|
||||
ws.registerHandler('cs:message', (pkt: CsMessageType) => {
|
||||
console.log('接受消息:', pkt.data.content)
|
||||
setAllUsersMessages(pkt.data.sessionId, pkt.data)
|
||||
});
|
||||
@@ -308,10 +326,13 @@ export const useCsSessionStore = defineStore('csSession', () => {
|
||||
|
||||
/** 彻底销毁 ws(登出时调) */
|
||||
function destroyWs() {
|
||||
if (!ws) return
|
||||
if (ws) {
|
||||
ws?.destroy();
|
||||
ws = null;
|
||||
wsStatus.value = 'closed';
|
||||
}
|
||||
}
|
||||
|
||||
/* ===================== 消息辅助 ===================== */
|
||||
|
||||
@@ -321,6 +342,7 @@ export const useCsSessionStore = defineStore('csSession', () => {
|
||||
return userLists.value[activeUserType.value];
|
||||
})
|
||||
|
||||
// 设置未读消息数量
|
||||
function setReadCount(sessionId: string, count: number) {
|
||||
userLists.value[activeUserType.value].forEach(item => {
|
||||
if (item.sessionId === sessionId) {
|
||||
@@ -367,6 +389,7 @@ export const useCsSessionStore = defineStore('csSession', () => {
|
||||
setSending(true)
|
||||
client.sendString(JSON.stringify(sendObj))
|
||||
toggleSession()
|
||||
getRightUserList()
|
||||
} catch (err) {
|
||||
console.error('消息发送失败:', err)
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
<div class="loginModel">
|
||||
<span>账号登录</span>
|
||||
</div>
|
||||
<el-form-item prop="username" label-position="top" label="管理员账号">
|
||||
<el-form-item label="账号" label-position="top" prop="username">
|
||||
<el-input
|
||||
v-model="loginForm.username"
|
||||
type="text"
|
||||
@@ -150,7 +150,7 @@
|
||||
<span v-if="!loading">{{ $t("login.login") }}</span>
|
||||
<span v-else>{{ $t("login.logging") }}</span>
|
||||
</el-button>
|
||||
<p class="tip">如需开通管理员账号,请联系系统管理员</p>
|
||||
<p class="tip">如需开通账号,请联系系统管理员</p>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</section>
|
||||
|
||||
@@ -5,9 +5,11 @@
|
||||
<el-input
|
||||
ref="inputRef"
|
||||
v-model="inputText"
|
||||
:autosize="{ minRows:5, maxRows:8 }"
|
||||
:autosize="{ minRows:5, maxRows:8, }"
|
||||
placeholder="请输入回复内容"
|
||||
:disabled="disable"
|
||||
:maxlength="200"
|
||||
:show-word-limit="true"
|
||||
type="textarea"
|
||||
@keydown="handleKeyDown"
|
||||
/>
|
||||
|
||||
@@ -113,7 +113,6 @@ const handleScroll = () => {
|
||||
prevScrollTop = currentTop
|
||||
|
||||
if (scrollingUp && currentTop <= TOP_THRESHOLD && !props.loadingHistory && !isLoadingMore) {
|
||||
console.log('向上滚动到顶部了')
|
||||
isLoadingMore = true;
|
||||
setTimeout(() => {
|
||||
isLoadingMore = false
|
||||
|
||||
@@ -161,7 +161,7 @@ const acceptAgentList = ref<AgentPresenceType[]>([])
|
||||
// 获取转接客服列表
|
||||
function getAgentList() {
|
||||
getAgentPresence().then(res => {
|
||||
acceptAgentList.value = res.data;
|
||||
acceptAgentList.value = res.data.filter(item => item.activeSessionCount !== 1)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -198,10 +198,11 @@ const submitForm = () => {
|
||||
demoFormRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
buttonLoading.value = true;
|
||||
console.log(form.value)
|
||||
transferAgentPresence(form.value).then(() => {
|
||||
csSessionStore.getRightUserList()
|
||||
csSessionStore.setCurrentUserInfoMain(null)
|
||||
ElMessage.success('转接成功')
|
||||
cancel()
|
||||
}).finally(() => {
|
||||
buttonLoading.value = false;
|
||||
})
|
||||
|
||||
@@ -133,8 +133,18 @@
|
||||
</el-table-column>
|
||||
<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="queueNo" width="100">
|
||||
<template #default="scope">
|
||||
<span style="color:#EA580C">{{
|
||||
scope.row.queueNo ? `第 ${scope.row.queueNo} 位` : '--'
|
||||
}}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :show-overflow-tooltip="true" align="center" label="等待时长" prop="os" width="100">
|
||||
<template #default="{ row }">
|
||||
<AwaitTime :row-id="row.id" :start-time="row.startTime" :status="row.status"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<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="操作"
|
||||
@@ -296,6 +306,16 @@ const handleExport = () => {
|
||||
`批量会话导出${new Date().getTime()}.xlsx`
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
import {provide} from 'vue'
|
||||
import {useWaitTimerManager} from '@/components/AwaitTime/useWaitTimerManager'
|
||||
import AwaitTime from '@/components/AwaitTime/index.vue'
|
||||
|
||||
const {register, unregister} = useWaitTimerManager()
|
||||
provide('timerManager', {register, unregister})
|
||||
|
||||
|
||||
onMounted(() => {
|
||||
getList();
|
||||
getOverViewSession()
|
||||
|
||||
@@ -5,10 +5,11 @@ import {deskCsAgentDeskBySessionId, getDeskCsAgentHistory} from "@/api/system/cs
|
||||
import {hiddenPhone} from "@/utils/phone";
|
||||
import {MAX_MESSAGES} from "@/store/modules/csSession";
|
||||
import {download as requestDownload} from "@/utils/request";
|
||||
import defaultAvatar from '@/assets/images/default.png'
|
||||
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
const defaultImage = import.meta.env.VITE_DEFAULT_USER_IMAGE;
|
||||
const defaultImage = defaultAvatar || import.meta.env.VITE_DEFAULT_USER_IMAGE;
|
||||
|
||||
const form = ref({
|
||||
"customer": {
|
||||
@@ -34,6 +35,7 @@ const form = ref({
|
||||
}
|
||||
})
|
||||
const msgList = ref([])
|
||||
const messageListRef = ref(null)
|
||||
|
||||
onMounted(() => {
|
||||
if (route.query.id) {
|
||||
@@ -42,8 +44,8 @@ onMounted(() => {
|
||||
let latestSeq = Math.max(form.value.session.latestSeq - MAX_MESSAGES, 0)
|
||||
getDeskCsAgentHistory(form.value.session.sessionId, latestSeq, form.value.session.latestSeq).then(res => {
|
||||
msgList.value = res.data || []
|
||||
console.log(msgList.value)
|
||||
loadingHistory.value = false
|
||||
messageListRef?.value.scrollToBottom()
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -58,7 +60,6 @@ function rollback() {
|
||||
const loadingHistory = ref(false)
|
||||
|
||||
function handleLoadMore() {
|
||||
console.log('loading history')
|
||||
loadingHistory.value = true
|
||||
if (!form.value.session.sessionId) return
|
||||
console.log('滚动到顶部了,想要加载更多消息')
|
||||
@@ -69,7 +70,6 @@ function handleLoadMore() {
|
||||
// 2. 减去 MAX_MESSAGES 条消息
|
||||
let latestSeq = Math.max(seq - MAX_MESSAGES, 0)
|
||||
// 3. 拉取过往新消息
|
||||
// console.log('拉取过往新消息从', latestSeq)
|
||||
getDeskCsAgentHistory(form.value.session.sessionId, latestSeq, seq).then(res => {
|
||||
msgList.value = [...res.data || [], ...msgList.value]
|
||||
loadingHistory.value = false
|
||||
@@ -128,7 +128,7 @@ function exportCsSessionStore() {
|
||||
</div>
|
||||
</div>
|
||||
<div class="content beautify_scroll">
|
||||
<MessageList ref="messageList" :loading-history="loadingHistory" :messages="msgList"
|
||||
<MessageList ref="messageListRef" :loading-history="loadingHistory" :messages="msgList"
|
||||
:user-avatar="form.customer.avatarUrl || ''"
|
||||
@load-more="handleLoadMore"></MessageList>
|
||||
</div>
|
||||
|
||||
@@ -4,6 +4,9 @@ import cskbEditor from '@/components/Editor/cskb.vue'
|
||||
import {FormInstance, FormRules} from "element-plus";
|
||||
import {addCsKb} from "@/api/system/cskb";
|
||||
import modal from "@/plugins/modal";
|
||||
import {useDict} from "@/utils/dict";
|
||||
|
||||
const {com_question_categories} = toRefs<any>(useDict('com_question_categories'));
|
||||
|
||||
const formRef = ref<FormInstance>()
|
||||
const router = useRouter();
|
||||
@@ -36,7 +39,7 @@ const actions = {
|
||||
resolved: {"buttonCode": "resolved", "label": "已解决", "sort": 1, value: 'resolved'},
|
||||
transfer_human: {"buttonCode": "transfer_human", "label": "转人工", "sort": 2, value: 'transfer_human'},
|
||||
}
|
||||
|
||||
const ActionsButtons = ref([])
|
||||
|
||||
function handleBack() {
|
||||
router.replace({
|
||||
@@ -46,11 +49,10 @@ function handleBack() {
|
||||
|
||||
async function submit(isEnable = false) {
|
||||
if (!formRef.value) return
|
||||
console.log(form.value)
|
||||
await formRef.value.validate((valid) => {
|
||||
if (valid) {
|
||||
// isEnable=true 代表保存并启用
|
||||
form.value.buttons = form.value.buttons.map(item => {
|
||||
form.value.buttons = ActionsButtons.value.map(item => {
|
||||
return actions[item]
|
||||
})
|
||||
addCsKb(form.value).then(() => {
|
||||
@@ -116,8 +118,12 @@ function reset() {
|
||||
<el-col :span="12">
|
||||
<FormItemTip
|
||||
v-model.trim="form.category"
|
||||
:inputAttrs="{ placeholder: '请选择问题分类', maxlength:30}"
|
||||
:inputAttrs="{ placeholder: '请选择问题分类'}"
|
||||
label="问题分类"
|
||||
:radioOptions="com_question_categories"
|
||||
label-key="label"
|
||||
type="select"
|
||||
valueKey="value"
|
||||
prop="category"
|
||||
>
|
||||
</FormItemTip>
|
||||
@@ -142,7 +148,7 @@ function reset() {
|
||||
<el-row :gutter="24">
|
||||
<el-col :span="12">
|
||||
<FormItemTip
|
||||
v-model="form.buttons"
|
||||
v-model="ActionsButtons"
|
||||
:radio-options="Object.values(actions)"
|
||||
label="关联快捷按钮"
|
||||
prop="buttons"
|
||||
|
||||
@@ -4,6 +4,9 @@ import cskbEditor from '@/components/Editor/cskb.vue'
|
||||
import {getCsKb, updateCsKb} from "@/api/system/cskb";
|
||||
import {FormInstance, FormRules} from "element-plus";
|
||||
import modal from "@/plugins/modal";
|
||||
import {useDict} from "@/utils/dict";
|
||||
|
||||
const {com_question_categories} = toRefs<any>(useDict('com_question_categories'));
|
||||
// 表单实例
|
||||
const formRef = ref<FormInstance>()
|
||||
const router = useRouter();
|
||||
@@ -47,8 +50,7 @@ function init() {
|
||||
if (route.query.id) {
|
||||
getCsKb(route.query.id as string).then(res => {
|
||||
form.value = res.data;
|
||||
form.value.buttons = res.data.buttons.map(item => actions[item.buttonCode].value);
|
||||
|
||||
ActionsButtons.value = res.data.buttons.map(item => actions[item.buttonCode].value);
|
||||
showForm.value = JSON.parse(JSON.stringify(form.value));
|
||||
})
|
||||
}
|
||||
@@ -63,7 +65,7 @@ const actions = {
|
||||
'value': 'resolved',
|
||||
"sort": 1
|
||||
},
|
||||
transfer_human: {
|
||||
"transfer_human": {
|
||||
"buttonCode": "transfer_human",
|
||||
"buttonId": "2108377417910558722",
|
||||
"kbId": "1761700000000002001",
|
||||
@@ -73,6 +75,7 @@ const actions = {
|
||||
}
|
||||
}
|
||||
|
||||
const ActionsButtons = ref([])
|
||||
onMounted(() => {
|
||||
init()
|
||||
})
|
||||
@@ -89,7 +92,7 @@ async function submit() {
|
||||
await formRef.value.validate((valid) => {
|
||||
if (valid) {
|
||||
// 这里调用新增/编辑接口
|
||||
form.value.buttons = form.value.buttons.map(item => {
|
||||
form.value.buttons = ActionsButtons.value.map(item => {
|
||||
return actions[item]
|
||||
})
|
||||
console.log('校验通过,提交数据', form.value)
|
||||
@@ -153,6 +156,8 @@ function handleCancel() {
|
||||
v-model="form.category"
|
||||
:inputAttrs="{ placeholder: '请选择问题分类'}"
|
||||
label="问题分类"
|
||||
:radioOptions="com_question_categories"
|
||||
type="select"
|
||||
prop="category"
|
||||
tip="必填,可选:设备配网 / 耗材滤芯 / 固件升级 / 设备报修"
|
||||
>
|
||||
@@ -176,7 +181,7 @@ function handleCancel() {
|
||||
<el-row :gutter="24">
|
||||
<el-col :span="12">
|
||||
<FormItemTip
|
||||
v-model="form.buttons"
|
||||
v-model="ActionsButtons"
|
||||
:radio-options="Object.values(actions)"
|
||||
label="底部快捷按钮"
|
||||
prop="buttons"
|
||||
|
||||
@@ -57,7 +57,11 @@
|
||||
<div class="title" style="text-align: left">{{ scope.row.title }}</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="分类" prop="category" width="100"/>
|
||||
<el-table-column align="center" label="分类" prop="category" width="100">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="com_question_categories" :value="scope.row.category"></dict-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="回复内容" prop="content">
|
||||
<template #default="scope">
|
||||
<div class="content" @click="preview(scope.row)">
|
||||
@@ -138,6 +142,7 @@ import {useSearchReset} from '@/hooks/form/useSearchReset';
|
||||
import {useSearchToggle} from '@/hooks/form/useSearchToggle';
|
||||
import {useTableSelection} from '@/hooks/table/useTableSelection';
|
||||
import modal from '@/plugins/modal';
|
||||
import {useDict} from "@/utils/dict";
|
||||
|
||||
const csKbList = ref<CsKbVO[]>([]);
|
||||
const {loading, withLoading} = useLoading(true);
|
||||
@@ -151,7 +156,7 @@ const {
|
||||
applyDateRange: applyUpdateTimeDateRange,
|
||||
resetDateRange: resetUpdateTimeDateRange
|
||||
} = useDateRangeQuery('UpdateTime');
|
||||
|
||||
const {com_question_categories} = toRefs<any>(useDict('com_question_categories'));
|
||||
const queryFormRef = ref<ElFormInstance>();
|
||||
|
||||
const initFormData: CsKbForm = {
|
||||
@@ -312,12 +317,12 @@ function getOverView() {
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (row?: Partial<CsKbVO>) => {
|
||||
const _kbIds = row?.kbNo || ids.value;
|
||||
if (row) {
|
||||
await modal.confirm('是否确认删除客服知识库编号为"' + _kbIds + '"的数据项?');
|
||||
await modal.confirm('是否确认删除客服知识库编号为"' + row?.kbNo + '"的数据项?');
|
||||
} else {
|
||||
await modal.confirm('是否确认删除 选择的客服知识库,删除后将无法恢复?');
|
||||
}
|
||||
const _kbIds = row?.kbId || ids.value;
|
||||
await delCsKb(_kbIds);
|
||||
modal.msgSuccess('删除成功');
|
||||
await getList();
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import FormItemTip from "@/components/FormItemTip/index.vue";
|
||||
import {getCsAgent, updateCsAgent} from "@/api/system/cssAgent";
|
||||
import modal from '@/plugins/modal';
|
||||
import defaultAvatar from '@/assets/images/default.png'
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
@@ -27,7 +28,7 @@ const defaultImag = computed(() => {
|
||||
if (form.value.avatarUrl) {
|
||||
return form.value.avatarUrl
|
||||
}
|
||||
return import.meta.env.VITE_DEFAULT_USER_IMAGE
|
||||
return defaultAvatar || import.meta.env.VITE_DEFAULT_USER_IMAGE
|
||||
})
|
||||
|
||||
function init() {
|
||||
|
||||
@@ -7,7 +7,9 @@ import modal from "@/plugins/modal";
|
||||
import {uploadOss} from "@/api/system/oss";
|
||||
import {FormInstance, FormRules} from "element-plus";
|
||||
import Administrative from "@/data/Administrative.json";
|
||||
import defaultAvatar from '@/assets/images/default.png'
|
||||
|
||||
const defaultImag = defaultAvatar || import.meta.env.VITE_DEFAULT_USER_IMAGE;
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
const form = ref({
|
||||
@@ -135,7 +137,7 @@ function handelChangeQuery(code: string[]) {
|
||||
<div class="flex infoBox">
|
||||
<el-image
|
||||
class="customer-Img"
|
||||
:src="form.avatarUrl"></el-image>
|
||||
:src="form.avatarUrl || defaultImag"></el-image>
|
||||
<div class="flex flex-col justify-between">
|
||||
<div>
|
||||
<span class="userName">{{ form.nickName }}</span>
|
||||
@@ -182,10 +184,10 @@ function handelChangeQuery(code: string[]) {
|
||||
<FormItemTip
|
||||
v-model="editForm.nickName"
|
||||
prop="nickName"
|
||||
:inputAttrs="{ placeholder: '请输入用户昵称', disabled: false , showWordLimit:true ,maxlength:20}"
|
||||
:inputAttrs="{ placeholder: '请输入用户昵称', disabled: false , showWordLimit:true ,maxlength:10}"
|
||||
:required="true"
|
||||
type="input"
|
||||
tip="必填,最多 20 个字符,将同步展示在 APP 端"
|
||||
tip="必填,最多 10 个字符,将同步展示在 APP 端"
|
||||
>
|
||||
<template #label>
|
||||
<span>用户昵称</span>
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
<script lang="ts" setup>
|
||||
import pageCrumb from '@/components/Pagecrumb/index.vue';
|
||||
import {getUser, resetPwdUser, updateUserStatus} from '@/api/system/customer';
|
||||
import {getUser, getUserMainDevices, resetPwdUser, updateUserStatus} from '@/api/system/customer';
|
||||
import {hiddenPhone} from "@/utils/phone";
|
||||
import modal from "@/plugins/modal";
|
||||
import defaultAvatar from '@/assets/images/default.png'
|
||||
|
||||
const defaultImag = import.meta.env.VITE_DEFAULT_USER_IMAGE;
|
||||
const defaultImag = defaultAvatar || import.meta.env.VITE_DEFAULT_USER_IMAGE;
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
@@ -35,6 +36,14 @@ function changeStatus(status: '0' | '1') {
|
||||
})
|
||||
}
|
||||
|
||||
function getDeviceMain(deviceId: string) {
|
||||
router.push({
|
||||
path: '/device/deviceMain',
|
||||
query: {
|
||||
id: deviceId
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function handleBack() {
|
||||
router.push({
|
||||
@@ -66,6 +75,7 @@ const form = ref({
|
||||
"avatarOssId": "",
|
||||
"avatarUrl": "",
|
||||
})
|
||||
const deviceList = ref([])
|
||||
|
||||
function init() {
|
||||
if (route.query.id) {
|
||||
@@ -74,7 +84,9 @@ function init() {
|
||||
...form.value,
|
||||
...res.data
|
||||
}
|
||||
console.log(form.value)
|
||||
getUserMainDevices(form.value.userId).then(res => {
|
||||
deviceList.value = res.data;
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -208,24 +220,27 @@ init();
|
||||
</div>
|
||||
<el-table
|
||||
class="data-table"
|
||||
style="width: 100%"
|
||||
:data="deviceList"
|
||||
max-height="500"
|
||||
style="width: 100%;max-height: 500px"
|
||||
>
|
||||
<el-table-column :show-overflow-tooltip="true" align="center" label="设备名称" prop="tokenId"/>
|
||||
<el-table-column :show-overflow-tooltip="true" align="center" label="MAC地址" prop="userName"/>
|
||||
<el-table-column :show-overflow-tooltip="true" align="center" label="型号" prop="clientKey"/>
|
||||
<el-table-column :show-overflow-tooltip="true" align="center" label="设备名称" prop="name"/>
|
||||
<el-table-column :show-overflow-tooltip="true" align="center" label="MAC地址" prop="mac"/>
|
||||
<el-table-column :show-overflow-tooltip="true" align="center" label="型号" prop="model"/>
|
||||
<el-table-column align="center" label="在线状态">
|
||||
<template #default="scope">
|
||||
<el-tag type="primary">在线</el-tag>
|
||||
<el-tag type="danger">离线</el-tag>
|
||||
<el-tag v-if="scope.row.status === '1'" type="primary">在线</el-tag>
|
||||
<el-tag v-else type="danger">离线</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :show-overflow-tooltip="true" align="center" label="绑定时间" prop="userName"/>
|
||||
<el-table-column :show-overflow-tooltip="true" align="center" label="绑定时间" prop="createTime"/>
|
||||
<el-table-column align="center" label="操作">
|
||||
<template #default="scope">
|
||||
<el-button plain type="primary">查看设备详情</el-button>
|
||||
<el-button plain type="primary" @click="getDeviceMain(scope.row.deviceId)">查看设备详情</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -198,7 +198,7 @@ init()
|
||||
<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>
|
||||
<span style="color: rgba(17, 24, 39, 1);">{{ form.updateTime }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex-item flex flex-col">
|
||||
@@ -206,7 +206,7 @@ init()
|
||||
<i class="circle" style="background: #2563eb"></i>
|
||||
<span>运行数据</span>
|
||||
</div>
|
||||
<div class="flex-1 flex flex-col justify-evenly">
|
||||
<div class="flex-1 flex flex-col justify-evenly ">
|
||||
<div class="footer" style="margin-top: 0">
|
||||
<span>运行模式</span>
|
||||
<div>
|
||||
@@ -230,11 +230,6 @@ init()
|
||||
<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 ">
|
||||
@@ -251,7 +246,9 @@ init()
|
||||
</div>
|
||||
<el-progress :percentage="form.filterLife" :show-text="false"></el-progress>
|
||||
<div class="tip">
|
||||
<span>预计剩余可用 {{ form.filterRemainDays || '---' }} 天</span>
|
||||
<span>预计剩余可用 {{
|
||||
form.filterLife === 0 ? '---' : Math.round((form.filterLife / 100) * 180)
|
||||
}} 天</span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="form.deviceBattery!==null && form.filterLife !==null" class="line"></div>
|
||||
@@ -262,23 +259,29 @@ init()
|
||||
<span class="unit">%</span>
|
||||
</div>
|
||||
<el-progress :percentage="form.deviceBattery" :show-text="false" color="#22C55E"></el-progress>
|
||||
<el-tag type="success">充电中</el-tag>
|
||||
<el-tag v-if="form.powerMode == powerMode.usb" 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>
|
||||
<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>
|
||||
<el-tag type="success">车载模式</el-tag>
|
||||
<span class="describe">USB 外部供电断开后,电池供电继续运行 5 分钟消杀再自动关机;</span>
|
||||
</li>
|
||||
<li class="modelLi">
|
||||
<el-tag type="info">关闭</el-tag>
|
||||
<span class="describe">不执行该套低电量策略,仅保留基础净化逻辑。</span>
|
||||
<li class="modelLi flex items-center justify-items-start">
|
||||
<el-tag type="warning">桌面模式</el-tag>
|
||||
<ol class="describe flex-1" style="list-style: decimal;padding-left:0;margin: 0">
|
||||
<li class="describe">1. 电量<span style="color: #bd6724;font-weight: bold"><10%</span> 时关闭等离子消杀
|
||||
</li>
|
||||
<li class="describe">2. 电量<span style="color: #be123c;font-weight: bold"><5%</span> 时
|
||||
整机锁关机(防止电池过放)。
|
||||
</li>
|
||||
</ol>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -630,7 +633,7 @@ init()
|
||||
.modelLi {
|
||||
margin-bottom: 12px;
|
||||
|
||||
span.describe {
|
||||
.describe {
|
||||
margin-left: 12px;
|
||||
line-height: 16px;
|
||||
color: rgba(75, 85, 99, 1);
|
||||
|
||||
@@ -0,0 +1,530 @@
|
||||
<script lang="ts" setup>
|
||||
import cardNav from '@/components/cardNav/index.vue';
|
||||
import FormItemTip from '@/components/FormItemTip/index.vue';
|
||||
import {DeviceForm} from "@/api/system/device/types";
|
||||
import {getDevice, getLocationListOptions, updateDevice} from "@/api/system/device";
|
||||
import modal from "@/plugins/modal";
|
||||
import {airLevel, DeviceStatus, fanLevel, powerMode, runMode} from "@/views/system/device/devicelist/type";
|
||||
|
||||
function submitForm() {
|
||||
if (!form.value.name || form.value.name.trim() === "") {
|
||||
return ElMessage.warning('设备名称不能为空')
|
||||
}
|
||||
if (!form.value.locationName || form.value.locationName.trim() === "") {
|
||||
return ElMessage.warning('所在房间不能为空')
|
||||
}
|
||||
updateDevice(form.value).then(() => {
|
||||
modal.msgSuccess('修改成功');
|
||||
backMain()
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
function backMain() {
|
||||
router.replace(
|
||||
{
|
||||
path: '/device/deviceMain',
|
||||
query: {
|
||||
id: form.value.deviceId,
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
function backList() {
|
||||
router.replace({
|
||||
path: '/device/deviceList',
|
||||
})
|
||||
}
|
||||
|
||||
const locationList = ref([]);
|
||||
const route = useRoute();
|
||||
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();
|
||||
|
||||
function init() {
|
||||
form.value = {...initFormData};
|
||||
if (route.query.id) {
|
||||
getDevice(route.query.id as string).then(res => {
|
||||
Object.assign(form.value, res.data);
|
||||
getLocationList();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function getLocationList() {
|
||||
getLocationListOptions(form.value.deviceId).then(res => {
|
||||
locationList.value = res.data;
|
||||
})
|
||||
}
|
||||
|
||||
init()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="edit">
|
||||
<nav class="flex justify-between" style="padding-top:22px">
|
||||
<Pagecrumb></Pagecrumb>
|
||||
<div>
|
||||
<el-button plain type="info" @click="backList">返回设备列表</el-button>
|
||||
<el-button plain type="info" @click="backMain">返回设备详情</el-button>
|
||||
</div>
|
||||
</nav>
|
||||
<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=ImgDetedit&o=7&rm=3"></el-image>
|
||||
<div class="info">
|
||||
<div class="nav">
|
||||
<div class="title">Z2空气净化器</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="describe">DEV-2026-000138·AA:BB:CC:DD:EE:B·客厅·CZ-Z2023</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="editCard commonCard">
|
||||
<card-nav line-color="#2563eb" subTitle="仅可修改设备名称、所在房间与备注,实时运行数据不可编辑"
|
||||
title="静态档案信息"></card-nav>
|
||||
|
||||
<el-form :model="form" label-position="top" style="margin-top:44px;">
|
||||
<el-row :gutter="24">
|
||||
<el-col :span="12">
|
||||
<FormItemTip
|
||||
v-model="form.name"
|
||||
:inputAttrs="{ placeholder: '请输入设备名称', disabled: false , showWordLimit:true ,maxlength:20}"
|
||||
:required="true"
|
||||
label="设备名称"
|
||||
prop="name"
|
||||
tip="必填,最多20个字符"
|
||||
>
|
||||
</FormItemTip>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<FormItemTip
|
||||
v-model="form.model"
|
||||
:inputAttrs="{ placeholder: '请输入产品型号', disabled: true }"
|
||||
:required="false"
|
||||
prop="model"
|
||||
tip="设备型号出厂固定,不支持修改"
|
||||
>
|
||||
<template #label>
|
||||
<span>产品型号</span>
|
||||
<el-tag style="margin-left: 4px" type="info">锁定</el-tag>
|
||||
</template>
|
||||
</FormItemTip>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="24">
|
||||
<el-col :span="12">
|
||||
<FormItemTip
|
||||
v-model="form.mac"
|
||||
:inputAttrs="{ placeholder: '请输入MAC地址', disabled: true }"
|
||||
:required="false"
|
||||
prop="mac"
|
||||
tip="MAC 地址为设备唯一标识,不支持修改"
|
||||
>
|
||||
<template #label>
|
||||
<span>MAC地址</span>
|
||||
<el-tag style="margin-left: 4px" type="info">锁定</el-tag>
|
||||
</template>
|
||||
</FormItemTip>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<FormItemTip
|
||||
v-model="form.locationId"
|
||||
:inputAttrs="{ placeholder: '请输入所在房间',maxlength:20, }"
|
||||
:radioOptions="locationList"
|
||||
:required="true"
|
||||
label="所在房间"
|
||||
labelKey="locationName"
|
||||
prop="locationName"
|
||||
tip="必填"
|
||||
type="select"
|
||||
valueKey="locationId"
|
||||
>
|
||||
<template #option="{ item }">
|
||||
<div class="flex justify-between items-center">
|
||||
<div> {{ item.locationName }}</div>
|
||||
<el-tag type="primary">{{ item.homeName }}</el-tag>
|
||||
</div>
|
||||
</template>
|
||||
</FormItemTip>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<div>
|
||||
<FormItemTip
|
||||
v-model="form.remark"
|
||||
:inputAttrs="{ placeholder: '请输入备注信息,如采购批次、安装位置说明等' }"
|
||||
:required="false"
|
||||
prop="remark"
|
||||
type="textarea"
|
||||
>
|
||||
<template #label>
|
||||
<span>备注</span>
|
||||
<span style="color:rgba(156, 163, 175, 1);font-size: 12px">(选填)</span>
|
||||
</template>
|
||||
</FormItemTip>
|
||||
</div>
|
||||
</el-form>
|
||||
|
||||
<div v-if="form.purifier" class="readTimeInfo">
|
||||
<div class="nav flex justify-between">
|
||||
<div>
|
||||
<span class="title">实时运行数据</span>
|
||||
<el-tag style="margin-left:4px" type="info">只读</el-tag>
|
||||
</div>
|
||||
<span class="tip">由设备蓝牙自动上报,后台不可编辑 · 更新于 {{ form.updateTime }}</span>
|
||||
</div>
|
||||
|
||||
|
||||
<ul>
|
||||
<li class="li-item">
|
||||
<div class="title">TVOC数值</div>
|
||||
<div class="value">
|
||||
<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">
|
||||
<div class="title">运行模式</div>
|
||||
<div class="value">
|
||||
<span v-if="form.runMode == runMode.dask" class="Num">桌面模式</span>
|
||||
<span v-else-if="form.runMode == runMode.car" class="Num">车载模式</span>
|
||||
<span v-else class="Num">自动</span>
|
||||
</div>
|
||||
</li>
|
||||
<li class="li-item">
|
||||
<div class="title">风速挡位</div>
|
||||
<div class="value">
|
||||
<span v-if="form.fanLevel == fanLevel.power" class="Num">强力</span>
|
||||
<span v-else-if="form.fanLevel == fanLevel.lower" class="Num">低档</span>
|
||||
<span v-else class="Num">标准</span>
|
||||
</div>
|
||||
</li>
|
||||
<li class="li-item">
|
||||
<div class="title">供电模式</div>
|
||||
<div class="value">
|
||||
<span v-if="form.powerMode == powerMode.usb" class="Num">USB供电</span>
|
||||
<span v-else class="Num">电池供电</span>
|
||||
</div>
|
||||
</li>
|
||||
<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.filterLife === 0 ? '---' : Math.round((form.filterLife / 100) * 180)
|
||||
}}} 天
|
||||
</div>
|
||||
</li>
|
||||
<li v-if="form.deviceBattery !== null" class="li-item">
|
||||
<div class="title">电池电量</div>
|
||||
<div class="value">
|
||||
<span class="Num">{{ form.deviceBattery }}%</span>
|
||||
</div>
|
||||
<div class="tip"></div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="tip">
|
||||
运行数据来源于设备上报,无法在后台修改;如需调整运行模式与风速,请在 APP 设备详情页操作。
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer">
|
||||
<el-button size="large" type="default">取消</el-button>
|
||||
<el-button size="large" type="primary" @click="submitForm">保存</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.edit {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
overflow: auto;
|
||||
|
||||
.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: 57px;
|
||||
height: 56px;
|
||||
border-radius: 12px 12px 12px 12px;
|
||||
}
|
||||
|
||||
.info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
margin-left: 24px;
|
||||
|
||||
.nav {
|
||||
display: flex;
|
||||
align-items: end;
|
||||
margin-bottom: 10px;
|
||||
|
||||
.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.describe {
|
||||
line-height: 16px;
|
||||
color: rgba(156, 163, 175, 1);
|
||||
font-size: 12px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.editCard {
|
||||
min-height: 763px;
|
||||
|
||||
.readTimeInfo {
|
||||
.nav {
|
||||
margin-bottom: 16px;
|
||||
|
||||
.title {
|
||||
line-height: 17px;
|
||||
color: rgba(31, 41, 55, 1);
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.tip {
|
||||
line-height: 16px;
|
||||
color: rgba(156, 163, 175, 1);
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ul {
|
||||
gap: 16px;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
|
||||
|
||||
.li-item {
|
||||
height: 102px;
|
||||
border-radius: 12px 12px 12px 12px;
|
||||
background-color: rgba(247, 249, 252, 1);
|
||||
border: 1px solid rgba(238, 240, 243, 1);
|
||||
padding: 17px;
|
||||
|
||||
.title {
|
||||
margin-bottom: 10px;
|
||||
line-height: 16px;
|
||||
color: rgba(156, 163, 175, 1);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.value {
|
||||
margin: 4px 0 8px 0;
|
||||
|
||||
.Num {
|
||||
line-height: 24px;
|
||||
color: rgba(17, 24, 39, 1);
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
margin-right: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.tip {
|
||||
line-height: 14px;
|
||||
color: rgba(156, 163, 175, 1);
|
||||
font-size: 11px;
|
||||
text-align: left;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
& > .tip {
|
||||
margin-top: 16px;
|
||||
height: 42px;
|
||||
border-radius: 12px 12px 12px 12px;
|
||||
background-color: rgba(241, 245, 249, 1);
|
||||
padding: 12px;
|
||||
line-height: 18px;
|
||||
color: rgba(100, 116, 139, 1);
|
||||
font-size: 12px;
|
||||
text-align: left;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.footer {
|
||||
margin-top: 20px;
|
||||
width: 100%;
|
||||
text-align: right;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -2,9 +2,9 @@
|
||||
import cardNav from '@/components/cardNav/index.vue';
|
||||
import FormItemTip from '@/components/FormItemTip/index.vue';
|
||||
import {DeviceForm} from "@/api/system/device/types";
|
||||
import {getDevice, updateDevice} from "@/api/system/device";
|
||||
import {getDevice, getLocationListOptions, updateDevice} from "@/api/system/device";
|
||||
import modal from "@/plugins/modal";
|
||||
import {airLevel, DeviceStatus} from "@/views/system/device/devicelist/type";
|
||||
import {airLevel, DeviceStatus, fanLevel, powerMode, runMode} from "@/views/system/device/devicelist/type";
|
||||
|
||||
function submitForm() {
|
||||
if (!form.value.name || form.value.name.trim() === "") {
|
||||
@@ -39,32 +39,22 @@ function backList() {
|
||||
})
|
||||
}
|
||||
|
||||
const locationList = ref([]);
|
||||
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,
|
||||
@@ -75,23 +65,26 @@ const initFormData: DeviceForm = {
|
||||
createTime: undefined,
|
||||
updateBy: undefined,
|
||||
updateTime: undefined,
|
||||
activeDeviceNo: undefined,
|
||||
activeImei: undefined,
|
||||
activeMac: undefined,
|
||||
}
|
||||
|
||||
const form = ref();
|
||||
|
||||
function init() {
|
||||
form.value = {...initFormData};
|
||||
console.log(form.value);
|
||||
if (route.query.id) {
|
||||
getDevice(route.query.id as string).then(res => {
|
||||
Object.assign(form.value, res.data);
|
||||
getLocationList();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function getLocationList() {
|
||||
getLocationListOptions(form.value.deviceId).then(res => {
|
||||
locationList.value = res.data;
|
||||
})
|
||||
}
|
||||
|
||||
init()
|
||||
</script>
|
||||
|
||||
@@ -177,13 +170,23 @@ init()
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<FormItemTip
|
||||
v-model="form.locationName"
|
||||
:inputAttrs="{ placeholder: '请输入所在房间', }"
|
||||
v-model="form.locationId"
|
||||
:inputAttrs="{ placeholder: '请输入所在房间',maxlength:20, }"
|
||||
:required="true"
|
||||
label="所在房间"
|
||||
:radioOptions="locationList"
|
||||
labelKey="locationName"
|
||||
tip="必填"
|
||||
type="select"
|
||||
prop="locationName"
|
||||
tip="必填,可选:客厅 / 洗衣间 / 阳台 / 厨房"
|
||||
valueKey="locationId"
|
||||
>
|
||||
<template #option="{ item }">
|
||||
<div class="flex justify-between items-center">
|
||||
<div> {{ item.locationName }}</div>
|
||||
<el-tag type="primary">{{ item.homeName }}</el-tag>
|
||||
</div>
|
||||
</template>
|
||||
</FormItemTip>
|
||||
</el-col>
|
||||
</el-row>
|
||||
@@ -227,23 +230,23 @@ init()
|
||||
<li class="li-item">
|
||||
<div class="title">运行模式</div>
|
||||
<div class="value">
|
||||
<span v-if="form.runMode == '2'" class="Num">桌面模式</span>
|
||||
<span v-else-if="form.runMode == '1'" class="Num">车载模式</span>
|
||||
<span v-if="form.runMode == runMode.dask" class="Num">桌面模式</span>
|
||||
<span v-else-if="form.runMode == runMode.car" class="Num">车载模式</span>
|
||||
<span v-else class="Num">自动</span>
|
||||
</div>
|
||||
</li>
|
||||
<li class="li-item">
|
||||
<div class="title">风速挡位</div>
|
||||
<div class="value">
|
||||
<span v-if="form.fanLevel == '1'" class="Num">强力</span>
|
||||
<span v-else-if="form.fanLevel == '2'" class="Num">低档</span>
|
||||
<span v-if="form.fanLevel == fanLevel.power" class="Num">强力</span>
|
||||
<span v-else-if="form.fanLevel == fanLevel.lower" class="Num">低档</span>
|
||||
<span v-else class="Num">标准</span>
|
||||
</div>
|
||||
</li>
|
||||
<li class="li-item">
|
||||
<div class="title">供电模式</div>
|
||||
<div class="value">
|
||||
<span v-if="form.powerMode == '0'" class="Num">USB供电</span>
|
||||
<span v-if="form.powerMode == powerMode.usb" class="Num">USB供电</span>
|
||||
<span v-else class="Num">电池供电</span>
|
||||
</div>
|
||||
</li>
|
||||
@@ -252,7 +255,10 @@ init()
|
||||
<div class="value">
|
||||
<span class="Num">{{ form.filterLife }}%</span>
|
||||
</div>
|
||||
<div class="tip">剩余 {{ form.filterRemainDays || '--' }} 天</div>
|
||||
<div class="tip">剩余 {{
|
||||
form.filterLife === 0 ? '---' : Math.round((form.filterLife / 100) * 180)
|
||||
}}} 天
|
||||
</div>
|
||||
</li>
|
||||
<li v-if="form.deviceBattery !== null" class="li-item">
|
||||
<div class="title">电池电量</div>
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
<el-table-column align="center" type="selection" width="55"/>
|
||||
<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="所在房间" min-width="150" prop="locationName"/>
|
||||
<el-table-column align="center" label="在线状态" prop="status" width="100">
|
||||
<template #default="scope">
|
||||
<el-tag v-if="scope.row.status === DeviceStatus.online" type="success">在线</el-tag>
|
||||
@@ -122,7 +122,6 @@
|
||||
|
||||
<script lang="ts" name="Device" setup>
|
||||
import {
|
||||
delDevice,
|
||||
listDevice,
|
||||
} from '@/api/system/device';
|
||||
import {DeviceForm, DeviceQuery, DeviceVO} from '@/api/system/device/types';
|
||||
@@ -131,7 +130,6 @@ import {useDateRangeQuery} from '@/hooks/form/useDateRangeQuery';
|
||||
import {useSearchReset} from '@/hooks/form/useSearchReset';
|
||||
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";
|
||||
|
||||
@@ -167,28 +165,17 @@ const queryFormRef = ref<ElFormInstance>();
|
||||
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,
|
||||
@@ -199,9 +186,6 @@ const initFormData: DeviceForm = {
|
||||
createTime: undefined,
|
||||
updateBy: undefined,
|
||||
updateTime: undefined,
|
||||
activeDeviceNo: undefined,
|
||||
activeImei: undefined,
|
||||
activeMac: undefined,
|
||||
}
|
||||
const data = reactive<PageData<DeviceForm, DeviceQuery>>({
|
||||
form: {...initFormData},
|
||||
@@ -328,15 +312,6 @@ function handleEdit(row: Partial<DeviceVO>) {
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (row?: Partial<DeviceVO>) => {
|
||||
const deviceIds = row?.deviceId || ids.value;
|
||||
await modal.confirm('是否确认删除该设备?');
|
||||
await delDevice(deviceIds);
|
||||
modal.msgSuccess('删除成功');
|
||||
await getList();
|
||||
};
|
||||
|
||||
/** 导出按钮操作 */
|
||||
const handleExport = () => {
|
||||
requestDownload(
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<script lang="ts" setup>
|
||||
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 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();
|
||||
@@ -84,9 +84,10 @@ import {DeviceStatus, fanLevel, parkingShutDown, powerMode, runMode} from "@/vie
|
||||
// }
|
||||
//
|
||||
// init()
|
||||
import type {Component} from 'vue'
|
||||
|
||||
const compDefine = ref<any>(null)
|
||||
const compMap: Record<string, () => Promise<typeof import("*.vue")>> = {
|
||||
const compDefine = ref<Component>(null)
|
||||
const compMap: Record<string, () => Promise<{ default: Component }>> = {
|
||||
airPurifier: () => import('./component/AirPurifier.vue'),
|
||||
}
|
||||
const currentComp = computed(() => compDefine.value)
|
||||
|
||||
@@ -162,7 +162,7 @@
|
||||
v-hasPermi="['system:user:edit']"
|
||||
link
|
||||
type="danger"
|
||||
@click="handleAuthRole(scope.row)"
|
||||
@click="handleStatusChange(scope.row)"
|
||||
>禁用
|
||||
</el-button>
|
||||
<el-button
|
||||
@@ -170,7 +170,7 @@
|
||||
v-hasPermi="['system:user:edit']"
|
||||
link
|
||||
type="success"
|
||||
@click="handleAuthRole(scope.row)"
|
||||
@click="handleStatusChange(scope.row)"
|
||||
>启用
|
||||
</el-button>
|
||||
<el-button
|
||||
@@ -613,11 +613,14 @@ const handleUnlock = async () => {
|
||||
|
||||
/** 用户状态修改 */
|
||||
const handleStatusChange = async (row: Partial<UserVO>) => {
|
||||
const text = row.status === '0' ? '启用' : '停用';
|
||||
const text = row.status === '0' ? '停用' : '启用';
|
||||
const status = row.status === '0' ? "1" : '0'
|
||||
try {
|
||||
await modal.confirm('确认要"' + text + '""' + row.userName + '"用户吗?');
|
||||
await api.changeUserStatus(row.userId, row.status);
|
||||
modal.confirm('确认要"' + text + '""' + row.userName + '"用户吗?').then(async () => {
|
||||
await api.changeUserStatus(row.userId, status);
|
||||
modal.msgSuccess(text + '成功');
|
||||
await getList();
|
||||
});
|
||||
} catch (err) {
|
||||
row.status = row.status === '0' ? '1' : '0';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user