From e08ed33cd9c766e1db52f86fb99cc701e385ee61 Mon Sep 17 00:00:00 2001 From: ailanyin Date: Fri, 28 Apr 2023 17:37:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=BA=E6=99=AF=E8=81=94=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/device/linkage.js | 44 + src/components/NotificationCenter/index.vue | 112 +- src/components/TableSelect/index.vue | 52 +- src/constant/dict.js | 13 + src/settings.js | 2 +- src/store/modules/user.js | 8 +- src/views/device/linkage/index.vue | 1283 +++++++++++++++++++ src/views/product/alertRule/index.vue | 149 +-- src/views/product/product/edit.vue | 2 +- src/views/product/product/index.vue | 36 +- src/views/system/tenant/index.vue | 28 +- 11 files changed, 1542 insertions(+), 187 deletions(-) create mode 100644 src/api/device/linkage.js create mode 100644 src/views/device/linkage/index.vue diff --git a/src/api/device/linkage.js b/src/api/device/linkage.js new file mode 100644 index 0000000..0f3b7b9 --- /dev/null +++ b/src/api/device/linkage.js @@ -0,0 +1,44 @@ +import request from "@/utils/request"; + +// 查询场景联动列表 +export function listLinkage(query) { + return request({ + url: "/device/linkage/list", + method: "get", + params: query, + }); +} + +// 查询场景联动详细 +export function getLinkage(sceneId) { + return request({ + url: "/device/linkage/" + sceneId, + method: "get", + }); +} + +// 新增场景联动 +export function addLinkage(data) { + return request({ + url: "/device/linkage", + method: "post", + data: data, + }); +} + +// 修改场景联动 +export function updateLinkage(data) { + return request({ + url: "/device/linkage", + method: "put", + data: data, + }); +} + +// 删除场景联动 +export function delLinkage(sceneId) { + return request({ + url: "/device/linkage/" + sceneId, + method: "delete", + }); +} diff --git a/src/components/NotificationCenter/index.vue b/src/components/NotificationCenter/index.vue index 0874dc4..cf16ffe 100644 --- a/src/components/NotificationCenter/index.vue +++ b/src/components/NotificationCenter/index.vue @@ -8,10 +8,7 @@ width="320" > @@ -116,8 +111,7 @@ {{ msgDetail.msgContent }} - + @@ -146,9 +140,9 @@ const data = reactive({ queryParams: { pageNum: 1, pageSize: 10, - status: 1 + status: 1, }, - msgDetail: {} + msgDetail: {}, }); const router = useRouter(); const loadKey = ref(0); @@ -166,36 +160,26 @@ const ids = ref([]); //选中的列表 const refreshList = () => { ids.value = []; selectMulti.value = false; - queryParams.value.status = status.value; queryParams.value.pageNum = 1; - // if (status.value === 2) { notificationList.value = []; - // } loadKey.value += 1; }; -watch(status, (value) => { - ids.value = []; - selectMulti.value = false; - queryParams.value.status = value; - queryParams.value.pageNum = 1; - // if (value === 2) { - notificationList.value = []; - // } - loadKey.value += 1; -}); + +watch( + () => queryParams.value.status, + (value) => { + ids.value = []; + selectMulti.value = false; + queryParams.value.pageNum = 1; + notificationList.value = []; + loadKey.value += 1; + } +); const loadMore = async ($state) => { - // console.log($state); try { loading.value = true; const resp = await listMsg(queryParams.value); - // if (queryParams.value.status === 0) { - // notificationStore.pushItems(resp.rows); - // } else if (queryParams.value.status === 2) { notificationList.value.push(...resp.rows); - // } - // queryParams.value.status === 0 && - // resp.rows.length && - // updateMsg(resp.rows.map((el) => el.msgId).join(","), 1); total.value = resp.total; if (queryParams.value.status === 1) { unreadCount.value = resp.total; @@ -232,9 +216,6 @@ const deleteReadMsg = async () => { const markAsRead = async () => { await updateMsg(ids.value.join(","), 2); refreshList(); - /* for (const id of ids.value) { - notificationStore.removeItem(id); - }*/ ids.value = []; selectMulti.value = false; }; @@ -256,55 +237,40 @@ function logout() { cancelButtonText: "取消", showCancelButton: false, showClose: false, - type: "warning" + type: "warning", }) .then(() => { userStore.logOut().then(() => { location.href = "/index"; - // router.go("/index") }); }) .catch(() => { userStore.logOut().then(() => { location.href = "/index"; - // router.go("/index") }); }); } watch(visible, (value) => { if (value) { + /*当打开通知弹窗时*/ notificationList.value = []; queryParams.value.pageNum = 1; queryParams.value.status = 1; - status.value = 1; loadKey.value++; } }); - +/*获取未读数量*/ const getUnreadCount = async () => { - // loading.value = true; - // notificationList.value = []; - // queryParams.value.pageNum = 1; - // queryParams.value.status = 1; - // status.value = 1; const resp = await listMsg({ - pageSize: 10, pageNum: 1, status: 1 + pageSize: 10, + pageNum: 1, + status: 1, }); - // if (queryParams.value.status === 0) { - // notificationStore.pushItems(resp.rows); - // } else if (queryParams.value.status === 2) { - - // notificationList.value.push(...resp.rows); - // } - // queryParams.value.status === 0 && - // resp.rows.length && - // updateMsg(resp.rows.map((el) => el.msgId).join(","), 1); unreadCount.value = resp.total; - // queryParams.value.pageNum++; - // loading.value = false; }; + onMounted(() => { getUnreadCount(); if (userStore.userId) { @@ -337,20 +303,12 @@ onMounted(() => { console.log(event.data); const wsData = JSON.parse(event.data); if (wsData.type === "msg") { - // if (visible.value) { - // refreshList(); - // } else { if (visible.value && queryParams.value.status === 1) { refreshList(); } else { getUnreadCount(); } - // } - // const msg = wsData.data; - // updateMsg(msg.msgId, 1); - // notificationStore.pushItem(msg); } else if (wsData.type === "offline") { - // showOfflineNotice.value = true; logout(); } }); @@ -396,7 +354,6 @@ onMounted(() => { margin-top: 16px; .notification-item { - display: flex; align-items: center; justify-content: space-between; @@ -449,7 +406,6 @@ onMounted(() => { &:last-child { border-bottom: 1px solid #eeefef; - } } } diff --git a/src/components/TableSelect/index.vue b/src/components/TableSelect/index.vue index 13c3439..3dfb8a2 100644 --- a/src/components/TableSelect/index.vue +++ b/src/components/TableSelect/index.vue @@ -11,6 +11,7 @@ v-loading="loading" :data="dataList" @select="handleSelect" + @row-click="handleRowClick" @select-all="handleSelectAll" > @@ -62,7 +63,7 @@ diff --git a/src/views/product/alertRule/index.vue b/src/views/product/alertRule/index.vue index 5901c36..35cd222 100644 --- a/src/views/product/alertRule/index.vue +++ b/src/views/product/alertRule/index.vue @@ -59,7 +59,7 @@ 搜索 + >搜索 重置 @@ -75,7 +75,7 @@ plain type="primary" @click="handleAdd" - >新增 + >新增 @@ -85,7 +85,7 @@ plain type="success" @click="getList" - >刷新 + >刷新 @@ -178,7 +178,7 @@ link type="warning" @click="handleUpdate(row)" - >{{ productId ? "修改" : "查看" }} + >{{ productId ? "修改" : "查看" }} 删除 + >删除 @@ -339,7 +339,7 @@ size="small" type="danger" @click="removeTriggerItem(index)" - >删除 + >删除 @@ -601,19 +601,19 @@ size="small" type="danger" @click="removeActionItem(index)" - >删除 + >删除 添加执行动作 + >添加执行动作