|
|
@@ -12,82 +12,34 @@
|
|
|
<a-row :gutter="16">
|
|
|
<a-col :span="6">
|
|
|
<a-form-item
|
|
|
- field="address"
|
|
|
- :label="t('dashboard.form.address')"
|
|
|
+ field="server"
|
|
|
+ :label="t('dashboard.form.server')"
|
|
|
label-col-flex="50px"
|
|
|
>
|
|
|
<a-input
|
|
|
- v-model="formModel.address"
|
|
|
- :placeholder="t('dashboard.form.address')"
|
|
|
+ v-model="formModel.server"
|
|
|
+ :placeholder="t('dashboard.form.server')"
|
|
|
allow-clear
|
|
|
/>
|
|
|
</a-form-item>
|
|
|
</a-col>
|
|
|
<a-col :span="6">
|
|
|
<a-form-item
|
|
|
- field="name"
|
|
|
- :label="t('dashboard.form.name')"
|
|
|
+ field="hostName"
|
|
|
+ :label="t('dashboard.form.hostName')"
|
|
|
label-col-flex="50px"
|
|
|
>
|
|
|
<a-input
|
|
|
- v-model="formModel.name"
|
|
|
- :placeholder="t('dashboard.form.name')"
|
|
|
+ v-model="formModel.hostName"
|
|
|
+ :placeholder="t('dashboard.form.hostName')"
|
|
|
allow-clear
|
|
|
/>
|
|
|
</a-form-item>
|
|
|
</a-col>
|
|
|
- <a-col :span="6">
|
|
|
- <a-form-item
|
|
|
- field="entityType"
|
|
|
- :label="t('dashboard.form.entityType')"
|
|
|
- label-col-flex="60px"
|
|
|
- >
|
|
|
- <a-select
|
|
|
- v-model="formModel.entityType"
|
|
|
- :placeholder="t('dashboard.form.entityType')"
|
|
|
- allow-clear
|
|
|
- @clear="formModel.entityType = null"
|
|
|
- >
|
|
|
- <a-option
|
|
|
- v-for="item of entityTypeList"
|
|
|
- :value="item.value"
|
|
|
- :label="item.label"
|
|
|
- />
|
|
|
- </a-select>
|
|
|
- </a-form-item>
|
|
|
- </a-col>
|
|
|
- <a-col :span="6">
|
|
|
- <a-form-item
|
|
|
- field="statusTypeList"
|
|
|
- :label="t('dashboard.form.status')"
|
|
|
- label-col-flex="60px"
|
|
|
- >
|
|
|
- <a-select
|
|
|
- v-model="formModel.status"
|
|
|
- :placeholder="t('dashboard.form.status')"
|
|
|
- allow-clear
|
|
|
- @clear="formModel.status = null"
|
|
|
- >
|
|
|
- <a-option
|
|
|
- v-for="item of statusTypeList"
|
|
|
- :value="item.value"
|
|
|
- :label="item.label"
|
|
|
- />
|
|
|
- </a-select>
|
|
|
- </a-form-item>
|
|
|
- </a-col>
|
|
|
- <a-col :span="6">
|
|
|
- <a-form-item
|
|
|
- :label="t('dashboard.form.timeRange')"
|
|
|
- label-col-flex="60px"
|
|
|
- >
|
|
|
- <a-range-picker v-model="formModel.time" />
|
|
|
- </a-form-item>
|
|
|
- </a-col>
|
|
|
</a-row>
|
|
|
</a-form>
|
|
|
</a-col>
|
|
|
- <a-divider :style="{ height: '84px' }" direction="vertical" />
|
|
|
+ <a-divider :style="{ height: '86px' }" direction="vertical" />
|
|
|
<a-col :flex="'86px'">
|
|
|
<a-space :size="10">
|
|
|
<a-button type="primary" @click="search">
|
|
|
@@ -103,14 +55,16 @@
|
|
|
{{ t('searchTable.form.reset') }}
|
|
|
</a-button>
|
|
|
</a-space>
|
|
|
- <a-space class="right-side">
|
|
|
- <a-button type="primary" @click="downloadExcel">
|
|
|
- <template #icon>
|
|
|
- <icon-download />
|
|
|
- </template>
|
|
|
- {{ t('searchTable.form.down') }}
|
|
|
- </a-button>
|
|
|
- </a-space>
|
|
|
+ <a-button
|
|
|
+ type="primary"
|
|
|
+ class="right-side"
|
|
|
+ @click="showEditDialog = true"
|
|
|
+ >
|
|
|
+ <template #icon>
|
|
|
+ <icon-plus />
|
|
|
+ </template>
|
|
|
+ {{ t('searchTable.form.add') }}
|
|
|
+ </a-button>
|
|
|
</a-col>
|
|
|
</a-row>
|
|
|
<a-table
|
|
|
@@ -118,7 +72,7 @@
|
|
|
row-key="name"
|
|
|
:loading="loading"
|
|
|
:pagination="pagination"
|
|
|
- :columns="(cloneColumns as TableColumnData[])"
|
|
|
+ :columns="cloneColumns as TableColumnData[]"
|
|
|
:data="renderData"
|
|
|
:bordered="false"
|
|
|
:size="size"
|
|
|
@@ -129,26 +83,26 @@
|
|
|
<template #index="{ rowIndex }">
|
|
|
{{ rowIndex + 1 + (pagination.current - 1) * pagination.pageSize }}
|
|
|
</template>
|
|
|
-
|
|
|
- <template #entityType="{ record }">
|
|
|
- <span>
|
|
|
- {{
|
|
|
- entityTypeList.find(item => item.value === record.entityType)
|
|
|
- ?.label
|
|
|
- }}
|
|
|
- </span>
|
|
|
- </template>
|
|
|
- <template #status="{ record }">
|
|
|
- <BTag :status="record.status">
|
|
|
- {{
|
|
|
- statusTypeList.find(item => item.value === record.status)?.label
|
|
|
- }}
|
|
|
- </BTag>
|
|
|
- </template>
|
|
|
- <template #time="{ record }">
|
|
|
- <span>{{
|
|
|
- record.time && dayjs(record.time).format('YYYY-MM-DD HH:mm:ss')
|
|
|
- }}</span>
|
|
|
+ <template #optional="{ record }">
|
|
|
+ <a-button
|
|
|
+ type="primary"
|
|
|
+ size="mini"
|
|
|
+ class="action-button"
|
|
|
+ @click="
|
|
|
+ () => {
|
|
|
+ ((pluginId = record.id), (showEditDialog = true));
|
|
|
+ }
|
|
|
+ "
|
|
|
+ >
|
|
|
+ {{ t('searchTable.form.edit') }}
|
|
|
+ </a-button>
|
|
|
+ <a-button
|
|
|
+ status="danger"
|
|
|
+ size="mini"
|
|
|
+ @click="handleDeleteFun(record.id)"
|
|
|
+ >
|
|
|
+ {{ t('searchTable.form.delete') }}
|
|
|
+ </a-button>
|
|
|
</template>
|
|
|
</a-table>
|
|
|
</a-card>
|
|
|
@@ -166,6 +120,11 @@
|
|
|
<!-- 只保留取消按钮,确认按钮被隐藏 -->
|
|
|
</template>
|
|
|
</a-modal>
|
|
|
+ <EditDialog
|
|
|
+ v-model="showEditDialog"
|
|
|
+ :id="pluginId"
|
|
|
+ @updateList="updateListFun"
|
|
|
+ ></EditDialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
@@ -178,10 +137,15 @@ import {
|
|
|
getCurrentInstance,
|
|
|
computed,
|
|
|
} from 'vue';
|
|
|
-import { queryDashboardList, exportDashboardList } from '@/api/dashboard';
|
|
|
-import type { DashboardParams, Data } from '@/api/dashboard';
|
|
|
+import {
|
|
|
+ queryPluginList,
|
|
|
+ exportPluginList,
|
|
|
+ deletePluginDetails,
|
|
|
+} from '@/api/dashboard';
|
|
|
+import type { PluginParams, DataList } from '@/api/dashboard';
|
|
|
import { SizeProps, Pagination } from '@/types/global';
|
|
|
import BTag from '@/components/business/b-tag/index.vue';
|
|
|
+import { Modal } from '@arco-design/web-vue';
|
|
|
import type { TableColumnData } from '@arco-design/web-vue';
|
|
|
import useLoading from '@/hooks/loading';
|
|
|
import { useI18n } from 'vue-i18n';
|
|
|
@@ -189,6 +153,7 @@ import { entityTypeList, statusTypeList, DeviceInfo } from './conf';
|
|
|
import dayjs from 'dayjs';
|
|
|
import { downLoadFun } from '@/utils/const';
|
|
|
import { useIntervalFn } from '@vueuse/core';
|
|
|
+import EditDialog from './edit.vue';
|
|
|
|
|
|
const { t } = useI18n();
|
|
|
|
|
|
@@ -203,33 +168,31 @@ const cloneColumns = computed(() => [
|
|
|
width: 60,
|
|
|
},
|
|
|
{
|
|
|
- title: t('dashboard.table.time'),
|
|
|
- dataIndex: 'time',
|
|
|
- slotName: 'time',
|
|
|
+ title: t('dashboard.form.server'),
|
|
|
+ dataIndex: 'server',
|
|
|
+ slotName: 'server',
|
|
|
ellipsis: true,
|
|
|
},
|
|
|
{
|
|
|
- title: t('dashboard.form.status'),
|
|
|
- dataIndex: 'status',
|
|
|
- slotName: 'status',
|
|
|
+ title: t('dashboard.form.user'),
|
|
|
+ dataIndex: 'user',
|
|
|
+ slotName: 'user',
|
|
|
width: 120,
|
|
|
},
|
|
|
{
|
|
|
- title: t('dashboard.form.name'),
|
|
|
- dataIndex: 'name',
|
|
|
- slotName: 'name',
|
|
|
+ title: t('dashboard.form.location'),
|
|
|
+ dataIndex: 'location',
|
|
|
+ slotName: 'location',
|
|
|
},
|
|
|
{
|
|
|
- title: t('dashboard.form.entityType'),
|
|
|
- dataIndex: 'entityType',
|
|
|
- slotName: 'entityType',
|
|
|
+ title: t('dashboard.form.hostName'),
|
|
|
+ dataIndex: 'hostName',
|
|
|
+ slotName: 'hostName',
|
|
|
},
|
|
|
-
|
|
|
{
|
|
|
- title: t('dashboard.form.address'),
|
|
|
- dataIndex: 'address',
|
|
|
- ellipsis: true,
|
|
|
- tooltip: true,
|
|
|
+ title: t('searchTable.table.optional'),
|
|
|
+ align: 'center',
|
|
|
+ slotName: 'optional',
|
|
|
},
|
|
|
]);
|
|
|
|
|
|
@@ -244,29 +207,24 @@ const generateFormModel = () => {
|
|
|
return {
|
|
|
pageIndex: 1,
|
|
|
pageSize: 20,
|
|
|
- name: null,
|
|
|
+ hostName: null,
|
|
|
address: null,
|
|
|
- status: null,
|
|
|
- startTime: null,
|
|
|
- endTime: null,
|
|
|
- time: ['', ''],
|
|
|
- entityType: null,
|
|
|
- } as DashboardParams;
|
|
|
+ user: null,
|
|
|
+ server: null,
|
|
|
+ location: null,
|
|
|
+ } as PluginParams;
|
|
|
};
|
|
|
-const renderData = ref<Data[]>([] as Data[]);
|
|
|
+const renderData = ref<DataList[]>([] as DataList[]);
|
|
|
const size = ref<SizeProps>('medium');
|
|
|
-const formModel = ref<DashboardParams>(generateFormModel());
|
|
|
+const formModel = ref<PluginParams>(generateFormModel());
|
|
|
const visible = shallowRef<boolean>(false);
|
|
|
+const showEditDialog = shallowRef<boolean>(false);
|
|
|
+const pluginId = shallowRef<number | null>(null);
|
|
|
const this_ = getCurrentInstance()?.appContext.config.globalProperties;
|
|
|
const deviceInfo = ref<DeviceInfo[]>([] as DeviceInfo[]);
|
|
|
function searchTable() {
|
|
|
// setLoading(true);
|
|
|
- const [startTime, endTime] = formModel.value.time
|
|
|
- ? formModel.value.time
|
|
|
- : ['', ''];
|
|
|
- formModel.value.startTime = startTime ? startTime : null;
|
|
|
- formModel.value.endTime = endTime ? endTime : null;
|
|
|
- queryDashboardList(formModel.value)
|
|
|
+ queryPluginList(formModel.value)
|
|
|
.then(res => {
|
|
|
pagination.current = formModel.value.pageIndex;
|
|
|
pagination.pageSize = pagination.pageSize;
|
|
|
@@ -278,11 +236,6 @@ function searchTable() {
|
|
|
});
|
|
|
}
|
|
|
searchTable();
|
|
|
-const { pause, resume, isActive } = useIntervalFn(() => {
|
|
|
- /* your function */
|
|
|
- formModel.value.pageIndex = 1;
|
|
|
- searchTable();
|
|
|
-}, 1000);
|
|
|
const search = () => {
|
|
|
searchTable();
|
|
|
};
|
|
|
@@ -291,10 +244,7 @@ const reset = () => {
|
|
|
};
|
|
|
const downloadExcel = () => {
|
|
|
setLoading(true);
|
|
|
- const [startTime, endTime] = formModel.value.time;
|
|
|
- formModel.value.startTime = startTime ? startTime : null;
|
|
|
- formModel.value.endTime = endTime ? endTime : null;
|
|
|
- exportDashboardList(formModel.value)
|
|
|
+ exportPluginList(formModel.value)
|
|
|
.then(res => {
|
|
|
if (!res.success) {
|
|
|
return;
|
|
|
@@ -308,18 +258,13 @@ const downloadExcel = () => {
|
|
|
};
|
|
|
const onPageChange = (current: number) => {
|
|
|
formModel.value.pageIndex = current;
|
|
|
- if (current === 1) {
|
|
|
- resume();
|
|
|
- } else {
|
|
|
- pause();
|
|
|
- }
|
|
|
searchTable();
|
|
|
};
|
|
|
|
|
|
-const handleClick = (value: Data) => {
|
|
|
- if (value.data) {
|
|
|
+const handleClick = (value: DataList) => {
|
|
|
+ if (value.server) {
|
|
|
deviceInfo.value.length = 0;
|
|
|
- const obj = JSON.parse(value.data);
|
|
|
+ const obj = JSON.parse(value.server);
|
|
|
for (const key in obj) {
|
|
|
deviceInfo.value.push({
|
|
|
label: key,
|
|
|
@@ -335,12 +280,36 @@ const handleClick = (value: Data) => {
|
|
|
const handleCancel = () => {
|
|
|
visible.value = false;
|
|
|
};
|
|
|
+const updateListFun = () => {
|
|
|
+ pluginId.value = null;
|
|
|
+ searchTable();
|
|
|
+};
|
|
|
+const handleDeleteFun = (id: number) => {
|
|
|
+ Modal.warning({
|
|
|
+ title: t('modal.warning.title'),
|
|
|
+ content: t('modal.warning.content'),
|
|
|
+ okText: t('searchTable.form.confirm'),
|
|
|
+ onBeforeOk: (done: (closed: boolean) => void) => {
|
|
|
+ deletePluginDetails({ id })
|
|
|
+ .then(res => {
|
|
|
+ if (res.success) {
|
|
|
+ this_?.$message.success(t('message.success'));
|
|
|
+ searchTable();
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .finally(() => {
|
|
|
+ done(true); // 确定关闭模态框
|
|
|
+ });
|
|
|
+ },
|
|
|
+ });
|
|
|
+};
|
|
|
</script>
|
|
|
|
|
|
<style lang="less" scoped>
|
|
|
.container {
|
|
|
padding: 10px 10px 20px;
|
|
|
|
|
|
+ // 注意这里的空行是重要的
|
|
|
.general-card {
|
|
|
padding-top: 20px;
|
|
|
|
|
|
@@ -350,7 +319,11 @@ const handleCancel = () => {
|
|
|
}
|
|
|
|
|
|
.table-list {
|
|
|
- margin-top: 0;
|
|
|
+ margin-top: 10px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .action-button {
|
|
|
+ margin-right: 10px;
|
|
|
}
|
|
|
}
|
|
|
</style>
|