Commit cc270f03edc0bd6423367f771a174d1bbe17b5cf
Merge branch 'ww' into 'main'
feat: add up and down record jump online record page See merge request huang/yun-teng-iot-front!465
Showing
6 changed files
with
60 additions
and
54 deletions
| ... | ... | @@ -244,7 +244,6 @@ |
| 244 | 244 | // selectedTotal.value = unref(selectedRowKeys).length; |
| 245 | 245 | pendingTotal.value = unref(pendingTotal) - currentPageSelectRows.length; |
| 246 | 246 | selectedTotal.value = unref(selectedTotal) + currentPageSelectRows.length; |
| 247 | - console.log(unref(pendingTotal)); | |
| 248 | 247 | |
| 249 | 248 | clearPendingSelectedRowKeys(); |
| 250 | 249 | handleTriggerEmit(unref(selectedRowKeys), unref(selectedRows)); | ... | ... |
| 1 | 1 | <script setup lang="ts"> |
| 2 | - import { List, Card, Button, PaginationProps, Popover, Slider, Tooltip } from 'ant-design-vue'; | |
| 3 | - import { ReloadOutlined, AppstoreOutlined } from '@ant-design/icons-vue'; | |
| 2 | + import { List, Card, Button, PaginationProps, Tooltip } from 'ant-design-vue'; | |
| 3 | + import { ReloadOutlined } from '@ant-design/icons-vue'; | |
| 4 | 4 | import { computed, onMounted, reactive, ref, unref } from 'vue'; |
| 5 | 5 | import { OrganizationIdTree, useResetOrganizationTree } from '../../common/organizationIdTree'; |
| 6 | 6 | import { |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | import { cloneDeep } from 'lodash'; |
| 22 | 22 | import { usePermission } from '/@/hooks/web/usePermission'; |
| 23 | 23 | import { useGlobSetting } from '/@/hooks/setting'; |
| 24 | - import { AuthIcon } from '/@/components/Widget'; | |
| 24 | + import { AuthIcon, CardLayoutButton } from '/@/components/Widget'; | |
| 25 | 25 | import AuthDropDown from '/@/components/Widget/AuthDropDown.vue'; |
| 26 | 26 | |
| 27 | 27 | const listColumn = ref(5); |
| ... | ... | @@ -34,6 +34,7 @@ |
| 34 | 34 | size: 'small', |
| 35 | 35 | showTotal: (total: number) => `共 ${total} 条数据`, |
| 36 | 36 | current: 1, |
| 37 | + pageSize: unref(listColumn) * 2, | |
| 37 | 38 | onChange: (page: number) => { |
| 38 | 39 | pagination.current = page; |
| 39 | 40 | getListData(); |
| ... | ... | @@ -63,16 +64,16 @@ |
| 63 | 64 | async function getListData(value: Recordable = {}) { |
| 64 | 65 | try { |
| 65 | 66 | loading.value = true; |
| 66 | - const pageSize = 4 * unref(listColumn); | |
| 67 | + const pageSize = unref(listColumn) * 2; | |
| 67 | 68 | const { items, total } = await getPage({ |
| 68 | 69 | organizationId: unref(organizationId), |
| 69 | 70 | ...value, |
| 70 | 71 | page: pagination.current!, |
| 71 | 72 | pageSize, |
| 72 | 73 | }); |
| 74 | + | |
| 73 | 75 | dataSource.value = items; |
| 74 | - pagination.total = total; | |
| 75 | - pagination.pageSize = pageSize; | |
| 76 | + Object.assign(pagination, { total, pageSize }); | |
| 76 | 77 | } catch (error) { |
| 77 | 78 | } finally { |
| 78 | 79 | loading.value = false; |
| ... | ... | @@ -138,6 +139,11 @@ |
| 138 | 139 | } catch (error) {} |
| 139 | 140 | }; |
| 140 | 141 | |
| 142 | + const handleCardLayoutChange = () => { | |
| 143 | + pagination.current = 1; | |
| 144 | + getListData(); | |
| 145 | + }; | |
| 146 | + | |
| 141 | 147 | const listEl = ref<Nullable<ComponentElRef>>(null); |
| 142 | 148 | |
| 143 | 149 | onMounted(() => { |
| ... | ... | @@ -180,23 +186,7 @@ |
| 180 | 186 | <Authority :value="ConfigurationPermission.CREATE"> |
| 181 | 187 | <Button type="primary" @click="handleCreateOrUpdate()">新增组态</Button> |
| 182 | 188 | </Authority> |
| 183 | - <Popover :trigger="['hover']"> | |
| 184 | - <template #content> | |
| 185 | - <div class="w-50"> | |
| 186 | - <div>每行显示数量</div> | |
| 187 | - <Slider | |
| 188 | - v-model:value="listColumn" | |
| 189 | - :max="12" | |
| 190 | - :min="4" | |
| 191 | - :marks="{ 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9, 10: 10, 11: 11, 12: 12 }" | |
| 192 | - @change="getListData" | |
| 193 | - /> | |
| 194 | - </div> | |
| 195 | - </template> | |
| 196 | - <Button type="primary"> | |
| 197 | - <AppstoreOutlined /> | |
| 198 | - </Button> | |
| 199 | - </Popover> | |
| 189 | + <CardLayoutButton v-model:value="listColumn" @change="handleCardLayoutChange" /> | |
| 200 | 190 | <Tooltip title="刷新"> |
| 201 | 191 | <Button type="primary" @click="getListData"> |
| 202 | 192 | <ReloadOutlined @click="getListData" /> |
| ... | ... | @@ -256,28 +246,6 @@ |
| 256 | 246 | ]" |
| 257 | 247 | :trigger="['hover']" |
| 258 | 248 | /> |
| 259 | - <!-- <Dropdown | |
| 260 | - :dropMenuList="[ | |
| 261 | - { | |
| 262 | - text: '编辑', | |
| 263 | - auth: ConfigurationPermission.UPDATE, | |
| 264 | - icon: 'clarity:note-edit-line', | |
| 265 | - event: '', | |
| 266 | - onClick: handleCreateOrUpdate.bind(null, item), | |
| 267 | - }, | |
| 268 | - { | |
| 269 | - text: '删除', | |
| 270 | - auth: ConfigurationPermission.DELETE, | |
| 271 | - icon: 'ant-design:delete-outlined', | |
| 272 | - color: 'error', | |
| 273 | - event: '', | |
| 274 | - onClick: handleDelete.bind(null, item), | |
| 275 | - }, | |
| 276 | - ]" | |
| 277 | - :trigger="['hover']" | |
| 278 | - > | |
| 279 | - <EllipsisOutlined key="ellipsis" /> | |
| 280 | - </Dropdown> --> | |
| 281 | 249 | </template> |
| 282 | 250 | <Card.Meta> |
| 283 | 251 | <template #title> |
| ... | ... | @@ -308,6 +276,10 @@ |
| 308 | 276 | height: 24px; |
| 309 | 277 | } |
| 310 | 278 | |
| 279 | + .configuration-list:deep(.ant-card-body) { | |
| 280 | + padding: 16px !important; | |
| 281 | + } | |
| 282 | + | |
| 311 | 283 | .configuration-list:deep(.ant-list-empty-text) { |
| 312 | 284 | @apply w-full h-full flex justify-center items-center; |
| 313 | 285 | } | ... | ... |
| ... | ... | @@ -135,6 +135,11 @@ |
| 135 | 135 | onClick: handleDispatchCustomer.bind(null, record), |
| 136 | 136 | }, |
| 137 | 137 | { |
| 138 | + label: '上下线记录', | |
| 139 | + icon: 'ant-design:rise-outlined', | |
| 140 | + onClick: handleUpAndDownRecord.bind(null, record), | |
| 141 | + }, | |
| 142 | + { | |
| 138 | 143 | label: '删除', |
| 139 | 144 | auth: 'api:yt:device:delete', |
| 140 | 145 | icon: 'ant-design:delete-outlined', |
| ... | ... | @@ -193,6 +198,7 @@ |
| 193 | 198 | import { useCopyToClipboard } from '/@/hooks/web/useCopyToClipboard'; |
| 194 | 199 | import { QuestionCircleOutlined } from '@ant-design/icons-vue'; |
| 195 | 200 | import { Authority } from '/@/components/Authority'; |
| 201 | + import { useRouter } from 'vue-router'; | |
| 196 | 202 | |
| 197 | 203 | export default defineComponent({ |
| 198 | 204 | name: 'DeviceManagement', |
| ... | ... | @@ -215,6 +221,7 @@ |
| 215 | 221 | setup(_) { |
| 216 | 222 | const { createMessage } = useMessage(); |
| 217 | 223 | const go = useGo(); |
| 224 | + const ROUTER = useRouter(); | |
| 218 | 225 | const immediateStatus = ref(false); |
| 219 | 226 | const searchInfo = reactive<Recordable>({}); |
| 220 | 227 | const { organizationIdTreeRef, resetFn } = useResetOrganizationTree(searchInfo); |
| ... | ... | @@ -405,6 +412,13 @@ |
| 405 | 412 | openGatewayDetailDrawer(true, data); |
| 406 | 413 | }; |
| 407 | 414 | |
| 415 | + const handleUpAndDownRecord = (record: Record<'name', string>) => { | |
| 416 | + ROUTER.push({ | |
| 417 | + path: '/operation/onlinerecord', | |
| 418 | + query: { deviceName: record.name }, | |
| 419 | + }); | |
| 420 | + }; | |
| 421 | + | |
| 408 | 422 | return { |
| 409 | 423 | registerTable, |
| 410 | 424 | handleCreate, |
| ... | ... | @@ -432,6 +446,7 @@ |
| 432 | 446 | handleOpenTbDeviceDetail, |
| 433 | 447 | handleOpenGatewayDetail, |
| 434 | 448 | registerGatewayDetailDrawer, |
| 449 | + handleUpAndDownRecord, | |
| 435 | 450 | }; |
| 436 | 451 | }, |
| 437 | 452 | }); | ... | ... |
| ... | ... | @@ -62,10 +62,13 @@ |
| 62 | 62 | |
| 63 | 63 | const loading = ref(false); |
| 64 | 64 | |
| 65 | + const colNumber = ref(5); | |
| 66 | + | |
| 65 | 67 | const pagination = reactive<PaginationProps>({ |
| 66 | 68 | size: 'small', |
| 67 | 69 | showTotal: (total: number) => `共 ${total} 条数据`, |
| 68 | 70 | current: 1, |
| 71 | + pageSize: unref(colNumber) * 2, | |
| 69 | 72 | onChange: (page: number) => { |
| 70 | 73 | pagination.current = page; |
| 71 | 74 | getDataSource(); |
| ... | ... | @@ -74,8 +77,6 @@ |
| 74 | 77 | |
| 75 | 78 | const dataSource = ref<ProfileRecord[]>([]); |
| 76 | 79 | |
| 77 | - const colNumber = ref(5); | |
| 78 | - | |
| 79 | 80 | const getSelectAllFlag = computed(() => { |
| 80 | 81 | return unref(dataSource).every((item) => item.checked); |
| 81 | 82 | }); |
| ... | ... | @@ -93,13 +94,14 @@ |
| 93 | 94 | setFieldsValue(otherParams); |
| 94 | 95 | } |
| 95 | 96 | const params = getFieldsValue(); |
| 97 | + const pageSize = unref(colNumber) * 2; | |
| 96 | 98 | const { items, total } = await deviceConfigGetQuery({ |
| 97 | 99 | page: pagination.current, |
| 98 | 100 | pageSize: unref(colNumber) * 2, |
| 99 | 101 | ...params, |
| 100 | 102 | ...otherParams, |
| 101 | 103 | }); |
| 102 | - pagination.total = total; | |
| 104 | + Object.assign(pagination, { total, pageSize }); | |
| 103 | 105 | dataSource.value = items.map((item) => ({ ...item, checked: false })); |
| 104 | 106 | } catch (error) { |
| 105 | 107 | } finally { |
| ... | ... | @@ -162,6 +164,12 @@ |
| 162 | 164 | throw error; |
| 163 | 165 | } |
| 164 | 166 | }; |
| 167 | + | |
| 168 | + const handleCardLayoutChange = () => { | |
| 169 | + pagination.current = 1; | |
| 170 | + getDataSource(); | |
| 171 | + }; | |
| 172 | + | |
| 165 | 173 | const { query: routeParams } = useRoute(); |
| 166 | 174 | onMounted(() => { |
| 167 | 175 | getDataSource(routeParams); |
| ... | ... | @@ -204,7 +212,7 @@ |
| 204 | 212 | </Authority> |
| 205 | 213 | |
| 206 | 214 | <ModeSwitchButton :value="$props.mode" @change="handleModeChange" /> |
| 207 | - <CardLayoutButton v-model:value="colNumber" @change="getDataSource" /> | |
| 215 | + <CardLayoutButton v-model:value="colNumber" @change="handleCardLayoutChange" /> | |
| 208 | 216 | |
| 209 | 217 | <Tooltip title="刷新"> |
| 210 | 218 | <Button type="primary" @click="getDataSource"> | ... | ... |
| ... | ... | @@ -48,7 +48,7 @@ |
| 48 | 48 | </template> |
| 49 | 49 | |
| 50 | 50 | <script lang="ts" setup> |
| 51 | - import { nextTick } from 'vue'; | |
| 51 | + import { nextTick, onMounted } from 'vue'; | |
| 52 | 52 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
| 53 | 53 | import { useDrawer } from '/@/components/Drawer'; |
| 54 | 54 | import OnlineRecordDrawer from './OnlineRecordDrawer.vue'; |
| ... | ... | @@ -58,9 +58,11 @@ |
| 58 | 58 | import { useBatchDelete } from '/@/hooks/web/useBatchDelete'; |
| 59 | 59 | import { Popconfirm } from 'ant-design-vue'; |
| 60 | 60 | import { Authority } from '/@/components/Authority'; |
| 61 | + import { useRoute } from 'vue-router'; | |
| 61 | 62 | |
| 62 | - const [registerTable, { setProps, reload }] = useTable({ | |
| 63 | + const [registerTable, { setProps, reload, getForm }] = useTable({ | |
| 63 | 64 | title: '上下线记录', |
| 65 | + immediate: false, | |
| 64 | 66 | api: deviceStateLogPage, |
| 65 | 67 | columns, |
| 66 | 68 | showIndexColumn: false, |
| ... | ... | @@ -117,4 +119,14 @@ |
| 117 | 119 | record, |
| 118 | 120 | }); |
| 119 | 121 | }; |
| 122 | + const ROUTE = useRoute(); | |
| 123 | + | |
| 124 | + onMounted(async () => { | |
| 125 | + const formActionType = getForm(); | |
| 126 | + const params = ROUTE.query; | |
| 127 | + if (params) { | |
| 128 | + await formActionType.setFieldsValue(params); | |
| 129 | + } | |
| 130 | + await reload(); | |
| 131 | + }); | |
| 120 | 132 | </script> | ... | ... |
| ... | ... | @@ -70,8 +70,8 @@ const handleGroupDevice = (options: DeviceRecord[]) => { |
| 70 | 70 | } |
| 71 | 71 | }); |
| 72 | 72 | const value = Array.from(map.entries()).map(([product, devices]) => ({ product, devices })); |
| 73 | - console.log(value); | |
| 74 | - return Array.from(map.entries()).map(([product, devices]) => ({ product, devices })); | |
| 73 | + | |
| 74 | + return value; | |
| 75 | 75 | }; |
| 76 | 76 | |
| 77 | 77 | const deviceTableFormSchema: FormSchema[] = [ | ... | ... |