Explorar o código

feat: thirdDevice

lvkun %!s(int64=2) %!d(string=hai) anos
pai
achega
5a45de9096

+ 1 - 1
config/proxy.ts

@@ -26,7 +26,7 @@ module.exports = {
       // target: 'http://120.223.238.91:8888',
       // target: 'http://120.223.238.91:8888',
       // target: 'http://124.222.113.37:8888',
-      target: 'http://111.231.55.175:18081',
+      target: 'http://101.126.68.200:18081',
       changeOrigin: true,
       pathRewrite: { '^/iot': '' }
     },

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

@@ -0,0 +1,40 @@
+
+import request from '@/service/request'
+
+export const getThirdDevicePage = (params: IOT.API.THIRDDEVICE.QueryParams & COMMON.API.QueryParams) => {
+  return request<IOT.API.THIRDDEVICE.Detail[]>({
+    url: '/thirdDevice/page',
+    method: 'GET',
+    params
+  })
+}
+
+export const addThirdDevice = (data: IOT.API.THIRDDEVICE.QueryParams) => {
+  return request<string>({
+    url: '/thirdDevice',
+    method: 'POST',
+    data
+  })
+}
+
+export const updateThirdDevice = (data: IOT.API.THIRDDEVICE.QueryParams) => {
+  return request<string>({
+    url: '/thirdDevice',
+    method: 'PUT',
+    data
+  })
+}
+
+export const delThirdDevice = (deviceCode: string) => {
+  return request<string>({
+    url: '/thirdDevice/' + deviceCode,
+    method: 'DELETE'
+  })
+}
+
+export const getThirdDeviceByCode = (deviceCode: string) => {
+  return request<IOT.API.THIRDDEVICE.Detail>({
+    url: '/thirdDevice/' + deviceCode,
+    method: 'GET'
+  })
+}

+ 2 - 0
src/controller/index.ts

@@ -30,3 +30,5 @@ export { AiboxCloudController } from './cvs/aiboxCloudController'
 export { DataToolController } from './datacenter/dataTool'
 
 export { TpsController } from './iot/tps'
+
+export { ThirdDeviceController } from './iot/thirdDevice'

+ 28 - 0
src/controller/iot/thirdDevice.ts

@@ -0,0 +1,28 @@
+import { addThirdDevice, delThirdDevice, getThirdDeviceByCode, getThirdDevicePage, updateThirdDevice } from '@/api/iot/thirdDevice'
+import { message } from 'ant-design-vue'
+
+export class ThirdDeviceController {
+  static async page (params: IOT.API.THIRDDEVICE.QueryParams & COMMON.API.QueryParams) {
+    return await getThirdDevicePage(params)
+  }
+
+  static async add (data: IOT.API.THIRDDEVICE.QueryParams) {
+    const { code, msg } = await addThirdDevice(data)
+    code === 200 ? message.success('新增成功') : message.error(msg)
+  }
+
+  static async update (data: IOT.API.THIRDDEVICE.QueryParams) {
+    const { code, msg } = await updateThirdDevice(data)
+    code === 200 ? message.success('编辑成功') : message.error(msg)
+  }
+
+  static async byCode (code: string) {
+    const { data } = await getThirdDeviceByCode(code)
+    return data
+  }
+
+  static async del (code: string) {
+    const { code: _code, msg } = await delThirdDevice(code)
+    _code === 200 ? message.success('删除成功') : message.error(msg)
+  }
+}

+ 166 - 0
src/pages/Iot/thirdDevice/index.vue

@@ -0,0 +1,166 @@
+<template>
+<a-card title="第三方平台" >
+
+  <table-pro
+    :service="ThirdDeviceController.page"
+    :columns="columns"
+    :serviceParams="queryParams"
+    ref="tableProDom"
+    @add="openModal('add', {})"
+  >
+    <template #render="{column, record}" >
+      <template v-if="column.key === 'action'" >
+        <a-space>
+          <a @click="openModal('update', record)" >编辑</a>
+          <a-popconfirm
+            title="确定要删除这个设备吗?"
+            ok-text="Yes"
+            cancel-text="No"
+            @confirm="delDevice(record.deviceCode)"
+          >
+            <a>删除</a>
+          </a-popconfirm>
+        </a-space>
+      </template>
+    </template>
+  </table-pro>
+</a-card>
+
+<modal-pro
+    title="第三方设备"
+    :open="visible"
+    @cancel="visible = false"
+    @ok="ok"
+  >
+    <a-form  :labelCol="{span: 6}" :wrapperCol="{span: 14}" >
+      <a-form-item label="设备编码" v-bind="validateInfos.deviceCode"  >
+        <a-input :disabled="opraState === 'update'"  allowClear v-model:value="state.deviceCode" />
+      </a-form-item>
+      <a-form-item label="设备名称" v-bind="validateInfos.deviceLabel"  >
+        <a-input allowClear v-model:value="state.deviceLabel" />
+      </a-form-item>
+      <a-form-item label="设备类型"  >
+        <a-input allowClear v-model:value="state.deviceType" />
+        <!-- <a-select allowClear v-model:value="state.deviceType" >
+          <a-select-option
+            v-for="item in []"
+            :key="item.id"
+            :value="item.id"
+          >
+            {{item.modelLabel}}
+          </a-select-option>
+        </a-select> -->
+      </a-form-item>
+      <a-form-item label="设备描述" v-bind="validateInfos.deviceDesc"  >
+        <a-input allowClear v-model:value="state.deviceDesc" />
+      </a-form-item>
+      <a-form-item label="设备地址" >
+        <a-input allowClear v-model:value="state.deviceAddr" />
+      </a-form-item>
+    </a-form>
+</modal-pro>
+</template>
+<script lang='ts' setup >
+import { ThirdDeviceController } from '@/controller'
+import { reactive, ref } from 'vue'
+import { Form, message } from 'ant-design-vue'
+
+const columns = [
+  {
+    title: '设备编码',
+    dataIndex: 'deviceCode',
+    key: 'deviceCode'
+  },
+  {
+    title: '设备名称',
+    dataIndex: 'deviceLabel',
+    key: 'deviceLabel'
+  },
+  {
+    title: '设备类型',
+    dataIndex: 'deviceType',
+    key: 'deviceType'
+  },
+  {
+    title: '设备状态',
+    dataIndex: 'deviceStatus',
+    key: 'deviceStatus'
+  },
+  {
+    title: '设备状态描述',
+    dataIndex: 'deviceStatusDesc',
+    key: 'deviceStatusDesc'
+  },
+  {
+    title: '设备描述',
+    dataIndex: 'deviceDesc',
+    key: 'deviceDesc'
+  },
+  {
+    title: '设备地址',
+    dataIndex: 'deviceAddr',
+    key: 'deviceAddr'
+  },
+  {
+    title: '设备数据',
+    dataIndex: 'deviceData',
+    key: 'deviceData'
+  },
+  {
+    title: '操作',
+    dataIndex: 'action',
+    key: 'action'
+  }
+]
+
+const useForm = Form.useForm
+
+const queryParams = reactive({
+  deviceCode: null,
+  deviceLabel: null,
+  deviceType: null,
+  deviceStatus: null
+})
+
+const tableProDom = ref()
+
+const visible = ref(false)
+
+const opraState = ref('add')
+
+const state = reactive({
+  deviceCode: null, // 设备编码 唯一标志 必须填写
+  deviceLabel: null, // 设备名称 必须填写
+  deviceType: null, // 设备类型
+  deviceDesc: null, // 设备描述
+  deviceAddr: null // 设备地址
+})
+
+const { resetFields, validate, validateInfos } = useForm(state, reactive({
+  deviceCode: [{ required: true, message: '请填写设备编码' }],
+  deviceLabel: [{ required: true, message: '请填写设备名称' }]
+}))
+
+const ok = () => {
+  validate().then(async () => {
+    opraState.value === 'add' ? await ThirdDeviceController.add(state) : await ThirdDeviceController.update(state)
+    tableProDom.value.reload()
+    visible.value = false
+  })
+}
+
+const openModal = (type: 'add' | 'update', record: any) => {
+  visible.value = true
+  opraState.value = type
+  if (type === 'update') resetFields(record)
+  else resetFields({})
+}
+
+const delDevice = async (deviceCode: string) => {
+  await ThirdDeviceController.del(deviceCode)
+  tableProDom.value.reload()
+}
+
+</script>
+<style lang='less' scoped >
+</style>

+ 6 - 0
src/router/index.ts

@@ -172,6 +172,12 @@ const iot = {
       icon: 'FolderAddOutlined',
       component: () => import('@/pages/iot/ota/index.vue')
     },
+    {
+      path: '/thirdDevice',
+      name: '第三方设备',
+      icon: 'FolderAddOutlined',
+      component: () => import('@/pages/iot/thirdDevice/index.vue')
+    },
     {
       path: '/tps',
       name: '第三方服务',

+ 23 - 0
src/type/iot.d.ts

@@ -490,6 +490,29 @@ declare namespace IOT {
       }
     }
 
+    namespace THIRDDEVICE {
+
+      interface QueryParams {
+        'deviceCode'?: string, // 设备编码 唯一标志 必须填写
+        'deviceLabel'?: string, // 设备名称 必须填写
+        'deviceType'?: string, // 设备类型
+        'deviceDesc'?: string, // 设备描述
+        'deviceAddr'?: string, // 设备地址
+      }
+
+      interface Detail {
+        'deviceCode': string, // 设备编码 唯一标志
+        'deviceLabel': string, // 设备名称
+        'deviceType': string, // 设备类型
+        'deviceStatus': string, // 设备状态
+        'deviceStatusDesc': string, // 设备状态描述
+        'deviceDesc': string, // 设备描述
+        'deviceAddr': string, // 设备地址
+        'deviceData': string, // 设备数据,json 或者字符串,可以点击放大查看 或者其他展示方式
+      }
+
+    }
+
   }
 
 }