Просмотр исходного кода

Merge branch 'ming' of uskycloud/usky-web-mobile into master

gez 1 неделя назад
Родитель
Сommit
c4c6bb5ab8

+ 19 - 0
src/api/business/fireIot/deviceManage.js

@@ -44,3 +44,22 @@ export function last(param) {
         data: param,
     });
 }
+
+// 命令列表
+export function getList(data) {
+    return request({
+        url: '/service-iot/dmpProductCommand/page',
+        method: 'POST',
+        data,
+    })
+  }
+
+  
+//设备离线状态更新
+export function doorControl(params) {
+    return request({
+        url: '/service-iot/deviceHttp/doorControl',
+        method: 'get',
+        params,
+    })
+  }

+ 7 - 0
src/pages.json

@@ -513,6 +513,13 @@
                         "enablePullDownRefresh": false
                     }
                 },
+                {
+                    "path": "deviceManage/components/goAction",
+                    "style": {
+                        "navigationBarTitleText": "执行动作",
+                        "enablePullDownRefresh": false
+                    }
+                },
                 {
                     "path": "facilitiesGather/index",
                     "style": {

+ 80 - 6
src/pages/business/fireIot/deviceManage/components/deviceDetails.vue

@@ -79,9 +79,16 @@
           </view>
         </view>
 
-        <view v-else>
+        <view v-if="tabPosition == 2">
           <br/>
-          设备调试数据待对接
+          <u-row
+            gutter="10"
+          >
+              <u-col span="3" v-for="(item, index) in deviceCotrolList" :key="index">
+                  <view class="demo-layout" @click="goAction(item)">{{ item.commandName }}</view>
+              </u-col>
+              
+          </u-row>
           <br/>
           <br/>
           <br/>
@@ -113,9 +120,9 @@
 <script setup>
 /*----------------------------------依赖引入-----------------------------------*/
 import { onLoad, onShow, onReady, onHide, onLaunch, onNavigationBarButtonTap, onPageScroll } from "@dcloudio/uni-app";
-import { ref, reactive, computed, getCurrentInstance, toRefs, inject } from "vue";
+import { ref, reactive, computed, getCurrentInstance, toRefs, inject,watch } from "vue";
 /*----------------------------------接口引入-----------------------------------*/
-import { dmpProductAttribute, historyMetrics, last } from "@/api/business/fireIot/deviceManage.js";
+import { dmpDeviceInfo,dmpProductAttribute, historyMetrics, last,getList } from "@/api/business/fireIot/deviceManage.js";
 /*----------------------------------组件引入-----------------------------------*/
 import chart from "./chart.vue";
 /*----------------------------------store引入-----------------------------------*/
@@ -160,6 +167,10 @@ const modalShow = ref(false); //模态框显示隐藏
 const calendar = ref(null);
 const calendarStartTime = ref(""); //日历开始时间
 const calendarEndTime = ref(""); //日历结束时间
+const productId = ref(0); //产品id
+const deviceId = ref(0); //设备id
+const productCode = ref(""); //产品code
+const deviceCotrolList = ref([]) //设备调试数据存储
 function open() {
   calendar.value.open();
 }
@@ -167,12 +178,34 @@ function open() {
 /**
  * @初始化
  */
+
+
+ /**
+ * @详情查询
+ * @api接口查询
+ */
+function dmpDeviceInfoApi() {
+  dmpDeviceInfo({ productId: productId.value, deviceId:deviceId.value,current: 1, size: 10 }).then((requset) => {
+    if (requset.status === "SUCCESS") {
+      dataList.value[0].value = requset.data.records[0].deviceName;
+      dataList.value[1].value = requset.data.records[0].deviceId;
+      dataList.value[2].value = requset.data.records[0].simCode ;
+      dataList.value[3].value = requset.data.records[0].installAddress
+      dataList.value[4].value = requset.data.records[0].createdTime ? requset.data.records[0].createdTime.replace("T", " ") : requset.data.records[0].createdTime;
+      productCode.value = requset.data.records[0].productCode;
+    }
+  });
+}
+
+
 function init() {
+  dmpDeviceInfoApi();
   dmpProductAttribute({
     current: 1,
     size: 100,
     attributeName: "",
-    productId: commonStore.deviceDetailsArray.productId,
+    productId: productId.value,
+    deviceId:deviceId.value,
   }).then((requset) => {
     if (requset.status === "SUCCESS") {
       checkboxDataList.value = requset.data.records;
@@ -203,6 +236,21 @@ function init() {
   });
 }
 
+
+function deviceControlData(){
+  getList({
+    current: 1,
+    size: 10,
+    productCode:productCode.value,
+  }).then((response) => {
+    deviceCotrolList.value=response.data.records
+    // console.log(response.data.records)
+    // dataList.value = response.data.records;
+    // state.total = response.data.total;
+    // state.loading = false;
+  });
+}
+
 /**
  * @tabs切换change事件
  */
@@ -267,6 +315,10 @@ function historyMetricsApi() {
   });
 }
 
+function goAction(row) {
+  proxy.$tab.navigateTo(`/pages/business/fireIot/deviceManage/components/goAction?productCode=${row.productCode}&commandCode=${row.commandCode}&deviceId=${deviceId.value}`);
+}
+
 onReady(() => {});
 
 onShow(() => {
@@ -275,8 +327,25 @@ onShow(() => {
 });
 
 onLoad((options) => {
-  init();
+  if ("deviceId" in options) {
+    deviceId.value = options.deviceId;
+  }
+  if ("productId" in options) {
+    productId.value = parseInt(options.productId);
+    init();
+  }
+
 });
+
+watch(
+  () => tabPosition.value,
+  (val) => {
+    if(val==2){
+      deviceControlData()
+    }
+   
+  }
+);
 </script>
 
 <style lang="scss" scoped>
@@ -285,4 +354,9 @@ onLoad((options) => {
   margin-bottom: 10px;
   padding: 0px 5rem;
 }
+.demo-layout{
+  border:1px solid #e0e0e0;
+  padding:15px;
+  box-shadow:0px 0px 12px rgba(0, 0, 0, 0.12);
+}
 </style>

+ 7 - 5
src/pages/business/fireIot/deviceManage/components/deviceDetailsList.vue

@@ -84,7 +84,7 @@ const data = reactive({
     { label: "在线", value: "1" },
     { label: "离线", value: "2" },
   ],
-  radioValue: "",
+  radioValue: "1",
   dropdownShow: false,
 });
 
@@ -103,8 +103,8 @@ function init() {
  */
 
 function dmpDeviceInfoApi() {
-  dmpDeviceInfo({ productId: productId.value, deviceName: deviceName.value, current: current.value, size: pageSize.value }).then((requset) => {
-    if (requset.status === "SUCCESS") {
+  dmpDeviceInfo({ current: current.value, size: pageSize.value ,deviceStatus:radioValue.value }).then((requset) => {
+    if (requset.status == "SUCCESS") {
       dataList.value = requset.data.records;
       total.value = requset.data.total;
 
@@ -119,7 +119,7 @@ function dmpDeviceInfoApi() {
  * @设备详情跳转点击事件
  */
 function handleToDevice(array) {
-  proxy.$tab.navigateTo("/pages/business/fireIot/deviceManage/components/deviceDetails");
+  proxy.$tab.navigateTo(`/pages/business/fireIot/deviceManage/components/deviceDetails?productId=${array.productId}&deviceId=${array.deviceId}`);
 
   commonStore.deviceDetailsArray = array;
   commonStore.deviceDetailsArray.productName = productName.value;
@@ -129,8 +129,10 @@ function handleToDevice(array) {
  * @单选change事件
  */
 function radioChange(e) {
+  // console.log(e,'e')
   radioValue.value = e;
-  selectListApi();
+  dmpDeviceInfoApi();
+  dropdownShow.value=false
 }
 
 /**

+ 247 - 0
src/pages/business/fireIot/deviceManage/components/goAction.vue

@@ -0,0 +1,247 @@
+<template>
+  <oa-scroll
+    customClass="unitInfoCollection-container scroll-height"
+    :refresherLoad="false"
+    :refresherEnabled="false"
+    :refresherEnabledTitle="false"
+    :refresherDefaultStyle="'none'"
+    :refresherThreshold="44"
+    :refresherBackground="'#f5f6f7'"
+    :data-theme="'theme-' + proxy.$settingStore.themeColor.name"
+  >
+    <template #default>
+  
+      <view class="centerOne">
+        <u--form ref="uForm" :model="form" :rules="rules" labelWidth="130">
+          <view style="padding: 10px 0">
+            <view style="padding: 10px 10px 20px 10px; background: #ffffff">
+              <view style="padding-left: 9px">
+                <u-form-item label="命令" prop="commandName" required :borderBottom="true">
+                  <u-input v-model="form.commandName" placeholder="请输入命令名称" border="none">
+                   
+                  </u-input>
+                </u-form-item>
+                <u-form-item label="命令属性" v-if="form.dataType==1" prop="commandValue" required :borderBottom="true" @click="handleAction('命令属性')">
+                  <u-input v-model="form.commandName1" placeholder="请选择命令属性" suffixIcon="arrow-right" suffixIconStyle="color: #909399" border="none" disabledColor="transparent" disabled />
+                </u-form-item>
+                <u-form-item v-else label="参数值" prop="commandValue" required :borderBottom="true">
+                  <u-input v-model="form.commandValue" placeholder="请输入参数值" border="none">
+                    
+                  </u-input>
+                </u-form-item>
+                
+              </view>
+            </view>
+          </view>
+        </u--form>
+
+        <view class="app-button">
+          <view class="app-button-padding"></view>
+          <view class="app-button-fixed">
+            <u-button class="app-buttom" type="primary" @click="handleSubmit('命令下发')" shape="circle"> 命 令 下 发 </u-button>
+          </view>
+        </view>
+      </view>
+
+     
+      <u-picker
+        :show="actionShow"
+        :columns="actionsList"
+        :title="'请选择' + actionTitle"
+        keyName="name"
+        visibleItemCount="6"
+        :defaultIndex="[actionDefaultIndex]"
+        :closeOnClickOverlay="true"
+        @close="actionShow = false"
+        @cancel="actionShow = false"
+        @confirm="selectAction"
+      ></u-picker>
+
+
+    </template>
+  </oa-scroll>
+</template>
+
+<script setup>
+/*----------------------------------依赖引入-----------------------------------*/
+import { onLoad, onShow } from "@dcloudio/uni-app";
+import { ref, reactive, toRefs, getCurrentInstance } from "vue";
+/*----------------------------------接口引入-----------------------------------*/
+import { getList,doorControl} from "@/api/business/fireIot/deviceManage.js";
+/*----------------------------------组件引入-----------------------------------*/
+/*----------------------------------store引入-----------------------------------*/
+/*----------------------------------公共方法引入-----------------------------------*/
+/*----------------------------------公共变量-----------------------------------*/
+const { proxy } = getCurrentInstance();
+/*----------------------------------变量声明-----------------------------------*/
+
+const deviceId=ref('')
+
+const dataList = reactive({
+  form: {
+    commandName: "", //命令名称
+    commandCode: "", //命令编码
+    productCode: "", //产品编码
+  },
+  rules: {
+    commandName: [{ required: true, message: "请输入命令", trigger: "blur" }],
+    commandValue:[
+            { required: true},
+            { validator: commandValueScale,trigger: 'blur'}
+          ]
+  },
+  actionTitle: "",
+  actionShow: false,
+  actionDefaultIndex: 0,
+  actionsList: [[]],
+});
+
+const {
+  form,
+  rules,
+  actionTitle,
+  actionsList,
+  actionShow,
+  actionDefaultIndex,
+} = toRefs(dataList);
+
+const scanBool = ref(false);
+
+//参数值校验范围
+function commandValueScale(rule, value, callback) {
+  console.log(form.value.maximum,222)
+  if(form.value.maximum&&form.value.minimum){
+    if (value > form.value.minimum && value <form.value.maximum) {
+        callback();
+      } else {
+        callback(new Error(`输入的参数值必须大于${form.value.minimum}且小于${form.value.maximum}`));
+      }
+  }else{
+    callback();
+  }          
+}
+
+//详情数据
+function getData(){
+  getList({
+    current: 1,
+    size: 10,
+    productCode:form.value.productCode,
+    commandCode:form.value.commandCode,
+  }).then((response) => {
+    form.value=response.data.records[0];
+    form.value.commandDict = form.value.commandDict?JSON.parse(form.value.commandDict):'';
+    rules.value.commandValue[0].message=form.value.dataType==1?'请选择命令属性':"请输入参数值"
+    rules.value.commandValue[0].tigger=form.value.dataType==1?'change':"blur";
+  });
+}
+
+/**
+ * @上一步
+ * @命令下发
+ * @提交
+ * @按钮点击事件
+ */
+function handleSubmit(value) {
+  proxy.$refs["uForm"]
+      .validate()
+      .then((res) => {
+        proxy.$modal.msg("校验通过");
+        var params={
+            commandCode:form.value.commandCode,
+            commandValue:form.value.commandValue,
+            productCode:form.value.productCode,
+            deviceId:deviceId.value,
+          }
+        doorControl(params).then((res) => {
+          if (res.status == "SUCCESS") {
+            if (scanBool.value) {
+              proxy.$tab.reLaunch(`/pages/common/success/index?codeName=提交成功&showNow=${false}`);
+            } else {
+              proxy.$modal.msg("提交成功");
+              setTimeout(() => {  
+                proxy.$tab.redirectTo("/pages/business/fireIot/deviceManage/index"); //返回到需要执行方法的页面
+              }, 2000);
+            }
+          }
+        })
+      })
+      .catch((errors) => {
+        // proxy.$modal.msg("校验失败");
+      });
+}
+
+
+
+/**
+ * @action弹出框点击事件
+ */
+function handleAction(value, index, ind) {
+  if (value == "命令属性") {
+    actionTitle.value = "命令属性";
+    actionsList.value = [
+      form.value.commandDict
+    ];
+    if (form.value.commandDict) {
+      actionsList.value[0].forEach((el, ind) => {
+        if (el.value === form.value.commandValue) {
+          actionDefaultIndex.value = ind;
+        }
+      });
+    } else {
+      actionDefaultIndex.value = 0;
+    }
+  }
+
+  actionShow.value = true;
+}
+
+/**
+ * @action弹出框选择事件
+ */
+function selectAction(e) {
+  if (actionTitle.value == "命令属性") {
+    form.value.commandValue = e.value[0].value;
+    form.value.commandName1 = e.value[0].name;
+  }
+  actionShow.value = false;
+}
+
+
+onLoad((options) => {
+  if ("commandCode" in options) {
+    form.value.commandCode = options.commandCode;
+    
+  }
+  if ("productCode" in options) {
+    form.value.productCode = options.productCode;
+  }
+  if ("deviceId" in options) {
+   deviceId.value = options.deviceId;
+  }
+  getData()
+
+});
+
+onShow(() => {
+  //调用系统主题颜色
+  proxy.$settingStore.systemThemeColor([1]);
+});
+</script>
+
+<style lang="scss">
+.unitInfoCollection-container {
+  .centerOne,
+  .centerTwo {
+    .title {
+      color: #333333;
+      text-align: center;
+      margin-top: 10px;
+    }
+  }
+
+  :deep(.u-picker__view__column__item) {
+    font-size: 13px;
+  }
+}
+</style>