lvkun преди 2 години
родител
ревизия
1ae8d62d1e
променени са 3 файла, в които са добавени 48 реда и са изтрити 3 реда
  1. 8 0
      src/api/iot/thirdDevice.ts
  2. 6 1
      src/controller/iot/thirdDevice.ts
  3. 34 2
      src/pages/Iot/thirdDevice/index.vue

+ 8 - 0
src/api/iot/thirdDevice.ts

@@ -45,3 +45,11 @@ export const getThirdDeviceDataByCode = (deviceCode: string) => {
     method: 'GET'
   })
 }
+
+export const updateDeviceAttr = (deviceCode: string, data: {devicePropCode: string, devicePropVal: 0 | 1}) => {
+  return request<string>({
+    url: `/thirdDevice/data/${deviceCode}`,
+    method: 'PUT',
+    data
+  })
+}

+ 6 - 1
src/controller/iot/thirdDevice.ts

@@ -1,4 +1,4 @@
-import { addThirdDevice, delThirdDevice, getThirdDeviceByCode, getThirdDeviceDataByCode, getThirdDevicePage, updateThirdDevice } from '@/api/iot/thirdDevice'
+import { addThirdDevice, delThirdDevice, getThirdDeviceByCode, getThirdDeviceDataByCode, getThirdDevicePage, updateThirdDevice, updateDeviceAttr } from '@/api/iot/thirdDevice'
 import { message } from 'ant-design-vue'
 
 export class ThirdDeviceController {
@@ -30,4 +30,9 @@ export class ThirdDeviceController {
     const { data } = await getThirdDeviceDataByCode(code)
     return data
   }
+
+  static async updateDeviceAttr (deviceCode: string, data: {devicePropCode: string, devicePropVal: 0 | 1}) {
+    const { code: _code, msg } = await updateDeviceAttr(deviceCode, data)
+    _code === 200 ? message.success('修改成功') : message.error(msg)
+  }
 }

+ 34 - 2
src/pages/Iot/thirdDevice/index.vue

@@ -7,13 +7,28 @@
     ref="tableProDom"
     @add="openModal('add', {})"
   >
+    <template #search >
+      <a-space>
+        <a-input style="width: 170px;" placeholder="请输入设备名称" v-model:value="queryParams.deviceLabel" > </a-input>
+        <a-input style="width: 170px;" placeholder="请输入设备编码" v-model:value="queryParams.deviceCode" >  </a-input>
+        <a-cascader
+          style="width: 170px;"
+          v-model:value="queryParams.deviceType"
+          :options="options"
+          placeholder="请选择设备类型"
+          change-on-select
+        />
+        <a-button type="primary" @click='search' >搜索</a-button>
+      </a-space>
+    </template>
     <template #render="{column, record}" >
       <template v-if="column.key === 'onLineState'">
         {{record.onLineState == 0 ? '离线' : '在线'}}
       </template>
       <template v-if="column.key === 'action'" >
         <a-space>
-          <a @click="openDataView(record)" >查看</a>
+          <a @click="openDataView(record)" v-if="record.deviceType != 3" >查看</a>
+          <a @click="openDataView(record)" v-if="record.deviceType = 3" >阀⻔数据</a>
           <a @click="openModal('update', record)" >编辑</a>
           <a-popconfirm
             title="确定要删除这个设备吗?"
@@ -84,7 +99,7 @@
 <script lang='ts' setup >
 import { ThirdDeviceController } from '@/controller'
 import { reactive, ref } from 'vue'
-import { Form, message } from 'ant-design-vue'
+import { Form, message, CascaderProps } from 'ant-design-vue'
 import { RealView } from '@/components/RealView/index'
 
 const columns = [
@@ -173,6 +188,19 @@ const dataColumns = [
   }
 ]
 
+const options: CascaderProps['options'] = [
+  {
+    value: 'zhejiang',
+    label: 'Zhejiang',
+    children: [
+      {
+        value: 'hangzhou',
+        label: 'Hangzhou'
+      }
+    ]
+  }
+]
+
 const onLineStateDescMap = new Map([
   ['UN_ACTIVE', '223'],
   ['UN_ACTIVE1', '']
@@ -226,6 +254,10 @@ const delDevice = async (deviceCode: string) => {
   tableProDom.value.reload()
 }
 
+const search = () => {
+  tableProDom.value.reload()
+}
+
 const deviceData = ref()
 
 const realViewVisible = ref(false)