143 lines
4.1 KiB
Plaintext
143 lines
4.1 KiB
Plaintext
<template>
|
|
<PageWrapper>
|
|
<a-card :bordered="false" class="pt-3 mb-3 proCard">
|
|
<BasicForm @register="register" @submit="handleSubmit" @reset="handleReset">
|
|
<template #statusSlot="{ model, field }">
|
|
<a-input v-model="model[field]" />
|
|
</template>
|
|
</BasicForm>
|
|
</a-card>
|
|
<a-card :bordered="false" class="proCard">
|
|
<BasicTable
|
|
:columns="columns"
|
|
:request="loadDataTable"
|
|
:row-key="(row) => row.id"
|
|
ref="tableRef"
|
|
scroll-x="1200"
|
|
:row-selection="{onChange: onSelectionChange}"
|
|
virtual-scroll
|
|
>
|
|
<template #tableTitle>
|
|
<a-space>
|
|
<a-button type="primary" @click="handleAdd" v-perm="['sys:dataSource:add']">
|
|
<template #icon>
|
|
<PlusOutlined />
|
|
</template>
|
|
新建
|
|
</a-button>
|
|
|
|
<a-button type="danger" @click="handleDelete()" :disabled="!selectionData.length" v-perm="['sys:dataSource:batchDelete']">
|
|
<template #icon>
|
|
<DeleteOutlined />
|
|
</template>
|
|
删除
|
|
</a-button>
|
|
</a-space>
|
|
</template>
|
|
<template #bodyCell="{ column, record }">
|
|
<template v-if="column.key === 'action'">
|
|
<a-space>
|
|
<a-button type="primary" @click="handleEdit(record.id)" v-perm="['sys:dataSource:update']">
|
|
<template #icon><EditOutlined /></template>
|
|
编辑
|
|
</a-button>
|
|
<a-button type="primary" danger @click="handleDelete(record.id)" v-perm="['sys:dataSource:delete']">
|
|
<template #icon><DeleteOutlined /></template>
|
|
删除
|
|
</a-button>
|
|
</a-space>
|
|
</template>
|
|
</template>
|
|
</BasicTable>
|
|
</a-card>
|
|
<editDialog
|
|
v-if="editVisible"
|
|
:dataSourceId="dataSourceId"
|
|
v-model:visible="editVisible"
|
|
@success="reloadTable('noRefresh')"
|
|
>
|
|
</editDialog>
|
|
</PageWrapper>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { h, nextTick, reactive, ref ,defineAsyncComponent} from 'vue';
|
|
import { PlusOutlined,EditOutlined,DeleteOutlined} from '@ant-design/icons-vue';
|
|
import { useForm } from '@/components/Form/index';
|
|
import { getDataSourceList,dataSourceDelete,dataSourceBatchDelete } from '@/api/monitor/dataSource';
|
|
import { columns } from './columns';
|
|
import { schemas } from './querySchemas';
|
|
import { Modal,message } from 'ant-design-vue';
|
|
const dataSourceId = ref(0);
|
|
const tableRef = ref();
|
|
const editVisible = ref(false)
|
|
const selectionData = ref([])
|
|
const editDialog = defineAsyncComponent(() =>
|
|
import('./edit.vue'))
|
|
const formParams = reactive({
|
|
name: ''
|
|
});
|
|
const loadDataTable = async (res) => {
|
|
const result = await getDataSourceList({ ...formParams, ...res });
|
|
return result;
|
|
};
|
|
|
|
function reloadTable(noRefresh='') {
|
|
tableRef.value.reload(noRefresh?{}:{pageNo:1});
|
|
}
|
|
async function handleEdit(id) {
|
|
dataSourceId.value=id
|
|
await nextTick();
|
|
editVisible.value=true
|
|
}
|
|
|
|
async function handleDelete(id) {
|
|
Modal.confirm({
|
|
title: '提示',
|
|
content: "确定要删除?",
|
|
onOk: async () => {
|
|
id? await dataSourceDelete(id):await dataSourceBatchDelete(selectionData.value);
|
|
message.success("删除成功");
|
|
reloadTable()
|
|
}
|
|
});
|
|
}
|
|
function handleSubmit(values) {
|
|
for (const key in formParams) {
|
|
formParams[key] ='';
|
|
}
|
|
for (const key in values) {
|
|
formParams[key] = values[key]
|
|
}
|
|
reloadTable();
|
|
}
|
|
function handleReset() {
|
|
for (const key in formParams) {
|
|
formParams[key] ='';
|
|
}
|
|
reloadTable();
|
|
}
|
|
function onSelectionChange(value){
|
|
selectionData.value = value
|
|
}
|
|
const [register, {}] = useForm({
|
|
rowProps: { gutter: [16, 0] },
|
|
colProps: {
|
|
xs: 24,
|
|
sm: 24,
|
|
md: 12,
|
|
lg: 8,
|
|
xl: 6,
|
|
},
|
|
labelCol: { span: 6, offset: 0 },
|
|
schemas
|
|
});
|
|
//添加
|
|
const handleAdd = async () => {
|
|
dataSourceId.value=0
|
|
await nextTick();
|
|
editVisible.value=true
|
|
};
|
|
</script>
|
|
|