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 | 1 | <script lang="ts" setup> |
2 | 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 | 4 | import { PageWrapper } from '/@/components/Page'; |
5 | 5 | import { BasicTable, useTable } from '/@/components/Table'; |
6 | 6 | import { realTimeDataColumns } from '../../config/detail.config'; |
... | ... | @@ -31,6 +31,9 @@ |
31 | 31 | key?: string; |
32 | 32 | value?: string; |
33 | 33 | time?: number; |
34 | + type?: string; | |
35 | + boolClose?: string; | |
36 | + boolOpen?: string; | |
34 | 37 | } |
35 | 38 | |
36 | 39 | const props = defineProps<{ |
... | ... | @@ -214,6 +217,14 @@ |
214 | 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 | 228 | onUnmounted(() => close()); |
218 | 229 | </script> |
219 | 230 | |
... | ... | @@ -252,13 +263,9 @@ |
252 | 263 | </template> |
253 | 264 | <section class="min-h-16 flex flex-col justify-between"> |
254 | 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 | 269 | <div class="text-xs flex items-center">{{ item.unit }}</div> |
263 | 270 | </div> |
264 | 271 | <div class="text-dark-800 text-xs"> | ... | ... |
... | ... | @@ -92,7 +92,6 @@ export const schemas: DescItem[] = [ |
92 | 92 | render(_val: any, data: TaskRecordType) { |
93 | 93 | const { executeTime } = data; |
94 | 94 | const { time, type, periodType, pollUnit, period } = executeTime; |
95 | - console.log({ time, type, periodType, pollUnit }); | |
96 | 95 | return type === ExecuteTimeTypeEnum.POLL |
97 | 96 | ? `${time}${TimeUnitNameEnum[pollUnit]}` |
98 | 97 | : `${PeriodTypeNameEnum[periodType]} ${ | ... | ... |
... | ... | @@ -11,6 +11,7 @@ |
11 | 11 | import { FormValueType } from './util'; |
12 | 12 | import { unref } from 'vue'; |
13 | 13 | import { computed } from 'vue'; |
14 | + import { useMessage } from '/@/hooks/web/useMessage'; | |
14 | 15 | |
15 | 16 | const props = defineProps<{ |
16 | 17 | reload: Fn; |
... | ... | @@ -49,6 +50,7 @@ |
49 | 50 | }); |
50 | 51 | |
51 | 52 | const loading = ref(false); |
53 | + const { createMessage } = useMessage(); | |
52 | 54 | const handleOk = async () => { |
53 | 55 | try { |
54 | 56 | loading.value = true; |
... | ... | @@ -58,6 +60,9 @@ |
58 | 60 | formMode.value === DataActionModeEnum.CREATE |
59 | 61 | ? await createTask(_res) |
60 | 62 | : await updateTask({ ..._res, id: unref(dataSource)?.id as string }); |
63 | + createMessage.success( | |
64 | + unref(modalMode) === DataActionModeEnum.CREATE ? '创建成功' : '修改成功' | |
65 | + ); | |
61 | 66 | closeModal(); |
62 | 67 | props.reload?.(); |
63 | 68 | } catch (error) { | ... | ... |
... | ... | @@ -65,7 +65,7 @@ export const formSchemas: FormSchema[] = [ |
65 | 65 | component: 'ApiSelect', |
66 | 66 | label: '指定目标设备', |
67 | 67 | ifShow: ({ model }) => model[FormFieldsEnum.EXECUTE_TARGET_TYPE] === TargetType.ASSIGN, |
68 | - rules: [{ required: true, message: '请选择指定目标设备' }], | |
68 | + rules: [{ required: true, message: '请选择指定目标设备', type: 'array' }], | |
69 | 69 | componentProps: ({ formModel }) => { |
70 | 70 | const record = JSON.parse(formModel[FormFieldsEnum.TASK_RECORD]) as TaskRecordType; |
71 | 71 | const isDevices = record.targetType === TaskTargetEnum.DEVICES; | ... | ... |
1 | 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 | 3 | import { PageWrapper } from '/@/components/Page'; |
4 | 4 | import { BasicForm, useForm } from '/@/components/Form'; |
5 | 5 | import { PermissionEnum, formSchemas } from './config'; |
... | ... | @@ -19,6 +19,7 @@ |
19 | 19 | import { RunTaskModal } from './components/RunTaskModal'; |
20 | 20 | import { DetailDrawer } from './components/DetailDrawer'; |
21 | 21 | import { useDrawer } from '/@/components/Drawer'; |
22 | + import { CardLayoutButton } from '/@/components/Widget'; | |
22 | 23 | |
23 | 24 | const [registerModal, { openModal }] = useModal(); |
24 | 25 | const [registerDrawer, { openDrawer }] = useDrawer(); |
... | ... | @@ -41,12 +42,14 @@ |
41 | 42 | getDataSource(); |
42 | 43 | }; |
43 | 44 | |
45 | + const colNumber = ref(5); | |
44 | 46 | const pagination = reactive({ |
45 | 47 | current: 1, |
46 | - pageSize: 10, | |
47 | 48 | total: 0, |
49 | + pageSize: unref(colNumber) * 2, | |
48 | 50 | showQuickJumper: true, |
49 | 51 | size: 'small', |
52 | + showSizeChanger: false, | |
50 | 53 | showTotal: (total: number) => `共 ${total} 条数据`, |
51 | 54 | onChange: paginationChange, |
52 | 55 | onShowSizeChange: paginationChange, |
... | ... | @@ -58,13 +61,15 @@ |
58 | 61 | try { |
59 | 62 | loading.value = true; |
60 | 63 | const params = getFieldsValue(); |
64 | + const pageSize = unref(colNumber) * 2; | |
61 | 65 | const { items, total } = await getTaskCenterList({ |
62 | 66 | page: pagination.current, |
63 | - pageSize: pagination.pageSize, | |
67 | + pageSize, | |
64 | 68 | ...params, |
65 | 69 | }); |
66 | 70 | dataSource.value = items; |
67 | 71 | pagination.total = total; |
72 | + pagination.pageSize = pageSize; | |
68 | 73 | } catch (error) { |
69 | 74 | throw error; |
70 | 75 | } finally { |
... | ... | @@ -148,11 +153,14 @@ |
148 | 153 | <div> |
149 | 154 | <span class="text-lg font-medium">任务列表</span> |
150 | 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 | 164 | </section> |
157 | 165 | </template> |
158 | 166 | <template #renderItem="{ item }"> | ... | ... |