Quellcode durchsuchen

fix: 8/26bug修复

lvkun vor 2 Jahren
Ursprung
Commit
062ace6aaa

+ 0 - 0
src/api/schedule/dataLake.ts


+ 0 - 0
src/api/schedule/dataSource.ts


+ 4 - 3
src/components/CodeMirror/index.tsx

@@ -4,10 +4,11 @@ import { basicSetup } from 'codemirror'
 import { EditorView } from '@codemirror/view'
 import { EditorState, StateEffect } from '@codemirror/state'
 import { javascript } from '@codemirror/lang-javascript'
-import { sql } from '@codemirror/lang-sql'
-
+// import { sql } from '@codemirror/lang-sql'
 import { useId } from '@/hooks'
 
+const sql = () => {}
+
 export const CodeMirrorTsx = defineComponent({
   name: 'code-mirror-tsx',
   props: {
@@ -45,7 +46,7 @@ export const CodeMirrorTsx = defineComponent({
       if (props.bodyType === 'javascript') {
         extensions.push(javascript())
       } else if (props.bodyType === 'sql') {
-        extensions.push(sql())
+        // extensions.push(sql())
       }
       const editorState = EditorState.create({
         doc: transDoc(),

+ 33 - 1
src/components/MicroComponents/index.tsx

@@ -1,5 +1,6 @@
 import { defineComponent, ref } from 'vue'
-import { LoadingOutlined, ReloadOutlined } from '@ant-design/icons-vue'
+import { LoadingOutlined, ReloadOutlined, CopyTwoTone } from '@ant-design/icons-vue'
+import { useCopy } from '@/hooks/dom'
 
 /* 此代码导出一个名为“ReloadIconTsx”的 Vue
 组件,该组件显示一个用于重新加载内容的图标。该组件有两个道具:`loading`(一个布尔值,指示内容当前是否正在加载)和`reload`(单击重新加载图标时调用的函数)。该组件使用 Vue
@@ -128,3 +129,34 @@ export const SelectTsx = defineComponent({
 export const InputTsx = defineComponent({
   name: 'input-tsx'
 })
+
+/**
+ * @description 文字copy按钮
+ */
+export const CopyTsx = defineComponent({
+  name: 'copy-tsx',
+  props: {
+    text: {
+      type: String,
+      required: true
+    }
+  },
+  emits: ['success'],
+  setup (props, ctx) {
+    if (!props.text) {
+      console.warn('缺少必备的参数 text')
+    }
+
+    const onCopy = () => {
+      useCopy(props.text)
+    }
+
+    return () => (
+      <a-tooltip
+        title='复制'
+      >
+        <CopyTwoTone style="font-size: 20px;" onClick={onCopy}/>
+      </a-tooltip>
+    )
+  }
+})

+ 2 - 0
src/controller/index.ts

@@ -10,3 +10,5 @@ export { SysController } from './iot/sys'
 export { OtaController } from './iot/ota'
 
 export { UserController } from './user/index'
+
+export { DataSourceController } from './schedule/dataSource'

+ 20 - 21
src/controller/iot/device.ts

@@ -97,8 +97,8 @@ export class DeviceContriller {
   }
 
   static async post (data: IOT.API.DEVICE.BodyParams) {
-    await addDevice(data)
-    message.success('新增成功')
+    const { code } = await addDevice(data)
+    if (code === 200) message.success('新增成功')
   }
 
   static async del (id: string | string[]) {
@@ -127,13 +127,13 @@ export class DeviceContriller {
 
   /** 新增子设备 */
   static async postSub (data: IOT.API.DEVICE.SubBodyParams) {
-    await addSubDevice(data)
-    message.success('新增成功')
+    const { code } = await addSubDevice(data)
+    if (code === 200) message.success('新增成功')
   }
 
   static async delSub (id: string) {
-    await delSubDevice(id)
-    message.success('删除成功')
+    const { code } = await delSubDevice(id)
+    if (code === 200) message.success('删除成功')
   }
 
   static async ListTag (params: {deviceId: number | string}) {
@@ -141,18 +141,18 @@ export class DeviceContriller {
   }
 
   static async delTag (id: string) {
-    await delDeviceTag(id)
-    message.success('删除标签成功')
+    const { code } = await delDeviceTag(id)
+    if (code === 200) message.success('删除标签成功')
   }
 
   static async postTag (data: IOT.API.DEVICE.DeviceTag[]) {
-    await addDeviceTag(data)
-    message.success('新增标签成功')
+    const { code } = await addDeviceTag(data)
+    if (code === 200) message.success('新增标签成功')
   }
 
   static async updateLabel (data: {id: string, deviceLabel: string}) {
-    await updateDeviceLabel(data)
-    message.success('修改设备名称成功')
+    const { code } = await updateDeviceLabel(data)
+    if (code === 200) message.success('修改设备名称成功')
   }
 
   static async count () {
@@ -193,14 +193,14 @@ export class DeviceContriller {
 
   /** 命令下发 新增命令 */
   static async addDeviceCmd (data: { deviceId: string, cmdLabel: string, cmdParameters: any}) {
-    await addDeviceCmd(data)
-    message.success('新增命令成功')
+    const { code } = await addDeviceCmd(data)
+    if (code === 200) message.success('新增命令成功')
   }
 
   /** 设备分组 新增分组 */
   static async postDeviceGroup (data: { groupLabel: string, upperGroupId: string }) {
-    await addDeviceGroup(data)
-    message.success('新增分组成功')
+    const { code } = await addDeviceGroup(data)
+    if (code === 200) message.success('新增分组成功')
   }
 
   /** 设备分组 查询分组 */
@@ -210,8 +210,8 @@ export class DeviceContriller {
 
   /** 设备分组 设备绑定分组 */
   static async postGroupBindDevice (data: { deviceGroupId: string, deviceId: string }[]) {
-    await postGroupBindDevice(data)
-    message.success('绑定成功')
+    const { code } = await postGroupBindDevice(data)
+    if (code === 200) message.success('绑定成功')
   }
 
   /**
@@ -219,8 +219,8 @@ export class DeviceContriller {
  * @param data - 参数 `data` 是一个包含两个属性的对象:
  */
   static async delGroupBindDevice (data: { deviceGroupId: string, deviceId: string }[]) {
-    await delGroupBindDevice(data)
-    message.success('取消绑定成功')
+    const { code } = await delGroupBindDevice(data)
+    if (code === 200) message.success('取消绑定成功')
   }
 
   /**
@@ -266,7 +266,6 @@ export class DeviceContriller {
 
   static async OtaByDeviceId (deviceId: string) {
     const data = await getOtaByDeviceId(deviceId)
-    console.log('data.data.otaPkgLabel:', data.data.otaPkgLabel === '--')
 
     return {
       ...data,

+ 22 - 0
src/controller/schedule/dataSource.ts

@@ -0,0 +1,22 @@
+
+export class DataSourceController {
+  static async dataSource () {
+
+  }
+
+  static async addDataSource () {
+
+  }
+
+  static async updateDataSource () {
+
+  }
+
+  static async delDataSource (id: string) {
+
+  }
+
+  static async dataSourceById () {
+
+  }
+}

+ 17 - 1
src/pages/Iot/device/components/cloudview.vue

@@ -34,6 +34,20 @@
           <template v-if="column.key === 'status'">
             <span>{{ DeviceContriller.deviceMag.get(record.status)?.name }}</span>
           </template>
+          <template v-if="column.key === 'cmdPayload'" >
+            <a-tooltip color="white" :overlayStyle="{width: '800px'}" >
+              <template #title>
+                <a-textarea
+                  :bordered="false"
+                  style="width: 600px;"
+                  :auto-size="{ minRows: 5, maxRows: 15 }"
+                  :value="JSON.stringify(JSON.parse(record.cmdPayload), null, '\t')"
+                  >
+                </a-textarea>
+              </template>
+              {{record.cmdPayload}}
+            </a-tooltip>
+          </template>
           <template v-if="column.key === 'createAt'">
             {{dayjs(record.createAt).format('YYYY-MM-DD HH:mm:ss')}}
           </template>
@@ -164,6 +178,7 @@ import { computed, onMounted, reactive, ref } from 'vue'
 import { useRoute, useRouter } from 'vue-router'
 import { Form, message } from 'ant-design-vue'
 import dayjs from 'dayjs'
+import { CodeMirrorTsx } from '@/components/CodeMirror/index'
 
 const msg = '消息下发不依赖产品模型,平台会以异步方式(消息下发后无需等待设备侧回复响应)下发消息给设备。当前仅MQTT设备支持消息下发。'
 const cmdMsg = '如果设备所属产品定义了命令功能,则您可以通过应用调用平台接口或者操作下面的“下发命令”按钮下发命令。当前MQTT设备仅支持同步命令下发,设备仅支持异步命令下发 。'
@@ -224,7 +239,8 @@ const cmdColumns = [
   },
   {
     title: '消息内容',
-    dataIndex: 'cmdPayload'
+    dataIndex: 'cmdPayload',
+    key: 'cmdPayload'
   },
   {
     title: '消息创建时间',

+ 14 - 3
src/pages/Iot/device/components/overview.vue

@@ -23,14 +23,24 @@
       style="margin-top: 20px;"
     >
         <a-descriptions-item label="设备标识码">{{state.deviceDetail?.deviceStatus}}</a-descriptions-item>
-        <a-descriptions-item label="设备ID">{{state.deviceDetail?.id}}</a-descriptions-item>
+        <a-descriptions-item label="设备ID">
+          <a-space>
+            <span>  {{state.deviceDetail?.id}}</span>
+            <copy-tsx :text="state.deviceDetail?.id!" />
+          </a-space>
+
+        </a-descriptions-item>
         <a-descriptions-item label="认证类型">{{state.deviceDetail?.authType === 'SECRET' ? '密钥认证' : '证书'}}</a-descriptions-item>
         <a-descriptions-item label="设备密钥">
           <a-space>
             <span  >{{ secretState.visible ? secretState.secret : '******' }}</span>
             <span>
-              <eye-invisible-two-tone v-if="secretState.visible" style="font-size: 20px;" @click="secretState.visible = false" />
-              <eye-two-tone v-else style="font-size: 20px;" @click="getSecret" />
+              <a-space>
+                <eye-invisible-two-tone v-if="secretState.visible" style="font-size: 20px;" @click="secretState.visible = false" />
+                <eye-two-tone v-else style="font-size: 20px;" @click="getSecret" />
+                <copy-tsx v-if="secretState.visible" :text="secretState.secret" />
+              </a-space>
+
             </span>
           </a-space>
         </a-descriptions-item>
@@ -85,6 +95,7 @@ import { useRoute } from 'vue-router'
 import dayjs from 'dayjs'
 import { EyeTwoTone, EyeInvisibleTwoTone } from '@ant-design/icons-vue'
 import { message } from 'ant-design-vue'
+import { CopyTsx } from '@/components/MicroComponents/index'
 
 const route = useRoute()
 const deviceId = route.query.id as string

+ 5 - 7
src/pages/Iot/device/group.vue

@@ -285,10 +285,6 @@ const columns = [
   {
     title: '所属产品',
     dataIndex: 'modelLabel'
-  },
-  {
-    title: '操作',
-    key: 'action'
   }
 ]
 
@@ -461,6 +457,8 @@ const bindDevice = async () => {
       deviceGroupId: state.treeActiveKey[0]
     }
   })
+  console.log('params:', params)
+
   await DeviceContriller.postGroupBindDevice(params)
   state.drawerVisible = false
   state.selectedRowKeys = []
@@ -512,8 +510,6 @@ const changeTreeActiveKey = (id: string, e?: TouchEvent) => {
   console.log(state.treeActiveKey)
   getDeviceByGroup()
   state.selectGroup = state.groupData.find(item => item.id === state.treeActiveKey)
-
-  console.log(state.selectGroup)
 }
 
 const addDevicegroup = (e: TouchEvent) => {
@@ -523,10 +519,12 @@ const addDevicegroup = (e: TouchEvent) => {
 
 const getDeviceByGroup = async () => {
   state.tableLoading = true
+  console.log('state.treeActiveKey:', state.treeActiveKey)
+
   const { data, sum } = await DeviceContriller.getDeviceByGroup({
     page: 1,
     pageSize: 200,
-    deviceGroupId: state.treeActiveKey
+    deviceGroupId: typeof state.treeActiveKey === 'object' ? state.treeActiveKey[0] : state.treeActiveKey
   })
   state.tableLoading = false
   state.groupDeviceDataSource = data

+ 3 - 3
src/pages/Iot/device/topology.vue

@@ -161,8 +161,6 @@ const scaleHandle = (event) => {
 window.addEventListener('wheel', scaleHandle)
 
 onUnmounted(() => {
-  console.log('removeEventListener:', 'wheel')
-
   window.removeEventListener('wheel', scaleHandle)
 })
 
@@ -209,12 +207,14 @@ const getDeviceTopology = async () => {
 
   treeData.richMediaData = obj
   state.loading = false
-  console.log('obj:', obj)
 }
 
 const getModelList = async () => {
   const { data } = await ModelController.list()
   state.modelList = data
+  if (data.length) {
+    state.modelId = data[0].id
+  }
 }
 
 onMounted(() => {

+ 3 - 1
src/pages/Iot/model/components/modelDefine.vue

@@ -413,6 +413,8 @@ const okCmdParams = () => {
 }
 
 const confirmDel = async (modalName: 'attr' | 'cmd', id: string) => {
+  console.log('arreId:', id)
+
   modalName === 'attr' ? await ModelAttrController.del(id) : await ModelCmdController.del(id)
   modalName === 'attr' ? getModelAttr() : getModelCmd()
 }
@@ -491,7 +493,7 @@ const getModelAttr = async () => {
   state.dataSource = data.map(item => {
     return {
       ...item,
-      id: item.attributeKey ? item.attributeKey : useId()
+      id: item.id ? item.id : useId()
     }
   })
   state.queryParams.total = sum

+ 8 - 4
src/pages/Iot/model/components/plugins.vue

@@ -49,7 +49,6 @@ import { ref, onMounted, reactive } from 'vue'
 import { ModelCmdController, ModelController } from '@/controller'
 import { useRoute } from 'vue-router'
 import { computed } from '@vue/reactivity'
-import { sql } from '@codemirror/lang-sql'
 
 const placeholder = computed(() => {
   return state.decode
@@ -66,6 +65,8 @@ const route = useRoute()
 
 const modelId = route.query.id as string
 
+const codemirrorRef = ref()
+
 const state = reactive({
   decode: false,
   input: '',
@@ -86,9 +87,12 @@ const debugPlugin = async () => {
 
 const savePlugin = async () => {
   const requestFn = state.pluginId ? ModelController.updatePlugin : ModelController.postPlugin
+  const codeValue = codemirrorRef.value.state.doc.toJSON().join('\n')
+  console.log(codeValue)
+
   await requestFn({
     modelPluginType: 'JS',
-    modelPluginBody: state.modelPluginBody,
+    modelPluginBody: codeValue,
     modelId,
     id: state.pluginId
   })
@@ -134,10 +138,10 @@ onMounted(() => {
 const createView = () => {
   const editorState = EditorState.create({
     doc: state.modelPluginBody,
-    extensions: [basicSetup, javascript(), sql()]
+    extensions: [basicSetup, javascript()]
   })
 
-  const view = new EditorView({
+  codemirrorRef.value = new EditorView({
     state: editorState,
     parent: editorRef.value
   })

+ 3 - 4
src/pages/Iot/model/index.vue

@@ -196,8 +196,8 @@ const router = useRouter()
 const modelRef = reactive({
   modelTemplateId: '',
   modelLabel: '',
-  transportType: '',
-  payloadType: '',
+  transportType: null,
+  payloadType: null,
   deviceType: '',
   modelDescription: '',
   rts: false
@@ -215,7 +215,6 @@ watch(
     if (modelRef.modelTemplateId) {
       formOptions.hideRequiredMark = true
       formOptions.disabled = true
-      console.log(12)
     } else {
       formOptions.hideRequiredMark = false
       formOptions.disabled = false
@@ -262,7 +261,7 @@ const ok = async () => {
       await opraModel()
       state.visible = false
       getModel()
-    })
+    }).catch(() => {})
   }
 }
 

+ 5 - 1
src/pages/Iot/rule/forwardRule.vue

@@ -130,7 +130,7 @@
       <div v-else-if="state.stepCount === 1" >您可以设置将数据转发至华为云其他服务或私有服务器。</div>
     </div>
     <div v-if="state.stepCount == 0">
-      <a-form :label-col="{span: 4 }" :wrapper-col="{ span: 14 }" style="height: 400px; overflow-y: auto;">
+      <a-form :label-col="{span: 4 }" :wrapper-col="{ span: 14 }" style="height: 300px; overflow-y: auto;">
         <a-form-item  label="规则名称" v-bind="validateInfosStep1.ruleLabel" >
           <a-input v-model:value="forwardRStateStep1.ruleLabel" ></a-input>
         </a-form-item>
@@ -1004,4 +1004,8 @@ onMounted(() => {
 })
 </script>
 <style lang='less' scoped >
+
+::v-deep ant-form {
+  height: 200px!;
+}
 </style>

+ 66 - 0
src/pages/schedule/dataSource/manage/index.vue

@@ -1,8 +1,74 @@
 <template>
 <a-card title="数据源管理" >
+
+  <a-row>
+    <a-col></a-col>
+  </a-row>
+
+  <a-table
+      style="margin-top: 10px;"
+      :columns="columns"
+      :data-source="state.dataSource"
+      :loading="state.loading"
+      :pagination="queryState"
+      @change="changePage"
+    >
+    <template #bodyCell="{column, record}">
+        <template v-if="column.key === 'action'" >
+        </template>
+    </template>
+  </a-table>
 </a-card>
 </template>
 <script lang='ts' setup >
+import { DataSourceController } from '@/controller'
+import { reactive, onMounted } from 'vue'
+const columns = [
+  {
+    title: '名称',
+    dataIndex: 'title'
+  },
+  {
+    title: '类型',
+    dataIndex: 'type'
+  },
+  {
+    title: '描述',
+    dataIndex: 'desc'
+  },
+  {
+    title: '操作',
+    dataIndex: 'action',
+    key: 'action'
+  }
+]
+
+const queryState = reactive({
+  page: 1,
+  pageSize: 10,
+  total: 0
+})
+
+const state = reactive({
+  loading: false,
+  dataSource: []
+})
+
+const changePage = ({ current }) => {
+  queryState.page = current
+  getDataSource()
+}
+
+const getDataSource = async () => {
+  state.loading = true
+  const { data } = await DataSourceController.dataSource()
+  state.loading = false
+  state.dataSource = data
+}
+
+onMounted(() => {
+  getDataSource()
+})
 </script>
 <style lang='less' scoped >
 </style>

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

@@ -38,6 +38,7 @@ declare namespace IOT {
 
     namespace MODELATTR {
       interface ModelAttr {
+        id?: string
         attributeKey: string
         attributeLabel: string
         dataType: string