wms-antdvue/.svn/pristine/d3/d39bb183e16d5b6485856aeb9212bed343f33967.svn-base
2024-11-07 16:33:03 +08:00

98 lines
2.6 KiB
Plaintext

<template>
<PageWrapper>
<a-card :bordered="false" class="pt-3 mb-3 proCard">
<BasicForm @register="register" @submit="handleSubmit" @reset="handleReset"></BasicForm>
</a-card>
<a-card :bordered="false" class="proCard">
<a-table
:columns="columns"
:style="{ minHeight: fwbHeight+'px' }"
:scroll="{ x: '100%',y: fwbHeight+'px',}"
:pagination="{hideOnSinglePage:true}"
:dataSource="onlineTableData.slice((pager.page - 1) * pager.size, pager.page * pager.size)">
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<a-space>
<a-button type="danger" @click="handleDelete(record.tokenId)">
<template #icon><EditOutlined /></template>
强退
</a-button>
</a-space>
</template>
</template>
</a-table>
<pagination style="justify-content: flex-end" class="mt-10 flex" v-model="pager" @change="loadDataTable"/>
</a-card>
</PageWrapper>
</template>
<script lang="ts" setup>
import { reactive, ref, onMounted } from 'vue';
import { columns } from './columns';
import { schemas } from './querySchemas';
import { useForm } from '@/components/Form/index';
import { getOnlineList, onlineOut } from '@/api/monitor/online';
import { Modal,message } from 'ant-design-vue';
const onlineTableData = ref([])
const formParams = reactive({
ipAddr: '',
username: ''
});
const pager = ref({
page: 1,
size: 10,
count: onlineTableData.value.length
});
const fwbHeight = document.body.clientHeight - 420
const loadTable = async () => {
onlineTableData.value = await getOnlineList({ ...formParams });
pager.value.count = onlineTableData.value.length;
}
const [register, {}] = useForm({
rowProps: { gutter: [16, 0] },
colProps: {
xs: 24,
sm: 24,
md: 12,
lg: 8,
xl: 6,
},
labelCol: { span: 6, offset: 0 },
schemas
});
function handleSubmit(values) {
for (const key in formParams) {
formParams[key] ='';
}
for (const key in values) {
formParams[key] = values[key]
}
loadTable();
}
function handleReset() {
for (const key in formParams) {
formParams[key] = '';
}
pager.value.page = 1;
loadTable();
}
async function handleDelete(id) {
Modal.confirm({
title: '提示',
content: "确定要强退?",
onOk: async () => {
await onlineOut(id)
message.success("强退成功");
loadTable()
}
});
}
onMounted(() => {
loadTable()
})
</script>
<style lang="scss" scoped></style>