Commit 67a97b78a5c5dfa8fee82518ff031b3219fbd4c7

Authored by ww
1 parent 77028fb7

wip: data board component

@@ -42,12 +42,12 @@ async function genreateIcon() { @@ -42,12 +42,12 @@ async function genreateIcon() {
42 42
43 const iconNameList = Array.from(string.matchAll(groupReg)).map(([string]) => { 43 const iconNameList = Array.from(string.matchAll(groupReg)).map(([string]) => {
44 const [, , name] = string.match(getIdReg) || []; 44 const [, , name] = string.match(getIdReg) || [];
45 - return name; 45 + return name.replace('iconfont-', '');
46 }); 46 });
47 47
48 await fs.writeFileSync( 48 await fs.writeFileSync(
49 join(output, outputFileName), 49 join(output, outputFileName),
50 - `export default ${JSON.stringify({ icons: iconNameList }, null, 2)}` 50 + `export default ${JSON.stringify({ prefix: 'iconfont', icons: iconNameList }, null, 2)}`
51 ); 51 );
52 52
53 global.console.log( 53 global.console.log(
@@ -32,6 +32,7 @@ import ApiRadioGroup from './components/ApiRadioGroup.vue'; @@ -32,6 +32,7 @@ import ApiRadioGroup from './components/ApiRadioGroup.vue';
32 import JAddInput from './externalCompns/components/JAddInput.vue'; 32 import JAddInput from './externalCompns/components/JAddInput.vue';
33 import { JEasyCron } from './externalCompns/components/JEasyCron'; 33 import { JEasyCron } from './externalCompns/components/JEasyCron';
34 import ColorPicker from './components/ColorPicker.vue'; 34 import ColorPicker from './components/ColorPicker.vue';
  35 +import IconDrawer from './components/IconDrawer.vue';
35 36
36 const componentMap = new Map<ComponentType, Component>(); 37 const componentMap = new Map<ComponentType, Component>();
37 38
@@ -71,6 +72,7 @@ componentMap.set('Upload', BasicUpload); @@ -71,6 +72,7 @@ componentMap.set('Upload', BasicUpload);
71 componentMap.set('JAddInput', JAddInput); 72 componentMap.set('JAddInput', JAddInput);
72 componentMap.set('JEasyCron', JEasyCron); 73 componentMap.set('JEasyCron', JEasyCron);
73 componentMap.set('ColorPicker', ColorPicker); 74 componentMap.set('ColorPicker', ColorPicker);
  75 +componentMap.set('IconDrawer', IconDrawer);
74 76
75 export function add(compName: ComponentType, component: Component) { 77 export function add(compName: ComponentType, component: Component) {
76 componentMap.set(compName, component); 78 componentMap.set(compName, component);
  1 +<script lang="ts" setup>
  2 + import { BasicDrawer, useDrawer, useDrawerInner } from '/@/components/Drawer';
  3 + import IconData from '/@/components/Icon/data/iconfont.data';
  4 + import { SvgIcon } from '/@/components/Icon';
  5 + import { computed } from '@vue/reactivity';
  6 + import { onMounted, unref } from 'vue';
  7 +
  8 + const props = defineProps<{
  9 + value?: string;
  10 + color?: string;
  11 + }>();
  12 + const emit = defineEmits(['update:value']);
  13 + const iconList = IconData.icons;
  14 + const [register, { openDrawer, closeDrawer }] = useDrawer();
  15 + const getIcon = computed(() => {
  16 + return props.value || 'temperature';
  17 + });
  18 +
  19 + const getColor = computed(() => {
  20 + return props.color || '#377DFF';
  21 + });
  22 +
  23 + const handleOpenDrawer = () => {
  24 + openDrawer();
  25 + };
  26 +
  27 + const handleClick = (icon: string) => {
  28 + emit('update:value', icon);
  29 + closeDrawer();
  30 + };
  31 +
  32 + onMounted(() => {
  33 + emit('update:value', unref(getIcon));
  34 + });
  35 +</script>
  36 +
  37 +<template>
  38 + <SvgIcon
  39 + :name="getIcon"
  40 + :icon="getIcon"
  41 + prefix="iconfont"
  42 + class="cursor-pointer !w-6 !h-6"
  43 + :style="{ color: getColor }"
  44 + @click="handleOpenDrawer"
  45 + />
  46 + <BasicDrawer @register="register" v-bind="$attrs" title="选择图标" width="300px">
  47 + <section class="flex flex-wrap justify-start">
  48 + <SvgIcon
  49 + class="!h-6 cursor-pointer mb-3"
  50 + style="flex: 0 0 25%"
  51 + v-for="item in iconList"
  52 + :key="item"
  53 + :icon="item"
  54 + :name="item"
  55 + prefix="iconfont"
  56 + @click="handleClick(item)"
  57 + />
  58 + </section>
  59 + </BasicDrawer>
  60 +</template>
  61 +
  62 +<style scoped></style>
@@ -113,4 +113,5 @@ export type ComponentType = @@ -113,4 +113,5 @@ export type ComponentType =
113 | 'Slider' 113 | 'Slider'
114 | 'JAddInput' 114 | 'JAddInput'
115 | 'Rate' 115 | 'Rate'
116 - | 'ColorPicker'; 116 + | 'ColorPicker'
  117 + | 'IconDrawer';
1 export default { 1 export default {
2 - icons: [  
3 - 'iconfont-offline',  
4 - 'iconfont-online',  
5 - 'iconfont-wind-speed',  
6 - 'iconfont-temperature',  
7 - 'iconfont-CO2',  
8 - 'iconfont-wind-speed-1',  
9 - ], 2 + prefix: 'iconfont',
  3 + icons: ['offline', 'online', 'wind-speed', 'temperature', 'CO2', 'wind-speed-1'],
10 }; 4 };
@@ -3,3 +3,5 @@ export enum MoreActionEvent { @@ -3,3 +3,5 @@ export enum MoreActionEvent {
3 COPY = 'copy', 3 COPY = 'copy',
4 DELETE = 'delete', 4 DELETE = 'delete',
5 } 5 }
  6 +
  7 +// export enum
@@ -7,8 +7,11 @@ @@ -7,8 +7,11 @@
7 import { ref, unref } from 'vue'; 7 import { ref, unref } from 'vue';
8 import VisualOptionsModal from './VisualOptionsModal.vue'; 8 import VisualOptionsModal from './VisualOptionsModal.vue';
9 import { useModal } from '/@/components/Modal'; 9 import { useModal } from '/@/components/Modal';
  10 + import { buildUUID } from '/@/utils/uuid';
10 11
11 - const dataSource = ref([{ id: 1 }]); 12 + const props = defineProps();
  13 +
  14 + const dataSource = ref([{ id: 'string' }]);
12 15
13 const [basicRegister, basicMethod] = useForm({ 16 const [basicRegister, basicMethod] = useForm({
14 schemas: basicSchema, 17 schemas: basicSchema,
@@ -48,7 +51,7 @@ @@ -48,7 +51,7 @@
48 51
49 const handleAdd = () => { 52 const handleAdd = () => {
50 unref(dataSource).push({ 53 unref(dataSource).push({
51 - id: Math.random(), 54 + id: buildUUID(),
52 }); 55 });
53 }; 56 };
54 </script> 57 </script>
@@ -70,7 +73,7 @@ @@ -70,7 +73,7 @@
70 <CopyOutlined @click="handleCopy(item)" class="cursor-pointer text-lg" /> 73 <CopyOutlined @click="handleCopy(item)" class="cursor-pointer text-lg" />
71 </Tooltip> 74 </Tooltip>
72 <Tooltip title="设置"> 75 <Tooltip title="设置">
73 - <SettingOutlined @click="handleSetting(item)" class="cursor-pointer text-lg" /> 76 + <SettingOutlined @click="handleSetting()" class="cursor-pointer text-lg" />
74 </Tooltip> 77 </Tooltip>
75 <Tooltip title="删除"> 78 <Tooltip title="删除">
76 <DeleteOutlined @click="handleDelete(item)" class="cursor-pointer text-lg" /> 79 <DeleteOutlined @click="handleDelete(item)" class="cursor-pointer text-lg" />
1 <script lang="ts" setup> 1 <script lang="ts" setup>
2 import { Tabs } from 'ant-design-vue'; 2 import { Tabs } from 'ant-design-vue';
3 - import { ref } from 'vue';  
4 import BasicModal from '/@/components/Modal/src/BasicModal.vue'; 3 import BasicModal from '/@/components/Modal/src/BasicModal.vue';
5 import BasicConfiguration from './BasicConfiguration.vue'; 4 import BasicConfiguration from './BasicConfiguration.vue';
6 import VisualConfiguration from './VisualConfiguration.vue'; 5 import VisualConfiguration from './VisualConfiguration.vue';
7 - import VisualOptionsModal from './VisualOptionsModal.vue';  
8 - const activeKey = ref('1'); 6 + import { ref } from 'vue';
  7 +
  8 + const componentId = ref('');
  9 +
  10 + interface SettingOption {
  11 + color?: string;
  12 + }
  13 +
  14 + const handleSettingUpdate = (value: SettingOption) => {};
9 </script> 15 </script>
10 16
11 <template> 17 <template>
12 <BasicModal v-bind="$attrs" title="自定义组件" width="70%"> 18 <BasicModal v-bind="$attrs" title="自定义组件" width="70%">
13 <section> 19 <section>
14 - <Tabs type="card" v-model:activeKey="activeKey"> 20 + <Tabs type="card">
15 <Tabs.TabPane key="1" tab="基础配置"> 21 <Tabs.TabPane key="1" tab="基础配置">
16 - <BasicConfiguration /> 22 + <BasicConfiguration @change="handleSettingUpdate" />
17 </Tabs.TabPane> 23 </Tabs.TabPane>
18 <Tabs.TabPane key="2" tab="可视化配置"> 24 <Tabs.TabPane key="2" tab="可视化配置">
19 - <VisualConfiguration />  
20 - </Tabs.TabPane>  
21 - <Tabs.TabPane key="3" tab="可视化选项">  
22 - <VisualOptionsModal /> 25 + <VisualConfiguration v-model:value="componentId" />
23 </Tabs.TabPane> 26 </Tabs.TabPane>
24 </Tabs> 27 </Tabs>
25 </section> 28 </section>
1 <script lang="ts" setup> 1 <script lang="ts" setup>
2 import { Tabs, List } from 'ant-design-vue'; 2 import { Tabs, List } from 'ant-design-vue';
3 - import { ref } from 'vue';  
4 import VisualWidgetSelect from './VisualWidgetSelect.vue'; 3 import VisualWidgetSelect from './VisualWidgetSelect.vue';
5 import TextComponent from '../../components/TextComponent/TextComponent.vue'; 4 import TextComponent from '../../components/TextComponent/TextComponent.vue';
6 import { textComponentConfig } from '../../components/TextComponent/config'; 5 import { textComponentConfig } from '../../components/TextComponent/config';
7 - const checkedId = ref('1'); 6 + const props = defineProps<{
  7 + value: string;
  8 + }>();
  9 + const emit = defineEmits(['update:value']);
8 10
9 const handleCheck = (checked: string) => { 11 const handleCheck = (checked: string) => {
10 - checkedId.value = checked; 12 + emit('update:value', checked);
11 }; 13 };
12 </script> 14 </script>
13 15
@@ -15,11 +17,14 @@ @@ -15,11 +17,14 @@
15 <section> 17 <section>
16 <Tabs> 18 <Tabs>
17 <Tabs.TabPane key="1" tab="文本组件"> 19 <Tabs.TabPane key="1" tab="文本组件">
18 - <List :grid="{ gutter: 10, column: 3 }" :data-source="textComponentConfig"> 20 + <List
  21 + :grid="{ gutter: 10, column: 3, xs: 3, sm: 3, md: 3, lg: 3, xl: 3, xxl: 3 }"
  22 + :data-source="textComponentConfig"
  23 + >
19 <template #renderItem="{ item }"> 24 <template #renderItem="{ item }">
20 <List.Item> 25 <List.Item>
21 <VisualWidgetSelect 26 <VisualWidgetSelect
22 - :checked-id="checkedId" 27 + :checked-id="props.value"
23 :control-id="item.id" 28 :control-id="item.id"
24 @change="handleCheck" 29 @change="handleCheck"
25 > 30 >
1 <script lang="ts" setup> 1 <script lang="ts" setup>
2 - import { modeOne } from '../config/visualOptions'; 2 + import { modeOne, modeTwo, modeThree, modeFour } from '../config/visualOptions';
3 import { useForm, BasicForm } from '/@/components/Form'; 3 import { useForm, BasicForm } from '/@/components/Form';
4 import { BasicModal, useModalInner } from '/@/components/Modal'; 4 import { BasicModal, useModalInner } from '/@/components/Modal';
  5 +
5 const [registerForm, method] = useForm({ 6 const [registerForm, method] = useForm({
6 - schemas: modeOne, 7 + schemas: modeTwo,
7 showActionButtonGroup: false, 8 showActionButtonGroup: false,
8 labelWidth: 120, 9 labelWidth: 120,
9 baseColProps: { 10 baseColProps: {
@@ -11,17 +12,21 @@ @@ -11,17 +12,21 @@
11 }, 12 },
12 }); 13 });
13 14
14 - const [registerModal, { closeModal }] = useModalInner(); 15 + const [register, { closeModal }] = useModalInner();
15 16
16 const handleGetValue = () => { 17 const handleGetValue = () => {
17 const value = method.getFieldsValue(); 18 const value = method.getFieldsValue();
18 console.log(value); 19 console.log(value);
19 }; 20 };
  21 +
  22 + const handleClose = () => {
  23 + handleGetValue();
  24 + closeModal();
  25 + };
20 </script> 26 </script>
21 27
22 <template> 28 <template>
23 - <BasicModal v-bind="$attrs" @register="registerModal" title="" width="60%"> 29 + <BasicModal v-bind="$attrs" @register="register" @ok="handleClose" title="选项" width="60%">
24 <BasicForm @register="registerForm" /> 30 <BasicForm @register="registerForm" />
25 - <button @click="handleGetValue">啊按钮</button>  
26 </BasicModal> 31 </BasicModal>
27 </template> 32 </template>
  1 +import { getOrganizationList } from '/@/api/system/system';
1 import { FormSchema } from '/@/components/Form'; 2 import { FormSchema } from '/@/components/Form';
2 3
3 export const basicSchema: FormSchema[] = [ 4 export const basicSchema: FormSchema[] = [
@@ -16,11 +17,19 @@ export const basicSchema: FormSchema[] = [ @@ -16,11 +17,19 @@ export const basicSchema: FormSchema[] = [
16 export const dataSourceSchema: FormSchema[] = [ 17 export const dataSourceSchema: FormSchema[] = [
17 { 18 {
18 field: 'org', 19 field: 'org',
19 - component: 'TreeSelect', 20 + component: 'ApiTreeSelect',
20 label: '组织', 21 label: '组织',
21 colProps: { span: 6 }, 22 colProps: { span: 6 },
22 - componentProps: {  
23 - placeholder: '请选择组织', 23 + componentProps() {
  24 + return {
  25 + placeholder: '请选择组织',
  26 + api: async () => {
  27 + const data = await getOrganizationList();
  28 + return data;
  29 + },
  30 +
  31 + onChange() {},
  32 + };
24 }, 33 },
25 }, 34 },
26 { 35 {
@@ -29,7 +29,7 @@ export const modeOne: FormSchema[] = [ @@ -29,7 +29,7 @@ export const modeOne: FormSchema[] = [
29 29
30 export const modeTwo: FormSchema[] = [ 30 export const modeTwo: FormSchema[] = [
31 { 31 {
32 - field: visualOptionField.UNIT, 32 + field: visualOptionField.FONT_COLOR,
33 label: '数值字体颜色', 33 label: '数值字体颜色',
34 component: 'ColorPicker', 34 component: 'ColorPicker',
35 changeEvent: 'update:value', 35 changeEvent: 'update:value',
@@ -51,7 +51,14 @@ export const modeTwo: FormSchema[] = [ @@ -51,7 +51,14 @@ export const modeTwo: FormSchema[] = [
51 { 51 {
52 field: visualOptionField.ICON, 52 field: visualOptionField.ICON,
53 label: '图标', 53 label: '图标',
54 - component: 'Input', 54 + component: 'IconDrawer',
  55 + changeEvent: 'update:value',
  56 + componentProps({ formModel }) {
  57 + const color = formModel[visualOptionField.ICON_COLOR];
  58 + return {
  59 + color,
  60 + };
  61 + },
55 }, 62 },
56 ]; 63 ];
57 64
@@ -180,7 +180,7 @@ @@ -180,7 +180,7 @@
180 :w="item.w" 180 :w="item.w"
181 :h="item.h" 181 :h="item.h"
182 :i="item.i" 182 :i="item.i"
183 - style="display: flex; flex-wrap: wrap" 183 + :style="{ display: 'flex', flexWrap: 'wrap' }"
184 class="grid-item-layout" 184 class="grid-item-layout"
185 @resized="itemResized" 185 @resized="itemResized"
186 @resize="itemResized" 186 @resize="itemResized"
@@ -189,7 +189,7 @@ @@ -189,7 +189,7 @@
189 > 189 >
190 <WidgetWrapper 190 <WidgetWrapper
191 :key="item.i" 191 :key="item.i"
192 - :ref="(el) => setComponentRef(el, item)" 192 + :ref="(el: Element) => setComponentRef(el, item)"
193 :data-source="item.chart" 193 :data-source="item.chart"
194 > 194 >
195 <template #header> 195 <template #header>
@@ -58,7 +58,7 @@ @@ -58,7 +58,7 @@
58 ]; 58 ];
59 59
60 const handleMenuEvent = (event: DropMenu) => { 60 const handleMenuEvent = (event: DropMenu) => {
61 - if (event.event === MoreEvent.EDIT) { 61 + if (event.event === MoreActionEvent.EDIT) {
62 handleEdit(); 62 handleEdit();
63 } 63 }
64 }; 64 };