Commit 49f41cf6db41e5098d2978fcac52722e626d6e29

Authored by fengwotao
1 parent 4fe7ee40

feat(external/Compose): 组合-更多下新增了按钮和日期时间两个控件

... ... @@ -15,5 +15,5 @@ export const LeftCenterRightHeadConfig: ConfigType = {
15 15 categoryName: ChatCategoryEnumName.HEADCOMBINATION,
16 16 package: EPackagesCategoryEnum.COMPOSES,
17 17 chartFrame: ChartFrameEnum.COMMON,
18   - image: 'left_center_rightHead.png',
  18 + image: 'customHead1.png',
19 19 }
... ...
1 1 <template>
2 2 <div class="go-animat">
3 3 <div class="go-animat-item" :style="{ marginLeft: animat.x + 'px', marginTop: animat.y + 'px' }">
4   - <svg :width="animat.w + 'px'" :height="animat.h + 'px'">
  4 + <svg :width="w" :height="h">
5 5 <polyline
6 6 fill="transparent"
7 7 stroke-width="3"
8   - :points="`0,20 ${animat.w / 5.555555555555556},20 ${animat.w / 5},40 ${animat.w / 4},40 ${
9   - animat.w / 3.703703703703704
10   - },60 ${animat.w / 1.388888888888889},60 ${animat.w / 1.333333333333333},40 ${animat.w / 1.25},40 ${
11   - animat.w / 1.219512195121951
12   - },20 ${animat.w},20`"
  8 + :points="`0,20 ${w / 5.555555555555556},20 ${w / 5},40 ${w / 4},40 ${
  9 + w / 3.703703703703704
  10 + },60 ${w / 1.388888888888889},60 ${w / 1.333333333333333},40 ${w / 1.25},40 ${
  11 + w / 1.219512195121951
  12 + },20 ${w},20`"
13 13 :stroke="animat.colors[0]"
14 14 >
15 15 <animate
... ... @@ -28,7 +28,7 @@
28 28 <polyline
29 29 fill="transparent"
30 30 stroke-width="2"
31   - :points="`${animat.w / 3.333333333333333},80 ${animat.w / 1.428571428571429},80`"
  31 + :points="`${w / 3.333333333333333},80 ${w / 1.428571428571429},80`"
32 32 :stroke="animat.colors[1]"
33 33 >
34 34 <animate
... ... @@ -70,6 +70,8 @@ props.chartConfig.attr.h = 300
70 70 props.chartConfig.attr.x = 0
71 71 props.chartConfig.attr.y = 0
72 72
  73 +const { w, h } = toRefs(props.chartConfig.attr)
  74 +
73 75 const { animat } = toRefs(props.chartConfig.option)
74 76 </script>
75 77
... ...
... ... @@ -13,5 +13,5 @@ export const LeftCenterRightHeadCommonConfig: ConfigType = {
13 13 categoryName: ChatCategoryEnumName.HEADCOMBINATION,
14 14 package: EPackagesCategoryEnum.COMPOSES,
15 15 chartFrame: ChartFrameEnum.COMMON,
16   - image: 'left_center_rightHead.png',
  16 + image: 'customHead2.png',
17 17 }
... ...
  1 +import { PublicConfigClass } from '@/packages/public'
  2 +import { CreateComponentType } from '@/packages/index.d'
  3 +import { ButtonConfig } from './index'
  4 +import cloneDeep from 'lodash/cloneDeep'
  5 +
  6 +export const option = {
  7 + dataset: '默认',
  8 + /**
  9 + * Naive UI button部分属性
  10 + */
  11 + attribute:{
  12 + //尺寸
  13 + size:'medium',
  14 + //透明
  15 + ghost:false,
  16 + //加载
  17 + loading:false,
  18 + //自定义颜色
  19 + color:'#ffffff',
  20 + //文字背景
  21 + textColor:'black'
  22 + }
  23 +}
  24 +
  25 +export default class Config extends PublicConfigClass implements CreateComponentType {
  26 + public key = ButtonConfig.key
  27 + public chartConfig = cloneDeep(ButtonConfig)
  28 + public option = cloneDeep(option)
  29 +}
... ...
  1 +<template>
  2 + <CollapseItem name="按钮配置" :expanded="true">
  3 + <SettingItemBox name="信息">
  4 + <SettingItem name="文字">
  5 + <n-input size="small" v-model:value="optionData.dataset"></n-input>
  6 + </SettingItem>
  7 + <SettingItem name="文字颜色">
  8 + <n-color-picker size="small" :modes="['hex']" v-model:value="optionData.attribute.textColor"></n-color-picker>
  9 + </SettingItem>
  10 + <SettingItem>
  11 + <n-button size="small" @click="optionData.attribute.textColor ='black'"> 恢复默认 </n-button>
  12 + </SettingItem>
  13 + </SettingItemBox>
  14 + <SettingItemBox name="属性">
  15 + <SettingItem name="颜色">
  16 + <n-color-picker size="small" :modes="['hex']" v-model:value="optionData.attribute.color"></n-color-picker>
  17 + </SettingItem>
  18 + <SettingItem>
  19 + <n-button size="small" @click="optionData.attribute.color ='#ffffff'"> 恢复默认 </n-button>
  20 + </SettingItem>
  21 + <SettingItem name="是否透明">
  22 + <n-switch v-model:value="optionData.attribute.ghost" />
  23 + </SettingItem>
  24 + <SettingItem name="是否加载">
  25 + <n-switch v-model:value="optionData.attribute.loading" />
  26 + </SettingItem>
  27 + </SettingItemBox>
  28 + </CollapseItem>
  29 +</template>
  30 +
  31 +<script setup lang="ts">
  32 +import { PropType } from 'vue'
  33 +import { option } from './config'
  34 +import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting'
  35 +
  36 +defineProps({
  37 + optionData: {
  38 + type: Object as PropType<typeof option>,
  39 + required: true
  40 + }
  41 +})
  42 +</script>
... ...
  1 +import { ChartFrameEnum, ConfigType } from '@/packages/index.d'
  2 +import { EPackagesCategoryEnum } from '@/packages/components/external/types'
  3 +import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d'
  4 +import { useWidgetKey } from '@/packages/external/useWidgetKey'
  5 +
  6 +const { key, chartKey, conKey } = useWidgetKey('Button')
  7 +export const ButtonConfig: ConfigType = {
  8 + key,
  9 + chartKey,
  10 + conKey,
  11 + title: '按钮',
  12 + category: ChatCategoryEnum.MORE,
  13 + categoryName: ChatCategoryEnumName.MORE,
  14 + package: EPackagesCategoryEnum.COMPOSES,
  15 + chartFrame: ChartFrameEnum.NAIVE_UI,
  16 + image: 'button.png',
  17 +}
... ...
  1 +<template>
  2 + <div class="go-content-box">
  3 + <n-button class="content" @click="handleClick" v-bind={...attribute}>{{dataset}}</n-button>
  4 + </div>
  5 +</template>
  6 +<script setup lang="ts">
  7 +import { PropType, toRefs } from 'vue'
  8 +import { CreateComponentType } from '@/packages/index.d'
  9 +import {option as configOption} from './config'
  10 +
  11 +
  12 +const props = defineProps({
  13 + chartConfig: {
  14 + type: Object as PropType<CreateComponentType>,
  15 + required: true
  16 + }
  17 +})
  18 +
  19 +//修改默认宽高距离位置
  20 +props.chartConfig.attr.w = 100
  21 +props.chartConfig.attr.h = 50
  22 +props.chartConfig.attr.x = 200
  23 +props.chartConfig.attr.y = 200
  24 +
  25 +const { dataset,attribute }= toRefs(props.chartConfig.option) as unknown as typeof configOption
  26 +
  27 +const { w, h } = toRefs(props.chartConfig.attr)
  28 +
  29 +const handleClick=()=>{
  30 + attribute.loading=true
  31 + window['$message'].success('您点击了按钮')
  32 + attribute.loading=false
  33 +}
  34 +
  35 +
  36 +
  37 +</script>
  38 +
  39 +<style lang="scss" scoped>
  40 +.go-content-box{
  41 + display: flex;
  42 + align-items: center;
  43 + justify-content: center;
  44 + .content{
  45 + width:v-bind('w + "px"');
  46 + height:v-bind('h + "px"');
  47 + }
  48 +}
  49 +</style>
... ...
  1 +import { PublicConfigClass } from '@/packages/public'
  2 +import { CreateComponentType } from '@/packages/index.d'
  3 +import { DateTimeConfig } from './index'
  4 +import cloneDeep from 'lodash/cloneDeep'
  5 +
  6 +export const option = {
  7 + /**
  8 + * Naive UI Date Picker部分属性
  9 + */
  10 + dataset:[Date.now(), Date.now()],
  11 + attribute:{
  12 + //是否支持清除
  13 + clearable:false,
  14 + //是否禁用
  15 + disabled:false,
  16 + //尺寸
  17 + size:'medium'
  18 + }
  19 +}
  20 +
  21 +export default class Config extends PublicConfigClass implements CreateComponentType {
  22 + public key = DateTimeConfig.key
  23 + public chartConfig = cloneDeep(DateTimeConfig)
  24 + public option = cloneDeep(option)
  25 +}
... ...
  1 +<template>
  2 + <CollapseItem name="日期时间配置" :expanded="true">
  3 + <SettingItemBox name="属性">
  4 + <SettingItem name="是否支持清除">
  5 + <n-switch v-model:value="optionData.attribute.clearable" />
  6 + </SettingItem>
  7 + <SettingItem name="是否禁用">
  8 + <n-switch v-model:value="optionData.attribute.disabled" />
  9 + </SettingItem>
  10 + <SettingItem name="尺寸">
  11 + <n-select v-model:value="optionData.attribute.size" :options="options" />
  12 + </SettingItem>
  13 + </SettingItemBox>
  14 + </CollapseItem>
  15 +</template>
  16 +
  17 +<script setup lang="ts">
  18 +import { PropType } from 'vue'
  19 +import { option } from './config'
  20 +import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting'
  21 +
  22 +defineProps({
  23 + optionData: {
  24 + type: Object as PropType<typeof option>,
  25 + required: true
  26 + }
  27 +})
  28 +
  29 +const options=[
  30 + {
  31 + label: "小型",
  32 + value: 'small',
  33 + },
  34 + {
  35 + label: '中等',
  36 + value: 'medium'
  37 + },
  38 + {
  39 + label: '大型',
  40 + value: 'large'
  41 + },
  42 +]
  43 +</script>
... ...
  1 +import { ChartFrameEnum, ConfigType } from '@/packages/index.d'
  2 +import { EPackagesCategoryEnum } from '@/packages/components/external/types'
  3 +import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d'
  4 +import { useWidgetKey } from '@/packages/external/useWidgetKey'
  5 +
  6 +const { key, chartKey, conKey } = useWidgetKey('DateTime')
  7 +export const DateTimeConfig: ConfigType = {
  8 + key,
  9 + chartKey,
  10 + conKey,
  11 + title: '日期时间',
  12 + category: ChatCategoryEnum.MORE,
  13 + categoryName: ChatCategoryEnumName.MORE,
  14 + package: EPackagesCategoryEnum.COMPOSES,
  15 + chartFrame: ChartFrameEnum.NAIVE_UI,
  16 + image: 'dateTime.png',
  17 +}
... ...
  1 +<template>
  2 + <div class="go-content-box" >
  3 + <n-date-picker class="content" @confirm="handleOnConfirm" v-bind={...attribute} v-model:value="dataset" type="datetimerange" />
  4 + </div>
  5 +</template>
  6 +<script setup lang="ts">
  7 +import { PropType, toRefs } from 'vue'
  8 +import { CreateComponentType } from '@/packages/index.d'
  9 +
  10 +const props = defineProps({
  11 + chartConfig: {
  12 + type: Object as PropType<CreateComponentType>,
  13 + required: true
  14 + }
  15 +})
  16 +
  17 +//修改默认宽高距离位置
  18 +props.chartConfig.attr.w = 600
  19 +props.chartConfig.attr.h = 100
  20 +props.chartConfig.attr.x = 200
  21 +props.chartConfig.attr.y = 200
  22 +
  23 +const { dataset,attribute }= toRefs(props.chartConfig.option)
  24 +
  25 +const { w, h } = toRefs(props.chartConfig.attr)
  26 +
  27 +const handleOnConfirm=(values:[number, number])=>{
  28 + window['$message'].success(`您选中了时间段[${values}]`)
  29 +}
  30 +
  31 +
  32 +
  33 +</script>
  34 +
  35 +<style lang="scss" scoped>
  36 +.go-content-box {
  37 + display: flex;
  38 + align-items: center;
  39 + justify-content: center;
  40 + .content{
  41 + width:v-bind('w + "px"');
  42 + height:v-bind('h + "px"');
  43 + }
  44 +}
  45 +</style>
... ...
1 1 import { WordCloudConfig } from './WordCloud/index'
  2 +import { ButtonConfig } from './Button/index'
  3 +import { DateTimeConfig } from './DateTime/index'
2 4
3   -export default [WordCloudConfig]
  5 +export default [WordCloudConfig,ButtonConfig,DateTimeConfig]
... ...