feat: 分组管理

This commit is contained in:
xuziqiang
2024-07-09 16:27:21 +08:00
parent fb1980d73a
commit 30286253e7
9 changed files with 94 additions and 25 deletions

View File

@@ -10,20 +10,25 @@
<NsModalFrom ref="modalFormRef" v-bind="nsModalFormConfig" />
<div class="groupContainer">
<div class="tree">
<ns-tree-api v-bind="tConfig" @select="handleSelect">
<ns-tree-api ref="treeRef" v-bind="tConfig" @select="handleSelect">
<template #title="data">
<div class="treeRow">
<span>{{ data.title }}</span>
<div>
<ns-icon :name="data.pointType !== '计算节点' ? 'fenzujiedian' : 'jisuanjiedian'" />
<span style="padding-left: 8px">{{ data.pointName }}</span>
</div>
<a-dropdown>
<ns-icon name="actionMore" size="14" class="actionMore" />
<template #overlay>
<a-menu>
<a-menu-item
v-for="(item, index) in actionList"
:key="index"
@click="item.func(data)">
<span>{{ item.title }}</span>
</a-menu-item>
<template v-for="(item, index) in actionList" :key="index">
<!-- 全部节点只需要新增子节点 -->
<a-menu-item
v-if="data.id !== 'all' || item.key === 'addNodeSon'"
@click="item.func(data)">
<span>{{ item.title }}</span>
</a-menu-item>
</template>
</a-menu>
</template>
</a-dropdown>
@@ -45,6 +50,7 @@
import { NsMessage, NsModal } from '/nerv-lib/component';
import NsModalFrom from '/@/components/ns-modal-form.vue';
import { group } from '/@/api/deviceManage';
import { http } from '/nerv-lib/util/http';
type opType = 'up' | 'down';
const { getParams } = useParams();
@@ -52,6 +58,7 @@
const editDrawerRef = ref();
const editGroupRef = ref();
const editFormulaRef = ref();
const treeRef = ref();
const defaultType = ref(true);
const result = JSON.parse(sessionStorage.getItem('ORGID')!);
const config = tableConfig(editDrawerRef, editGroupRef, editFormulaRef);
@@ -65,6 +72,9 @@
extraModalConfig: {
bodyStyle: { paddingBottom: 0 },
},
success: () => {
treeRef.value?.treeReload();
},
});
nextTick(() => {
console.log(modalFormRef.value, 'modal');
@@ -74,30 +84,35 @@
console.log(data);
nsModalFormConfig.value.title = '新增';
nsModalFormConfig.value.data = {
pointName: '新增',
isCreate: true,
isCreatSon: false,
orgId: result,
};
if (data.id !== 'all') {
nsModalFormConfig.value.data.pid = data.id;
nsModalFormConfig.value.data.isCreatSon = true;
}
modalFormRef.value?.toggle();
};
const editNode = (data) => {
console.log(data);
nsModalFormConfig.value.title = '编辑';
nsModalFormConfig.value.data = { pointName: 123 };
nsModalFormConfig.value.data = data;
modalFormRef.value?.toggle();
data.value = { pointName: 'qwe' };
};
const moveNode = (data, type: opType) => {
console.log(data);
};
const deleteNode = (a) => {
const deleteNode = (record) => {
NsModal.confirm({
centered: true,
title: '提示',
content: '确定删除吗?',
onOk: () => {
console.log(a);
http.post(group.del, { id: record.id }).then(() => {
treeRef.value?.treeReload();
NsMessage.success('删除成功');
});
},
});
};