Showing
1 changed file
with
15 additions
and
11 deletions
... | ... | @@ -39,11 +39,11 @@ |
39 | 39 | </Select> |
40 | 40 | </div> |
41 | 41 | <div> |
42 | - <Empty v-show="notFoundData" /> | |
42 | + <Empty v-show="item.emptyFlag" /> | |
43 | 43 | <div |
44 | - v-show="!notFoundData" | |
44 | + v-show="!item.emptyFlag" | |
45 | 45 | :id="`chart-${item.device}`" |
46 | - :style="{ height, width }" | |
46 | + style="width: 100%; height: 400px" | |
47 | 47 | ></div> |
48 | 48 | </div> |
49 | 49 | </div> |
... | ... | @@ -86,7 +86,7 @@ |
86 | 86 | let currentRecord: ExecuteReportRecord = {} as unknown as ExecuteReportRecord; |
87 | 87 | |
88 | 88 | const chartInstance = ref< |
89 | - { device: string; name: string; attributes: string[]; active?: string }[] | |
89 | + { device: string; name: string; attributes: string[]; active?: string; emptyFlag?: boolean }[] | |
90 | 90 | >([]); |
91 | 91 | |
92 | 92 | const notFoundData = ref(false); |
... | ... | @@ -257,6 +257,15 @@ |
257 | 257 | try { |
258 | 258 | loading.value = true; |
259 | 259 | const result = await exportViewChartApi(device, sendParams); |
260 | + chartInstance.value.forEach((f) => { | |
261 | + if (f.device === device) { | |
262 | + if (Object.keys(result).length === 0) { | |
263 | + f.emptyFlag = true; | |
264 | + } else { | |
265 | + f.emptyFlag = false; | |
266 | + } | |
267 | + } | |
268 | + }); | |
260 | 269 | validateHasData(result); |
261 | 270 | const { xAxisData, series } = getChartsOption(result as unknown as ResponsData); |
262 | 271 | |
... | ... | @@ -272,15 +281,10 @@ |
272 | 281 | |
273 | 282 | const validateHasData = (record: Recordable) => { |
274 | 283 | notFoundData.value = true; |
275 | - if (Object.keys(record).length === 0) { | |
276 | - notFoundData.value = true; | |
277 | - } else { | |
284 | + const { val = [], attr } = (record as unknown as ResponsData) || {}; | |
285 | + if (!attr || !val.length) { | |
278 | 286 | notFoundData.value = false; |
279 | 287 | } |
280 | - // const { val = [], attr } = (record as unknown as ResponsData) || {}; | |
281 | - // if (!attr || !val.length) { | |
282 | - // notFoundData.value = false; | |
283 | - // } | |
284 | 288 | }; |
285 | 289 | |
286 | 290 | const handleChangeChars = (value: string, device: string) => { | ... | ... |