瀏覽代碼

新增守护计划

wangming 1 月之前
父節點
當前提交
9c30100dde

+ 0 - 1
src/components/component/tenMinutes.vue

@@ -477,7 +477,6 @@ export default {
                 })
                 .then((res) => {
                     if (res.data.data) {
-                        console.log(res.data.data, 9999);
                         if (res.data.data.length > 0) {
                             this.hanledLists = res.data.data;
                             this.selectHanled = this.hanledLists[0];

+ 2 - 2
src/components/js_sdk/index.js

@@ -5,9 +5,9 @@ http.setConfig(config => {
     if (__wxConfig.envVersion == 'develop') {
         let selectedService = uni.getStorageSync("sercviceChoice")
         if (!selectedService || selectedService == 'aloneServe') {
-            // config.baseUrl = "https://api.radar-power.asia:4443/portal-service-server/";
+            config.baseUrl = "https://api.radar-power.asia:4443/portal-service-server/";
         }
-        config.baseUrl = "https://radar-power.cn/portal-service-server/";
+        // config.baseUrl = "https://radar-power.cn/portal-service-server/";
     }
     if (__wxConfig.envVersion == 'trial') {
         let selectedService = uni.getStorageSync("sercviceChoice")

+ 1 - 1
src/pages.json

@@ -191,7 +191,7 @@
                     "path": "healthAlarm/healthAlarm",
                     "style": {
                         "enablePullDownRefresh": true,
-                        "navigationBarTitleText": "健康闹钟",
+                        "navigationBarTitleText": "守护计划",
                         "navigationBarBackgroundColor": "#faede2",
                         "navigationBarTextStyle": "black"
                     }

+ 1 - 1
src/pagesA/deviceDetail/deviceDetail.vue

@@ -246,7 +246,7 @@
             <view class="handle-btn">
                 <view class="btn1" @click="shareDevice">分享</view>
                 <view class="btn1" @click="gotoSetting">设置</view>
-                <view class="btn2" @click="healthAlarm"> 健康闹钟 </view>
+                <view class="btn2" @click="healthAlarm">守护计划</view>
             </view>
         </view>
 

+ 252 - 27
src/pagesA/healthAlarm/healthAlarm.vue

@@ -5,21 +5,20 @@
                 <view class="device-bottom">
                     <view
                         class="info-box"
-                        v-for="(item, index) in modules"
+                        v-for="(item, index) in selectedPlan"
                         :key="index"
                     >
                         <view class="info-text">
                             <text>{{ item.name }}</text>
-                            <text>({{ item.width }}*{{ item.length }})cm</text>
                         </view>
                         <view class="edit_del">
                             <image
-                                @click="deleteItem(index)"
+                                @click="deleteItem(item)"
                                 src="../../static/delete.png"
                                 alt=""
                             ></image>
                             <image
-                                @click="editItem(index)"
+                                @click="editItem(item)"
                                 style="margin-left: 10rpx"
                                 src="../../static/edit.png"
                                 alt=""
@@ -29,25 +28,209 @@
                 </view>
             </view>
         </view>
-        <view class="bottomTwo" @click="saveRoom">
-            <view class="addNewAlarm">新增设备告警计划</view>
-            <view class="previousTip">保存</view>
+        <view class="bottomTwo">
+            <view class="addNewAlarm" @click="addNewAlarm">新增守护计划</view>
+        </view>
+
+        <!-- 选择守护计划遮罩层 -->
+        <view v-if="showPopup" class="mask" @click="showPopup = false"></view>
+
+        <view v-if="showPopup" class="popup">
+            <view class="popup-body">
+                <picker
+                    mode="selector"
+                    :range="planListName"
+                    @change="bindPickerChange"
+                    :value="selectedIndex"
+                >
+                    <view class="picker-text">
+                        {{
+                            planListName[selectedIndex] ||
+                            "点击此处选择守护计划"
+                        }}
+                    </view>
+                </picker>
+            </view>
+            <view class="popup-footer">
+                <view class="cancel-btn" @click="showPopup = false">
+                    取消
+                </view>
+                <view type="primary" @click="confirmSelect" class="sure-btn">
+                    确定
+                </view>
+            </view>
         </view>
     </view>
 </template>
 <script>
 export default {
     data() {
-        return { modules: [] };
+        return {
+            devInfo: {},
+            showPopup: false,
+            planList: [],
+            planListName: [],
+            selectedIndex: null,
+            // 已经新增的守护计划
+            selectedPlan: [],
+        };
     },
     computed: {},
     methods: {
-        saveRoom() {
-            console.log("保存");
+        getPlanList() {
+            this.$http
+                .post("wap/alarm/plan/queryTpl", {
+                    eventVal: "",
+                    name: "",
+                })
+                .then((res) => {
+                    if (res.data.code == 200) {
+                        if (res.data.data.length > 0) {
+                            this.planList = res.data.data;
+                            this.planListName = res.data.data.map(
+                                (ele) => ele.name
+                            );
+                            console.log(this.planList, 99999);
+                        }
+                    }
+                });
+        },
+        confirmSelect() {
+            if (this.selectedIndex !== null) {
+                let selectedPlan = this.planList.find(
+                    (plan) => plan.name == this.planListName[this.selectedIndex]
+                );
+                selectedPlan.clientId = this.devInfo.clientId;
+                if (!selectedPlan.alarmTimePlan) {
+                    this.$set(selectedPlan, "alarmTimePlan", {});
+                }
+                selectedPlan.alarmTimePlan.startDate = this.$time(
+                    new Date(),
+                    1
+                );
+                selectedPlan.alarmTimePlan.stopDate = this.$time(
+                    new Date(
+                        new Date().setFullYear(new Date().getFullYear() + 1)
+                    ),
+                    1
+                );
+
+                this.$http
+                    .post(
+                        "wap/alarm/plan/save",
+                        {
+                            ...selectedPlan,
+                        },
+                        {
+                            header: {
+                                "Content-Type":
+                                    "application/json;charset=UTF-8",
+                                token: uni.getStorageSync("tokenValue") || "",
+                            },
+                        }
+                    )
+                    .then((res) => {
+                        if (res.data.code == 200) {
+                            uni.showToast({
+                                title: "添加计划成功",
+                                icon: "success",
+                                duration: 1500,
+                            });
+                        } else {
+                            uni.showToast({
+                                title: res.data.message,
+                                icon: "none",
+                                duration: 1500,
+                            });
+                        }
+                        this.getSelectPlan();
+                    });
+                this.showPopup = false;
+            }
+        },
+        bindPickerChange(e) {
+            this.selectedIndex = e.detail.value;
+        },
+        addNewAlarm() {
+            this.showPopup = true;
+        },
+        getSelectPlan() {
+            this.$http
+                .post(
+                    "wap/alarm/plan/query",
+                    {
+                        clientId: this.devInfo.clientId,
+                    },
+                    {
+                        header: {
+                            "Content-Type": "application/json;charset=UTF-8",
+                            token: uni.getStorageSync("tokenValue") || "",
+                        },
+                    }
+                )
+                .then((res) => {
+                    if (res.data.code == 200) {
+                        if (res.data.data.length > 0) {
+                            this.selectedPlan = res.data.data;
+                        }
+                    }
+                });
+        },
+        deleteItem(item) {
+            uni.showModal({
+                content: "是否删除该计划",
+                complete: (res) => {
+                    if (res.confirm) {
+                        this.$http
+                            .post(
+                                "wap/alarm/plan/del",
+                                {
+                                    id: item.id,
+                                },
+                                {
+                                    header: {
+                                        "Content-Type":
+                                            "application/json;charset=UTF-8",
+                                        token:
+                                            uni.getStorageSync("tokenValue") ||
+                                            "",
+                                    },
+                                }
+                            )
+                            .then((res) => {
+                                if (res.data.code == 200) {
+                                    uni.showToast({
+                                        title: "守护计划删除成功",
+                                        icon: "success",
+                                        duration: 1500,
+                                    });
+                                } else {
+                                    uni.showToast({
+                                        title: res.data.message,
+                                        icon: "none",
+                                        duration: 1500,
+                                    });
+                                }
+                                this.getSelectPlan();
+                            });
+                    }
+                    if (res.cancel) {
+                    }
+                    return;
+                },
+            });
+        },
+        editItem(item) {
+            console.log(item, 88888);
         },
     },
-    onLoad(options) {},
-    onShow() {},
+    onLoad(options) {
+        this.devInfo = JSON.parse(options.devInfo);
+        this.getSelectPlan();
+    },
+    onShow() {
+        this.getPlanList();
+    },
 };
 </script>
 <style lang="less" scoped>
@@ -152,10 +335,11 @@ export default {
         height: 120rpx;
         background: #f3e2dd;
         .addNewAlarm {
+            margin: 0 auto;
             display: flex;
             align-items: center;
             justify-content: center;
-            width: 400rpx;
+            width: 700rpx;
             height: 94rpx;
             background: #ffebe4;
             border-radius: 28rpx;
@@ -164,21 +348,62 @@ export default {
             font-size: 32rpx;
             text-align: center;
         }
-        .previousTip {
+    }
+
+    .mask {
+        position: fixed;
+        top: 0;
+        left: 0;
+        right: 0;
+        bottom: 0;
+        background: rgba(0, 0, 0, 0.4);
+        z-index: 99;
+    }
+    .popup {
+        position: fixed;
+        left: 50%;
+        top: 50%;
+        transform: translate(-50%, -50%);
+        width: 500rpx;
+        background: #fff;
+        border-radius: 16rpx;
+        padding: 20rpx;
+        z-index: 100;
+        .popup-body {
+            text-align: center;
+            margin-bottom: 20rpx;
+
+            .picker-text {
+                padding: 20rpx;
+                border-radius: 8rpx;
+            }
+        }
+        .popup-footer {
             display: flex;
-            align-items: center;
-            justify-content: center;
-            width: 328rpx;
-            height: 94rpx;
-            background: linear-gradient(105.95deg, #a27867 0%, #74483d 100%);
-            border-radius: 28rpx;
-            box-shadow: 0rpx 4.69rpx 18.75rpx rgba(72, 41, 29, 0.15),
-                0rpx 9.38rpx 9.38rpx rgba(154, 132, 89, 0.2),
-                0rpx -4.69rpx 28.13rpx 4.69rpx #a16647 inset;
-            font-family: MiSans;
-            font-weight: 500;
-            color: #ffffff;
-            font-size: 32rpx;
+            justify-content: space-around;
+            margin-top: 40rpx;
+            .cancel-btn {
+                width: 200rpx;
+                height: 75rpx;
+                background: #ffebe4;
+                line-height: 75rpx;
+                border-radius: 28rpx;
+                font-weight: 500;
+                color: #111111;
+                font-size: 32rpx;
+                text-align: center;
+            }
+            .sure-btn {
+                width: 200rpx;
+                height: 75rpx;
+                background: #4f372e;
+                line-height: 75rpx;
+                border-radius: 28rpx;
+                font-weight: 500;
+                color: #ffffff;
+                font-size: 32rpx;
+                text-align: center;
+            }
         }
     }
 }