mirror of
https://gitee.com/dromara/go-view.git
synced 2025-06-30 00:29:16 +08:00
feat: 手动输入数据
This commit is contained in:
parent
2292bc95ce
commit
3519ce17c3
20
src/hooks/commonDataComponents/useManualInputRes.ts
Normal file
20
src/hooks/commonDataComponents/useManualInputRes.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import { publicInterface } from "@/api/path";
|
||||
import { commonDataType, ManualInputType } from '@/store/modules/chartEditStore/chartEditStore.d'
|
||||
import { CreateComponentType } from '@/packages/index.d'
|
||||
import { ResultErrcode } from "@/enums/httpEnum";
|
||||
import dataJson from './data.json'
|
||||
|
||||
export const handleManulInput = (targetComponent: CreateComponentType) => {
|
||||
let { enable, dataset } = (targetComponent.commonData as commonDataType).manualInput as ManualInputType
|
||||
if(!enable) return {
|
||||
errcode: ResultErrcode.SUCCESS,
|
||||
data: { ...dataJson },
|
||||
errmsg: ''
|
||||
}
|
||||
|
||||
return {
|
||||
errcode: ResultErrcode.SUCCESS,
|
||||
data: dataset,
|
||||
errmsg: ''
|
||||
}
|
||||
}
|
20
src/hooks/commonDataComponents/useManualInputSingleRes.ts
Normal file
20
src/hooks/commonDataComponents/useManualInputSingleRes.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import { publicInterface } from "@/api/path";
|
||||
import { commonDataType, ManualInputSingleType } from '@/store/modules/chartEditStore/chartEditStore.d'
|
||||
import { CreateComponentType } from '@/packages/index.d'
|
||||
import { ResultErrcode } from "@/enums/httpEnum";
|
||||
import singleDataJson from './singleData.json'
|
||||
|
||||
export const handleManulInputSingle = (targetComponent: CreateComponentType) => {
|
||||
let { enable, result } = (targetComponent.commonData as commonDataType).manualInputSingle as ManualInputSingleType
|
||||
if(!enable) return {
|
||||
errcode: ResultErrcode.SUCCESS,
|
||||
data: { ...singleDataJson },
|
||||
errmsg: ''
|
||||
}
|
||||
|
||||
return {
|
||||
errcode: ResultErrcode.SUCCESS,
|
||||
data: result,
|
||||
errmsg: ''
|
||||
}
|
||||
}
|
@ -15,6 +15,8 @@ import { handleMonthAlarmClass } from './commonDataComponents/useMonthAlarmClass
|
||||
import { handleDeviceClass } from './commonDataComponents/useDeviceClassRes'
|
||||
import { handlePointTable } from "./commonDataComponents/usePointTableRes";
|
||||
import { handleNoParam } from './commonDataComponents/useNoParamRes'
|
||||
import { handleManulInput } from './commonDataComponents/useManualInputRes'
|
||||
import { handleManulInputSingle } from './commonDataComponents/useManualInputSingleRes'
|
||||
import { ResultErrcode } from '@/enums/httpEnum'
|
||||
|
||||
// 获取类型
|
||||
@ -46,7 +48,8 @@ export const useChartCommonData = (
|
||||
// if(!dataset.dimensions) return
|
||||
if(targetComponent.option){
|
||||
const SingleDataArr = [
|
||||
CurrentSourceEnum.SINGLEPOINT
|
||||
CurrentSourceEnum.SINGLEPOINT,
|
||||
CurrentSourceEnum.MANUALINPUTSINGLE
|
||||
]
|
||||
const currentSource = targetComponent.commonData?.currentSource
|
||||
// 多个值的处理方式
|
||||
@ -130,6 +133,13 @@ export const useChartCommonData = (
|
||||
case CurrentSourceEnum.POINTTABLE:
|
||||
res = await handlePointTable(targetComponent)
|
||||
break;
|
||||
case CurrentSourceEnum.MANUALINPUT:
|
||||
res = await handleManulInput(targetComponent)
|
||||
break;
|
||||
case CurrentSourceEnum.MANUALINPUTSINGLE:
|
||||
res = await handleManulInputSingle(targetComponent)
|
||||
isMultiple = false
|
||||
break;
|
||||
default:
|
||||
// res = await handleNoParam(targetComponent)
|
||||
break;
|
||||
@ -163,9 +173,10 @@ export const useChartCommonData = (
|
||||
// 更新回调函数
|
||||
if (updateCallback) updateCallback(data)
|
||||
}
|
||||
else throw Error()
|
||||
else throw Error('1234')
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
if(!isPreview()) window['$message'].error('数据错误')
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="box">
|
||||
<div ref="list" class="list" :style="{transform: `translateY(${translateY}px)`}">
|
||||
<template v-if="isPointTable">
|
||||
<template v-if="isTag">
|
||||
<div class="item" v-for="(item, i) in datasetSource" :key="i">
|
||||
<img class="img" :src="Snow">
|
||||
<div class="label">{{item.name}}</div>
|
||||
@ -79,8 +79,12 @@ const option = computed(() => props.chartConfig.option)
|
||||
|
||||
const commonData = computed(() => props.chartConfig.commonData)
|
||||
|
||||
const isPointTable = computed(() => {
|
||||
return commonData.value.currentSource === CurrentSourceEnum.POINTTABLE
|
||||
// const isPointTable = computed(() => {
|
||||
// return commonData.value.currentSource === CurrentSourceEnum.POINTTABLE
|
||||
// })
|
||||
|
||||
const isTag = computed(() => {
|
||||
return option.value.dataset.source.length && Object.prototype.hasOwnProperty.call(option.value.dataset.source[0], 'status')
|
||||
})
|
||||
|
||||
const datasetDimensions = computed(() => {
|
||||
|
@ -2,6 +2,9 @@ import { getUUID } from '@/utils'
|
||||
import { RequestConfigType, commonDataType, CustomEventType, CurrentSourceEnum, DateTypeEnum } from '@/store/modules/chartEditStore/chartEditStore.d'
|
||||
import { groupTitle } from '@/settings/designSetting'
|
||||
import { BaseEvent, EventLife } from '@/enums/eventEnum'
|
||||
import dataJson from '@/hooks/commonDataComponents/data.json'
|
||||
import singleDataJson from '@/hooks/commonDataComponents/singleData.json'
|
||||
|
||||
import {
|
||||
RequestHttpEnum,
|
||||
RequestDataTypeEnum,
|
||||
@ -97,6 +100,14 @@ const commonData: commonDataType = {
|
||||
unit: '',
|
||||
value: 0
|
||||
}
|
||||
},
|
||||
manualInput: {
|
||||
enable: false,
|
||||
dataset: {...dataJson}
|
||||
},
|
||||
manualInputSingle: {
|
||||
enable: false,
|
||||
result: {...singleDataJson}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -267,7 +267,11 @@ export enum CurrentSourceEnum {
|
||||
// 当月告警分类统计
|
||||
MONTHALARMCLASS = 'monthAlarmClass',
|
||||
// 测点表格
|
||||
POINTTABLE = 'pointTable'
|
||||
POINTTABLE = 'pointTable',
|
||||
// 手动输入
|
||||
MANUALINPUT = 'manualInput',
|
||||
// 手动输入(单值)
|
||||
MANUALINPUTSINGLE = 'manualInputSingle',
|
||||
}
|
||||
|
||||
// 测点历史参数
|
||||
@ -349,6 +353,23 @@ export interface PointTableType {
|
||||
ids: string[]
|
||||
}
|
||||
|
||||
// 手动输入值
|
||||
export interface ManualInputType {
|
||||
enable: boolean
|
||||
dataset: {
|
||||
dimensions: string[],
|
||||
source: {
|
||||
[k: string]: any
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 手动输入值(单值)
|
||||
export interface ManualInputSingleType {
|
||||
enable: boolean
|
||||
result: resultType
|
||||
}
|
||||
|
||||
// 通用组件数据
|
||||
export interface commonDataType {
|
||||
// 多数据
|
||||
@ -364,6 +385,10 @@ export interface commonDataType {
|
||||
deviceClass: DeviceClassType
|
||||
// 单数据
|
||||
singlePoint: SinglePointType
|
||||
// 手动输入
|
||||
manualInput: ManualInputType
|
||||
// 手动输入(单值)
|
||||
manualInputSingle: ManualInputSingleType
|
||||
}
|
||||
|
||||
// customEvent事件
|
||||
|
@ -0,0 +1,57 @@
|
||||
<template>
|
||||
<setting-item-box name="启用数据" :alone="true">
|
||||
<n-space justify="start">
|
||||
<n-switch v-model:value="manualInput.enable"/>
|
||||
</n-space>
|
||||
</setting-item-box>
|
||||
<setting-item-box name="数据" :alone="true">
|
||||
<n-input
|
||||
v-model:value="dataset"
|
||||
placeholder="请输入"
|
||||
size="small"
|
||||
clearable
|
||||
/>
|
||||
</setting-item-box>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useTargetData } from "../../hooks/useTargetData.hook";
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import type { Ref } from "vue";
|
||||
import { commonDataType, ManualInputType } from '@/store/modules/chartEditStore/chartEditStore.d'
|
||||
import { SettingItemBox } from '@/components/Pages/ChartItemSetting'
|
||||
import dataJson from '@/hooks/commonDataComponents/data.json'
|
||||
|
||||
const { targetData } = useTargetData() as { targetData: Ref<{ commonData: commonDataType }> }
|
||||
const manualInput: Ref<ManualInputType> = computed(() => targetData.value.commonData.manualInput)
|
||||
|
||||
const dataset = ref(JSON.stringify(dataJson))
|
||||
|
||||
const setDataset = (v: string) => {
|
||||
let obj = {...dataJson}
|
||||
try {
|
||||
let d = JSON.parse(v)
|
||||
if(Object.prototype.toString.call(d.dimensions) === '[object Array]' && Object.prototype.toString.call(d.source)) {
|
||||
obj = d
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
manualInput.value.dataset = obj
|
||||
// dataset.value = JSON.stringify(obj)
|
||||
}
|
||||
|
||||
watch(() => dataset.value, () => {
|
||||
let obj = {...dataJson}
|
||||
setDataset(manualInput.value.enable ? dataset.value : JSON.stringify(obj))
|
||||
})
|
||||
|
||||
watch(() => manualInput.value.enable, v => {
|
||||
let obj = {...dataJson}
|
||||
setDataset(v ? dataset.value : JSON.stringify(obj))
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
</style>
|
@ -0,0 +1,58 @@
|
||||
<template>
|
||||
<setting-item-box name="启用数据" :alone="true">
|
||||
<n-space justify="start">
|
||||
<n-switch v-model:value="manualInputSingle.enable"/>
|
||||
</n-space>
|
||||
</setting-item-box>
|
||||
<setting-item-box name="数据" :alone="true">
|
||||
<n-input
|
||||
v-model:value="dataset"
|
||||
placeholder="请输入"
|
||||
size="small"
|
||||
clearable
|
||||
/>
|
||||
</setting-item-box>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useTargetData } from "../../hooks/useTargetData.hook";
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import type { Ref } from "vue";
|
||||
import { commonDataType, ManualInputSingleType } from '@/store/modules/chartEditStore/chartEditStore.d'
|
||||
import { SettingItemBox } from '@/components/Pages/ChartItemSetting'
|
||||
import singleDataJson from '@/hooks/commonDataComponents/singleData.json'
|
||||
|
||||
const { targetData } = useTargetData() as { targetData: Ref<{ commonData: commonDataType }> }
|
||||
const manualInputSingle: Ref<ManualInputSingleType> = computed(() => targetData.value.commonData.manualInputSingle)
|
||||
|
||||
const dataset = ref(JSON.stringify(singleDataJson))
|
||||
|
||||
const setDataset = (v: string) => {
|
||||
let obj = {...singleDataJson}
|
||||
try {
|
||||
let d = JSON.parse(v)
|
||||
if(Object.prototype.toString.call(d) === '[object Object]') {
|
||||
obj = d
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
manualInputSingle.value.result = obj
|
||||
// dataset.value = JSON.stringify(obj)
|
||||
}
|
||||
|
||||
watch(() => dataset.value, () => {
|
||||
let obj = {...singleDataJson}
|
||||
setDataset(manualInputSingle.value.enable ? dataset.value : JSON.stringify(obj))
|
||||
})
|
||||
|
||||
watch(() => manualInputSingle.value.enable, v => {
|
||||
let obj = {...singleDataJson}
|
||||
setDataset(v ? dataset.value : JSON.stringify(obj))
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
</style>
|
@ -160,9 +160,19 @@ export const sourceOptions: sourceOptionsItemType[] = [
|
||||
value: CurrentSourceEnum.POINTTABLE,
|
||||
type: optionTypeEnum.MULTIPLE,
|
||||
},
|
||||
{
|
||||
label: '手动输入值',
|
||||
value: CurrentSourceEnum.MANUALINPUT,
|
||||
type: optionTypeEnum.MULTIPLE,
|
||||
},
|
||||
{
|
||||
label: '单测点实时值',
|
||||
value: CurrentSourceEnum.SINGLEPOINT,
|
||||
type: optionTypeEnum.SINGLE,
|
||||
},
|
||||
{
|
||||
label: '手动输入值(单值)',
|
||||
value: CurrentSourceEnum.MANUALINPUTSINGLE,
|
||||
type: optionTypeEnum.SINGLE,
|
||||
},
|
||||
]
|
||||
|
@ -11,14 +11,16 @@
|
||||
<MonthAlarmClass v-else-if="matchComponent(CurrentSourceEnum.MONTHALARMCLASS)"/>
|
||||
<DeviceClass v-else-if="matchComponent(CurrentSourceEnum.DEVICECLASS)"/>
|
||||
<PointTable v-else-if="matchComponent(CurrentSourceEnum.POINTTABLE)"/>
|
||||
<ManualInput v-else-if="matchComponent(CurrentSourceEnum.MANUALINPUT)"/>
|
||||
</template>
|
||||
<template v-else-if="IsCommonSingle">
|
||||
<setting-item-box name="数据源" :alone="true">
|
||||
<n-select v-model:value="targetData.commonData.currentSource" :options="singleSourceOptions" size="small"/>
|
||||
</setting-item-box>
|
||||
<SinglePoint v-if="matchComponent(CurrentSourceEnum.SINGLEPOINT)"/>
|
||||
<ManualInputSingle v-if="matchComponent(CurrentSourceEnum.MANUALINPUTSINGLE)"/>
|
||||
</template>
|
||||
<setting-item-box name="更新间隔" :alone="true">
|
||||
<setting-item-box v-if="!matchComponent(CurrentSourceEnum.MANUALINPUT)" name="更新间隔" :alone="true">
|
||||
<n-input-group>
|
||||
<n-input-number
|
||||
v-model:value.trim="targetData.request.requestInterval"
|
||||
@ -66,6 +68,8 @@ import SinglePoint from './components/SinglePoint.vue'
|
||||
import MonthAlarmClass from './components/MonthAlarmClass.vue'
|
||||
import DeviceClass from './components/DeviceClass.vue'
|
||||
import PointTable from './components/PointTable.vue'
|
||||
import ManualInput from './components/ManualInput.vue'
|
||||
import ManualInputSingle from './components/ManualInputSingle.vue'
|
||||
import NoParam from './components/NoParam.vue'
|
||||
import { computed } from 'vue'
|
||||
import type { Ref } from 'vue'
|
||||
|
Loading…
x
Reference in New Issue
Block a user