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

@@ -62,7 +62,12 @@ const mockData = ref(data.listData);
export const formSchema = [
{
field: 'isCreate',
component: 'NsInput',
component: 'NsCheck',
show: false,
},
{
field: 'isCreatSon',
component: 'NsCheck',
show: false,
},
{
@@ -71,7 +76,12 @@ export const formSchema = [
show: false,
},
{
field: 'isCreatSon',
field: 'id',
component: 'NsInput',
show: false,
},
{
field: 'pid',
component: 'NsInput',
show: false,
},
@@ -95,10 +105,10 @@ export const formSchema = [
component: 'NsSelectApi',
componentProps: {
placeholder: '请选择节点类型(必填)',
api: dict,
params: { dicKey: 'COUNT_POINT' },
api: () => dict({ params: { dicKey: 'COUNT_POINT' } }),
// params: { dicKey: 'COUNT_POINT' },
immediate: true,
resultField: 'data.COUNT_POINT',
// resultField: 'data.COUNT_POINT',
labelField: 'cnValue',
valueField: 'cnValue',
},
@@ -118,6 +128,7 @@ export const treeConfig = (orgId) => {
title: '能耗分组',
},
params: { orgId },
showLine: { showLeafIcon: false },
api: group.queryDeviceGroupTree,
// api: () => {
// return new Promise((resolve) => {
@@ -127,7 +138,7 @@ export const treeConfig = (orgId) => {
// });
// },
transform: (data) => {
return [{ title: '全部', key: 'all', selectable: false, children: data }];
return [{ pointName: '全部', id: 'all', selectable: false, children: data }];
},
formConfig: {
schemas: [

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('删除成功');
});
},
});
};

View File

@@ -26,6 +26,7 @@
</div>
<a-drawer
:width="500"
title=" "
:visible="visible"
:body-style="{ paddingBottom: '80px' }"
:footer-style="{ textAlign: 'right' }"
@@ -545,7 +546,8 @@
{
label: '新增',
name: 'userAdd',
type: 'primary',
style: { marginBottom: '16px' },
// type: 'primary',
handle: () => {
addformvisible.value = true;
},
@@ -644,6 +646,9 @@
:deep(.ns-table-main) {
border-top: 0;
padding: 0;
.drawerTable {
margin-top: 16px;
}
}
}
</style>