mirror of
https://gitee.com/dromara/go-view.git
synced 2025-06-30 08:39:15 +08:00
fix: 修复数据模块id加错位置
This commit is contained in:
parent
3793cdfb05
commit
7c86c9abfd
@ -35,6 +35,7 @@ export const useChartCommonData = (
|
|||||||
// if (vChartRef.value) {
|
// if (vChartRef.value) {
|
||||||
// setOption(vChartRef.value, { dataset: dataset })
|
// setOption(vChartRef.value, { dataset: dataset })
|
||||||
// }
|
// }
|
||||||
|
if(!dataset.dimensions) return
|
||||||
if(targetComponent.option){
|
if(targetComponent.option){
|
||||||
let seriesItem = cloneDeep(targetComponent.option.series[0])
|
let seriesItem = cloneDeep(targetComponent.option.series[0])
|
||||||
let series = []
|
let series = []
|
||||||
@ -105,7 +106,7 @@ export const useChartCommonData = (
|
|||||||
if (res) {
|
if (res) {
|
||||||
try {
|
try {
|
||||||
const { data } = res
|
const { data } = res
|
||||||
echartsUpdateHandle(data.length ? data[0] : { dimensions: [], source: [] })
|
if(data.length) echartsUpdateHandle(data[0])
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
}
|
}
|
||||||
|
@ -3,14 +3,14 @@
|
|||||||
</setting-item-box>
|
</setting-item-box>
|
||||||
<setting-item-box name="启用数据" :alone="true">
|
<setting-item-box name="启用数据" :alone="true">
|
||||||
<n-space justify="start">
|
<n-space justify="start">
|
||||||
<n-switch v-model:value="targetData.commonData.enable" />
|
<n-switch v-model:value="commonData.enable" />
|
||||||
</n-space>
|
</n-space>
|
||||||
</setting-item-box>
|
</setting-item-box>
|
||||||
<setting-item-box name="时间" :alone="true">
|
<setting-item-box name="时间" :alone="true">
|
||||||
<n-select v-model:value="targetData.commonData.dateType" :options="DateOptions" size="small"/>
|
<n-select v-model:value="commonData.dateType" :options="DateOptions" size="small"/>
|
||||||
</setting-item-box>
|
</setting-item-box>
|
||||||
<setting-item-box name="统计方式" :alone="true">
|
<setting-item-box name="统计方式" :alone="true">
|
||||||
<n-select multiple v-model:value="targetData.commonData.methods" :options="MethodsOptions" size="small" />
|
<n-select multiple v-model:value="commonData.methods" :options="MethodsOptions" size="small" />
|
||||||
</setting-item-box>
|
</setting-item-box>
|
||||||
<setting-item-box name="测点ID" :alone="true">
|
<setting-item-box name="测点ID" :alone="true">
|
||||||
<n-space vertical>
|
<n-space vertical>
|
||||||
@ -28,7 +28,14 @@
|
|||||||
</template>
|
</template>
|
||||||
</n-button>
|
</n-button>
|
||||||
</n-space>
|
</n-space>
|
||||||
<n-input v-model:value="templateValue" @blur="handleBlur" @keydown.enter="handleBlur" placeholder="请输入测点ID" size="small" clearable/>
|
<n-space align="center" :wrap="false">
|
||||||
|
<n-input v-model:value="templateValue" placeholder="请输入测点ID" size="small" clearable/>
|
||||||
|
<n-button @click="handleAdd" circle size="tiny">
|
||||||
|
<template #icon>
|
||||||
|
<n-icon><AddIcon /></n-icon>
|
||||||
|
</template>
|
||||||
|
</n-button>
|
||||||
|
</n-space>
|
||||||
</n-space>
|
</n-space>
|
||||||
</setting-item-box>
|
</setting-item-box>
|
||||||
<setting-item-box name="更新间隔" :alone="true">
|
<setting-item-box name="更新间隔" :alone="true">
|
||||||
@ -49,7 +56,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, watch, reactive, toRefs } from 'vue'
|
import { ref, watch, reactive, toRefs, computed } from 'vue'
|
||||||
import type { Ref } from 'vue'
|
import type { Ref } from 'vue'
|
||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
import { SettingItemBox } from '@/components/Pages/ChartItemSetting'
|
import { SettingItemBox } from '@/components/Pages/ChartItemSetting'
|
||||||
@ -60,83 +67,48 @@ import { icon } from '@/plugins/icon'
|
|||||||
import { commonDataType, RequestConfigType } from '@/store/modules/chartEditStore/chartEditStore.d'
|
import { commonDataType, RequestConfigType } from '@/store/modules/chartEditStore/chartEditStore.d'
|
||||||
import { selectTimeOptions } from '../index.d'
|
import { selectTimeOptions } from '../index.d'
|
||||||
|
|
||||||
const { CloseIcon } = icon.ionicons5
|
const { CloseIcon, AddIcon } = icon.ionicons5
|
||||||
|
|
||||||
const { targetData } = useTargetData() as { targetData: Ref<{ commonData: commonDataType, id: string, request: RequestConfigType }> }
|
const { targetData } = useTargetData() as { targetData: Ref<{ commonData: commonDataType, id: string, request: RequestConfigType }> }
|
||||||
|
|
||||||
const templateValue = ref('')
|
const commonData: Ref<commonDataType> = computed(() => targetData.value.commonData)
|
||||||
|
|
||||||
type computeIdsItemType = {
|
type computeIdsItemType = {
|
||||||
id: string,
|
id: string,
|
||||||
value: string
|
value: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const { commonData } = toRefs(targetData.value) as { commonData: Ref<commonDataType> }
|
const computeIds: computeIdsItemType[] = reactive([])
|
||||||
|
|
||||||
let computeIds: computeIdsItemType[] = reactive(commonData.value.dems_device_points_uid.map((_: string) => {
|
let templateValue = ref('')
|
||||||
return {
|
|
||||||
id: nanoid(),
|
|
||||||
value: _
|
|
||||||
}
|
|
||||||
}))
|
|
||||||
|
|
||||||
// 用targetData.value.commonData.dems_device_points_uid 不用commonData.value.dems_device_points_uid
|
watch(() => [targetData.value?.id, commonData.value], () => {
|
||||||
// commonData.value.dems_device_points_uid好像丢失了响应性 晚点在研究
|
templateValue.value = ''
|
||||||
watch(() => targetData.value.id, () => {
|
let arr = commonData.value.dems_device_points_uid.map(item => {
|
||||||
if(!targetData.value.commonData) return
|
|
||||||
let arr = targetData.value.commonData.dems_device_points_uid.map((_: string) => {
|
|
||||||
return {
|
return {
|
||||||
id: nanoid(),
|
id: nanoid(),
|
||||||
value: _
|
value: item
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
computeIds.splice(0, computeIds.length, ...arr)
|
computeIds.splice(0, computeIds.length, ...arr)
|
||||||
})
|
|
||||||
|
|
||||||
watch(() => commonData.value.dems_device_points_uid, (v) => {
|
|
||||||
const length = commonData.value.dems_device_points_uid.length
|
|
||||||
if(length > computeIds.length) {
|
|
||||||
computeIds.push({
|
|
||||||
id: nanoid(),
|
|
||||||
value: v[length - 1]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
else if(length < computeIds.length) {
|
|
||||||
for(let i = 0; i < computeIds.length; i++) {
|
|
||||||
if(i === computeIds.length - 1) {
|
|
||||||
computeIds.splice(-1)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
else if(computeIds[i].value !== commonData.value.dems_device_points_uid[i]){
|
|
||||||
computeIds.splice(i, 1)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
computeIds.forEach((item, i) => {
|
|
||||||
item.value = commonData.value.dems_device_points_uid[i]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}, {
|
}, {
|
||||||
deep: true
|
deep: true,
|
||||||
|
immediate: true
|
||||||
})
|
})
|
||||||
|
|
||||||
const handleBlur = () => {
|
const handleChange = (v: string, i: number) => {
|
||||||
if(targetData.value && commonData.value && templateValue.value) {
|
targetData.value.commonData.dems_device_points_uid[i] = v
|
||||||
commonData.value.dems_device_points_uid.push(templateValue.value)
|
}
|
||||||
|
|
||||||
|
const handleAdd = () => {
|
||||||
|
if(templateValue.value) {
|
||||||
|
targetData.value.commonData.dems_device_points_uid.push(templateValue.value)
|
||||||
templateValue.value = ''
|
templateValue.value = ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleChange = (v: string, i: number) => {
|
|
||||||
if(targetData.value && commonData.value) {
|
|
||||||
commonData.value.dems_device_points_uid[i] = v
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleDelete = (i: number) => {
|
const handleDelete = (i: number) => {
|
||||||
commonData.value.dems_device_points_uid.splice(i, 1)
|
targetData.value.commonData.dems_device_points_uid.splice(i, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user