Kaynağa Gözat

adm:feat> 添加设备接口替换

onlyh 3 yıl önce
ebeveyn
işleme
822af7a9ab

+ 9 - 1
src/api/datacenter.ts

@@ -2,6 +2,7 @@
  * 数据中台通用接口文档
  */
 import httputils from "@/api/httputils";
+
 const baseApi = "/datacenter";
 
 // 创建项目
@@ -67,6 +68,12 @@ export function createEquip(postParams: any): any {
     return httputils.postJson(`${baseApi}/object/equip/create`, postParams)
 }
 
+// 统计所有的设备类型
+export function allDevices(postParams: any) {
+    return httputils.postJson(`${baseApi}/dict/category`, postParams)
+
+}
+
 // 更新设备信息
 export function updateEquip(postParams: any): any {
     return httputils.postJson(`${baseApi}/object/equip/update`, postParams)
@@ -178,6 +185,7 @@ export function updateCalcTime(getParams: any) {
     const url = `${baseApi}/rel/graphic/updateCalcTime?graphCode=${getParams.graphCode}&relType=${getParams.relType}&computingTime=${getParams.computingTime}`
     return httputils.getJson(url, {})
 }
+
 // execl上传
 export function importGrahpic(postParams: any) {
     return httputils.postJson(`${baseApi}/rel/graphic/import`, postParams)
@@ -187,4 +195,4 @@ export function importGrahpic(postParams: any) {
 export function exportGraphic(getParams: any) {
     const url = `${baseApi}/rel/graphic/export`
     return httputils.getJson(url, getParams)
-}
+}

+ 14 - 9
src/api/equipComponent.ts

@@ -1,37 +1,42 @@
 import httputils from "@/api/httputils";
+
 const baseUrl = '/equip-component'
 const rwd = '/rwd'
 
 //类型下信息点
 export function dictInfo(params: any): any {
-    return httputils.getJson(`${ baseUrl }/dict/equip/info?category=${ params.category }`, {})
+    return httputils.getJson(`${baseUrl}/dict/equip/info?category=${params.category}`, {})
 }
 
 //所有设备类型
 export function dictType(params: any): any {
-    return httputils.getJson(`${ baseUrl }/dict/equip/type`, {})
+    return httputils.getJson(`${baseUrl}/dict/equip/type`, {})
 }
 
 
 //获取设定参数和动态参数
 export function BeatchQueryParam(param: any) {
-    let url = `${ rwd }/iot/data/current?projectId=${ param.projectId }&groupCode=${ param.groupCode }&appId=${ param.appId }`
+    let url = `${rwd}/iot/data/current?projectId=${param.projectId}&groupCode=${param.groupCode}&appId=${param.appId}`
     let data = param.data
     return httputils.postJson(url, data)
 }
 
 // 统计项目已有的设备类型
-export function allDevice(param:any) {
-    return httputils.getJson(`${ baseUrl }/dict/project/equip/type`, {})
+export function allDevice(param: any) {
+    return httputils.getJson(`${baseUrl}/dict/project/equip/type`, {})
 
 }
+
+
 // 统计项目已有的系统类型
-export function allSystem(param:any) {
-    return httputils.getJson(`${ baseUrl }/dict/project/system/type`, {})
+export function allSystem(param: any) {
+    return httputils.getJson(`${baseUrl}/dict/project/system/type`, {})
 
 }
+
 // 统计所有的系统类型
-export function allSystems(param:any) {
-    return httputils.getJson(`${ baseUrl }/dict/system/type`, {})
+export function allSystems(param: any) {
+    return httputils.getJson(`${baseUrl}/dict/system/type`, {})
 
 }
+

+ 1 - 1
src/utils/maintain.ts

@@ -1,7 +1,7 @@
 export const tools = {
     //根据key值去对象中取对应的值
     dataForKey: function (data: any, key: any) {
-        let arr = key.split(".")
+        const arr = key.split(".")
         if (arr && arr[0]) {
             for (let i = 0; i < arr.length; i++) {
                 if (arr[i] && data[arr[i]]) {

+ 18 - 8
src/views/maintain/device/index.vue

@@ -49,7 +49,7 @@
                     <template v-if="next">
                         <div class="align " :style="{ 'height': isWidth ? '400px':'200px' }">
                             <span class="text ">设备类别</span>
-                            <el-cascader :options="list" clearable v-model="deviceVal"
+                            <el-cascader :options="addlist" clearable v-model="deviceVal"
                                          :props="optionProps"
                                          class="adm-select"></el-cascader>
                         </div>
@@ -97,7 +97,7 @@
 import {Component, Vue, Watch} from "vue-property-decorator";
 import {AdmMultiTable, AdmSearch, dataForm, Pagination, Statistics} from '../components/index'
 import {allDevice, BeatchQueryParam, dictInfo} from "@/api/equipComponent";
-import {createEquip, queryCount, queryEquip, updateEquip, deleteEquip} from "@/api/datacenter";
+import {createEquip, queryCount, queryEquip, updateEquip, deleteEquip, allDevices} from "@/api/datacenter";
 import {UserModule} from "@/store/modules/user";
 import deviceGraph from "./components/deviceGraph.vue"
 import tools from "@/utils/maintain"
@@ -141,6 +141,8 @@ export default class extends Vue {
     inputSearch = ''
     // 下拉数据
     list = []
+    // 添加设备下拉数据
+    addlist = []
     // 弹窗开关
     dialogVisible = false
     // tabs数据
@@ -177,6 +179,11 @@ export default class extends Vue {
         return UserModule.projectId
     }
 
+    // 获取级联的最后一项
+    get deviceTypeEnd() {
+        return this.deviceType[this.deviceType.length - 1]
+    }
+
     created() {
         this.deviceList();
         this.dataCount()
@@ -198,13 +205,13 @@ export default class extends Vue {
     }
 
     handleChangeDevice() {
-        if (this.deviceType[2]) {
+        if (this.deviceTypeEnd) {
             this.loading = true
             let param = {
-                category: this.deviceType[2]
+                category: this.deviceTypeEnd
             }
             let param2 = {
-                filters: this.deviceType[2] ? `classCode='${this.deviceType[2]}'` : undefined,
+                filters: this.deviceTypeEnd ? `classCode='${this.deviceTypeEnd}'` : undefined,
                 pageNumber: this.paginationList.page,
                 pageSize: this.paginationList.size,
                 orders: "createTime desc, id asc",
@@ -408,19 +415,19 @@ export default class extends Vue {
     // 搜索
     SearchValue(val: string) {
         this.inputSearch = val
-        this.handleChangeDevice(this.deviceType[2])
+        this.handleChangeDevice(this.deviceTypeEnd)
     }
 
     // 当前分页
     handleCurrentChange(val: number) {
         console.log(val)
         this.paginationList.page = val
-        this.handleChangeDevice(this.deviceType[2])
+        this.handleChangeDevice(this.deviceTypeEnd)
     }
 
     handleSizeChange(val: number) {
         this.paginationList.size = val
-        this.handleChangeDevice(this.deviceType[2])
+        this.handleChangeDevice(this.deviceTypeEnd)
     }
 
     // 添加设备
@@ -428,6 +435,9 @@ export default class extends Vue {
         this.deviceMsg = '添加设备'
         this.dialogVisible = true
         this.currRowContent = {}
+        allDevices({"type": "systemEquipment"}).then(res => {
+            this.addlist = res.content
+        })
     }