添加卡片列表模板.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<card-list v-model:searchValue="formModel.searchValue"
|
||||
create-card-position="head"
|
||||
:card-height="172"
|
||||
:card-height="176"
|
||||
:loading="loading"
|
||||
:fieldConfig="fieldConfig"
|
||||
:list="list"
|
||||
@@ -11,8 +11,8 @@
|
||||
:add-permission="['asset:host:create']"
|
||||
@add="emits('openAdd')"
|
||||
@reset="reset"
|
||||
@search="fetchTableData"
|
||||
@page-change="fetchTableData">
|
||||
@search="fetchListData"
|
||||
@page-change="fetchListData">
|
||||
<!-- 标题 -->
|
||||
<template #title="{ record }">
|
||||
{{ record.name }}
|
||||
@@ -104,6 +104,7 @@
|
||||
:allowCreate="false"
|
||||
:limit="0"
|
||||
type="HOST"
|
||||
tag-type="hostTags"
|
||||
placeholder="请选择主机标签" />
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
@@ -160,7 +161,7 @@
|
||||
await deleteHost(id);
|
||||
Message.success('删除成功');
|
||||
// 重新加载数据
|
||||
await fetchTableData();
|
||||
await fetchListData();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -169,12 +170,12 @@
|
||||
|
||||
// 添加后回调
|
||||
const addedCallback = () => {
|
||||
fetchTableData();
|
||||
fetchListData();
|
||||
};
|
||||
|
||||
// 更新后回调
|
||||
const updatedCallback = () => {
|
||||
fetchTableData();
|
||||
fetchListData();
|
||||
};
|
||||
|
||||
defineExpose({
|
||||
@@ -184,11 +185,11 @@
|
||||
// 重置条件
|
||||
const reset = () => {
|
||||
resetObject(formModel, ['extra']);
|
||||
fetchTableData();
|
||||
fetchListData();
|
||||
};
|
||||
|
||||
// 加载数据
|
||||
const doFetchTableData = async (request: HostQueryRequest) => {
|
||||
const doFetchListData = async (request: HostQueryRequest) => {
|
||||
try {
|
||||
setLoading(true);
|
||||
const { data } = await getHostPage(request);
|
||||
@@ -203,10 +204,10 @@
|
||||
};
|
||||
|
||||
// 切换页码
|
||||
const fetchTableData = (page = 1, limit = pagination.pageSize, form = formModel) => {
|
||||
doFetchTableData({ page, limit, ...form });
|
||||
const fetchListData = (page = 1, limit = pagination.pageSize, form = formModel) => {
|
||||
doFetchListData({ page, limit, ...form });
|
||||
};
|
||||
fetchTableData();
|
||||
fetchListData();
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
:allowCreate="true"
|
||||
:limit="5"
|
||||
type="HOST"
|
||||
tag-type="hostTags"
|
||||
placeholder="请选择主机标签" />
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
@@ -93,7 +94,7 @@
|
||||
const openUpdate = (record: any) => {
|
||||
title.value = '修改主机';
|
||||
isAddHandle.value = false;
|
||||
const tags = record?.tags?.map((s: { id: any; }) => s.id);
|
||||
const tags = record?.hostTags?.map((s: { id: any; }) => s.id);
|
||||
renderForm({ ...defaultForm(), ...record, tags });
|
||||
setVisible(true);
|
||||
};
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
:allowCreate="false"
|
||||
:limit="0"
|
||||
type="HOST"
|
||||
tag-type="hostTags"
|
||||
placeholder="请选择主机标签" />
|
||||
</a-form-item>
|
||||
</a-query-header>
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
try {
|
||||
const { data } = await getTagList('HOST');
|
||||
// 设置到缓存
|
||||
cacheStore.set('tags', data);
|
||||
cacheStore.set('hostTags', data);
|
||||
} catch {
|
||||
Message.error('tag加载失败');
|
||||
}
|
||||
@@ -78,7 +78,7 @@
|
||||
|
||||
// 卸载时清除 tags cache
|
||||
onUnmounted(() => {
|
||||
cacheStore.set('tags', []);
|
||||
cacheStore.set('hostTags', []);
|
||||
cacheStore.set('hostKeys', []);
|
||||
cacheStore.set('hostIdentities', []);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user