Showing
3 changed files
with
34 additions
and
33 deletions
| ... | ... | @@ -115,12 +115,12 @@ export const getVideoUrl = (id: string) => |
| 115 | 115 | }) |
| 116 | 116 | |
| 117 | 117 | //获取行政区域 |
| 118 | -export const getGeoJsonMap = (code: number | string, level: string) =>{ | |
| 118 | +export const getGeoJsonMap = (code: number | string, level: string) => { | |
| 119 | 119 | return defHttp.get({ |
| 120 | 120 | url: `${Api.GEOJSONURL}${code}/${level}` |
| 121 | - },{withShareToken:isShareMode()}) | |
| 121 | + }, { withShareToken: isShareMode() }) | |
| 122 | 122 | } |
| 123 | - | |
| 123 | + | |
| 124 | 124 | |
| 125 | 125 | // 获取设备详情 |
| 126 | 126 | export const getDeviceDetail = (id: string) => |
| ... | ... | @@ -136,11 +136,11 @@ export const getAttribute = (deviceProfileId: string) => |
| 136 | 136 | |
| 137 | 137 | // 获取设备最新数据 |
| 138 | 138 | export const getDeviceLatest = (tbDeviceId: string) => |
| 139 | -defHttp.get({ | |
| 140 | - url: `${Api.GET_DEVICE_LATEST}${tbDeviceId}/values/timeseries` | |
| 141 | -}, { | |
| 142 | - joinPrefix: false | |
| 143 | -}) | |
| 139 | + defHttp.get({ | |
| 140 | + url: `${Api.GET_DEVICE_LATEST}${tbDeviceId}/values/timeseries` | |
| 141 | + }, { | |
| 142 | + joinPrefix: false | |
| 143 | + }) | |
| 144 | 144 | |
| 145 | 145 | //获取产品属性 |
| 146 | 146 | export const getProfileAttrs = (params: { deviceProfileId: string; dataType?: string }) => { | ... | ... |
| ... | ... | @@ -94,13 +94,15 @@ const extraValue = (object: Recordable) => { |
| 94 | 94 | |
| 95 | 95 | const handleParams = (Params: Recordable) => { |
| 96 | 96 | if (Params.keys && Params?.keys?.length) { |
| 97 | + // 过滤无效参数 | |
| 98 | + Reflect.deleteProperty(Params, 'attrName') | |
| 97 | 99 | /** ft 修改select联动下拉框选择了属性(单个)报错问题 |
| 98 | 100 | * 源代码 Params.keys = (Params.keys || [] as any).join(',') |
| 99 | 101 | */ |
| 100 | - if(!Array.isArray(Params.keys)){ | |
| 101 | - Params.keys = ([Params.keys] || [] as any).join(',') | |
| 102 | - }else{ | |
| 103 | - Params.keys = (Params.keys || [] as any).join(',') | |
| 102 | + if (!Array.isArray(Params.keys)) { | |
| 103 | + Params.keys = ([Params.keys] || [] as any).join(',') | |
| 104 | + } else { | |
| 105 | + Params.keys = (Params.keys || [] as any).join(',') | |
| 104 | 106 | } |
| 105 | 107 | //ft |
| 106 | 108 | } |
| ... | ... | @@ -116,12 +118,12 @@ const handleParams = (Params: Recordable) => { |
| 116 | 118 | } |
| 117 | 119 | |
| 118 | 120 | //post请求动态追加query参数 |
| 119 | -const objConvertQuery= (data:Recordable)=> { | |
| 121 | +const objConvertQuery = (data: Recordable) => { | |
| 120 | 122 | const _result = []; |
| 121 | 123 | for (const key in data) { |
| 122 | 124 | const value = data[key]; |
| 123 | 125 | if (value.constructor == Array) { |
| 124 | - value.forEach(function(_value) { | |
| 126 | + value.forEach(function (_value) { | |
| 125 | 127 | _result.push(key + "=" + _value); |
| 126 | 128 | }); |
| 127 | 129 | } else { |
| ... | ... | @@ -152,11 +154,12 @@ export const customRequest = async (request: RequestConfigType) => { |
| 152 | 154 | * 修改后代码 requestHttpType === RequestHttpEnum.GET.toUpperCase() ? requestUrl: `${requestUrl}?${objConvertQuery(Params)} |
| 153 | 155 | */ |
| 154 | 156 | Params = handleParams(Params) |
| 157 | + console.log(Params) | |
| 155 | 158 | return customHttp.request<any>({ |
| 156 | - url: requestHttpType === RequestHttpEnum.GET.toUpperCase() ? requestUrl: `${requestUrl}?${objConvertQuery(Params)}`, | |
| 159 | + url: requestHttpType === RequestHttpEnum.GET.toUpperCase() ? requestUrl : `${requestUrl}?${objConvertQuery(Params)}`, | |
| 157 | 160 | baseURL: getOriginUrl(requestOriginUrl!), |
| 158 | 161 | method: requestHttpType, |
| 159 | - params: requestHttpType === RequestHttpEnum.GET.toUpperCase() ? Params: null, | |
| 162 | + params: requestHttpType === RequestHttpEnum.GET.toUpperCase() ? Params : null, | |
| 160 | 163 | data: body, |
| 161 | 164 | headers: extraValue(Header) |
| 162 | 165 | }, { | ... | ... |
| 1 | 1 | <template> |
| 2 | - <v-chart | |
| 3 | - ref="vChartRef" | |
| 4 | - :init-options="initOptions" | |
| 5 | - :theme="themeColor" | |
| 6 | - :option="option" | |
| 7 | - :manual-update="isPreview()" | |
| 2 | + <v-chart ref="vChartRef" :init-options="initOptions" :theme="themeColor" :option="option" :manual-update="isPreview()" | |
| 8 | 3 | :update-options="{ |
| 9 | 4 | replaceMerge: replaceMergeArr |
| 10 | - }" | |
| 11 | - autoresize | |
| 12 | - @mouseover="handleHighlight" | |
| 13 | - @mouseout="handleDownplay" | |
| 14 | - > | |
| 5 | + }" autoresize @mouseover="handleHighlight" @mouseout="handleDownplay"> | |
| 15 | 6 | </v-chart> |
| 16 | 7 | </template> |
| 17 | 8 | |
| ... | ... | @@ -186,6 +177,12 @@ watch( |
| 186 | 177 | for (let i = 0; i < dimensionsGap; i++) { |
| 187 | 178 | seriesArr.push(cloneDeep(seriesItem)) |
| 188 | 179 | } |
| 180 | + | |
| 181 | + const { request } = props.chartConfig | |
| 182 | + const { requestParams: { Params: { attrName } } } = request || {} | |
| 183 | + seriesArr.forEach((item: any, index: number) => { | |
| 184 | + item.name = attrName?.[index] | |
| 185 | + }) | |
| 189 | 186 | props.chartConfig.option.series.push(...seriesArr) |
| 190 | 187 | } |
| 191 | 188 | replaceMergeArr.value = ['series'] |
| ... | ... | @@ -205,28 +202,29 @@ watch( |
| 205 | 202 | //fix 修复v-chart图表绑定联动组件视图不更新问题 |
| 206 | 203 | const updateVChart = (newData: SocketReceiveMessageType) => { |
| 207 | 204 | if (!newData) return |
| 208 | - const { option,request } = props.chartConfig | |
| 209 | - const {requestParams:{Params:{attrName}}} = request || {} | |
| 205 | + const { option, request } = props.chartConfig | |
| 206 | + const { requestParams: { Params: { attrName } } } = request || {} | |
| 210 | 207 | const { dataset: overrideDataset } = option |
| 211 | 208 | const { dimensions } = overrideDataset |
| 212 | 209 | if (!Array.isArray(dimensions)) return |
| 213 | 210 | const { data } = newData |
| 214 | - const { record } = useAssembleDataHooks(data,dimensions,(attrName as any)) | |
| 211 | + const { record } = useAssembleDataHooks(data, dimensions, (attrName as any)) | |
| 215 | 212 | if (unref(realTimeList).length >= chartMaxDataPoint.value) { |
| 216 | 213 | unref(realTimeList).splice(0, 1) |
| 217 | 214 | } |
| 218 | 215 | realTimeList.value.push(record) |
| 219 | - const dataset = { | |
| 216 | + const dataset = { | |
| 220 | 217 | dimensions: ['ts', ...attrName], |
| 221 | 218 | source: toRaw(unref(realTimeList)) |
| 222 | 219 | } |
| 223 | - option.series.forEach((item:any,index:number)=>{ | |
| 220 | + option.series.forEach((item: any, index: number) => { | |
| 224 | 221 | item.name = attrName?.[index] |
| 225 | 222 | }) |
| 223 | + | |
| 226 | 224 | vChartRef.value?.setOption({ |
| 227 | 225 | ...option, |
| 228 | 226 | dataset, |
| 229 | - legend:{data:attrName || []} | |
| 227 | + legend: { data: attrName || [] } | |
| 230 | 228 | }) |
| 231 | 229 | } |
| 232 | 230 | const { vChartRef } = useChartDataFetch(props.chartConfig, useChartEditStore, newData => { | ... | ... |