Quellcode durchsuchen

Merge branch 'master' of https://e.coding.net/jiaolongcloud/cloudlink/cloudlink-ui

wang xiao vor 1 Jahr
Ursprung
Commit
3fbab3dd85

+ 28 - 28
src/controller/iot/modelAttr.ts

@@ -1,28 +1,28 @@
-
-import { addModelAttribute, getModelAttribute, updateModelAttribute, delModelAttribute, getModelAttributeList } from '@/api/iot/model'
-import { message } from 'ant-design-vue'
-
-export class ModelAttrController {
-  static async page (params: any) {
-    return await getModelAttribute(params)
-  }
-
-  static async post (data: IOT.API.MODELATTR.ModelAttr & {modelId: string}) {
-    await addModelAttribute(data)
-    message.success('新增成功')
-  }
-
-  static async update (data: IOT.API.MODELATTR.ModelAttr & {modelId: string}) {
-    await updateModelAttribute(data)
-    message.success('修改成功')
-  }
-
-  static async del (id: string) {
-    await delModelAttribute(id)
-    message.success('删除成功')
-  }
-
-  static async list (params: {modelId: string, excludeRts: boolean} = { modelId: '', excludeRts: false }) {
-    return await getModelAttributeList(params)
-  }
-}
+
+import { addModelAttribute, getModelAttribute, updateModelAttribute, delModelAttribute, getModelAttributeList } from '@/api/iot/model'
+import { message } from 'ant-design-vue'
+
+export class ModelAttrController {
+  static async page (params: any) {
+    return await getModelAttribute(params)
+  }
+
+  static async post (data: IOT.API.MODELATTR.ModelAttr & {modelId: string}) {
+    await addModelAttribute(data)
+    message.success('新增成功')
+  }
+
+  static async update (data: IOT.API.MODELATTR.ModelAttr & {modelId: string}) {
+    await updateModelAttribute(data)
+    message.success('修改成功')
+  }
+
+  static async del (id: string) {
+    await delModelAttribute(id)
+    message.success('删除成功')
+  }
+
+  static async list (params: {modelId: string, excludeRts: boolean} = { modelId: '', excludeRts: false }) {
+    return await getModelAttributeList(params)
+  }
+}

+ 30 - 28
src/controller/iot/modelCmd.ts

@@ -1,28 +1,30 @@
-
-import { addModelCmd, getModelCmd, updateModelCmd, delModelCmd, getModelList, getModelCmdLIst } from '@/api/iot/model'
-import { message } from 'ant-design-vue'
-
-export class ModelCmdController {
-  static async page (params: any) {
-    return await getModelCmd(params)
-  }
-
-  static async post (data: IOT.API.CMD.Cmd) {
-    await addModelCmd(data)
-    message.success('新增成功')
-  }
-
-  static async update (data: IOT.API.CMD.Cmd) {
-    await updateModelCmd(data)
-    message.success('修改成功')
-  }
-
-  static async del (id: string) {
-    await delModelCmd(id)
-    message.success('删除成功')
-  }
-
-  static async list (params: {modelId: string}) {
-    return await getModelCmdLIst(params)
-  }
-}
+
+import { addModelCmd, getModelCmd, updateModelCmd, delModelCmd, getModelList, getModelCmdLIst } from '@/api/iot/model'
+import { message } from 'ant-design-vue'
+
+export class ModelCmdController {
+  static cmdTypes = [{ key: 'DEFAULT', label: '默认', value: 'DEFAULT' }, { key: 'THIRD_SERVICE', label: '第三方服务', value: 'THIRD_SERVICE' }]
+
+  static async page (params: any) {
+    return await getModelCmd(params)
+  }
+
+  static async post (data: IOT.API.CMD.Cmd) {
+    await addModelCmd(data)
+    message.success('新增成功')
+  }
+
+  static async update (data: IOT.API.CMD.Cmd) {
+    await updateModelCmd(data)
+    message.success('修改成功')
+  }
+
+  static async del (id: string) {
+    await delModelCmd(id)
+    message.success('删除成功')
+  }
+
+  static async list (params: {modelId: string}) {
+    return await getModelCmdLIst(params)
+  }
+}

+ 150 - 143
src/pages/Iot/dataServer/history.vue

@@ -1,143 +1,150 @@
-<template>
-<a-card>
-  <a-row>
-    <a-col>
-      <a-space>
-
-        <a-select allowClear v-model:value="queryParams.modelId" placeholder="请选择产品" style="width: 170px;" >
-          <a-select-option
-            v-for="item in state.modelList"
-            :key="item.id"
-            :value="item.id"
-          >
-            {{item.modelLabel}}
-          </a-select-option>
-        </a-select>
-
-        <a-select allowClear v-model:value="queryParams.deviceId" placeholder="请选择设备" style="width: 170px;" >
-          <a-select-option
-            v-for="item in state.deviceList"
-            :key="item.id"
-            :value="item.id"
-          >
-            {{item.deviceLabel}}
-          </a-select-option>
-        </a-select>
-
-        <a-range-picker v-model:value="time" :format="['DD/MM/YYYY', 'DD/MM/YYYY']"  />
-        <a-button type="primary"  @click="getHistoryPage">搜索</a-button>
-      </a-space>
-
-    </a-col>
-  </a-row>
-  <a-table
-    style="margin-top: 20px;"
-    :columns="columns"
-    :loading="state.loading"
-    :data-source="state.dataSource"
-    :pagination="queryParams"
-    @change="changePage"
-  >
-
-  </a-table>
-</a-card>
-</template>
-<script lang='ts' setup >
-import { DeviceContriller, ModelController } from '@/controller'
-import { DataController } from '@/controller/iot/data'
-import { onMounted, reactive, ref, watch } from 'vue'
-import dayjs from 'dayjs'
-
-const columns = [
-  {
-    title: '设备ID',
-    dataIndex: 'deviceId'
-  },
-  {
-    title: 'key',
-    dataIndex: 'key'
-  },
-  {
-    title: 'keyLabel',
-    dataIndex: 'keyLabel'
-  },
-  {
-    title: '结果',
-    dataIndex: 'value'
-  },
-  {
-    title: '单位',
-    dataIndex: 'dataUnit'
-  }
-]
-
-const time = ref([])
-
-const queryParams = reactive({
-  page: 1,
-  pageSize: 10,
-  total: 0,
-  deviceId: null,
-  modelId: null,
-  attributeKey: '',
-  startTime: '',
-  endTime: ''
-})
-
-const state = reactive<{
-  loading: boolean,
-  dataSource: IOT.API.DATA.History[],
-  modelList: IOT.API.MODEL.Model[]
-  deviceList: IOT.API.DEVICE.Device[]
-}>({
-  loading: false,
-  dataSource: [],
-  modelList: [],
-  deviceList: []
-})
-
-watch(
-  () => time.value,
-  () => {
-    if (time.value && time.value.length === 2) {
-      queryParams.startTime = new Date(dayjs(time.value[0])).getTime()
-      queryParams.endTime = new Date(dayjs(time.value[1])).getTime()
-    } else {
-      queryParams.startTime = ''
-      queryParams.endTime = ''
-    }
-  }
-)
-
-const changePage = ({ current }) => {
-  queryParams.page = current
-  getHistoryPage()
-}
-
-const getDeviceList = async () => {
-  const { data } = await DeviceContriller.list()
-  state.deviceList = data
-}
-
-const getModelList = async () => {
-  const { data: modelData } = await ModelController.list()
-  state.modelList = modelData
-}
-
-const getHistoryPage = async () => {
-  state.loading = true
-
-  const { data: historyData, sum } = await DataController.pageHistory(queryParams)
-  state.loading = false
-  state.dataSource = historyData
-  queryParams.total = sum
-}
-
-onMounted(() => {
-  getModelList()
-  getDeviceList()
-})
-
-</script>
-<style lang='less' scoped >
-</style>
+<template>
+<a-card>
+  <a-row>
+    <a-col span="20" >
+      <a-space>
+        <a-select allowClear v-model:value="queryParams.modelId" placeholder="请选择产品" style="width: 170px;" >
+          <a-select-option
+            v-for="item in state.modelList"
+            :key="item.id"
+            :value="item.id"
+          >
+            {{item.modelLabel}}
+          </a-select-option>
+        </a-select>
+
+        <a-select allowClear v-model:value="queryParams.deviceId" placeholder="请选择设备" style="width: 170px;" >
+          <a-select-option
+            v-for="item in state.deviceList"
+            :key="item.id"
+            :value="item.id"
+          >
+            {{item.deviceLabel}}
+          </a-select-option>
+        </a-select>
+
+        <a-range-picker v-model:value="time" :format="['DD/MM/YYYY', 'DD/MM/YYYY']"  />
+        <a-button type="primary"  @click="getHistoryPage">搜索</a-button>
+      </a-space>
+    </a-col>
+    <a-col span="2" >
+      <a-button @click="exportExcel" >导出</a-button>
+    </a-col>
+  </a-row>
+  <a-table
+    style="margin-top: 20px;"
+    :columns="columns"
+    :loading="state.loading"
+    :data-source="state.dataSource"
+    :pagination="queryParams"
+    @change="changePage"
+  >
+
+  </a-table>
+</a-card>
+</template>
+<script lang='ts' setup >
+import { DeviceContriller, ModelController } from '@/controller'
+import { DataController } from '@/controller/iot/data'
+import { onMounted, reactive, ref, watch } from 'vue'
+import dayjs from 'dayjs'
+import { useExportExcel } from '@/hooks'
+
+const columns = [
+  {
+    title: '设备ID',
+    dataIndex: 'deviceId'
+  },
+  {
+    title: 'key',
+    dataIndex: 'key'
+  },
+  {
+    title: 'keyLabel',
+    dataIndex: 'keyLabel'
+  },
+  {
+    title: '结果',
+    dataIndex: 'value'
+  },
+  {
+    title: '单位',
+    dataIndex: 'dataUnit'
+  }
+]
+
+const time = ref([])
+
+const queryParams = reactive({
+  page: 1,
+  pageSize: 10,
+  total: 0,
+  deviceId: null,
+  modelId: null,
+  attributeKey: '',
+  startTime: '',
+  endTime: ''
+})
+
+const state = reactive<{
+  loading: boolean,
+  dataSource: IOT.API.DATA.History[],
+  modelList: IOT.API.MODEL.Model[]
+  deviceList: IOT.API.DEVICE.Device[]
+}>({
+  loading: false,
+  dataSource: [],
+  modelList: [],
+  deviceList: []
+})
+
+watch(
+  () => time.value,
+  () => {
+    if (time.value && time.value.length === 2) {
+      queryParams.startTime = new Date(dayjs(time.value[0])).getTime()
+      queryParams.endTime = new Date(dayjs(time.value[1])).getTime()
+    } else {
+      queryParams.startTime = ''
+      queryParams.endTime = ''
+    }
+  }
+)
+
+const exportExcel = async () => {
+  const { data } = await DataController.exportHistoryExecel(queryParams)
+  useExportExcel(data, '历史数据')
+}
+
+const changePage = ({ current }) => {
+  queryParams.page = current
+  getHistoryPage()
+}
+
+const getDeviceList = async () => {
+  const { data } = await DeviceContriller.list()
+  state.deviceList = data
+}
+
+const getModelList = async () => {
+  const { data: modelData } = await ModelController.list()
+  state.modelList = modelData
+}
+
+const getHistoryPage = async () => {
+  state.loading = true
+
+  const { data: historyData, sum } = await DataController.pageHistory(queryParams)
+  state.loading = false
+  state.dataSource = historyData
+  queryParams.total = sum
+}
+
+onMounted(() => {
+  getModelList()
+  getDeviceList()
+})
+
+</script>
+<style lang='less' scoped >
+</style>

+ 1 - 1
src/pages/Iot/device/index.vue

@@ -271,7 +271,7 @@ const { resetFields: resetFieldsDevice, validate: validateDevice, validateInfos:
 
 const exportExcel = async () => {
   const { data } = await DeviceContriller.exportDeviceExcel(searchState)
-  useExportExcel(data, '测试')
+  useExportExcel(data, '设备列表')
 }
 
 const changePage = ({ current }) => {

+ 25 - 11
src/pages/Iot/model/components/modelDefine.vue

@@ -101,6 +101,11 @@
           <a-select-option :value="item.value" v-for="item in dataTypes" :key="item.value" >{{item.label}}</a-select-option>
         </a-select>
       </a-form-item>
+      <a-form-item label="命令类型" v-bind="validateInfos.cmdType" >
+        <a-select allowClear v-model:value="attrRef.cmdType" >
+          <a-select-option :value="item.value" v-for="item in dataTypes" :key="item.value" >{{item.label}}</a-select-option>
+        </a-select>
+      </a-form-item>
       <a-form-item label="访问权限" v-bind="validateInfos.scope" >
         <a-checkbox-group v-model:value="attrRef.scope" name="checkboxgroup" :options="[{label: '读', value: 'R'}, {label: '写', value: 'W'}]" />
       </a-form-item>
@@ -123,11 +128,18 @@
     cancel-text="取消"
   >
     <a-form :label-col="{span: 4}" :wrapper-col="{span: 18}" >
-      <a-form-item label="命令编码" v-bind="validateInfosCmd.attributeLabel" >
+      <a-form-item label="命令名称" v-bind="validateInfosCmd.cmdLabel" >
+        <a-input allowClear v-model:value="cmdRef.cmdLabel"  />
+      </a-form-item>
+      <a-form-item label="命令编码" v-bind="validateInfosCmd.cmdCode" >
         <a-input allowClear v-model:value="cmdRef.cmdCode"  />
       </a-form-item>
-      <a-form-item label="命令名称" v-bind="validateInfosCmd.attributeLabel" >
-        <a-input allowClear v-model:value="cmdRef.cmdLabel"  />
+      <a-form-item label="命令类型" >
+        <a-select allowClear v-model:value="cmdRef.cmdType" >
+          <a-select-option :value="item.value" v-for="item in ModelCmdController.cmdTypes" :key="item.key" >
+            {{item.label}}
+          </a-select-option>
+        </a-select>
       </a-form-item>
       <a-form-item label="下发参数">
         <a-row style="width: 100%;">
@@ -392,7 +404,8 @@ const cmdRef = reactive({
   cmdParams: [],
   cmdResponses: [],
   modelId: '',
-  canRemove: false
+  canRemove: false,
+  cmdType: 'DEFAULT'
 })
 
 const cmdParamsRef = reactive({
@@ -410,14 +423,15 @@ const { resetFields, validate: validateAttr, validateInfos } = useForm(attrRef,
   scope: [{ required: true, message: '请选择访问权限' }]
 }))
 
-const { resetFields: resetFieldsCmd, validate: validateCmd, validateInfos: validateInfosCmd } = useForm(cmdRef, {
-  cmdLabel: [{ require: true, message: '请填写模型命令' }]
-})
+const { resetFields: resetFieldsCmd, validate: validateCmd, validateInfos: validateInfosCmd } = useForm(cmdRef, reactive({
+  cmdLabel: [{ required: true, message: '请填写模型命令' }],
+  cmdCode: [{ required: true, message: '请填写模型code' }]
+}))
 
-const { resetFields: resetFieldsCmdP, validate: validateCmdP, validateInfos: validateInfosCmdP } = useForm(cmdParamsRef, {
-  paramCode: [{ require: true, message: '请填写参数名称' }],
-  dataType: [{ require: true, message: '请选择数据类型' }]
-})
+const { resetFields: resetFieldsCmdP, validate: validateCmdP, validateInfos: validateInfosCmdP } = useForm(cmdParamsRef, reactive({
+  paramCode: [{ required: true, message: '请填写参数code' }],
+  dataType: [{ required: true, message: '请选择数据类型' }]
+}))
 
 const changeAttrPage = ({ current }) => {
   state.queryParams.page = current

+ 1 - 0
src/pages/Iot/rule/linkRules.vue

@@ -54,6 +54,7 @@
     :open="state.visible"
     @cancel="state.visible = false"
     @ok="ok"
+    footer
   >
       <a-card
         title="基本信息"