Commit 6db4cfff66b69a764e19718118071df05b0aacc4
Merge branch 'dev-fix-ww' into 'main_dev'
fix: 修复teambition BUG See merge request yunteng/thingskit-front!546
Showing
8 changed files
with
90 additions
and
18 deletions
src/components/List/index.ts
0 → 100644
src/components/List/src/BasicList.vue
0 → 100644
1 | +<script lang="ts" setup> | ||
2 | + import { ReloadOutlined } from '@ant-design/icons-vue'; | ||
3 | + import { Button, List, Tooltip } from 'ant-design-vue'; | ||
4 | + import { reactive } from 'vue'; | ||
5 | + import { ref } from 'vue'; | ||
6 | + | ||
7 | + const listElRef = ref<Nullable<ComponentElRef>>(null); | ||
8 | + | ||
9 | + const pagination = reactive({}); | ||
10 | + | ||
11 | + const loading = ref(false); | ||
12 | + | ||
13 | + const dataSource = ref([]); | ||
14 | + | ||
15 | + const getDataSource = () => {}; | ||
16 | +</script> | ||
17 | + | ||
18 | +<template> | ||
19 | + <section class="bg-light-50 my-4 p-4 x dark:text-gray-300 dark:bg-dark-900"> | ||
20 | + <List | ||
21 | + ref="listElRef" | ||
22 | + :dataSource="dataSource" | ||
23 | + :pagination="pagination" | ||
24 | + :grid="{ gutter: 16, xs: 1, sm: 1, md: 1, lg: 2, xl: 2, xxl: 3, column: 3 }" | ||
25 | + :loading="loading" | ||
26 | + > | ||
27 | + <template #header> | ||
28 | + <section class="flex justify-between gap-4 min-h-12 items-center"> | ||
29 | + <div class="text-lg font-semibold"> | ||
30 | + <span>任务列表</span> | ||
31 | + </div> | ||
32 | + <Tooltip title="刷新"> | ||
33 | + <Button type="primary" @click="getDataSource"> | ||
34 | + <ReloadOutlined :spin="loading" /> | ||
35 | + </Button> | ||
36 | + </Tooltip> | ||
37 | + </section> | ||
38 | + </template> | ||
39 | + <template #renderItem="{ item }"> | ||
40 | + <List.Item :key="item.id"> | ||
41 | + <slot name="item" :item="item"></slot> | ||
42 | + </List.Item> | ||
43 | + </template> | ||
44 | + </List> | ||
45 | + </section> | ||
46 | +</template> |
src/components/List/src/props.ts
0 → 100644
1 | <script lang="ts" setup> | 1 | <script lang="ts" setup> |
2 | import { nextTick, onMounted, onUnmounted, reactive, ref, unref } from 'vue'; | 2 | import { nextTick, onMounted, onUnmounted, reactive, ref, unref } from 'vue'; |
3 | - import { List, Button, Card } from 'ant-design-vue'; | 3 | + import { List, Button, Card, Tooltip } from 'ant-design-vue'; |
4 | import { PageWrapper } from '/@/components/Page'; | 4 | import { PageWrapper } from '/@/components/Page'; |
5 | import { BasicTable, useTable } from '/@/components/Table'; | 5 | import { BasicTable, useTable } from '/@/components/Table'; |
6 | import { realTimeDataColumns } from '../../config/detail.config'; | 6 | import { realTimeDataColumns } from '../../config/detail.config'; |
@@ -31,6 +31,9 @@ | @@ -31,6 +31,9 @@ | ||
31 | key?: string; | 31 | key?: string; |
32 | value?: string; | 32 | value?: string; |
33 | time?: number; | 33 | time?: number; |
34 | + type?: string; | ||
35 | + boolClose?: string; | ||
36 | + boolOpen?: string; | ||
34 | } | 37 | } |
35 | 38 | ||
36 | const props = defineProps<{ | 39 | const props = defineProps<{ |
@@ -214,6 +217,14 @@ | @@ -214,6 +217,14 @@ | ||
214 | open(); | 217 | open(); |
215 | }); | 218 | }); |
216 | 219 | ||
220 | + const formatValue = (item: DataSource) => { | ||
221 | + return item.type === DataTypeEnum.IS_BOOL | ||
222 | + ? !!Number(item.value) | ||
223 | + ? item.boolOpen | ||
224 | + : item.boolClose | ||
225 | + : item.value || '--'; | ||
226 | + }; | ||
227 | + | ||
217 | onUnmounted(() => close()); | 228 | onUnmounted(() => close()); |
218 | </script> | 229 | </script> |
219 | 230 | ||
@@ -252,13 +263,9 @@ | @@ -252,13 +263,9 @@ | ||
252 | </template> | 263 | </template> |
253 | <section class="min-h-16 flex flex-col justify-between"> | 264 | <section class="min-h-16 flex flex-col justify-between"> |
254 | <div class="flex font-bold text-lg mb-4 gap-2"> | 265 | <div class="flex font-bold text-lg mb-4 gap-2"> |
255 | - <div>{{ | ||
256 | - item.type === DataTypeEnum.IS_BOOL | ||
257 | - ? !!Number(item.value) | ||
258 | - ? item.boolOpen | ||
259 | - : item.boolClose | ||
260 | - : item.value || '--' | ||
261 | - }}</div> | 266 | + <Tooltip :title="formatValue(item)" placement="topLeft"> |
267 | + <div class="truncate">{{ formatValue(item) }}</div> | ||
268 | + </Tooltip> | ||
262 | <div class="text-xs flex items-center">{{ item.unit }}</div> | 269 | <div class="text-xs flex items-center">{{ item.unit }}</div> |
263 | </div> | 270 | </div> |
264 | <div class="text-dark-800 text-xs"> | 271 | <div class="text-dark-800 text-xs"> |
@@ -92,7 +92,6 @@ export const schemas: DescItem[] = [ | @@ -92,7 +92,6 @@ export const schemas: DescItem[] = [ | ||
92 | render(_val: any, data: TaskRecordType) { | 92 | render(_val: any, data: TaskRecordType) { |
93 | const { executeTime } = data; | 93 | const { executeTime } = data; |
94 | const { time, type, periodType, pollUnit, period } = executeTime; | 94 | const { time, type, periodType, pollUnit, period } = executeTime; |
95 | - console.log({ time, type, periodType, pollUnit }); | ||
96 | return type === ExecuteTimeTypeEnum.POLL | 95 | return type === ExecuteTimeTypeEnum.POLL |
97 | ? `${time}${TimeUnitNameEnum[pollUnit]}` | 96 | ? `${time}${TimeUnitNameEnum[pollUnit]}` |
98 | : `${PeriodTypeNameEnum[periodType]} ${ | 97 | : `${PeriodTypeNameEnum[periodType]} ${ |
@@ -11,6 +11,7 @@ | @@ -11,6 +11,7 @@ | ||
11 | import { FormValueType } from './util'; | 11 | import { FormValueType } from './util'; |
12 | import { unref } from 'vue'; | 12 | import { unref } from 'vue'; |
13 | import { computed } from 'vue'; | 13 | import { computed } from 'vue'; |
14 | + import { useMessage } from '/@/hooks/web/useMessage'; | ||
14 | 15 | ||
15 | const props = defineProps<{ | 16 | const props = defineProps<{ |
16 | reload: Fn; | 17 | reload: Fn; |
@@ -49,6 +50,7 @@ | @@ -49,6 +50,7 @@ | ||
49 | }); | 50 | }); |
50 | 51 | ||
51 | const loading = ref(false); | 52 | const loading = ref(false); |
53 | + const { createMessage } = useMessage(); | ||
52 | const handleOk = async () => { | 54 | const handleOk = async () => { |
53 | try { | 55 | try { |
54 | loading.value = true; | 56 | loading.value = true; |
@@ -58,6 +60,9 @@ | @@ -58,6 +60,9 @@ | ||
58 | formMode.value === DataActionModeEnum.CREATE | 60 | formMode.value === DataActionModeEnum.CREATE |
59 | ? await createTask(_res) | 61 | ? await createTask(_res) |
60 | : await updateTask({ ..._res, id: unref(dataSource)?.id as string }); | 62 | : await updateTask({ ..._res, id: unref(dataSource)?.id as string }); |
63 | + createMessage.success( | ||
64 | + unref(modalMode) === DataActionModeEnum.CREATE ? '创建成功' : '修改成功' | ||
65 | + ); | ||
61 | closeModal(); | 66 | closeModal(); |
62 | props.reload?.(); | 67 | props.reload?.(); |
63 | } catch (error) { | 68 | } catch (error) { |
@@ -65,7 +65,7 @@ export const formSchemas: FormSchema[] = [ | @@ -65,7 +65,7 @@ export const formSchemas: FormSchema[] = [ | ||
65 | component: 'ApiSelect', | 65 | component: 'ApiSelect', |
66 | label: '指定目标设备', | 66 | label: '指定目标设备', |
67 | ifShow: ({ model }) => model[FormFieldsEnum.EXECUTE_TARGET_TYPE] === TargetType.ASSIGN, | 67 | ifShow: ({ model }) => model[FormFieldsEnum.EXECUTE_TARGET_TYPE] === TargetType.ASSIGN, |
68 | - rules: [{ required: true, message: '请选择指定目标设备' }], | 68 | + rules: [{ required: true, message: '请选择指定目标设备', type: 'array' }], |
69 | componentProps: ({ formModel }) => { | 69 | componentProps: ({ formModel }) => { |
70 | const record = JSON.parse(formModel[FormFieldsEnum.TASK_RECORD]) as TaskRecordType; | 70 | const record = JSON.parse(formModel[FormFieldsEnum.TASK_RECORD]) as TaskRecordType; |
71 | const isDevices = record.targetType === TaskTargetEnum.DEVICES; | 71 | const isDevices = record.targetType === TaskTargetEnum.DEVICES; |
1 | <script setup lang="ts"> | 1 | <script setup lang="ts"> |
2 | - import { Button, List, Tooltip } from 'ant-design-vue'; | 2 | + import { Button, List, Space, Tooltip } from 'ant-design-vue'; |
3 | import { PageWrapper } from '/@/components/Page'; | 3 | import { PageWrapper } from '/@/components/Page'; |
4 | import { BasicForm, useForm } from '/@/components/Form'; | 4 | import { BasicForm, useForm } from '/@/components/Form'; |
5 | import { PermissionEnum, formSchemas } from './config'; | 5 | import { PermissionEnum, formSchemas } from './config'; |
@@ -19,6 +19,7 @@ | @@ -19,6 +19,7 @@ | ||
19 | import { RunTaskModal } from './components/RunTaskModal'; | 19 | import { RunTaskModal } from './components/RunTaskModal'; |
20 | import { DetailDrawer } from './components/DetailDrawer'; | 20 | import { DetailDrawer } from './components/DetailDrawer'; |
21 | import { useDrawer } from '/@/components/Drawer'; | 21 | import { useDrawer } from '/@/components/Drawer'; |
22 | + import { CardLayoutButton } from '/@/components/Widget'; | ||
22 | 23 | ||
23 | const [registerModal, { openModal }] = useModal(); | 24 | const [registerModal, { openModal }] = useModal(); |
24 | const [registerDrawer, { openDrawer }] = useDrawer(); | 25 | const [registerDrawer, { openDrawer }] = useDrawer(); |
@@ -41,12 +42,14 @@ | @@ -41,12 +42,14 @@ | ||
41 | getDataSource(); | 42 | getDataSource(); |
42 | }; | 43 | }; |
43 | 44 | ||
45 | + const colNumber = ref(5); | ||
44 | const pagination = reactive({ | 46 | const pagination = reactive({ |
45 | current: 1, | 47 | current: 1, |
46 | - pageSize: 10, | ||
47 | total: 0, | 48 | total: 0, |
49 | + pageSize: unref(colNumber) * 2, | ||
48 | showQuickJumper: true, | 50 | showQuickJumper: true, |
49 | size: 'small', | 51 | size: 'small', |
52 | + showSizeChanger: false, | ||
50 | showTotal: (total: number) => `共 ${total} 条数据`, | 53 | showTotal: (total: number) => `共 ${total} 条数据`, |
51 | onChange: paginationChange, | 54 | onChange: paginationChange, |
52 | onShowSizeChange: paginationChange, | 55 | onShowSizeChange: paginationChange, |
@@ -58,13 +61,15 @@ | @@ -58,13 +61,15 @@ | ||
58 | try { | 61 | try { |
59 | loading.value = true; | 62 | loading.value = true; |
60 | const params = getFieldsValue(); | 63 | const params = getFieldsValue(); |
64 | + const pageSize = unref(colNumber) * 2; | ||
61 | const { items, total } = await getTaskCenterList({ | 65 | const { items, total } = await getTaskCenterList({ |
62 | page: pagination.current, | 66 | page: pagination.current, |
63 | - pageSize: pagination.pageSize, | 67 | + pageSize, |
64 | ...params, | 68 | ...params, |
65 | }); | 69 | }); |
66 | dataSource.value = items; | 70 | dataSource.value = items; |
67 | pagination.total = total; | 71 | pagination.total = total; |
72 | + pagination.pageSize = pageSize; | ||
68 | } catch (error) { | 73 | } catch (error) { |
69 | throw error; | 74 | throw error; |
70 | } finally { | 75 | } finally { |
@@ -148,11 +153,14 @@ | @@ -148,11 +153,14 @@ | ||
148 | <div> | 153 | <div> |
149 | <span class="text-lg font-medium">任务列表</span> | 154 | <span class="text-lg font-medium">任务列表</span> |
150 | </div> | 155 | </div> |
151 | - <Tooltip v-if="dataSource.length" title="刷新"> | ||
152 | - <Button type="primary" @click="getDataSource"> | ||
153 | - <ReloadOutlined :spin="loading" /> | ||
154 | - </Button> | ||
155 | - </Tooltip> | 156 | + <Space> |
157 | + <CardLayoutButton v-model:value="colNumber" @change="reload" /> | ||
158 | + <Tooltip v-if="dataSource.length" title="刷新"> | ||
159 | + <Button type="primary" @click="getDataSource"> | ||
160 | + <ReloadOutlined :spin="loading" /> | ||
161 | + </Button> | ||
162 | + </Tooltip> | ||
163 | + </Space> | ||
156 | </section> | 164 | </section> |
157 | </template> | 165 | </template> |
158 | <template #renderItem="{ item }"> | 166 | <template #renderItem="{ item }"> |