修改问题

master
夜笙歌 2 days ago
parent 1eddf7e7ee
commit 3bdd9bf39d

@ -170,8 +170,13 @@ export default {
}, },
dataChange() { dataChange() {
this.pieData = this.networkData[this.defaultData.configForm.data] this.pieData = this.networkData[this.defaultData.configForm.data]
let keys = []
this.pieData.forEach(ee=>{
keys = [...new Set(keys.concat(Object.keys(ee)))]
})
console.log('this.pieData', this.pieData) console.log('this.pieData', this.pieData)
this.option = Object.keys(this.pieData?.[0]).map(e => { this.option = keys.map(e => {
return { return {
value: e, value: e,
label: e label: e

@ -127,7 +127,11 @@ export default {
}, },
dataChange() { dataChange() {
this.tableData = this.networkData[this.defaultData.tableDataKey] this.tableData = this.networkData[this.defaultData.tableDataKey]
let keys = Object.keys(this.tableData?.[0] || {})
let keys = []
this.tableData.forEach(ee=>{
keys = [...new Set(keys.concat(Object.keys(ee)))]
})
this.tdkeys = keys this.tdkeys = keys
} }
}, },

@ -486,16 +486,18 @@ export default {
}, },
testDeviceConnection(i, k) { testDeviceConnection(i, k) {
this.$set(this.requests[k], 'connectionStatus', 0) this.$set(this.requests[k], 'connectionStatus', 0)
getHistoryData({ this.$getDeviceData({
deviceModeId: i.deviceModeId, deviceModeId: i.deviceModeId,
functionIdentifier: i.functionIdentifier, functionIdentifier: i.functionIdentifier,
interval: i.interval, interval: i.interval,
isRealTime:i.isRealTime,
"sceneId": 144, "sceneId": 144,
"deviceId": i.deviceId, "deviceId": i.deviceId,
startTime: i.startTime, startTime: i.startTime,
endTime: i.endTime, endTime: i.endTime,
intervalType: 1 || i.intervalType, intervalType: 1 || i.intervalType,
}).then(e => { }).then(e => {
console.log('eee',e)
// this.$set(this.requests[k], 'connectionStatus', e.status ? 1 : 2) // this.$set(this.requests[k], 'connectionStatus', e.status ? 1 : 2)
this.$set(this.requests[k], 'connectionStatus', e.code === 200 ? 1 : 2) this.$set(this.requests[k], 'connectionStatus', e.code === 200 ? 1 : 2)
this.$set(this.requests[k], 'request', e.data) this.$set(this.requests[k], 'request', e.data)
@ -602,8 +604,9 @@ export default {
}, },
async setDeviceMapping(i, k) { async setDeviceMapping(i, k) {
if (!this.requests?.[k]?.request) { if (!this.requests?.[k]?.request) {
await getHistoryData({ await this.$getDeviceData({
deviceModeId: i.deviceModeId, deviceModeId: i.deviceModeId,
isRealTime:i.isRealTime,
functionIdentifier: i.functionIdentifier, functionIdentifier: i.functionIdentifier,
interval: i.interval, interval: i.interval,
"sceneId": 144, "sceneId": 144,
@ -637,11 +640,18 @@ export default {
children: fun(v[e]) children: fun(v[e])
} }
} else { } else {
let keys = []
if(Array.isArray(v[e])){
v[e].forEach(ee=>{
keys = [...new Set(keys.concat(Object.keys(ee)))]
})
}
console.log('keys',keys)
return { return {
value: e, value: e,
label: e, label: e,
type: Array.isArray(v[e]) ? 'Array' : 'String', type: Array.isArray(v[e]) ? 'Array' : 'String',
enum: Array.isArray(v[e]) ? Object.keys(v[e]?.[0] || {}) : [], enum: Array.isArray(v[e]) ? keys : [],
} }
} }
}) })
@ -649,6 +659,7 @@ export default {
let option = fun(data) let option = fun(data)
this.options = option this.options = option
console.log('option',option)
if (this.mappingForm.isArray) { if (this.mappingForm.isArray) {
this.mappingChange() this.mappingChange()
} }

@ -50,7 +50,8 @@ import {
clearArrNull, clearArrNull,
clearNull, clearNull,
getFinalData, getFinalData,
testColor testColor,
getDeviceData
} from '@/utils/scrin' } from '@/utils/scrin'
import request from '@/utils/request' import request from '@/utils/request'
@ -75,6 +76,7 @@ Vue.prototype.$request = request
Vue.prototype.$detectingNullValues = detectingNullValues Vue.prototype.$detectingNullValues = detectingNullValues
Vue.prototype.$getFinalData = getFinalData Vue.prototype.$getFinalData = getFinalData
Vue.prototype.$testColor = testColor Vue.prototype.$testColor = testColor
Vue.prototype.$getDeviceData = getDeviceData
// 全局组件挂载 // 全局组件挂载
Vue.component('DictTag', DictTag) Vue.component('DictTag', DictTag)

@ -2,6 +2,148 @@ import {interfaceRequest} from "@/components/networkRequest/requestSend";
import {getHistoryData} from "@/api/configuration/equipment"; import {getHistoryData} from "@/api/configuration/equipment";
import Vue from 'vue' import Vue from 'vue'
const getDeviceData = async (data) => {
let getTime = (e) => {
if (e === '1') {
return [(new Date().getTime() - (1000 * 60 * 60 * 24)), (new Date().getTime())]
}
if (e === '2') {
return [(new Date().getTime() - (1000 * 60 * 60 * 24)), (new Date().getTime())]
}
if (e === '3') {
return [(new Date().getTime() - (1000 * 60 * 60 * 24 * 7)), (new Date().getTime())]
}
if (e === '4') {
return [(new Date().getTime() - (1000 * 60 * 60 * 24 * 30)), (new Date().getTime())]
}
if (e === '5') {
return [(new Date().getTime() - (1000 * 60 * 60 * 24 * 365)), (new Date().getTime())]
}
}
const getTimeList = (e, isRealTime, startTimeArg, endTimeArg) => {
let startTime, endTime
if (!isRealTime) {
startTime = startTimeArg
endTime = endTimeArg
} else {
startTime = getTime(e)[0]
endTime = getTime(e)[1]
}
if (e === '1') {
let scope = Math.ceil((endTime - startTime) / (1000 * 60 * 60)) || 0
let arr = Array(scope).fill(1).map((v, k) => {
return parseTime(endTime - (1000 * 60 * 60) * k, '{y}-{m}-{d} {h}:{i}')
})
return arr.reverse()
}
if (e === '2') {
let scope = Math.ceil((endTime - startTime) / (1000 * 60 * 60)) || 0
let arr = Array(scope).fill(1).map((v, k) => {
return parseTime(endTime - (1000 * 60 * 60) * k, '{y}-{m}-{d} {h}')
})
return arr.reverse()
}
if (e === '3') {
let scope = Math.ceil((endTime - startTime) / (1000 * 60 * 60 * 24)) || 0
let arr = Array(scope).fill(1).map((v, k) => {
return parseTime(endTime - (1000 * 60 * 60 * 24) * k, '{y}-{m}-{d}')
})
return arr.reverse()
}
if (e === '4') {
let scope = Math.ceil((endTime - startTime) / (1000 * 60 * 60 * 24)) || 0
let arr = Array(scope).fill(1).map((v, k) => {
return parseTime(endTime - (1000 * 60 * 60 * 24) * k, '{y}-{m}-{d}')
})
return arr.reverse()
}
if (e === '5') {
let scope = Math.ceil((endTime - startTime) / (1000 * 60 * 60 * 24 * 30)) || 0
let arr = Array(scope).fill(1).map((v, k) => {
return parseTime(endTime - (1000 * 60 * 60 * 24 * 30) * k, '{y}-{m}')
})
return arr.reverse()
}
}
const res2 = await getHistoryData({
deviceModeId: data.deviceModeId,
functionIdentifier: data.functionIdentifier,
interval: data.interval,
"sceneId": 144,
"deviceId": data.deviceId,
startTime: data.isRealTime ? getTime(data.interval)?.[0] : data.startTime,
endTime: data.isRealTime ? getTime(data.interval)?.[1] : data.endTime,
intervalType: 1 || data.intervalType,
})
if (data.isRealTime) {
if (data.interval === '1') {
let arr = getTimeList(data.interval, data.isRealTime)
res2.data.groupDeviceData.dataList = arr.map(v => {
let data = res2.data.groupDeviceData.dataList.find(vv => parseTime(vv.time, '{y}-{m}-{d} {h}:{i}') === v)
return {...data, time: v}
})
}
if (data.interval === '2') {
let arr = getTimeList(data.interval, data.isRealTime)
res2.data.groupDeviceData.dataList = arr.map(v => {
let data = res2.data.groupDeviceData.dataList.find(vv => parseTime(vv.time, '{y}-{m}-{d} {h}') === v)
return {...data, time: v}
})
}
if (data.interval === '3') {
let arr = getTimeList(data.interval, data.isRealTime)
console.log('arr', arr)
res2.data.groupDeviceData.dataList = arr.map(v => {
let data = res2.data.groupDeviceData.dataList.find(vv => parseTime(vv.time, '{y}-{m}-{d}') === v)
return {...data, time: v}
})
}
if (data.interval === '4') {
let arr = getTimeList(data.interval, data.isRealTime)
console.log('arr', arr)
res2.data.groupDeviceData.dataList = arr.map(v => {
let data = res2.data.groupDeviceData.dataList.find(vv => parseTime(vv.time, '{y}-{m}-{d}') === v)
return {...data, time: v}
})
}
if (data.interval === '5') {
let arr = getTimeList(data.interval, data.isRealTime)
console.log('arr', arr)
res2.data.groupDeviceData.dataList = arr.map(v => {
let data = res2.data.groupDeviceData.dataList.find(vv => parseTime(vv.time, '{y}-{m}') === v)
return {...data, time: v}
})
}
} else {
if (data.interval === '5') {
res2.data.groupDeviceData.dataList = res2.data.groupDeviceData.dataList.map(e => {
return {...e, time: parseTime(e.time, '{y}-{m}')}
})
} else if (data.interval === '4' || data.interval === '3') {
res2.data.groupDeviceData.dataList = res2.data.groupDeviceData.dataList.map(e => {
return {...e, time: parseTime(e.time, '{y}-{m}-{d}')}
})
} else {
res2.data.groupDeviceData.dataList = res2.data.groupDeviceData.dataList.map(e => {
return {...e, time: parseTime(e.time, '{y}-{m}-{d} {h}:{i}:{s}')}
})
}
}
debugger
console.log('res2222222', res2)
debugger
return res2
}
const mappingFunction = async (data, method) => { const mappingFunction = async (data, method) => {
if (data.type === 1) { if (data.type === 1) {
let res2 = await interfaceRequest(data) let res2 = await interfaceRequest(data)
@ -28,145 +170,12 @@ const mappingFunction = async (data, method) => {
} }
if (data.type === 2) { if (data.type === 2) {
let getTime = (e) => { let res2 = await getDeviceData(data)
if (e === '1') { console.log('res2666', res2)
return [(new Date().getTime() - (1000 * 60 * 60 * 24)), (new Date().getTime())]
}
if (e === '2') {
return [(new Date().getTime() - (1000 * 60 * 60 * 24)), (new Date().getTime())]
}
if (e === '3') {
return [(new Date().getTime() - (1000 * 60 * 60 * 24 * 7)), (new Date().getTime())]
}
if (e === '4') {
return [(new Date().getTime() - (1000 * 60 * 60 * 24 * 30)), (new Date().getTime())]
}
if (e === '5') {
return [(new Date().getTime() - (1000 * 60 * 60 * 24 * 365)), (new Date().getTime())]
}
}
const getTimeList = (e, isRealTime, startTimeArg, endTimeArg) => {
let startTime, endTime
if (!isRealTime) {
startTime = startTimeArg
endTime = endTimeArg
} else {
startTime = getTime(e)[0]
endTime = getTime(e)[1]
}
if (e === '1') {
let scope = Math.ceil((endTime - startTime) / (1000 * 60 * 60)) || 0
let arr = Array(scope).fill(1).map((v, k) => {
return parseTime(endTime - (1000 * 60 * 60) * k, '{y}-{m}-{d} {h}:{i}')
})
return arr
}
if (e === '2') {
let scope = Math.ceil((endTime - startTime) / (1000 * 60 * 60)) || 0
let arr = Array(scope).fill(1).map((v, k) => {
return parseTime(endTime - (1000 * 60 * 60) * k, '{y}-{m}-{d} {h}')
})
return arr
}
if (e === '3') {
let scope = Math.ceil((endTime - startTime) / (1000 * 60 * 60 * 24)) || 0
let arr = Array(scope).fill(1).map((v, k) => {
return parseTime(endTime - (1000 * 60 * 60 * 24) * k, '{y}-{m}-{d}')
})
return arr
}
if (e === '4') {
let scope = Math.ceil((endTime - startTime) / (1000 * 60 * 60 * 24)) || 0
let arr = Array(scope).fill(1).map((v, k) => {
return parseTime(endTime - (1000 * 60 * 60 * 24) * k, '{y}-{m}-{d}')
})
return arr
}
if (e === '5') {
let scope = Math.ceil((endTime - startTime) / (1000 * 60 * 60 * 24 * 30)) || 0
let arr = Array(scope).fill(1).map((v, k) => {
return parseTime(endTime - (1000 * 60 * 60 * 24 * 30) * k, '{y}-{m}')
})
return arr
}
}
let res2 = await getHistoryData({
deviceModeId: data.deviceModeId,
functionIdentifier: data.functionIdentifier,
interval: data.interval,
"sceneId": 144,
"deviceId": data.deviceId,
startTime: data.isRealTime ? getTime(data.interval)?.[0] : data.startTime,
endTime: data.isRealTime ? getTime(data.interval)?.[1] : data.endTime,
intervalType: 1 || data.intervalType,
})
console.log('datadata', data)
if (data.isRealTime) {
if (data.interval === '1') {
let arr = getTimeList(data.interval, data.isRealTime)
res2.data.groupDeviceData.dataList = arr.map(v => {
let data = res2.data.groupDeviceData.dataList.find(vv => parseTime(vv.time, '{y}-{m}-{d} {h}:{i}') === v)
return {...data, time: v}
})
}
if (data.interval === '2') {
let arr = getTimeList(data.interval, data.isRealTime)
res2.data.groupDeviceData.dataList = arr.map(v => {
let data = res2.data.groupDeviceData.dataList.find(vv => parseTime(vv.time, '{y}-{m}-{d} {h}') === v)
return {...data, time: v}
})
}
if (data.interval === '3') {
let arr = getTimeList(data.interval, data.isRealTime)
console.log('arr', arr)
res2.data.groupDeviceData.dataList = arr.map(v => {
let data = res2.data.groupDeviceData.dataList.find(vv => parseTime(vv.time, '{y}-{m}-{d}') === v)
return {...data, time: v}
})
}
if (data.interval === '4') {
let arr = getTimeList(data.interval, data.isRealTime)
console.log('arr', arr)
res2.data.groupDeviceData.dataList = arr.map(v => {
let data = res2.data.groupDeviceData.dataList.find(vv => parseTime(vv.time, '{y}-{m}-{d}') === v)
return {...data, time: v}
})
}
if (data.interval === '5') {
let arr = getTimeList(data.interval, data.isRealTime)
console.log('arr', arr)
res2.data.groupDeviceData.dataList = arr.map(v => {
let data = res2.data.groupDeviceData.dataList.find(vv => parseTime(vv.time, '{y}-{m}') === v)
return {...data, time: v}
})
}
} else {
if (data.interval === '5') {
res2.data.groupDeviceData.dataList = res2.data.groupDeviceData.dataList.map(e => {
return {...e, time: parseTime(e.time, '{y}-{m}')}
})
} else if (data.interval === '4' || data.interval === '3') {
res2.data.groupDeviceData.dataList = res2.data.groupDeviceData.dataList.map(e => {
return {...e, time: parseTime(e.time, '{y}-{m}-{d}')}
})
} else {
res2.data.groupDeviceData.dataList = res2.data.groupDeviceData.dataList.map(e => {
return {...e, time: parseTime(e.time, '{y}-{m}-{d} {h}:{i}:{s}')}
})
}
}
console.log(res2)
let returnRes = {} let returnRes = {}
method?.mappingArr?.forEach(v => { method?.mappingArr?.forEach(v => {
let res = res2.data let res = res2.data
console.log(res)
for (let i of (v?.region || [])) { for (let i of (v?.region || [])) {
if (res[i]) { if (res[i]) {
res = res[i] res = res[i]
@ -176,9 +185,10 @@ const mappingFunction = async (data, method) => {
} }
} }
if (v?.isArray && v?.mapData && Array.isArray(res)) { if (v?.isArray && v?.mapData && Array.isArray(res)) {
console.log(res) console.log('res10101010101',res)
res = res.map(e => e[v.mapData]) res = res.map(e => e[v.mapData]||null)
} }
console.log('res10101010101--1',res)
returnRes = { returnRes = {
...returnRes, ...returnRes,
[v?.name]: res [v?.name]: res
@ -288,8 +298,9 @@ const clearObjNull = (e, data1) => {
return Object.keys(obj).length === 0 ? null : obj return Object.keys(obj).length === 0 ? null : obj
} }
const clearArrNull = (e, data1) => { const clearArrNull = (e, data1) => {
return e
if (!Array.isArray(e)) { if (!Array.isArray(e)) {
return null return e
} }
let arr = [] let arr = []
e.forEach(v => { e.forEach(v => {
@ -401,5 +412,6 @@ export {
detectingNullValues, detectingNullValues,
getFinalData, getFinalData,
parseTime, parseTime,
testColor testColor,
getDeviceData
} }

Loading…
Cancel
Save