Showing
20 changed files
with
204 additions
and
19 deletions
src/views/data/board/components/ColorPicker.vue
renamed from
src/views/data/board/cpns/ColorPicker.vue
src/views/data/board/components/CommandSendButton.vue
renamed from
src/views/data/board/cpns/CommandSendButton.vue
src/views/data/board/components/Dashboard/BaseDashboard.vue
renamed from
src/views/data/board/cpns/Dashboard/BaseDashboard.vue
src/views/data/board/components/IndicatorLight.vue
renamed from
src/views/data/board/cpns/IndicatorLight.vue
src/views/data/board/components/InformationPanel.vue
renamed from
src/views/data/board/cpns/InformationPanel.vue
src/views/data/board/components/LightBulbSwitch.vue
renamed from
src/views/data/board/cpns/LightBulbSwitch.vue
src/views/data/board/components/RockerSwitch.vue
renamed from
src/views/data/board/cpns/RockerSwitch.vue
src/views/data/board/components/SlidingSwitch.vue
renamed from
src/views/data/board/cpns/SlidingSwitch.vue
src/views/data/board/components/ToggleSwitch.vue
renamed from
src/views/data/board/cpns/ToggleSwitch.vue
src/views/data/board/components/WidgetHeader/BaseWidgetHeader.vue
renamed from
src/views/data/board/cpns/WidgetHeader/BaseWidgetHeader.vue
... | ... | @@ -4,32 +4,30 @@ |
4 | 4 | import Dropdown from '/@/components/Dropdown/src/Dropdown.vue'; |
5 | 5 | import { Tooltip } from 'ant-design-vue'; |
6 | 6 | import SvgIcon from '/@/components/Icon/src/SvgIcon.vue'; |
7 | - enum MoreEvent { | |
8 | - EDIT = 'edit', | |
9 | - COPY = 'copy', | |
10 | - DELETE = 'delete', | |
11 | - } | |
7 | + import { MoreActionEvent } from '../../config/config'; | |
8 | + | |
9 | + const emit = defineEmits(['action']); | |
12 | 10 | |
13 | 11 | const dropMenuList: DropMenu[] = [ |
14 | 12 | { |
15 | 13 | text: '编辑组件', |
16 | - event: MoreEvent.EDIT, | |
14 | + event: MoreActionEvent.EDIT, | |
17 | 15 | icon: 'ant-design:edit-outlined', |
18 | 16 | }, |
19 | 17 | { |
20 | 18 | text: '复制组件', |
21 | - event: MoreEvent.COPY, | |
19 | + event: MoreActionEvent.COPY, | |
22 | 20 | icon: 'ant-design:copy-outlined', |
23 | 21 | }, |
24 | 22 | { |
25 | 23 | text: '删除组件', |
26 | - event: MoreEvent.DELETE, | |
24 | + event: MoreActionEvent.DELETE, | |
27 | 25 | icon: 'ant-design:delete-outlined', |
28 | 26 | }, |
29 | 27 | ]; |
30 | 28 | |
31 | 29 | const handleMenuEvent = (event: DropMenu) => { |
32 | - console.log(event); | |
30 | + emit('action', event); | |
33 | 31 | }; |
34 | 32 | </script> |
35 | 33 | ... | ... |
src/views/data/board/components/WidgetWrapper/WidgetWrapper.vue
renamed from
src/views/data/board/cpns/WidgetWrapper/WidgetWrapper.vue
src/views/data/board/components/WidgetWrapper/type.ts
renamed from
src/views/data/board/cpns/WidgetWrapper/type.ts
1 | +<script lang="ts" setup> | |
2 | + import { CopyOutlined, DeleteOutlined } from '@ant-design/icons-vue'; | |
3 | + import { Tooltip, Button } from 'ant-design-vue'; | |
4 | + import { useForm } from '/@/components/Form'; | |
5 | + import { basicSchema, dataSourceSchema } from '../config/basicConfiguration'; | |
6 | + import BasicForm from '/@/components/Form/src/BasicForm.vue'; | |
7 | + import { ref, unref } from 'vue'; | |
8 | + | |
9 | + const dataSource = ref([{ id: 1 }]); | |
10 | + | |
11 | + const [basicRegister, basicMethod] = useForm({ | |
12 | + schemas: basicSchema, | |
13 | + showActionButtonGroup: false, | |
14 | + labelWidth: 96, | |
15 | + }); | |
16 | + | |
17 | + const [dataSourceRegister, dataSourceMethod] = useForm({ | |
18 | + schemas: dataSourceSchema, | |
19 | + showActionButtonGroup: false, | |
20 | + layout: 'inline', | |
21 | + labelCol: { | |
22 | + span: 0, | |
23 | + }, | |
24 | + baseColProps: { | |
25 | + span: 4, | |
26 | + }, | |
27 | + }); | |
28 | + | |
29 | + const handleCopy = (data: Recordable) => { | |
30 | + unref(dataSource).push({ | |
31 | + id: data.id + 1, | |
32 | + }); | |
33 | + }; | |
34 | + | |
35 | + const handleDelete = (data: Recordable) => { | |
36 | + const index = unref(dataSource).findIndex((item) => item.id === data.id); | |
37 | + | |
38 | + ~index && unref(dataSource).splice(index, 1); | |
39 | + }; | |
40 | + | |
41 | + const handleAdd = () => { | |
42 | + unref(dataSource).push({ | |
43 | + id: Math.random(), | |
44 | + }); | |
45 | + }; | |
46 | +</script> | |
47 | + | |
48 | +<template> | |
49 | + <section> | |
50 | + <h3 class="w-24 text-right pr-2 my-4">基础信息</h3> | |
51 | + <div class="w-3/4"> | |
52 | + <BasicForm @register="basicRegister" /> | |
53 | + </div> | |
54 | + <h3 class="w-24 text-right pr-2 my-4">选择数据源</h3> | |
55 | + <div v-for="item in dataSource" :key="item.id" class="flex"> | |
56 | + <div class="w-24 text-right">选择设备</div> | |
57 | + <div class="pl-2 flex-auto"> | |
58 | + <BasicForm @register="dataSourceRegister" /> | |
59 | + </div> | |
60 | + <div class="flex justify-center gap-3 w-12"> | |
61 | + <Tooltip title="复制"> | |
62 | + <CopyOutlined @click="handleCopy(item)" class="cursor-pointer text-lg" /> | |
63 | + </Tooltip> | |
64 | + <Tooltip title="删除"> | |
65 | + <DeleteOutlined @click="handleDelete(item)" class="cursor-pointer text-lg" /> | |
66 | + </Tooltip> | |
67 | + </div> | |
68 | + </div> | |
69 | + <div class="text-center"> | |
70 | + <Button type="primary" @click="handleAdd">添加数据源</Button> | |
71 | + </div> | |
72 | + </section> | |
73 | +</template> | ... | ... |
1 | +<script lang="ts" setup> | |
2 | + import { Tabs } from 'ant-design-vue'; | |
3 | + import { ref } from 'vue'; | |
4 | + import BasicModal from '/@/components/Modal/src/BasicModal.vue'; | |
5 | + import BasicConfiguration from './BasicConfiguration.vue'; | |
6 | + import VisualConfiguration from './VisualConfiguration.vue'; | |
7 | + import VisualOptions from './VisualOptions.vue'; | |
8 | + const activeKey = ref('1'); | |
9 | +</script> | |
10 | + | |
11 | +<template> | |
12 | + <BasicModal v-bind="$attrs" title="自定义组件" width="70%"> | |
13 | + <section> | |
14 | + <Tabs type="card" v-model:activeKey="activeKey"> | |
15 | + <Tabs.TabPane key="1" tab="基础配置"> | |
16 | + <BasicConfiguration /> | |
17 | + </Tabs.TabPane> | |
18 | + <Tabs.TabPane key="2" tab="可视化配置"> | |
19 | + <VisualConfiguration /> | |
20 | + </Tabs.TabPane> | |
21 | + <Tabs.TabPane key="3" tab="可视化选项"> | |
22 | + <VisualOptions /> | |
23 | + </Tabs.TabPane> | |
24 | + </Tabs> | |
25 | + </section> | |
26 | + </BasicModal> | |
27 | +</template> | ... | ... |
1 | +import { FormSchema } from '/@/components/Form'; | |
2 | + | |
3 | +export const basicSchema: FormSchema[] = [ | |
4 | + { | |
5 | + field: 'name', | |
6 | + label: '组件名称', | |
7 | + component: 'Input', | |
8 | + }, | |
9 | + { | |
10 | + field: 'remake', | |
11 | + label: '组件备注', | |
12 | + component: 'InputTextArea', | |
13 | + }, | |
14 | +]; | |
15 | + | |
16 | +export const dataSourceSchema: FormSchema[] = [ | |
17 | + { | |
18 | + field: 'org', | |
19 | + component: 'TreeSelect', | |
20 | + label: '组织', | |
21 | + colProps: { span: 6 }, | |
22 | + componentProps: { | |
23 | + placeholder: '请选择组织', | |
24 | + }, | |
25 | + }, | |
26 | + { | |
27 | + field: 'device', | |
28 | + component: 'Select', | |
29 | + label: '设备', | |
30 | + colProps: { span: 5 }, | |
31 | + componentProps: { | |
32 | + placeholder: '请选择设备', | |
33 | + }, | |
34 | + }, | |
35 | + { | |
36 | + field: 'attr', | |
37 | + component: 'Select', | |
38 | + label: '属性', | |
39 | + colProps: { span: 5 }, | |
40 | + componentProps: { | |
41 | + placeholder: '请选择属性', | |
42 | + }, | |
43 | + }, | |
44 | + { | |
45 | + field: 'deviceRename', | |
46 | + component: 'Input', | |
47 | + label: '设备', | |
48 | + colProps: { span: 4 }, | |
49 | + componentProps: { | |
50 | + placeholder: '设备重命名', | |
51 | + }, | |
52 | + }, | |
53 | + { | |
54 | + field: 'attrRename', | |
55 | + component: 'Input', | |
56 | + label: '属性', | |
57 | + colProps: { span: 4 }, | |
58 | + componentProps: { | |
59 | + placeholder: '属性重命名', | |
60 | + }, | |
61 | + }, | |
62 | +]; | ... | ... |
... | ... | @@ -2,9 +2,13 @@ |
2 | 2 | import { Button, PageHeader } from 'ant-design-vue'; |
3 | 3 | import { GridItem, GridLayout, Layout } from 'vue3-grid-layout'; |
4 | 4 | import { nextTick, ref } from 'vue'; |
5 | - import WidgetWrapper from '../cpns/WidgetWrapper/WidgetWrapper.vue'; | |
6 | - import BaseWidgetHeader from '../cpns/WidgetHeader/BaseWidgetHeader.vue'; | |
7 | - import InformationPanel from '../cpns/InformationPanel.vue'; | |
5 | + import WidgetWrapper from '../components/WidgetWrapper/WidgetWrapper.vue'; | |
6 | + import BaseWidgetHeader from '../components/WidgetHeader/BaseWidgetHeader.vue'; | |
7 | + import InformationPanel from '../components/InformationPanel.vue'; | |
8 | + import { DropMenu } from '/@/components/Dropdown'; | |
9 | + import DataBindModal from './components/DataBindModal.vue'; | |
10 | + import { useModal } from '/@/components/Modal'; | |
11 | + import { MoreActionEvent } from '../config/config'; | |
8 | 12 | const handleBack = () => {}; |
9 | 13 | |
10 | 14 | interface ChartAttr { |
... | ... | @@ -133,6 +137,12 @@ |
133 | 137 | if (el && (el as unknown as { update: Fn }).update) |
134 | 138 | widgetEl.set(record.i, (el as unknown as { update: Fn }).update); |
135 | 139 | }; |
140 | + | |
141 | + const [register, { openModal }] = useModal(); | |
142 | + | |
143 | + const handleMoreAction = (event: DropMenu) => { | |
144 | + if (event.event === MoreActionEvent.EDIT) openModal(true); | |
145 | + }; | |
136 | 146 | </script> |
137 | 147 | |
138 | 148 | <template> |
... | ... | @@ -184,7 +194,7 @@ |
184 | 194 | > |
185 | 195 | <template #header> |
186 | 196 | <!-- <div>header</div> --> |
187 | - <BaseWidgetHeader /> | |
197 | + <BaseWidgetHeader @action="handleMoreAction" /> | |
188 | 198 | </template> |
189 | 199 | <template #controls="{ record, add }"> |
190 | 200 | <InformationPanel /> |
... | ... | @@ -197,6 +207,7 @@ |
197 | 207 | </GridLayout> |
198 | 208 | </section> |
199 | 209 | </section> |
210 | + <DataBindModal @register="register" /> | |
200 | 211 | </template> |
201 | 212 | |
202 | 213 | <style> | ... | ... |
... | ... | @@ -8,6 +8,7 @@ |
8 | 8 | import { useRouter } from 'vue-router'; |
9 | 9 | import Dropdown from '/@/components/Dropdown/src/Dropdown.vue'; |
10 | 10 | import { DropMenu } from '/@/components/Dropdown'; |
11 | + import { MoreActionEvent } from './config/config'; | |
11 | 12 | const ListItem = List.Item; |
12 | 13 | |
13 | 14 | const router = useRouter(); |
... | ... | @@ -42,20 +43,16 @@ |
42 | 43 | clipboardRef.value = '123'; |
43 | 44 | unref(clipboardRef) && createMessage.success('复制成功'); |
44 | 45 | }; |
45 | - enum MoreEvent { | |
46 | - EDIT = 'edit', | |
47 | - DELETE = 'DELETE', | |
48 | - } | |
49 | 46 | |
50 | 47 | const dropMenuList: DropMenu[] = [ |
51 | 48 | { |
52 | 49 | text: '编辑', |
53 | - event: MoreEvent.EDIT, | |
50 | + event: MoreActionEvent.EDIT, | |
54 | 51 | icon: 'ant-design:edit-outlined', |
55 | 52 | }, |
56 | 53 | { |
57 | 54 | text: '删除', |
58 | - event: MoreEvent.DELETE, | |
55 | + event: MoreActionEvent.DELETE, | |
59 | 56 | icon: 'ant-design:delete-outlined', |
60 | 57 | }, |
61 | 58 | ]; | ... | ... |