mirror of
https://gitee.com/dromara/go-view.git
synced 2025-10-15 23:06:33 +08:00
feat: 添加表单模块 输入框组件
This commit is contained in:
parent
1c72bc47df
commit
63a598b423
@ -16,7 +16,11 @@ module.exports = {
|
|||||||
'vue/setup-compiler-macros': true,
|
'vue/setup-compiler-macros': true,
|
||||||
node: true,
|
node: true,
|
||||||
},
|
},
|
||||||
extends: ["plugin:vue/vue3-essential", "eslint:recommended"],
|
extends: [
|
||||||
|
"plugin:vue/vue3-essential",
|
||||||
|
"eslint:recommended",
|
||||||
|
"./.eslintrc-auto-import.json"
|
||||||
|
],
|
||||||
rules: {
|
rules: {
|
||||||
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
|
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
|
||||||
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
|
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
|
||||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,4 +1,5 @@
|
|||||||
node_modules
|
node_modules
|
||||||
|
.history
|
||||||
.husky
|
.husky
|
||||||
.DS_Store
|
.DS_Store
|
||||||
dist
|
dist
|
||||||
@ -7,4 +8,5 @@ dist-ssr
|
|||||||
.vscode
|
.vscode
|
||||||
stats.html
|
stats.html
|
||||||
auto-imports.d.ts
|
auto-imports.d.ts
|
||||||
|
.eslintrc-auto-import.json
|
||||||
components.d.ts
|
components.d.ts
|
14
plop/component-template/config.ts
Normal file
14
plop/component-template/config.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import { CreateComponentType } from '@/packages/index.d';
|
||||||
|
import { publicConfig } from '@/packages/public/publicConfig';
|
||||||
|
import { ComponentConfig } from './index'
|
||||||
|
import cloneDeep from 'lodash/cloneDeep'
|
||||||
|
|
||||||
|
export const option = {
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class Config extends publicConfig implements CreateComponentType
|
||||||
|
{
|
||||||
|
public key = ComponentConfig.key
|
||||||
|
public chartConfig = cloneDeep(ComponentConfig)
|
||||||
|
public option = cloneDeep(option)
|
||||||
|
}
|
27
plop/component-template/config.vue
Normal file
27
plop/component-template/config.vue
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<template>
|
||||||
|
<CollapseItem>
|
||||||
|
<SettingItem>
|
||||||
|
<SettingItemBox></SettingItemBox>
|
||||||
|
</SettingItem>
|
||||||
|
</CollapseItem>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { PropType } from 'vue'
|
||||||
|
import {
|
||||||
|
CollapseItem,
|
||||||
|
SettingItemBox,
|
||||||
|
SettingItem
|
||||||
|
} from '@/components/Pages/ChartItemSetting'
|
||||||
|
import { GlobalThemeJsonType } from '@/settings/chartThemes/index'
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
optionData: {
|
||||||
|
type: Object as PropType<GlobalThemeJsonType>,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style></style>
|
13
plop/component-template/index.ts
Normal file
13
plop/component-template/index.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import { FormCategoryEnum, FormCategoryEnumName } from './../../index.d';
|
||||||
|
import { PackagesCategoryEnum, ChartFrameEnum } from '@/packages/index.d';
|
||||||
|
import { getComponentConfig } from '@/utils/componets';
|
||||||
|
|
||||||
|
export const ComponentConfig = getComponentConfig({
|
||||||
|
key: 'InputCommon',
|
||||||
|
title: '输入框',
|
||||||
|
category: FormCategoryEnum.INPUT,
|
||||||
|
categoryName: FormCategoryEnumName.INPUT,
|
||||||
|
package: PackagesCategoryEnum.FORM,
|
||||||
|
chartFrame: ChartFrameEnum.COMMON
|
||||||
|
})
|
||||||
|
|
18
plop/component-template/index.vue
Normal file
18
plop/component-template/index.vue
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<template>
|
||||||
|
<div>your component</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { PropType } from 'vue'
|
||||||
|
import { CreateComponentType } from '@/packages/index.d'
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
chartConfig: {
|
||||||
|
type: Object as PropType<CreateComponentType>,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style></style>
|
13
src/enums/componentEnum.ts
Normal file
13
src/enums/componentEnum.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
export enum COMPONENT_SIZE_ENUM {
|
||||||
|
TINY = 'tiny',
|
||||||
|
SMALL = 'small',
|
||||||
|
MEDIUM = 'medium',
|
||||||
|
LARGE = 'large'
|
||||||
|
}
|
||||||
|
|
||||||
|
export const componentSizeMap = new Map([
|
||||||
|
[COMPONENT_SIZE_ENUM.TINY, '迷你'],
|
||||||
|
[COMPONENT_SIZE_ENUM.SMALL, '小'],
|
||||||
|
[COMPONENT_SIZE_ENUM.MEDIUM, '中'],
|
||||||
|
[COMPONENT_SIZE_ENUM.LARGE, '大'],
|
||||||
|
])
|
@ -30,9 +30,25 @@ export const EventTriggerTypeMap = new Map(
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
export const CommonEventMap = new Map(
|
// 数据组件事件
|
||||||
|
export enum DATA_COMPONENT_EVENT_ENUM {
|
||||||
|
LOAD_DATA ='loadData'
|
||||||
|
}
|
||||||
|
|
||||||
|
export const dataComponentEventMap = new Map(
|
||||||
[
|
[
|
||||||
['forceUpdate', '强制更新'],
|
[DATA_COMPONENT_EVENT_ENUM.LOAD_DATA, '加载数据'],
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
// 公共事件
|
||||||
|
export enum COMMON_EVENT_ENUM {
|
||||||
|
FORCE_UPDATE ='forceUpdate'
|
||||||
|
}
|
||||||
|
|
||||||
|
export const CommonEventMap = new Map(
|
||||||
|
[
|
||||||
|
[COMMON_EVENT_ENUM.FORCE_UPDATE, '强制更新'],
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import { CreateComponentType, ChartFrameEnum } from '@/packages/index.d'
|
|||||||
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
||||||
import { RequestDataTypeEnum } from '@/enums/httpEnum'
|
import { RequestDataTypeEnum } from '@/enums/httpEnum'
|
||||||
import { isPreview, newFunctionHandle, intervalUnitHandle } from '@/utils'
|
import { isPreview, newFunctionHandle, intervalUnitHandle } from '@/utils'
|
||||||
|
import { useIntervalFn } from '@vueuse/core'
|
||||||
|
|
||||||
// 获取类型
|
// 获取类型
|
||||||
type ChartEditStoreType = typeof useChartEditStore
|
type ChartEditStoreType = typeof useChartEditStore
|
||||||
@ -21,11 +22,17 @@ export const useChartDataFetch = (
|
|||||||
updateCallback?: (...args: any) => any
|
updateCallback?: (...args: any) => any
|
||||||
) => {
|
) => {
|
||||||
const vChartRef = ref<typeof VChart | null>(null)
|
const vChartRef = ref<typeof VChart | null>(null)
|
||||||
let fetchInterval: any = 0
|
let pauseFn: any = null
|
||||||
|
let resumeFn: any = null
|
||||||
|
let fetchFn: any = null
|
||||||
|
|
||||||
const requestIntervalFn = () => {
|
const requestIntervalFn = () => {
|
||||||
const chartEditStore = useChartEditStore()
|
const chartEditStore = useChartEditStore()
|
||||||
|
|
||||||
|
pauseFn = null
|
||||||
|
resumeFn = null
|
||||||
|
fetchFn = null
|
||||||
|
|
||||||
// 全局数据
|
// 全局数据
|
||||||
const {
|
const {
|
||||||
requestOriginUrl,
|
requestOriginUrl,
|
||||||
@ -55,9 +62,7 @@ export const useChartDataFetch = (
|
|||||||
const completePath = requestOriginUrl && requestOriginUrl.value + requestUrl.value
|
const completePath = requestOriginUrl && requestOriginUrl.value + requestUrl.value
|
||||||
if (!completePath) return
|
if (!completePath) return
|
||||||
|
|
||||||
clearInterval(fetchInterval)
|
fetchFn = async (callback: () => any) => {
|
||||||
|
|
||||||
const fetchFn = async () => {
|
|
||||||
const res = await customizeHttp(toRaw(targetComponent.request), toRaw(chartEditStore.requestGlobalConfig))
|
const res = await customizeHttp(toRaw(targetComponent.request), toRaw(chartEditStore.requestGlobalConfig))
|
||||||
if (res && res.data) {
|
if (res && res.data) {
|
||||||
try {
|
try {
|
||||||
@ -73,6 +78,7 @@ export const useChartDataFetch = (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
callback && callback()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
}
|
}
|
||||||
@ -87,11 +93,17 @@ export const useChartDataFetch = (
|
|||||||
// 单位
|
// 单位
|
||||||
const unit = targetInterval && targetInterval.value ? targetUnit.value : globalUnit.value
|
const unit = targetInterval && targetInterval.value ? targetUnit.value : globalUnit.value
|
||||||
// 开启轮询
|
// 开启轮询
|
||||||
if (time) fetchInterval = setInterval(fetchFn, intervalUnitHandle(time, unit))
|
if (time) {
|
||||||
|
const { pause, resume, isActive } = useIntervalFn(fetchFn, intervalUnitHandle(time, unit))
|
||||||
|
pauseFn = pause
|
||||||
|
resumeFn = resume
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
}
|
}
|
||||||
} catch (error) {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
isPreview() && requestIntervalFn()
|
isPreview() && requestIntervalFn()
|
||||||
return { vChartRef }
|
return { vChartRef, pauseFn, resumeFn, fetchFn }
|
||||||
}
|
}
|
||||||
|
13
src/packages/components/Charts/Bars/BarCommon/enum.ts
Normal file
13
src/packages/components/Charts/Bars/BarCommon/enum.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import { dataComponentEventMap } from '@/enums/eventEnum';
|
||||||
|
import { OptionsType } from '@/packages/index.d';
|
||||||
|
import { mapToOptions } from '@/utils';
|
||||||
|
|
||||||
|
//内置方法
|
||||||
|
export const methodList = mapToOptions(dataComponentEventMap) as Array<OptionsType>
|
||||||
|
|
||||||
|
export const config = {
|
||||||
|
key: 'BarCommon',
|
||||||
|
title: '柱状图',
|
||||||
|
methodList
|
||||||
|
}
|
||||||
|
|
@ -2,10 +2,10 @@ import image from '@/assets/images/chart/charts/bar_x.png'
|
|||||||
import { ConfigType, PackagesCategoryEnum, ChartFrameEnum } from '@/packages/index.d'
|
import { ConfigType, PackagesCategoryEnum, ChartFrameEnum } from '@/packages/index.d'
|
||||||
import { getComponentConfig } from '@/utils'
|
import { getComponentConfig } from '@/utils'
|
||||||
import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d'
|
import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d'
|
||||||
|
import { config } from './enum'
|
||||||
|
|
||||||
export const BarCommonConfig: ConfigType = getComponentConfig({
|
export const BarCommonConfig: ConfigType = getComponentConfig({
|
||||||
key: 'BarCommon',
|
...config,
|
||||||
title: '柱状图',
|
|
||||||
category: ChatCategoryEnum.BAR,
|
category: ChatCategoryEnum.BAR,
|
||||||
categoryName: ChatCategoryEnumName.BAR,
|
categoryName: ChatCategoryEnumName.BAR,
|
||||||
package: PackagesCategoryEnum.CHARTS,
|
package: PackagesCategoryEnum.CHARTS,
|
||||||
|
@ -49,5 +49,15 @@ const option = computed(() => {
|
|||||||
return mergeTheme(props.chartConfig.option, props.themeSetting, includes)
|
return mergeTheme(props.chartConfig.option, props.themeSetting, includes)
|
||||||
})
|
})
|
||||||
|
|
||||||
const { vChartRef } = useChartDataFetch(props.chartConfig, useChartEditStore)
|
const { vChartRef, pauseFn, resumeFn, fetchFn } = useChartDataFetch(props.chartConfig, useChartEditStore)
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
loadData: async () => {
|
||||||
|
if(fetchFn){
|
||||||
|
pauseFn()
|
||||||
|
await fetchFn()
|
||||||
|
resumeFn()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
import { CreateComponentType } from '@/packages/index.d';
|
||||||
|
import { publicConfig } from '@/packages/public/publicConfig';
|
||||||
|
import { DatePickerCommonConfig } from './index'
|
||||||
|
import cloneDeep from 'lodash/cloneDeep'
|
||||||
|
|
||||||
|
export const option = {
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class Config extends publicConfig implements CreateComponentType
|
||||||
|
{
|
||||||
|
public key = DatePickerCommonConfig.key
|
||||||
|
public chartConfig = cloneDeep(DatePickerCommonConfig)
|
||||||
|
public option = cloneDeep(option)
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
<template>
|
||||||
|
<div>config</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts"></script>
|
||||||
|
|
||||||
|
<style></style>
|
@ -0,0 +1,13 @@
|
|||||||
|
import { FormCategoryEnum, FormCategoryEnumName } from '../../index.d';
|
||||||
|
import { PackagesCategoryEnum, ChartFrameEnum } from '@/packages/index.d';
|
||||||
|
import { getComponentConfig } from '@/utils/componets';
|
||||||
|
|
||||||
|
export const DatePickerCommonConfig = getComponentConfig({
|
||||||
|
key: 'DatePickerCommon',
|
||||||
|
title: '日期选择',
|
||||||
|
category: FormCategoryEnum.DATE_PICKER,
|
||||||
|
categoryName: FormCategoryEnumName.DATE_PICKER,
|
||||||
|
package: PackagesCategoryEnum.FORM,
|
||||||
|
chartFrame: ChartFrameEnum.COMMON
|
||||||
|
})
|
||||||
|
|
@ -0,0 +1,13 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<span>DATE_PICKER</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang='ts'>
|
||||||
|
defineProps({})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
|
||||||
|
</style>
|
3
src/packages/components/Form/DatePickers/index.ts
Normal file
3
src/packages/components/Form/DatePickers/index.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
import { DatePickerCommonConfig } from './DatePickerCommon/index'
|
||||||
|
|
||||||
|
export default [ DatePickerCommonConfig ]
|
24
src/packages/components/Form/Inputs/InputCommon/config.ts
Normal file
24
src/packages/components/Form/Inputs/InputCommon/config.ts
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import { CreateComponentType } from '@/packages/index.d';
|
||||||
|
import { publicConfig } from '@/packages/public/publicConfig';
|
||||||
|
import { InputCommonConfig } from './index'
|
||||||
|
import cloneDeep from 'lodash/cloneDeep'
|
||||||
|
import { COMPONENT_SIZE_ENUM } from '@/enums/componentEnum';
|
||||||
|
|
||||||
|
export const option = {
|
||||||
|
// 参考 https://www.naiveui.com/zh-CN/os-theme/components/input
|
||||||
|
inputOption: {
|
||||||
|
clearable: true,
|
||||||
|
maxlength: 20,
|
||||||
|
placeholder: '',
|
||||||
|
round: false,
|
||||||
|
showCount: false,
|
||||||
|
size: COMPONENT_SIZE_ENUM.MEDIUM
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class Config extends publicConfig implements CreateComponentType
|
||||||
|
{
|
||||||
|
public key = InputCommonConfig.key
|
||||||
|
public chartConfig = cloneDeep(InputCommonConfig)
|
||||||
|
public option = cloneDeep(option)
|
||||||
|
}
|
48
src/packages/components/Form/Inputs/InputCommon/config.vue
Normal file
48
src/packages/components/Form/Inputs/InputCommon/config.vue
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
<template>
|
||||||
|
<CollapseItem name="属性配置" :expanded="true">
|
||||||
|
<n-form label-placement="left" label-align="right" label-width="auto">
|
||||||
|
<n-form-item label="可清空">
|
||||||
|
<n-switch v-model:value="inputOption.clearable"></n-switch>
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item label="最大长度">
|
||||||
|
<n-input-number v-model:value="inputOption.maxlength" :min="0" :max="200" :precision="0"/>
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item label="placeholder">
|
||||||
|
<n-input v-model:value="inputOption.placeholder"/>
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item label="圆角">
|
||||||
|
<n-switch v-model:value="inputOption.round"></n-switch>
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item label="显示字数统计">
|
||||||
|
<n-switch v-model:value="inputOption.showCount"></n-switch>
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item label="尺寸">
|
||||||
|
<n-select v-model:value="inputOption.size" :options="mapToOptions(componentSizeMap)"></n-select>
|
||||||
|
</n-form-item>
|
||||||
|
</n-form>
|
||||||
|
</CollapseItem>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { PropType, toRefs } from 'vue'
|
||||||
|
import {
|
||||||
|
CollapseItem,
|
||||||
|
SettingItemBox,
|
||||||
|
SettingItem
|
||||||
|
} from '@/components/Pages/ChartItemSetting'
|
||||||
|
import { GlobalThemeJsonType } from '@/settings/chartThemes/index'
|
||||||
|
import { mapToOptions } from '@/utils';
|
||||||
|
import { componentSizeMap } from '@/enums/componentEnum'
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
optionData: {
|
||||||
|
type: Object as PropType<GlobalThemeJsonType>,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const { inputOption } = toRefs(props.optionData)
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style></style>
|
13
src/packages/components/Form/Inputs/InputCommon/index.ts
Normal file
13
src/packages/components/Form/Inputs/InputCommon/index.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import { FormCategoryEnum, FormCategoryEnumName } from './../../index.d';
|
||||||
|
import { PackagesCategoryEnum, ChartFrameEnum } from '@/packages/index.d';
|
||||||
|
import { getComponentConfig } from '@/utils/componets';
|
||||||
|
|
||||||
|
export const InputCommonConfig = getComponentConfig({
|
||||||
|
key: 'InputCommon',
|
||||||
|
title: '输入框',
|
||||||
|
category: FormCategoryEnum.INPUT,
|
||||||
|
categoryName: FormCategoryEnumName.INPUT,
|
||||||
|
package: PackagesCategoryEnum.FORM,
|
||||||
|
chartFrame: ChartFrameEnum.COMMON
|
||||||
|
})
|
||||||
|
|
23
src/packages/components/Form/Inputs/InputCommon/index.vue
Normal file
23
src/packages/components/Form/Inputs/InputCommon/index.vue
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<template>
|
||||||
|
<n-form-item>
|
||||||
|
<n-input v-bind="inputOption" v-model:value="val"/>
|
||||||
|
</n-form-item>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { PropType, computed, ref } from 'vue'
|
||||||
|
import { CreateComponentType } from '@/packages/index.d'
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
chartConfig: {
|
||||||
|
type: Object as PropType<CreateComponentType>,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const inputOption = computed(() => props.chartConfig.option.inputOption)
|
||||||
|
|
||||||
|
const val = ref('')
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style></style>
|
3
src/packages/components/Form/Inputs/index.ts
Normal file
3
src/packages/components/Form/Inputs/index.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
import { InputCommonConfig } from './InputCommon/index'
|
||||||
|
|
||||||
|
export default [ InputCommonConfig ]
|
14
src/packages/components/Form/Selects/SelectCommon/config.ts
Normal file
14
src/packages/components/Form/Selects/SelectCommon/config.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import { CreateComponentType } from '@/packages/index.d';
|
||||||
|
import { publicConfig } from '@/packages/public/publicConfig';
|
||||||
|
import { SelectCommonConfig } from './index'
|
||||||
|
import cloneDeep from 'lodash/cloneDeep'
|
||||||
|
|
||||||
|
export const option = {
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class Config extends publicConfig implements CreateComponentType
|
||||||
|
{
|
||||||
|
public key = SelectCommonConfig.key
|
||||||
|
public chartConfig = cloneDeep(SelectCommonConfig)
|
||||||
|
public option = cloneDeep(option)
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
<template>
|
||||||
|
<div>config</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts"></script>
|
||||||
|
|
||||||
|
<style></style>
|
13
src/packages/components/Form/Selects/SelectCommon/index.ts
Normal file
13
src/packages/components/Form/Selects/SelectCommon/index.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import { FormCategoryEnum, FormCategoryEnumName } from './../../index.d';
|
||||||
|
import { PackagesCategoryEnum, ChartFrameEnum } from '@/packages/index.d';
|
||||||
|
import { getComponentConfig } from '@/utils/componets';
|
||||||
|
|
||||||
|
export const SelectCommonConfig = getComponentConfig({
|
||||||
|
key: 'SelectCommon',
|
||||||
|
title: '下拉框',
|
||||||
|
category: FormCategoryEnum.SELECT,
|
||||||
|
categoryName: FormCategoryEnumName.SELECT,
|
||||||
|
package: PackagesCategoryEnum.FORM,
|
||||||
|
chartFrame: ChartFrameEnum.COMMON
|
||||||
|
})
|
||||||
|
|
13
src/packages/components/Form/Selects/SelectCommon/index.vue
Normal file
13
src/packages/components/Form/Selects/SelectCommon/index.vue
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
select
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang='ts'>
|
||||||
|
defineProps({})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
|
||||||
|
</style>
|
3
src/packages/components/Form/Selects/index.ts
Normal file
3
src/packages/components/Form/Selects/index.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
import { SelectCommonConfig } from './SelectCommon/index'
|
||||||
|
|
||||||
|
export default [ SelectCommonConfig ]
|
13
src/packages/components/Form/index.d.ts
vendored
Normal file
13
src/packages/components/Form/index.d.ts
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
export enum FormCategoryEnum {
|
||||||
|
INPUT = 'Inputs',
|
||||||
|
SELECT = 'Selects',
|
||||||
|
DATE_PICKER = 'DatePickers',
|
||||||
|
MORE = 'Mores'
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum FormCategoryEnumName {
|
||||||
|
INPUT = '输入框',
|
||||||
|
SELECT = '下拉框',
|
||||||
|
DATE_PICKER = '日期选择',
|
||||||
|
MORE = '更多'
|
||||||
|
}
|
5
src/packages/components/Form/index.ts
Normal file
5
src/packages/components/Form/index.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import Inputs from './Inputs'
|
||||||
|
import DatePickers from './DatePickers'
|
||||||
|
import Selects from './Selects'
|
||||||
|
|
||||||
|
export const FormList = [...Inputs, ...DatePickers, ...Selects]
|
9
src/packages/index.d.ts
vendored
9
src/packages/index.d.ts
vendored
@ -33,7 +33,7 @@ export type ConfigType = {
|
|||||||
chartFrame?: ChartFrameEnum
|
chartFrame?: ChartFrameEnum
|
||||||
methodList?: Array<OptionsType>
|
methodList?: Array<OptionsType>
|
||||||
eventList?: Array<OptionsType>
|
eventList?: Array<OptionsType>
|
||||||
image: string | (() => Promise<typeof import('*.png')>)
|
image?: string | (() => Promise<typeof import('*.png')>)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -132,7 +132,8 @@ export enum PackagesCategoryEnum {
|
|||||||
CHARTS = 'Charts',
|
CHARTS = 'Charts',
|
||||||
TABLES = 'Tables',
|
TABLES = 'Tables',
|
||||||
INFORMATIONS = 'Informations',
|
INFORMATIONS = 'Informations',
|
||||||
DECORATES = 'Decorates'
|
DECORATES = 'Decorates',
|
||||||
|
FORM = 'Form',
|
||||||
}
|
}
|
||||||
|
|
||||||
// 包分类名称
|
// 包分类名称
|
||||||
@ -140,7 +141,8 @@ export enum PackagesCategoryName {
|
|||||||
CHARTS = '图表',
|
CHARTS = '图表',
|
||||||
TABLES = '列表',
|
TABLES = '列表',
|
||||||
INFORMATIONS = '信息',
|
INFORMATIONS = '信息',
|
||||||
DECORATES = '小组件'
|
DECORATES = '小组件',
|
||||||
|
FORM = '表单',
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取组件
|
// 获取组件
|
||||||
@ -155,4 +157,5 @@ export type PackagesType = {
|
|||||||
[PackagesCategoryEnum.INFORMATIONS]: ConfigType[]
|
[PackagesCategoryEnum.INFORMATIONS]: ConfigType[]
|
||||||
[PackagesCategoryEnum.TABLES]: ConfigType[]
|
[PackagesCategoryEnum.TABLES]: ConfigType[]
|
||||||
[PackagesCategoryEnum.DECORATES]: ConfigType[]
|
[PackagesCategoryEnum.DECORATES]: ConfigType[]
|
||||||
|
[PackagesCategoryEnum.FORM]: ConfigType[]
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ import { ChartList } from '@/packages/components/Charts/index'
|
|||||||
import { DecorateList } from '@/packages/components/Decorates/index'
|
import { DecorateList } from '@/packages/components/Decorates/index'
|
||||||
import { InformationList } from '@/packages/components/Informations/index'
|
import { InformationList } from '@/packages/components/Informations/index'
|
||||||
import { TableList } from '@/packages/components/Tables/index'
|
import { TableList } from '@/packages/components/Tables/index'
|
||||||
|
import { FormList } from '@/packages/components/Form/index'
|
||||||
import {
|
import {
|
||||||
PackagesCategoryEnum,
|
PackagesCategoryEnum,
|
||||||
PackagesType,
|
PackagesType,
|
||||||
@ -17,7 +18,8 @@ export let packagesList: PackagesType = {
|
|||||||
[PackagesCategoryEnum.CHARTS]: ChartList,
|
[PackagesCategoryEnum.CHARTS]: ChartList,
|
||||||
[PackagesCategoryEnum.INFORMATIONS]: InformationList,
|
[PackagesCategoryEnum.INFORMATIONS]: InformationList,
|
||||||
[PackagesCategoryEnum.TABLES]: TableList,
|
[PackagesCategoryEnum.TABLES]: TableList,
|
||||||
[PackagesCategoryEnum.DECORATES]: DecorateList
|
[PackagesCategoryEnum.DECORATES]: DecorateList,
|
||||||
|
[PackagesCategoryEnum.FORM]: FormList,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -90,6 +90,7 @@ import {
|
|||||||
Filter as FilterIcon,
|
Filter as FilterIcon,
|
||||||
FilterEdit as FilterEditIcon,
|
FilterEdit as FilterEditIcon,
|
||||||
Edit as EditIcon,
|
Edit as EditIcon,
|
||||||
|
DataFormat as DataFormatIcon
|
||||||
} from '@vicons/carbon'
|
} from '@vicons/carbon'
|
||||||
|
|
||||||
const ionicons5 = {
|
const ionicons5 = {
|
||||||
@ -218,6 +219,7 @@ const ionicons5 = {
|
|||||||
|
|
||||||
const carbon = {
|
const carbon = {
|
||||||
EditIcon,
|
EditIcon,
|
||||||
|
DataFormatIcon,
|
||||||
// 图表
|
// 图表
|
||||||
RoadmapIcon,
|
RoadmapIcon,
|
||||||
// 信息
|
// 信息
|
||||||
|
@ -20,6 +20,11 @@ export const loadAsyncComponent = (loader: AsyncComponentLoader<any>) =>
|
|||||||
defineAsyncComponent({
|
defineAsyncComponent({
|
||||||
loader,
|
loader,
|
||||||
loadingComponent: AsyncLoading,
|
loadingComponent: AsyncLoading,
|
||||||
|
errorComponent: {
|
||||||
|
render(){
|
||||||
|
return '加载失败'
|
||||||
|
}
|
||||||
|
},
|
||||||
delay: 20,
|
delay: 20,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ export const newFunctionHandle = (
|
|||||||
try {
|
try {
|
||||||
if (!funcStr) return data
|
if (!funcStr) return data
|
||||||
const fn = new Function('data', funcStr)
|
const fn = new Function('data', funcStr)
|
||||||
const fnRes = fn(cloneDeep(data))
|
const fnRes = fn(data)
|
||||||
const resHandle = isToString ? toString(fnRes) : fnRes
|
const resHandle = isToString ? toString(fnRes) : fnRes
|
||||||
// 成功回调
|
// 成功回调
|
||||||
successCallBack && successCallBack(resHandle)
|
successCallBack && successCallBack(resHandle)
|
||||||
|
@ -13,6 +13,7 @@ const {
|
|||||||
RoadmapIcon,
|
RoadmapIcon,
|
||||||
SpellCheckIcon,
|
SpellCheckIcon,
|
||||||
GraphicalDataFlowIcon,
|
GraphicalDataFlowIcon,
|
||||||
|
DataFormatIcon,
|
||||||
} = icon.carbon
|
} = icon.carbon
|
||||||
|
|
||||||
|
|
||||||
@ -44,6 +45,10 @@ const packagesListObj = {
|
|||||||
icon: renderIcon(GraphicalDataFlowIcon),
|
icon: renderIcon(GraphicalDataFlowIcon),
|
||||||
label: PackagesCategoryName.DECORATES,
|
label: PackagesCategoryName.DECORATES,
|
||||||
},
|
},
|
||||||
|
[PackagesCategoryEnum.FORM]: {
|
||||||
|
icon: renderIcon(DataFormatIcon),
|
||||||
|
label: PackagesCategoryName.FORM,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理列表
|
// 处理列表
|
||||||
|
@ -70,6 +70,7 @@ const select = computed(() => {
|
|||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
transform: translate(-40%, -30%);
|
transform: translate(-40%, -30%);
|
||||||
|
cursor: col-resize;
|
||||||
&.t {
|
&.t {
|
||||||
width: 30px;
|
width: 30px;
|
||||||
transform: translate(-50%, -50%);
|
transform: translate(-50%, -50%);
|
||||||
|
@ -127,6 +127,12 @@ onMounted(() => {
|
|||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
export default {
|
||||||
|
name: 'ContentEdit'
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@include goId('chart-edit-layout') {
|
@include goId('chart-edit-layout') {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<component
|
<component
|
||||||
|
ref="componentRef"
|
||||||
:is="item.chartConfig.chartKey"
|
:is="item.chartConfig.chartKey"
|
||||||
:chartConfig="item"
|
:chartConfig="item"
|
||||||
:themeSetting="themeSetting"
|
:themeSetting="themeSetting"
|
||||||
@ -10,14 +11,15 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang='ts' setup>
|
<script lang='ts' setup>
|
||||||
import { PropType, toRefs, getCurrentInstance, ComponentInternalInstance } from 'vue'
|
import { PropType, toRefs, computed, getCurrentInstance, ComponentInternalInstance } from 'vue'
|
||||||
import { useEventBus } from '@/hooks'
|
import { useEventBus } from '@/hooks'
|
||||||
import { convertEventBusListeners } from '@/hooks/useEventBus.hook'
|
import { convertEventBusListeners } from '@/hooks/useEventBus.hook'
|
||||||
import { getSizeStyle } from '../../utils'
|
import { getSizeStyle } from '../../utils'
|
||||||
import { EventTriggerType } from '@/enums/eventEnum'
|
import { EventTriggerType } from '@/enums/eventEnum'
|
||||||
import { CreateComponentType, EventConfig } from '@/packages/index.d'
|
import { CreateComponentType, EventConfig, PackagesCategoryEnum } from '@/packages/index.d'
|
||||||
import { newFunctionHandle } from '@/utils'
|
import { newFunctionHandle } from '@/utils'
|
||||||
import isObject from 'lodash/isObject'
|
import isObject from 'lodash/isObject'
|
||||||
|
import { COMMON_EVENT_ENUM, DATA_COMPONENT_EVENT_ENUM } from '@/enums/eventEnum'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
item: {
|
item: {
|
||||||
@ -39,7 +41,8 @@ const props = defineProps({
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
const { item, themeSetting, themeColor, useEvent } = toRefs(props)
|
const { item, themeSetting, themeColor, useEvent } = toRefs(props);
|
||||||
|
const componentRef = ref(null)
|
||||||
const instance = getCurrentInstance() as ComponentInternalInstance
|
const instance = getCurrentInstance() as ComponentInternalInstance
|
||||||
const bus = useEventBus()
|
const bus = useEventBus()
|
||||||
/**
|
/**
|
||||||
@ -56,17 +59,17 @@ const getEventList = (eventConfig: EventConfig) => {
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
previousValue[currentValue] = eventConfig[currentValue].methodList.map((item: any) => {
|
previousValue[currentValue] = eventConfig[currentValue].methodList.map((item: any) => {
|
||||||
if(item.type === EventTriggerType.JAVASCRIPT){
|
if(item.type === EventTriggerType.JAVASCRIPT){
|
||||||
return (config: CreateComponentType) => {
|
return (e: any) => {
|
||||||
try {
|
try {
|
||||||
newFunctionHandle(config, item.code)
|
newFunctionHandle(e, item.code)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error, item.code)
|
console.error(error, item.code)
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
return () => {
|
return (data: any) => {
|
||||||
bus.emit(`${item.componentId}:${item.componentMethod}`)
|
bus.emit(`${item.componentId}:${item.componentMethod}`, data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -74,15 +77,27 @@ const getEventList = (eventConfig: EventConfig) => {
|
|||||||
}, {} as EventConfig)
|
}, {} as EventConfig)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
// 是否是数据组件
|
||||||
|
const isDataComponent = computed(() => {
|
||||||
|
return item.value.chartConfig.package === PackagesCategoryEnum.CHARTS ||
|
||||||
|
item.value.chartConfig.package === PackagesCategoryEnum.TABLES
|
||||||
|
})
|
||||||
|
|
||||||
const listeners = {
|
const listeners: Record<string, any> = {
|
||||||
on: {
|
on: {
|
||||||
forceUpdate: () => {
|
[COMMON_EVENT_ENUM.FORCE_UPDATE]: () => {
|
||||||
instance.proxy?.$forceUpdate()
|
instance.proxy?.$forceUpdate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(isDataComponent.value){
|
||||||
|
// 数据组件监听刷新数据
|
||||||
|
listeners.on[DATA_COMPONENT_EVENT_ENUM.LOAD_DATA] = () => {
|
||||||
|
componentRef.value.loadData()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
useEventBus(convertEventBusListeners(listeners, item.value.id))
|
useEventBus(convertEventBusListeners(listeners, item.value.id))
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -29,7 +29,13 @@ const devPlugins = [
|
|||||||
imports: [
|
imports: [
|
||||||
'vue',
|
'vue',
|
||||||
'vue-router',
|
'vue-router',
|
||||||
]
|
{
|
||||||
|
'vue': ['PropType']
|
||||||
|
}
|
||||||
|
],
|
||||||
|
eslintrc: {
|
||||||
|
enabled: true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
Components({
|
Components({
|
||||||
|
BIN
数据收集模块设计.drawio.png
Normal file
BIN
数据收集模块设计.drawio.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 66 KiB |
Loading…
x
Reference in New Issue
Block a user