浏览代码

feat: 远程开关清洗提醒

Ritchie 1 年之前
父节点
当前提交
b3188ecc14

二进制
src/assets/device/operIcon/alramClean.png


+ 8 - 0
src/assets/language/en.json

@@ -547,6 +547,7 @@
     "position": "Position",
     "viewPositioning": "View positioning",
     "restartAndroid": "Restart touch screen",
+    "alramClean": "Machine clean reminder",
     "refrigeration": "Refrigeration mode",
     "keepFresh": "Fresh-keeping mode",
     "stir": "Stirring mode",
@@ -1588,6 +1589,13 @@
     "content": "Do you want to switch?",
     "successfully": "Successfully sent, please wait a few seconds and re-enter"
   },
+  "alramClean": {
+    "openStatus": "Machine clean reminder function switch status: On",
+    "closeStatus": "Machine clean reminder function switch status: Off",
+    "tips": "Remind",
+    "content": "Do you want to switch?",
+    "successfully": "Successfully sent, please wait a few seconds and re-enter"
+  },
   "Account operation": "Account operation",
   "Discount code": "Discount code",
   "Alarm history": "Alarm history",

+ 8 - 0
src/assets/language/ja.json

@@ -564,6 +564,7 @@
         "position": "位置情報",
         "viewPositioning": "位置情報を見る",
         "restartAndroid": "画面を再起動",
+        "alramClean": "機器洗浄のお知らせ",
         "refrigeration": "冷却モードです",
         "keepFresh": "鮮度保持モードです",
         "stir": "撹拌モードです",
@@ -1607,6 +1608,13 @@
         "content": "スイッチを切り替えますか?",
         "successfully": "送信に成功しました。数秒待ってから再入力してください"
     },
+    "alramClean": {
+        "openStatus": "装置のクリーニングリマインダースイッチの状態:オン",
+        "closeStatus": "装置のクリーニングリマインダースイッチの状態:オフ",
+        "tips": "リマインダー",
+        "content": "スイッチを切り替えますか?",
+        "successfully": "送信成功、数秒後に再度確認してください"
+    },
     "账户操作": "アカウント操作",
     "优惠码": "プロモーションコード",
     "报警历史": "アラーム履歴",

+ 8 - 0
src/assets/language/zh.json

@@ -570,6 +570,7 @@
     "position": "定位",
     "viewPositioning": "查看定位",
     "restartAndroid": "重启触摸屏",
+    "alramClean": "设备清洗提醒",
     "refrigeration": "制冷模式",
     "keepFresh": "保鲜模式",
     "stir": "搅拌模式",
@@ -1639,6 +1640,13 @@
     "content": "是否切换开关?",
     "successfully": "发送成功,请等待几秒后重新进入查看"
   },
+  "alramClean": {
+    "openStatus": "设备清洗提醒开关状态:开启",
+    "closeStatus": "设备清洗提醒开关状态:关闭",
+    "tips": "提醒",
+    "content": "是否切换开关?",
+    "successfully": "发送成功,请等待几秒后重新进入查看"
+  },
   "账户操作": "账户操作",
   "优惠码": "优惠码",
   "报警历史": "报警历史",

+ 7 - 0
src/router/index.js

@@ -491,6 +491,13 @@ const router = createRouter({
       component: () => import("@/views/device/diyFlower/index"),
       meta: { index: 1 },
     },
+    // 设备清洗提醒
+    {
+      path: "/alramClean",
+      name: "alramClean",
+      component: () => import("@/views/device/alramClean/index"),
+      meta: { index: 1 },
+    },
     // 修改机器密码
     {
       path: "/devicePassword",

+ 10 - 0
src/service/device/index.js

@@ -212,6 +212,16 @@ export function updateDIYProductShow(params) {
     return axios.post(`/SZWL-SERVER/tEquipment/updateDIYProductShow`, params);
 }
 
+// 获取设备清洗提醒开关状态
+export function getAlarmClean(clientId) {
+    return axios.get(`/SZWL-SERVER/tAlarmClean/getAlarmClean/${clientId}`);
+}
+
+// 修改设备清洗提醒开关状态
+export function updateAlarmCleanStatus(params) {
+    return axios.post(`/SZWL-SERVER/tAlarmClean/updateAlarmCleanStatus`, params);
+}
+
 // 日志上传
 export function uploadLog(params) {
     return axios.get(`/SZWL-SERVER/tEquipment/uploadLog?${stringToUrl(params)}`);

+ 125 - 0
src/views/device/alramClean/index.vue

@@ -0,0 +1,125 @@
+<template>
+    <div class="showGoodsIdx">
+        <s-header :name="$t('device.alramClean')" :noback="false"></s-header>
+        <div class="headerCon kBordBott o-plr-10 o-ptb-16 l-flex-RC">
+            <div class="line o-mr-6"></div>
+            <div>
+                <span class="c-color c-text-14">{{ $t('device.showGoodsPage.equipmentName') }}:</span>
+                <span class="c-text-color c-text-14">{{ equipmentName }}</span>
+            </div>
+        </div>
+        <van-cell v-if="showCheckBtn" center
+            :title="checked ? $t('alramClean.openStatus') : $t('alramClean.closeStatus')" size="large"
+            title-style="color: #404d74;">
+            <template #right-icon>
+                <van-switch :model-value="checked" @update:model-value="updateStatus" size="24" />
+            </template>
+        </van-cell>
+
+    </div>
+</template>
+
+<script>
+// 导入接口
+import { updateAlarmCleanStatus, getAlarmClean } from '@/service/device/index';
+import sHeader from "@/components/SimpleHeader";
+import { ref } from "@vue/reactivity";
+import { onMounted } from '@vue/runtime-core';
+import { useRoute, useRouter } from 'vue-router';
+import { showConfirmDialog, showFailToast, showToast } from 'vant';
+import { useI18n } from "vue-i18n";
+import { styleUrl } from '../../../common/js/utils';
+export default {
+    components: {
+        sHeader
+    },
+    setup() {
+        // 引入语言
+        const { t } = useI18n();
+        // 路由
+        const route = useRoute();
+        const router = useRouter();
+
+        const switchStates = ref([]);
+
+        const equipmentId = ref('');
+        const equipmentName = ref('');
+        const clientId = ref('');
+        const checked = ref(true);
+        const showCheckBtn = ref(true)
+
+        // 刚进页面
+        onMounted(() => {
+            // 加载样式
+            styleUrl('showGoods');
+            equipmentId.value = route.query.deviceId || "";
+            const name = route.query.name || "";
+            clientId.value = route.query.clientId || "";
+            // console.log("route.query.clientId>>>", route.query.clientId);
+            if (equipmentId) {
+                equipmentName.value = name;
+            }
+            getList(clientId.value);
+
+        });
+
+        // 获取清洗提醒开关状态
+        const getList = async (clientId) => { // 声明为异步函数
+            try {
+                const { data } = await getAlarmClean(clientId); // 使用await等待异步函数执行完毕并返回结果
+                // 处理获取到的data
+                console.log("data>>>", data);
+                if (data.data === null) {
+                    showCheckBtn.value = false;
+                } else {
+                    if (data.code === '00000') {
+                        if (data.data.status === '0') {
+                            checked.value = false;
+                        }
+                    }
+                }
+            } catch (error) {
+                console.error('Error fetching data:', error);
+            }
+        }
+
+
+        const updateStatus = (newValue) => {
+            const params = {
+                clientId: clientId.value,
+                status: newValue ? '1' : '0',
+            };
+            showConfirmDialog({
+                title: t('alramClean.tips'),
+                message: t('alramClean.content'),
+            }).then(async () => {
+                console.log("params.clientId>>>", params.clientId);
+                console.log("params.status>>>", params.status);
+                const { data } = await updateAlarmCleanStatus(params);
+                console.log("updateData>>>", data);
+                if (data.code) {
+                    // checked.value = newValue;
+                    showToast(t('alramClean.successfully'));
+                    setTimeout(() => {
+                        router.go(-1);
+                    }, 1500);
+                } else {
+                    showFailToast(data.message);
+                }
+            }).catch((error) => {
+                console.log(error);
+            });
+        }
+
+        return {
+            equipmentName,
+            switchStates,
+            checked,
+            updateStatus,
+            showCheckBtn
+        };
+    },
+};
+</script>
+
+<style lang="less" scoped></style>

+ 17 - 1
src/views/device/deviceOper.vue

@@ -214,6 +214,13 @@
         </div>
         <div class="operText">{{ $t("device.viewPositioning") }}</div>
       </div> -->
+      <!-- 设备清洗提醒 -->
+      <div class="operItem" @click="alramCleanClk()">
+        <div class="operIcon">
+          <img class="operImg" src="../../assets/device/operIcon/alramClean.png" />
+        </div>
+        <div class="operText">{{ $t("device.alramClean") }}</div>
+      </div>
 
     </div>
   </van-dialog>
@@ -278,7 +285,15 @@ export default {
     const diyFlowerClk = () => {
       router.push({
         path: "diyFlower",
-        query: { deviceId: device.value.id, name: device.value.name, diyFlowerStatus: device.value.diyFlowerStatus, flower: device.value.flowers },
+        query: { deviceId: device.value.id, name: device.value.name, diyFlowerStatus: device.value.diyFlowerStatus, flower: device.value.flowers , clientId: device.value.clientId},
+      });
+    };
+
+    // 点击设备清洗提醒
+    const alramCleanClk = () => {
+      router.push({
+        path: "alramClean",
+        query: { deviceId: device.value.id, name: device.value.name, clientId: device.value.clientId },
       });
     };
     const { t } = useI18n();
@@ -636,6 +651,7 @@ export default {
       deleteDevice,
       lockDevice,
       restartAndroid,
+      alramCleanClk,
       // viewPosiClk,
       changePasswordClk,
       sleepIcon,