소스 검색

fix: 若干问题

lvkun 2 년 전
부모
커밋
7f49e88e70
5개의 변경된 파일27개의 추가작업 그리고 24개의 파일을 삭제
  1. 9 15
      src/pages/Iot/device/analysis.vue
  2. 7 3
      src/pages/Iot/device/index.vue
  3. 5 0
      src/pages/Iot/model/index.vue
  4. 5 5
      src/pages/Iot/rule/forwardRule.vue
  5. 1 1
      src/router/index.ts

+ 9 - 15
src/pages/Iot/device/analysis.vue

@@ -1,12 +1,17 @@
 <template>
-
+  <statistics-template
+    title="上下线统计"
+    :list="[{value: 20, color: 'green', label: '上线次数'}, {value: 20, color: 'red', label: '下线次数'}]"
+  />
   <a-card
+    style="margin-top: 20px;"
     title="设备分析"
     :tab-list="tabListNoTitle"
     :active-tab-key="activeTabKey"
     @tabChange="key => onTabChange(key)"
   >
     <a-row :gutter="[8, 8]" style="margin-top: 20px;" >
+
         <a-col :span="24" >
           <a-space>
             <a-spin
@@ -22,7 +27,6 @@
                 :filter-option="false"
                 :not-found-content="null"
                 :options="state.dataSource"
-                @change="selectDevice"
                 @search="getDeviceLabel"
               >
                 <template v-if="state.fetching" #notFoundContent>
@@ -30,7 +34,7 @@
                 </template>
               </a-select>
             </a-spin>
-            <a-range-picker  :value="getDateBeforeByHalf" @change="changeRangePicker" format="YYYY/MM/DD"  />
+            <a-range-picker  @change="changeRangePicker" format="YYYY/MM/DD"  />
           </a-space>
         </a-col>
         <a-col :span="24">
@@ -70,6 +74,7 @@ import * as echarts from 'echarts'
 import { useRoute } from 'vue-router'
 import { sessionEchartsJson, attrEchartsJson, scatterOption, barOption, calculateAverage } from './json/echartsJson'
 import dayjs from 'dayjs'
+import StatisticsTemplate from '@/components/StatisticsTemplate'
 
 const tabListNoTitle = [{
   key: 'session',
@@ -117,14 +122,7 @@ watch(
 )
 
 // 获取当前时间到半小时之前
-const getDateBeforeByHalf = () => {
-  const curTimeStamp = new Date().getTime()
-
-  const halfHourTimeStampBefore = curTimeStamp - 60 * 30 * 1000
-  return [dayjs(curTimeStamp), dayjs(halfHourTimeStampBefore)]
-}
-
-console.log(getDateBeforeByHalf())
+// const get
 
 // watch(
 //   () => state.attrSource,
@@ -207,10 +205,6 @@ const changeRangePicker = (time) => {
   activeTabKey.value === 'session' ? getDeviceSession() : getDeviceAttr()
 }
 
-const selectDevice = () => {
-
-}
-
 const getDeviceLabel = async (val: string) => {
   console.log('val:', val)
   if (!val) return

+ 7 - 3
src/pages/Iot/device/index.vue

@@ -135,12 +135,16 @@ import { DeviceContriller, ModelController } from '@/controller/index'
 import { onMounted, reactive, ref, toRefs, nextTick, computed, watch } from 'vue'
 import { Form, message } from 'ant-design-vue'
 import { DeviceAuthTypeEnum } from '@/enum/common'
-import { useRouter } from 'vue-router'
+import { useRoute, useRouter } from 'vue-router'
 import { DownOutlined } from '@ant-design/icons-vue'
 
 const useForm = Form.useForm
 const router = useRouter()
 
+const modelId = (useRoute().query.modelId || '') as string
+
+console.log('modelId:', modelId)
+
 const columns = [
   {
     title: '设备ID',
@@ -215,7 +219,7 @@ const state = reactive<{
   analysisVisible: boolean
   analysisType: 'session' | 'attr' | ''
 }>({
-  modelId: '',
+  modelId: modelId,
   deviceCount: [],
   dataSource: [],
   modelList: [],
@@ -231,7 +235,7 @@ const searchState = reactive({
   pageSize: 10,
   total: 0,
   deviceStatus: '',
-  modelId: '',
+  modelId: modelId,
   searchKey: 'deviceId',
   searchValue: '',
   showSizeChanger: false

+ 5 - 0
src/pages/Iot/model/index.vue

@@ -50,6 +50,7 @@
           <template v-if="column.key === 'action'">
             <a-space>
               <a @click="goDetailPage(record.id)" >查看</a>
+              <a  @click="goDevicePage(record.id)">管理</a>
                 <a-popconfirm
                   title="确实要删除吗?"
                   ok-text="确定"
@@ -236,6 +237,10 @@ watch(
 
 const { resetFields, validate, validateInfos } = useForm(modelRef, rulesRef)
 
+const goDevicePage = (id: string) => {
+  router.push({ path: '/device/index', query: { modelId: id } })
+}
+
 // 获取产品模型库列表
 const getModelTemplateList = async () => {
   const { data } = await ModelController.modelTemplate({

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

@@ -8,17 +8,17 @@
     <a-col :span="18" >
     <a-form style="width: 100%;"  :label-col="{span: 6}" :wrapper-col="{span: 16}" >
       <a-row style="width: 100%" :gutter="[8, 8]" >
-        <a-col :span="7" >
+        <a-col :xs="20" :md="12" :xl="7">
           <a-form-item label="规则ID" >
             <a-input allowClear v-model:value="queryParams.ruleId" placeholder="请输入规则id"></a-input>
           </a-form-item>
         </a-col>
-        <a-col :span="7">
+        <a-col :xs="20" :md="12" :xl="7">
           <a-form-item label="规则名称" >
               <a-input allowClear v-model:value="queryParams.ruleLabel" placeholder="请输入规则名称" ></a-input>
             </a-form-item>
         </a-col>
-        <a-col :span="7" >
+        <a-col :xs="20" :md="12" :xl="7" >
           <a-form-item label="数据来源" >
               <a-select allowClear v-model:value="queryParams.subjectResource"    placeholder="选择数据来源">
                 <a-select-option
@@ -31,7 +31,7 @@
               </a-select>
             </a-form-item>
         </a-col>
-        <a-col :span="7" >
+        <a-col :xs="20" :md="12" :xl="7" >
           <a-form-item label="触发事件" >
               <a-select allowClear v-model:value="queryParams.subjectEvent"  placeholder="选择触发事件">
                 <a-select-option
@@ -44,7 +44,7 @@
               </a-select>
             </a-form-item>
         </a-col>
-        <a-col :span="7" >
+        <a-col :xs="20" :md="12" :xl="7" >
           <a-form-item label="状态" >
               <a-select allowClear v-model:value="queryParams.status" >
                 <a-select-option

+ 1 - 1
src/router/index.ts

@@ -377,7 +377,7 @@ const demo = {
   component: () => import('@/pages/demo/index.vue')
 }
 
-const _routes = [iot, rts, schedule, view, lowcode, user, demo] as any
+const _routes = [iot, rts, schedule, view, lowcode, user] as any
 // const _routes = [iot] as any
 
 if (_routes[0].link) {