1
|
1
|
<script lang="ts" setup>
|
2
|
|
- import { PageHeader, RadioButton, RadioGroup, InputNumber, Button } from 'ant-design-vue';
|
3
|
|
- import { computed, ref, unref, onMounted } from 'vue';
|
|
2
|
+ import { PageHeader } from 'ant-design-vue';
|
|
3
|
+ import { computed, unref } from 'vue';
|
4
|
4
|
import { useRoute, useRouter } from 'vue-router';
|
5
|
5
|
import { decode } from '../..';
|
6
|
6
|
import { RollbackOutlined } from '@ant-design/icons-vue';
|
7
|
|
- import { Platform } from './config';
|
8
|
|
- import { useApp } from '../../hooks/useApp';
|
9
|
|
- import { getDataComponent } from '/@/api/dataBoard';
|
10
|
|
- import { updateDataBoard } from '/@/api/dataBoard';
|
11
|
|
- import { useMessage } from '/@/hooks/web/useMessage';
|
12
|
7
|
|
13
|
8
|
defineProps<{ widgetNumber: number }>();
|
14
|
|
- const emits = defineEmits(['getPhoneSize']);
|
15
|
9
|
|
16
|
10
|
const ROUTE = useRoute();
|
17
|
11
|
const ROUTER = useRouter();
|
18
|
12
|
|
19
|
|
- const { isPhone } = useApp();
|
20
|
13
|
const getIsSharePage = computed(() => {
|
21
|
14
|
return ROUTE.matched.find((item) => item.path === '/share/:viewType/:id/:publicId');
|
22
|
15
|
});
|
...
|
...
|
@@ -29,86 +22,6 @@ |
29
|
22
|
if (unref(getIsSharePage)) return;
|
30
|
23
|
ROUTER.go(-1);
|
31
|
24
|
};
|
32
|
|
-
|
33
|
|
- const getSize = () => {
|
34
|
|
- return {
|
35
|
|
- width: '',
|
36
|
|
- height: '',
|
37
|
|
- };
|
38
|
|
- };
|
39
|
|
-
|
40
|
|
- const phoneRadio = ref<string>('iPhone 8');
|
41
|
|
- const phoneSize = ref<{ width?: number | string; height?: number | string }>(getSize());
|
42
|
|
- const ifShowWidth = ref<boolean>(false);
|
43
|
|
-
|
44
|
|
- const phoneModel = ref<{
|
45
|
|
- key: string;
|
46
|
|
- width: string | number;
|
47
|
|
- height: number | string;
|
48
|
|
- title: string;
|
49
|
|
- }>();
|
50
|
|
- const getDataList = async () => {
|
51
|
|
- const values = await getDataComponent(decode((ROUTE.params as { boardId: string }).boardId));
|
52
|
|
- phoneModel.value = values?.data.phoneModel && JSON.parse(values?.data.phoneModel as string);
|
53
|
|
- phoneRadio.value = unref(phoneModel)?.key as any;
|
54
|
|
- ifShowWidth.value = unref(phoneRadio) === 'custom' ? true : false;
|
55
|
|
- phoneSize.value = {
|
56
|
|
- width: unref(phoneModel)?.width,
|
57
|
|
- height: unref(phoneModel)?.height,
|
58
|
|
- };
|
59
|
|
-
|
60
|
|
- emits('getPhoneSize', unref(phoneSize));
|
61
|
|
- };
|
62
|
|
-
|
63
|
|
- const updateComponent = () => {
|
64
|
|
- const { boardId, boardName, organizationId, platform } = ROUTE.params;
|
65
|
|
-
|
66
|
|
- const values = {
|
67
|
|
- id: boardId,
|
68
|
|
- boardName,
|
69
|
|
- organizationId,
|
70
|
|
- platform,
|
71
|
|
- phoneModel: JSON.stringify({
|
72
|
|
- key: unref(phoneRadio),
|
73
|
|
- ...phoneSize.value,
|
74
|
|
- }),
|
75
|
|
- };
|
76
|
|
- updateDataBoard(values as any);
|
77
|
|
- };
|
78
|
|
-
|
79
|
|
- const handleChange = (e) => {
|
80
|
|
- const { target } = e || {};
|
81
|
|
- phoneSize.value = getSize();
|
82
|
|
- if (target.value === 'custom') {
|
83
|
|
- ifShowWidth.value = true;
|
84
|
|
- return;
|
85
|
|
- } else {
|
86
|
|
- ifShowWidth.value = false;
|
87
|
|
- const values = Platform.find((item) => item.key == target.value);
|
88
|
|
- phoneSize.value = {
|
89
|
|
- width: values?.width || '',
|
90
|
|
- height: values?.height || '',
|
91
|
|
- };
|
92
|
|
- }
|
93
|
|
- updateComponent();
|
94
|
|
- emits('getPhoneSize', unref(phoneSize));
|
95
|
|
- };
|
96
|
|
-
|
97
|
|
- const { createMessage } = useMessage();
|
98
|
|
-
|
99
|
|
- const handleCustom = () => {
|
100
|
|
- const { width, height } = unref(phoneSize);
|
101
|
|
- if (!width || !height) {
|
102
|
|
- createMessage.warning('请填写尺寸大小');
|
103
|
|
- return;
|
104
|
|
- }
|
105
|
|
- emits('getPhoneSize', unref(phoneSize));
|
106
|
|
- updateComponent();
|
107
|
|
- };
|
108
|
|
-
|
109
|
|
- onMounted(() => {
|
110
|
|
- getDataList();
|
111
|
|
- });
|
112
|
25
|
</script>
|
113
|
26
|
|
114
|
27
|
<template>
|
...
|
...
|
@@ -132,18 +45,6 @@ |
132
|
45
|
<span class="mr-3 text-sm text-gray-500">已创建组件:</span>
|
133
|
46
|
<span class="text-blue-500"> {{ widgetNumber }}个</span>
|
134
|
47
|
</div>
|
135
|
|
- <div v-if="isPhone()" class="flex items-center my-1">
|
136
|
|
- <RadioGroup v-model:value="phoneRadio" button-style="solid" @change="handleChange">
|
137
|
|
- <RadioButton v-for="item in Platform" :value="item.key" :key="item.key">{{
|
138
|
|
- item.title
|
139
|
|
- }}</RadioButton>
|
140
|
|
- </RadioGroup>
|
141
|
|
- <div class="ml-1" v-if="ifShowWidth">
|
142
|
|
- <InputNumber v-model:value="phoneSize.width" :min="300" placeholder="请输入宽度" />
|
143
|
|
- <InputNumber v-model:value="phoneSize.height" :min="300" placeholder="请输入高度" />
|
144
|
|
- <Button type="primary" @click="handleCustom" class="ml-1">确定</Button>
|
145
|
|
- </div>
|
146
|
|
- </div>
|
147
|
48
|
</PageHeader>
|
148
|
49
|
</template>
|
149
|
50
|
|
...
|
...
|
|