fix 逐步引入新版表格

This commit is contained in:
bwcx_jzy 2024-03-18 15:36:53 +08:00
parent 2578d5deb7
commit a72211cde2
No known key found for this signature in database
GPG Key ID: E187D6E9DDDE8C53
8 changed files with 307 additions and 268 deletions

View File

@ -11,6 +11,8 @@
5. 【server】修复 docker 控制台网络选项卡页面空白(感谢@破冰) 5. 【server】修复 docker 控制台网络选项卡页面空白(感谢@破冰)
6. 【server】修复 节点历史监控统计图表时间查询不生效(感谢@九問) 6. 【server】修复 节点历史监控统计图表时间查询不生效(感谢@九問)
7. 【server】优化 SSH 脚本触发器支持传入参数当环境变量(感谢@小朱) 7. 【server】优化 SSH 脚本触发器支持传入参数当环境变量(感谢@小朱)
8. 【server】修复 h2迁移其它数据库时部分数据丢失感谢[@王先生](https://gitee.com/whz_gmg1)[Gitee issues I9977K](https://gitee.com/dromara/Jpom/issues/I9977K)
9. 【server】优化 逐步引入新版表格(构建、项目、节点、资产机器)(感谢[@a20070322](https://gitee.com/a20070322) [Gitee Pr 218](https://gitee.com/dromara/Jpom/pulls/218) / [Gitee Pr 220](https://gitee.com/dromara/Jpom/pulls/220) / [Gitee Pr 222](https://gitee.com/dromara/Jpom/pulls/222)
------ ------

View File

@ -124,7 +124,7 @@
</template> </template>
</template> </template>
<template v-if="tableLayout === 'table'"> <template v-if="tableLayout === 'table'">
<a-table v-bind="props" :columns="customColumn" :size="tableSize"> <a-table v-bind="props" :pagination="paginationByLayout" :columns="customColumn" :size="tableSize">
<template v-if="slots.tableBodyCell" #bodyCell="slotProps"> <template v-if="slots.tableBodyCell" #bodyCell="slotProps">
<slot name="tableBodyCell" v-bind="slotProps"></slot> <slot name="tableBodyCell" v-bind="slotProps"></slot>
</template> </template>
@ -138,14 +138,14 @@
</a-col> </a-col>
</template> </template>
<a-col v-else :span="24"> <a-col v-else :span="24">
<a-empty :image="Empty.PRESENTED_IMAGE_SIMPLE" description="没有任何节点" /> <a-empty :image="Empty.PRESENTED_IMAGE_SIMPLE" :description="props.emptyDescription" />
</a-col> </a-col>
</a-row> </a-row>
<div class="card-pagination"> <div class="card-pagination">
<a-pagination v-bind="props.pagination" size="small" @change="paginationChange" /> <a-pagination v-bind="paginationByLayout" size="small" @change="paginationChange" />
</div> </div>
<slot name="cardPageTool"></slot> <!-- <slot name="cardPageTool"></slot> -->
</template> </template>
<template v-else>未知的表格类型</template> <template v-else>未知的表格类型</template>
</a-card> </a-card>
@ -174,7 +174,7 @@ export default defineComponent({
inheritAttrs: false, inheritAttrs: false,
props: customTableProps, props: customTableProps,
slots: Object as CustomTableSlotsType, slots: Object as CustomTableSlotsType,
emits: ['refresh', 'change'], emits: ['refresh', 'change', 'changeTableLayout'],
setup(props, { attrs, slots, emit }) { setup(props, { attrs, slots, emit }) {
const userStore = useUserStore() const userStore = useUserStore()
const storageService: StorageService = new StorageService(props.tableName, { const storageService: StorageService = new StorageService(props.tableName, {
@ -266,6 +266,15 @@ export default defineComponent({
} }
return Object.keys(slots).filter((key) => key === 'cardBodyCell').length > 0 return Object.keys(slots).filter((key) => key === 'cardBodyCell').length > 0
}) })
const sizeOptions = computed(() => {
if (tableLayout.value === 'card') {
return ['8', '12', '16', '20', '24']
}
return ['5', '10', '15', '20', '25', '30', '35', '40', '50']
})
const paginationByLayout = computed(() => {
return { ...props.pagination, pageSizeOptions: sizeOptions.value }
})
onMounted(() => { onMounted(() => {
// //
@ -278,6 +287,7 @@ export default defineComponent({
}) })
const tableLayoutClick = () => { const tableLayoutClick = () => {
tableLayout.value = tableLayout.value === 'card' ? 'table' : 'card' tableLayout.value = tableLayout.value === 'card' ? 'table' : 'card'
emit('changeTableLayout', tableLayout.value)
} }
watch( watch(
() => tableLayout.value, () => tableLayout.value,
@ -423,7 +433,8 @@ export default defineComponent({
customCheckColumnList, customCheckColumnList,
resetCustomColumn, resetCustomColumn,
onCheckChange, onCheckChange,
paginationChange paginationChange,
paginationByLayout
} }
} }
}) })

View File

@ -48,6 +48,11 @@ export const customTableProps = initDefaultProps(
activePage: { activePage: {
type: Boolean, type: Boolean,
default: false default: false
},
// 空数据时现在内容
emptyDescription: {
type: String,
deafult: '暂无任何数据'
} }
}, },
{ {
@ -56,6 +61,7 @@ export const customTableProps = initDefaultProps(
isShowTools: false, isShowTools: false,
isHideRefresh: false, isHideRefresh: false,
autoRefreshTime: 10, autoRefreshTime: 10,
activePage: false activePage: false,
emptyDescription: '暂无任何数据'
} }
) )

View File

@ -27,6 +27,7 @@ export type CustomTableSlotsType = CustomSlotsType<{
tableBodyCell?: any tableBodyCell?: any
expandedRowRender?: any expandedRowRender?: any
expandColumnTitle?: any expandColumnTitle?: any
emptyDescription: string
bodyCell?: (props: { text: any; value: any; record: Record<string, any>; index: number; column: ColumnType }) => void bodyCell?: (props: { text: any; value: any; record: Record<string, any>; index: number; column: ColumnType }) => void
headerCell?: (props: { title: any; column: ColumnType }) => void headerCell?: (props: { title: any; column: ColumnType }) => void
customFilterIcon?: any customFilterIcon?: any

View File

@ -19,6 +19,7 @@
default-auto-refresh default-auto-refresh
:auto-refresh-time="5" :auto-refresh-time="5"
table-name="buildList" table-name="buildList"
empty-description="没有任何构建"
:active-page="activePage" :active-page="activePage"
:layout="layout" :layout="layout"
size="middle" size="middle"
@ -41,6 +42,15 @@
} }
" "
@refresh="loadData" @refresh="loadData"
@change-table-layout="
(layoutType) => {
tableSelections = []
listQuery = CHANGE_PAGE(listQuery, {
pagination: { limit: layoutType === 'card' ? 8 : 10 }
})
loadData()
}
"
> >
<template #title> <template #title>
<a-space wrap class="search-box"> <a-space wrap class="search-box">
@ -119,11 +129,8 @@
<a-button type="primary" :loading="loading" @click="loadData">搜索</a-button> <a-button type="primary" :loading="loading" @click="loadData">搜索</a-button>
</a-tooltip> </a-tooltip>
<a-button type="primary" @click="handleAdd">新增</a-button> <a-button type="primary" @click="handleAdd">新增</a-button>
<!-- <template v-if="layoutType === 'table'"> --> <template v-if="tableSelections && tableSelections.length">
<template v-if="!tableSelections || tableSelections.length <= 0"> <a-dropdown>
<a-button type="primary" :disabled="true"> 操作 <DownOutlined /> </a-button>
</template>
<a-dropdown v-else>
<template #overlay> <template #overlay>
<a-menu> <a-menu>
<a-menu-item key="1" @click="batchBuild"> 批量构建 </a-menu-item> <a-menu-item key="1" @click="batchBuild"> 批量构建 </a-menu-item>
@ -133,10 +140,10 @@
</template> </template>
<a-button type="primary"> 批量操作<DownOutlined /> </a-button> <a-button type="primary"> 批量操作<DownOutlined /> </a-button>
</a-dropdown> </a-dropdown>
<!-- </template> --> </template>
<!-- <a-tooltip v-else title="表格视图才能使用批量操作功能"> <a-tooltip v-else title="表格视图才能使用批量操作功能">
<a-button :disabled="true" type="primary"> 操作 <DownOutlined /> </a-button> <a-button :disabled="true" type="primary"> 批量操作 <DownOutlined /> </a-button>
</a-tooltip> --> </a-tooltip>
<!-- <a-button v-if="!layout" type="primary" @click="changeLayout"> <!-- <a-button v-if="!layout" type="primary" @click="changeLayout">
<template #icon> <template #icon>
@ -492,7 +499,7 @@
</a-space> </a-space>
</template> </template>
</template> </template>
<template #cardPageTool> <!-- <template #cardPageTool>
<a-row type="flex" justify="center"> <a-row type="flex" justify="center">
<a-divider v-if="listQuery.total / listQuery.limit > 1" dashed /> <a-divider v-if="listQuery.total / listQuery.limit > 1" dashed />
<a-col> <a-col>
@ -519,7 +526,7 @@
/> />
</a-col> </a-col>
</a-row> </a-row>
</template> </template> -->
</CustomTable> </CustomTable>
<!-- </template> --> <!-- </template> -->
<!-- </a-card> --> <!-- </a-card> -->
@ -704,8 +711,9 @@ import {
CHANGE_PAGE, CHANGE_PAGE,
COMPUTED_PAGINATION, COMPUTED_PAGINATION,
PAGE_DEFAULT_LIST_QUERY, PAGE_DEFAULT_LIST_QUERY,
parseTime, parseTime
PAGE_DEFAULT_SHOW_TOTAL // PAGE_DEFAULT_SHOW_TOTAL,
// getCachePageLimit
} from '@/utils/const' } from '@/utils/const'
export default { export default {
@ -897,7 +905,8 @@ export default {
}, },
methods: { methods: {
CHANGE_PAGE, CHANGE_PAGE,
PAGE_DEFAULT_SHOW_TOTAL, // PAGE_DEFAULT_SHOW_TOTAL,
// getCachePageLimit,
// //
loadGroupList() { loadGroupList() {
getBuildGroupAll().then((res) => { getBuildGroupAll().then((res) => {

View File

@ -29,6 +29,7 @@
:auto-refresh-time="30" :auto-refresh-time="30"
:active-page="activePage" :active-page="activePage"
table-name="nodeSearch" table-name="nodeSearch"
empty-description="没有任何节点"
:columns="columns" :columns="columns"
:data-source="list" :data-source="list"
bordered bordered
@ -49,6 +50,15 @@
} }
" "
@refresh="loadData" @refresh="loadData"
@change-table-layout="
(layoutType) => {
tableSelections = []
listQuery = CHANGE_PAGE(listQuery, {
pagination: { limit: layoutType === 'card' ? 8 : 10 }
})
loadData()
}
"
> >
<template #title> <template #title>
<a-space> <a-space>
@ -430,7 +440,7 @@
</a-row> </a-row>
</a-card> </a-card>
</template> </template>
<template #cardPageTool> <!-- <template #cardPageTool>
<a-row type="flex" justify="center"> <a-row type="flex" justify="center">
<a-divider v-if="listQuery.total / listQuery.limit > 1" dashed /> <a-divider v-if="listQuery.total / listQuery.limit > 1" dashed />
<a-col> <a-col>
@ -457,7 +467,7 @@
/> />
</a-col> </a-col>
</a-row> </a-row>
</template> </template> -->
</CustomTable> </CustomTable>
<!-- <template v-else-if="layoutType === 'card'"> <!-- <template v-else-if="layoutType === 'card'">
<a-row :gutter="[16, 16]"> <a-row :gutter="[16, 16]">
@ -654,9 +664,9 @@ import {
formatDuration, formatDuration,
renderSize, renderSize,
formatPercent2Number, formatPercent2Number,
parseTime, parseTime
PAGE_DEFAULT_SHOW_TOTAL, // PAGE_DEFAULT_SHOW_TOTAL,
getCachePageLimit // getCachePageLimit
} from '@/utils/const' } from '@/utils/const'
import { getWorkSpaceListAll } from '@/api/workspace' import { getWorkSpaceListAll } from '@/api/workspace'
import CustomSelect from '@/components/customSelect' import CustomSelect from '@/components/customSelect'
@ -848,14 +858,14 @@ export default {
this.listQuery = { ...this.listQuery, '%name%': searchNodeName } this.listQuery = { ...this.listQuery, '%name%': searchNodeName }
} }
this.changeLayout() this.loadData()
this.loadGroupList() this.loadGroupList()
}, },
methods: { methods: {
formatDuration, formatDuration,
renderSize, renderSize,
PAGE_DEFAULT_SHOW_TOTAL, // PAGE_DEFAULT_SHOW_TOTAL,
parseTime, parseTime,
CHANGE_PAGE, CHANGE_PAGE,
// //
@ -1140,22 +1150,22 @@ export default {
} }
}) })
}, },
// // //
changeLayout() { // changeLayout() {
if (!this.layoutType) { // if (!this.layoutType) {
const layoutType = localStorage.getItem('tableLayout') // const layoutType = localStorage.getItem('tableLayout')
// // //
this.layoutType = layoutType === 'card' ? 'card' : 'table' // this.layoutType = layoutType === 'card' ? 'card' : 'table'
} else { // } else {
this.layoutType = this.layoutType === 'card' ? 'table' : 'card' // this.layoutType = this.layoutType === 'card' ? 'table' : 'card'
localStorage.setItem('tableLayout', this.layoutType) // localStorage.setItem('tableLayout', this.layoutType)
} // }
this.listQuery = { // this.listQuery = {
...this.listQuery, // ...this.listQuery,
limit: this.layoutType === 'card' ? 8 : getCachePageLimit() // limit: this.layoutType === 'card' ? 8 : getCachePageLimit()
} // }
this.loadData() // this.loadData()
}, // },
onFinish() { onFinish() {
if (this.drawerVisible) { if (this.drawerVisible) {
// //

View File

@ -1,6 +1,39 @@
<template> <template>
<div> <div>
<a-card :body-style="{ padding: '10px' }"> <!-- <a-card :body-style="{ padding: '10px' }"> -->
<!-- 卡片视图 -->
<!-- <template v-if="layoutType === 'card'"> </template> -->
<!-- 表格视图 -->
<!-- <template v-else-if="layoutType === 'table'"> -->
<CustomTable
is-show-tools
default-auto-refresh
:auto-refresh-time="30"
table-name="buildList"
empty-description="没有资产机器"
:active-page="activePage"
:columns="columns"
:data-source="list"
bordered
size="middle"
row-key="id"
:pagination="pagination"
:row-selection="rowSelection"
:scroll="{
x: 'max-content'
}"
@change="changePage"
@refresh="getMachineList"
@change-table-layout="
(layoutType) => {
tableSelections = []
listQuery = CHANGE_PAGE(listQuery, {
pagination: { limit: layoutType === 'card' ? 8 : 10 }
})
getMachineList()
}
"
>
<template #title> <template #title>
<a-space wrap class="search-box"> <a-space wrap class="search-box">
<a-input <a-input
@ -56,7 +89,7 @@
<a-button :loading="loading" type="primary" @click="getMachineList">搜索</a-button> <a-button :loading="loading" type="primary" @click="getMachineList">搜索</a-button>
<a-button type="primary" @click="addMachine">新增</a-button> <a-button type="primary" @click="addMachine">新增</a-button>
<a-dropdown v-if="layoutType === 'table'"> <a-dropdown v-if="tableSelections && tableSelections.length">
<template #overlay> <template #overlay>
<a-menu> <a-menu>
<a-menu-item key="1" @click="syncToWorkspaceShow()"> 分配节点 </a-menu-item> <a-menu-item key="1" @click="syncToWorkspaceShow()"> 分配节点 </a-menu-item>
@ -69,14 +102,9 @@
<a-tooltip v-else title="表格视图才能使用同步配置功能"> <a-tooltip v-else title="表格视图才能使用同步配置功能">
<a-button :disabled="true" type="primary"> 批量操作<DownOutlined /></a-button> <a-button :disabled="true" type="primary"> 批量操作<DownOutlined /></a-button>
</a-tooltip> </a-tooltip>
<a-button type="primary" @click="changeLayout"> </a-space>
<template #icon>
<LayoutOutlined v-if="layoutType === 'card'" />
<TableOutlined v-else />
</template> </template>
<template #tableHelp>
{{ layoutType === 'card' ? '卡片' : '表格' }}
</a-button>
<a-tooltip> <a-tooltip>
<template #title> <template #title>
<ul> <ul>
@ -90,13 +118,57 @@
</template> </template>
<QuestionCircleOutlined /> <QuestionCircleOutlined />
</a-tooltip> </a-tooltip>
</template>
<template #tableBodyCell="{ column, text, record }">
<template v-if="column.dataIndex === 'name'">
<a-tooltip :title="text">
<a-button style="padding: 0" type="link" size="small" @click="showMachineInfo(record)">
{{ text }}
</a-button>
</a-tooltip>
</template>
<template v-else-if="column.tooltip">
<a-tooltip :title="text">
<span>{{ text }}</span>
</a-tooltip>
</template>
<template v-else-if="column.dataIndex === 'status'">
<a-tooltip
:title="`当前状态:${statusMap[record.status]} ${
record.statusMsg ? '状态消息:' + record.statusMsg : '还没有状态消息'
} `"
>
<a-tag :color="record.status === 1 ? 'green' : 'pink'" style="margin-right: 0">
{{ statusMap[record.status] }}
</a-tag>
</a-tooltip>
</template>
<template v-else-if="column.duration">
<a-tooltip placement="topLeft" :title="formatDuration(text)">
<span>{{ formatDuration(text, '', 2) }}</span>
</a-tooltip>
</template>
<template v-else-if="column.duration2">
<a-tooltip placement="topLeft" :title="formatDuration((text || 0) * 1000)">
<span>{{ formatDuration((text || 0) * 1000, '', 2) }}</span>
</a-tooltip>
</template>
<template v-else-if="column.percent2Number">
<a-tooltip placement="topLeft" :title="`${(text && formatPercent2Number(text) + '%') || '-'}`">
<span>{{ (text && formatPercent2Number(text) + '%') || '-' }}</span>
</a-tooltip>
</template>
<template v-else-if="column.dataIndex === 'operation'">
<a-space>
<a-button type="primary" size="small" @click="handleEdit(record)">编辑</a-button>
<a-button type="primary" size="small" @click="syncToWorkspaceShow(record)">分配</a-button>
<a-button type="primary" danger size="small" @click="deleteMachineInfo(item)">删除</a-button>
</a-space> </a-space>
</template> </template>
<!-- 卡片视图 --> </template>
<template v-if="layoutType === 'card'">
<a-row :gutter="[16, 16]"> <template #cardBodyCell="{ item }">
<template v-if="list && list.length">
<a-col v-for="(item, index) in list" :key="index" :span="6">
<a-card :head-style="{ padding: '0 6px' }" :body-style="{ padding: '10px' }"> <a-card :head-style="{ padding: '0 6px' }" :body-style="{ padding: '10px' }">
<template #title> <template #title>
<a-row :gutter="[4, 0]"> <a-row :gutter="[4, 0]">
@ -183,13 +255,8 @@
</a-button-group> </a-button-group>
</a-row> </a-row>
</a-card> </a-card>
</a-col>
</template> </template>
<!-- </template> --> <!-- <template #cardPageTool>
<a-col v-else :span="24">
<a-empty :image="Empty.PRESENTED_IMAGE_SIMPLE" description="没有任何节点" />
</a-col>
</a-row>
<a-row type="flex" justify="center"> <a-row type="flex" justify="center">
<a-divider v-if="listQuery.total / listQuery.limit > 1" dashed /> <a-divider v-if="listQuery.total / listQuery.limit > 1" dashed />
<a-col> <a-col>
@ -214,74 +281,11 @@
" "
@change="getMachineList" @change="getMachineList"
/> />
</a-col> </a-col> </a-row
</a-row> ></template> -->
</template> </CustomTable>
<!-- 表格视图 --> <!-- </template> -->
<template v-else-if="layoutType === 'table'"> <!-- </a-card> -->
<a-table
:columns="columns"
:data-source="list"
bordered
size="middle"
row-key="id"
:pagination="pagination"
:row-selection="rowSelection"
:scroll="{
x: 'max-content'
}"
@change="changePage"
>
<template #bodyCell="{ column, text, record }">
<template v-if="column.dataIndex === 'name'">
<a-tooltip :title="text">
<a-button style="padding: 0" type="link" size="small" @click="showMachineInfo(record)">
{{ text }}
</a-button>
</a-tooltip>
</template>
<template v-else-if="column.tooltip">
<a-tooltip :title="text">
<span>{{ text }}</span>
</a-tooltip>
</template>
<template v-else-if="column.dataIndex === 'status'">
<a-tooltip
:title="`当前状态:${statusMap[record.status]} ${
record.statusMsg ? '状态消息:' + record.statusMsg : '还没有状态消息'
} `"
>
<a-tag :color="record.status === 1 ? 'green' : 'pink'" style="margin-right: 0">
{{ statusMap[record.status] }}
</a-tag>
</a-tooltip>
</template>
<template v-else-if="column.duration">
<a-tooltip placement="topLeft" :title="formatDuration(text)">
<span>{{ formatDuration(text, '', 2) }}</span>
</a-tooltip>
</template>
<template v-else-if="column.duration2">
<a-tooltip placement="topLeft" :title="formatDuration((text || 0) * 1000)">
<span>{{ formatDuration((text || 0) * 1000, '', 2) }}</span>
</a-tooltip>
</template>
<template v-else-if="column.percent2Number">
<a-tooltip placement="topLeft" :title="`${(text && formatPercent2Number(text) + '%') || '-'}`">
<span>{{ (text && formatPercent2Number(text) + '%') || '-' }}</span>
</a-tooltip>
</template>
<template v-else-if="column.dataIndex === 'operation'">
<a-space>
<a-button type="primary" size="small" @click="handleEdit(record)">编辑</a-button>
<a-button type="primary" size="small" @click="syncToWorkspaceShow(record)">分配</a-button>
</a-space>
</template>
</template>
</a-table>
</template>
</a-card>
<!-- 编辑区 --> <!-- 编辑区 -->
<a-modal <a-modal
v-model:open="editVisible" v-model:open="editVisible"
@ -614,11 +618,11 @@ import {
CHANGE_PAGE, CHANGE_PAGE,
COMPUTED_PAGINATION, COMPUTED_PAGINATION,
PAGE_DEFAULT_LIST_QUERY, PAGE_DEFAULT_LIST_QUERY,
PAGE_DEFAULT_SHOW_TOTAL, // PAGE_DEFAULT_SHOW_TOTAL,
formatDuration, formatDuration,
parseTime, parseTime,
formatPercent2Number, formatPercent2Number
getCachePageLimit // getCachePageLimit
} from '@/utils/const' } from '@/utils/const'
import CustomSelect from '@/components/customSelect' import CustomSelect from '@/components/customSelect'
import { useAppStore } from '@/stores/app' import { useAppStore } from '@/stores/app'
@ -626,7 +630,7 @@ import { mapState } from 'pinia'
import machineInfo from './machine-func' import machineInfo from './machine-func'
import { getWorkSpaceListAll } from '@/api/workspace' import { getWorkSpaceListAll } from '@/api/workspace'
// import Upgrade from "@/pages/node/node-layout/system/upgrade.vue"; // import Upgrade from "@/pages/node/node-layout/system/upgrade.vue";
import { Empty } from 'ant-design-vue'
import { getWhiteList } from '@/api/node-system' import { getWhiteList } from '@/api/node-system'
import { getConfigData } from '@/api/system' import { getConfigData } from '@/api/system'
import codeEditor from '@/components/codeEditor' import codeEditor from '@/components/codeEditor'
@ -640,10 +644,9 @@ export default {
}, },
data() { data() {
return { return {
Empty,
statusMap, statusMap,
listQuery: Object.assign({ order: 'descend', order_field: 'networkDelay' }, PAGE_DEFAULT_LIST_QUERY, {}), listQuery: Object.assign({ order: 'descend', order_field: 'networkDelay' }, PAGE_DEFAULT_LIST_QUERY, {}),
sizeOptions: ['8', '12', '16', '20', '24'], // sizeOptions: ['8', '12', '16', '20', '24'],
list: [], list: [],
groupList: [], groupList: [],
loading: true, loading: true,
@ -774,7 +777,6 @@ export default {
dataIndex: 'operation', dataIndex: 'operation',
width: '120px', width: '120px',
fixed: 'right', fixed: 'right',
align: 'center' align: 'center'
} }
], ],
@ -790,6 +792,9 @@ export default {
pagination() { pagination() {
return COMPUTED_PAGINATION(this.listQuery) return COMPUTED_PAGINATION(this.listQuery)
}, },
activePage() {
return this.$attrs.routerUrl === this.$route.path
},
rowSelection() { rowSelection() {
return { return {
onChange: (selectedRowKeys) => { onChange: (selectedRowKeys) => {
@ -801,13 +806,14 @@ export default {
}, },
mounted() { mounted() {
this.loadGroupList() this.loadGroupList()
this.changeLayout() this.getMachineList()
}, },
methods: { methods: {
parseTime, parseTime,
formatDuration, formatDuration,
formatPercent2Number, formatPercent2Number,
PAGE_DEFAULT_SHOW_TOTAL, // PAGE_DEFAULT_SHOW_TOTAL,
// getCachePageLimit,
// //
loadGroupList() { loadGroupList() {
machineListGroup().then((res) => { machineListGroup().then((res) => {
@ -978,22 +984,7 @@ export default {
}) })
window.open(newpage.href, '_blank') window.open(newpage.href, '_blank')
}, },
//
changeLayout() {
if (!this.layoutType) {
const layoutType = localStorage.getItem('tableLayout')
//
this.layoutType = layoutType === 'card' ? 'card' : 'table'
} else {
this.layoutType = this.layoutType === 'card' ? 'table' : 'card'
localStorage.setItem('tableLayout', this.layoutType)
}
this.listQuery = {
...this.listQuery,
limit: this.layoutType === 'card' ? 8 : getCachePageLimit()
}
this.getMachineList()
},
syncNodeWhiteConfig() { syncNodeWhiteConfig() {
if (!this.tableSelections || this.tableSelections.length <= 0) { if (!this.tableSelections || this.tableSelections.length <= 0) {
$notification.warn({ $notification.warn({

View File

@ -93,11 +93,20 @@ export function COMPUTED_PAGINATION(queryParam: any, pageSizeOptions = PAGE_DEFA
*/ */
export function CHANGE_PAGE(listQuery, { pagination, sorter }) { export function CHANGE_PAGE(listQuery, { pagination, sorter }) {
if (pagination && Object.keys(pagination).length) { if (pagination && Object.keys(pagination).length) {
listQuery = { ...listQuery, page: pagination.current, limit: pagination.pageSize } let limit = pagination.pageSize || pagination.limit || listQuery.limit
if (limit === -1) {
limit = getCachePageLimit()
}
listQuery = {
...listQuery,
page: pagination.current || listQuery.page,
limit: limit
}
// //
localStorage.setItem(cachePageLimitKeyName, pagination.pageSize) localStorage.setItem(cachePageLimitKeyName, limit)
// //
PAGE_DEFAULT_LIST_QUERY.limit = pagination.pageSize PAGE_DEFAULT_LIST_QUERY.limit = limit
} }
if (sorter && Object.keys(sorter).length) { if (sorter && Object.keys(sorter).length) {
listQuery = { ...listQuery, order: sorter.order, order_field: sorter.field } listQuery = { ...listQuery, order: sorter.order, order_field: sorter.field }