Files
SaaS-lib/hx-ai-intelligent/src/view/equipmentManage/group/index.vue

160 lines
4.5 KiB
Vue
Raw Normal View History

2024-05-29 10:18:12 +08:00
<template>
2024-05-29 16:29:22 +08:00
<editDrawer ref="editDrawerRef" />
<editGroup ref="editGroupRef" />
<editFormula ref="editFormulaRef" />
2024-07-05 12:04:17 +08:00
<!-- <ns-modal ref="modalRef" title="新增" v-model:visible="visible">
<ns-form ref="formRef" :schemas="formSchema" :model="formData" formLayout="formVertical" />
</ns-modal> -->
<NsModalFrom ref="modalFormRef" v-bind="nsModalFormConfig" />
2024-06-27 15:21:14 +08:00
<div class="groupContainer">
<div class="tree">
2024-07-05 12:04:17 +08:00
<ns-tree-api v-bind="tConfig" @select="handleSelect">
<template #title="data">
<div class="treeRow">
<span>{{ data.title }}</span>
<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>
</a-menu>
</template>
</a-dropdown>
</div>
</template>
</ns-tree-api>
2024-06-27 15:21:14 +08:00
</div>
<ns-view-list-table v-show="defaultType" class="table" v-bind="config" />
<ns-view-list-table v-show="!defaultType" class="table" v-bind="configCal" />
</div>
2024-05-29 10:18:12 +08:00
</template>
<script lang="ts" setup>
2024-07-05 12:04:17 +08:00
import { createVNode, nextTick, onMounted, ref } from 'vue';
import { tableConfig, treeConfig, tableConfigCal, formSchema } from './config';
2024-05-29 16:29:22 +08:00
import { useParams } from '/nerv-lib/use';
import editDrawer from './edit.vue';
import editGroup from './editGroup.vue';
import editFormula from './editFormula.vue';
2024-07-05 12:04:17 +08:00
import { NsMessage, NsModal } from '/nerv-lib/component';
import NsModalFrom from '/@/components/ns-modal-form.vue';
import { group } from '/@/api/deviceManage';
2024-05-29 16:29:22 +08:00
2024-07-05 12:04:17 +08:00
type opType = 'up' | 'down';
2024-05-29 16:29:22 +08:00
const { getParams } = useParams();
2024-07-05 12:04:17 +08:00
const modalFormRef = ref();
2024-05-29 16:29:22 +08:00
const editDrawerRef = ref();
const editGroupRef = ref();
const editFormulaRef = ref();
2024-06-27 15:21:14 +08:00
const defaultType = ref(true);
2024-07-05 12:04:17 +08:00
const result = JSON.parse(sessionStorage.getItem('ORGID')!);
2024-05-29 16:29:22 +08:00
const config = tableConfig(editDrawerRef, editGroupRef, editFormulaRef);
2024-06-27 15:21:14 +08:00
const configCal = tableConfigCal(editDrawerRef, editGroupRef, editFormulaRef);
2024-07-05 12:04:17 +08:00
const tConfig = treeConfig(result);
const nsModalFormConfig = ref({
api: group.creatOrUpdate,
data: {},
title: '新增',
schemas: formSchema,
extraModalConfig: {
bodyStyle: { paddingBottom: 0 },
},
});
nextTick(() => {
console.log(modalFormRef.value, 'modal');
});
const addNodeSon = (data) => {
console.log(data);
nsModalFormConfig.value.title = '新增';
nsModalFormConfig.value.data = {
pointName: '新增',
isCreate: true,
isCreatSon: false,
orgId: result,
};
modalFormRef.value?.toggle();
};
const editNode = (data) => {
console.log(data);
nsModalFormConfig.value.title = '编辑';
nsModalFormConfig.value.data = { pointName: 123 };
modalFormRef.value?.toggle();
data.value = { pointName: 'qwe' };
};
const moveNode = (data, type: opType) => {
console.log(data);
};
const deleteNode = (a) => {
NsModal.confirm({
content: '确定删除吗?',
onOk: () => {
console.log(a);
},
});
};
const filterAction = (data) => {};
const actionList = [
{ title: '新增子节点', key: 'addNodeSon', func: (data) => addNodeSon(data) },
{ title: '编辑', key: 'editNode', func: (data) => editNode(data) },
{ title: '上移', key: 'moveUp', func: (data) => moveNode(data, 'up') },
{ title: '下移', key: 'moveDown', func: (data) => moveNode(data, 'down') },
{ title: '删除', key: 'deleteNode', func: (data) => deleteNode(data) },
];
2024-06-27 15:21:14 +08:00
const handleSelect = () => {
defaultType.value = !defaultType.value;
};
2024-05-29 10:18:12 +08:00
</script>
2024-06-27 15:21:14 +08:00
<style lang="less" scoped>
.groupContainer {
height: 100%;
overflow-y: auto;
background-color: @ns-content-bg;
display: flex;
// gap: @ns-gap;
.tree,
.table {
background-color: @white;
border-radius: @ns-border-radius;
overflow-y: auto;
}
.tree {
margin-right: @ns-gap;
:deep(.ant-spin-nested-loading) {
width: 300px;
background-color: @white;
}
}
.table {
flex: 1;
min-width: 0;
}
}
2024-07-05 12:04:17 +08:00
.actionMore {
display: none;
}
:deep(.ant-tree-node-content-wrapper) {
&:hover {
.actionMore {
display: block;
}
}
}
.treeRow {
display: flex;
justify-content: space-between;
align-items: center;
}
2024-06-27 15:21:14 +08:00
</style>