Commit a30c10854c5d5dc37139b99c82f33fdfe34a5b41

Authored by loveumiko
1 parent d89a9f01

fix: 修改看板手机端逻辑

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
... ...
... ... @@ -14,8 +14,8 @@ export const DEFAULT_ITEM_MARIGN = 20;
14 14 export const PHONE_SIZE = {
15 15 DEFAULT_WIDGET_WIDTH: 12,
16 16 DEFAULT_WIDGET_HEIGHT: 4,
17   - DEFAULT_MIN_HEIGHT: 4,
18   - DEFAULT_MIN_WIDTH: 11,
  17 + DEFAULT_MIN_HEIGHT: 3,
  18 + DEFAULT_MIN_WIDTH: 8,
19 19 };
20 20
21 21 import { ViewTypeEnum } from '/@/views/sys/share/config/config';
... ...
... ... @@ -188,9 +188,6 @@
188 188 width: '' || 375,
189 189 height: '' || 667,
190 190 });
191   - const getPhoneSize = (values) => {
192   - phoneSize.value = { ...values };
193   - };
194 191 </script>
195 192
196 193 <template>
... ... @@ -198,11 +195,7 @@
198 195 ref="containerRefEl"
199 196 class="palette w-full h-full flex-col bg-neutral-100 flex dark:bg-dark-700 dark:text-light-50"
200 197 >
201   - <PageHeader
202   - v-if="!getIsAppPage"
203   - :widget-number="dataSource.length"
204   - @getPhoneSize="getPhoneSize"
205   - >
  198 + <PageHeader v-if="!getIsAppPage" :widget-number="dataSource.length">
206 199 <Authority :value="VisualComponentPermission.CREATE">
207 200 <Button
208 201 v-if="!getIsSharePage && !isCustomerUser"
... ... @@ -228,7 +221,7 @@
228 221 "
229 222 style="border-radius: 1%"
230 223 >
231   - <!-- 手机端的模拟样式 -->
  224 + <!-- 手机端的模拟样式 -->
232 225 <div
233 226 v-if="!getIsAppPage && isPhone()"
234 227 style="height: 60px; background: white"
... ... @@ -268,7 +261,7 @@
268 261 :use-css-transforms="true"
269 262 style="width: 100%"
270 263 :style="{
271   - '--is-app': isPhone() ? 'auto' : 'none',
  264 + '--is-app': getIsAppPage ? 'auto' : 'none',
272 265 }"
273 266 >
274 267 <GridItem
... ...