lvkun 2 жил өмнө
parent
commit
5e2af75c8f

+ 5 - 2
config/proxy.ts

@@ -7,19 +7,22 @@ module.exports = {
   dev: {
     '/user': {
       // target: 'http://120.223.238.91:8888',
+      // target: 'http://124.222.113.37:9999',
       target: 'http://124.222.113.37:9999',
       changeOrigin: true,
       pathRewrite: { '^/user': '' }
     },
     '/cvss': {
-      target: 'http://120.223.238.91:6666',
+      // target: 'http://120.223.238.91:6666',
       // target: 'http://172.28.0.3:18082',
+      target: 'http://124.222.113.37:8080',
       changeOrigin: true,
       pathRewrite: { '^/cvss': '' }
     },
     '/iot': {
       // target: 'http://120.223.238.91:8888',
-      target: 'http://120.223.238.91:8888',
+      // target: 'http://120.223.238.91:8888',
+      target: 'http://124.222.113.37:8888',
       changeOrigin: true,
       pathRewrite: { '^/iot': '' }
     },

+ 46 - 0
src/api/iot/tps.ts

@@ -0,0 +1,46 @@
+import request from '@/service/request'
+
+export const getTpsList = () => {
+  return request<TPS.List[]>({
+    url: '/deviceThird/services',
+    method: 'GET'
+  })
+}
+
+export const getDevicePage = (params: {page: number, pageSize: number, label?: string, deviceId?: string}) => {
+  return request<TPS.Device[]>({
+    url: '/deviceThird/page',
+    method: 'GET',
+    params
+  })
+}
+
+export const getDeviceById = (id: string) => {
+  return request<TPS.Device>({
+    url: `/deviceThird/${id}`,
+    method: 'GET'
+  })
+}
+
+export const delDeviceById = (id: string) => {
+  return request<string>({
+    url: `/deviceThird/${id}`,
+    method: 'DELETE'
+  })
+}
+
+export const addDevice = (data: TPS.Device) => {
+  return request<string>({
+    url: '/deviceThird',
+    method: 'POST',
+    data
+  })
+}
+
+export const updateDevice = (data: TPS.Device) => {
+  return request<string>({
+    url: '/deviceThird',
+    method: 'PUT',
+    data
+  })
+}

+ 10 - 5
src/components/RealView/index.tsx

@@ -58,11 +58,16 @@ const RealView = defineComponent({
                   </a-space>
                 </div>
               </Row>
-              <div class="tabs" >
-                  <Tabs activeKey={tabKey.value} tabBarStyle={{ backgroundColor: 'fff', height: '45px' }} onChange={(key) => onTabChange(key)} >
-                    { tabsList.value.map(item => <Tabs.TabPane key={item.key} tab={item.tab}> </Tabs.TabPane>) }
-                  </Tabs>
-               </div>
+              {
+                tabsList.value.length
+                  ? <div class="tabs" >
+                <Tabs activeKey={tabKey.value} tabBarStyle={{ backgroundColor: 'fff', height: '45px' }} onChange={(key) => onTabChange(key)} >
+                  { tabsList.value.map(item => <Tabs.TabPane key={item.key} tab={item.tab}> </Tabs.TabPane>) }
+                </Tabs>
+             </div>
+                  : <></>
+              }
+
               <div class='real-view-content' >
                 {ctx.slots.default?.()}
               </div>

+ 2 - 0
src/controller/index.ts

@@ -26,3 +26,5 @@ export { NodesController } from './cvs/nodesController'
 export { AiboxController } from './cvs/aiboxController'
 
 export { DataToolController } from './datacenter/dataTool'
+
+export { TpsController } from './iot/tps'

+ 34 - 0
src/controller/iot/tps.ts

@@ -0,0 +1,34 @@
+import { getTpsList, getDevicePage, delDeviceById, getDeviceById, addDevice, updateDevice } from '@/api/iot/tps'
+import { message } from 'ant-design-vue'
+
+export class TpsController {
+  static async list () {
+    const { data } = await getTpsList()
+    return data
+  }
+
+  static async devicePage (params: {page: number, pageSize: number, label?: string, deviceId?: string}) {
+    const { data } = await getDevicePage(params)
+    return data
+  }
+
+  static async delDeviceById (id: string) {
+    const { msg, code } = await delDeviceById(id)
+    code === 200 ? message.success('删除成功') : message.error(msg)
+  }
+
+  static async getDeviceById (id: string) {
+    const { data } = await getDeviceById(id)
+    return data
+  }
+
+  static async addDevice (data: TPS.Device) {
+    const { msg, code } = await addDevice(data)
+    code === 200 ? message.success('新增成功') : message.error(msg)
+  }
+
+  static async updateDevice (data: TPS.Device) {
+    const { msg, code } = await updateDevice(data)
+    code === 200 ? message.success('修改成功') : message.error(msg)
+  }
+}

+ 101 - 0
src/pages/Iot/tps/device.vue

@@ -0,0 +1,101 @@
+<template>
+  <a-card title="设备服务" >
+    <table-pro
+      :service="TpsController.devicePage"
+      :serviceParams="queryParams"
+      :columns="columns"
+      ref="tableProDom"
+      @add="openModal"
+    >
+    <template #search >
+      <!-- <a-space><InputTsx placeholder="请输入设备名称进行搜索" v-model:value="deviceName" /> <a-button type="primary" @click="search">搜索</a-button> </a-space> -->
+    </template>
+    <template #render="{column, record}" >
+      <template v-if="column.key === 'action'" >
+        <a-space>
+          <a @click="openModal('update', record)">详情</a>
+          <a @click="openModal('update', record)">修改</a>
+          <a @click="delDevice(record.id)">删除</a>
+        </a-space>
+      </template>
+    </template>
+    </table-pro>
+  </a-card>
+
+  <RealView
+    :open="visible"
+    @cancel="closeModal"
+  >
+
+  </RealView>
+</template>
+<script lang='ts' setup >
+import { TpsController } from '@/controller'
+import { reactive, ref } from 'vue'
+import { RealView } from '@/components/RealView/index'
+
+const columns = [
+  {
+    title: '名称',
+    dataIndex: 'label',
+    key: 'label'
+  },
+  {
+    title: '设备ID',
+    dataIndex: 'deviceId',
+    key: 'deviceId'
+  },
+  {
+    title: '设备方法',
+    dataIndex: 'deviceMethod',
+    key: 'deviceMethod'
+  },
+
+  {
+    title: '第三服务code',
+    dataIndex: 'thirdCode',
+    key: 'thirdCode'
+  },
+  {
+    title: '第三服务参数',
+    dataIndex: 'thirdParam',
+    key: 'thirdParam'
+  },
+  {
+    title: '操作',
+    dataIndex: 'action',
+    key: 'action'
+  }
+]
+
+const queryParams = reactive({
+  page: 1,
+  pageSize: 10
+})
+
+const tableProDom = ref()
+
+const visible = ref(false)
+
+const delDevice = async (id: string) => {
+  await TpsController.delDeviceById(id)
+  tableProDom.value.reload()
+}
+
+const opraState = ref<'add' | 'update'>('add')
+
+const device = ref<TPS.Device>()
+
+const openModal = (type: 'add' | 'update', record: TPS.Device) => {
+  opraState.value = type
+  visible.value = true
+  device.value = record
+}
+
+const closeModal = () => {
+  visible.value = false
+}
+
+</script>
+  <style lang='less' scoped >
+  </style>

+ 45 - 0
src/pages/Iot/tps/list.vue

@@ -0,0 +1,45 @@
+<template>
+<a-card title="第三方列表" >
+  <table-pro
+    :service="TpsController.list"
+    :columns="columns"
+    :hiddenMeunKeys="['add']"
+  >
+
+  </table-pro>
+</a-card>
+</template>
+<script lang='ts' setup >
+import { TpsController } from '@/controller'
+
+const columns = [
+  {
+    title: '服务ID',
+    dataIndex: 'id',
+    key: 'id'
+  },
+  {
+    title: '名称',
+    dataIndex: 'label',
+    key: 'label'
+  },
+  {
+    title: '编码',
+    dataIndex: 'code',
+    key: 'code'
+  },
+  {
+    title: '描述',
+    dataIndex: 'description',
+    key: 'description'
+  },
+  {
+    title: '注册时间',
+    dataIndex: 'registerTime',
+    key: 'registerTime'
+  }
+]
+
+</script>
+<style lang='less' scoped >
+</style>

+ 18 - 0
src/router/index.ts

@@ -189,6 +189,24 @@ const iot = {
         }
       ]
     },
+    {
+      path: '/tps',
+      name: '第三方服务',
+      redirect: '/sys/noticeway',
+      icon: 'DatabaseOutlined',
+      children: [
+        {
+          path: '/tps/list',
+          name: '服务列表',
+          component: () => import('@/pages/iot/tps/list.vue')
+        },
+        {
+          path: '/tps/device',
+          name: '设备服务',
+          component: () => import('@/pages/iot/tps/device.vue')
+        }
+      ]
+    },
     {
       path: '/doc',
       name: '使用文档',

+ 25 - 0
src/type/tps.d.ts

@@ -0,0 +1,25 @@
+
+declare namespace TPS {
+
+  interface List {
+    code: string
+    label: string
+    description: stringß
+    registerTime?: string
+  }
+
+  interface Device {
+    deviceId: string // 设备id ,put post 都必须有
+    thirdCode: string // 第三服务code ,put post 都必须有
+    label: string // 名称,自定义输入” put post 都无所谓
+    deviceMethod: string // 设备方法,用户选择,选择模型 然后模型方法 方法的名称 put post 都必须有
+    thirdParam: {
+      ak:'ak' // put post 都无所谓
+      sk:'sk' /// // put post 都无所谓
+      endpoint: string // string //"服务地址"put post 都必须有
+      method: string // "服务方法",put post 都无所谓,可以做成下拉框 GET POST DELETE PUT
+      attributeKey: string // “属性key",put post 都无所谓,提示下 选择的属性必需在模型中定义
+      attributeJsonPath: string // “属性值在结果中jsonPath地址” put post 都无所谓,提示下 填写了属性key 必需填写该值,按照JsonPath规则
+    }
+  }
+}