|
@@ -0,0 +1,112 @@
|
|
|
+<template>
|
|
|
+ <div class="config" v-if="show" v-loading="state.loading">
|
|
|
+ <el-button @click="$emit('update:show', false)">关闭</el-button>
|
|
|
+ <div style="display: flex">
|
|
|
+ <div style="width: 60px">过滤</div><el-input v-model="state.text"/>
|
|
|
+ </div>
|
|
|
+ <div class="tabs" style="display: flex;gap: 20px;">
|
|
|
+ <el-button @click="state.tab = 1">规则</el-button>
|
|
|
+ <el-button @click="state.tab = 2">区域</el-button>
|
|
|
+ </div>
|
|
|
+ <template v-if="state.tab == 1">
|
|
|
+ <el-button @click="expendRules">{{rulesExpandAllCpt ? '收起' : '展开'}}全部</el-button>
|
|
|
+ <el-tree
|
|
|
+ ref="ref_rulesTree"
|
|
|
+ :data="state.rulesList"
|
|
|
+ :props="ruleProps"
|
|
|
+ node-key="id"
|
|
|
+ >
|
|
|
+ <template #default="{ node, data }">
|
|
|
+ <span class="custom-tree-node">
|
|
|
+ <span>{{ node.label }}</span>
|
|
|
+ <span v-if="node.level > 1">
|
|
|
+ <el-button @click.stop="$util._console(node)">编辑</el-button>
|
|
|
+ <el-button @click.stop="$util._console(node)">查看</el-button>
|
|
|
+ </span>
|
|
|
+ <span v-else>
|
|
|
+ <el-button @click.stop="onViewModel(data)">查看</el-button>
|
|
|
+ </span>
|
|
|
+ </span>
|
|
|
+ </template>
|
|
|
+ </el-tree>
|
|
|
+ </template>
|
|
|
+ <template v-else-if="state.tab == 2">
|
|
|
+
|
|
|
+ </template>
|
|
|
+ <ModelDialog v-model:show="state.model.show" :transfer="state.model.transfer"/>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup lang="ts">
|
|
|
+import {computed, getCurrentInstance, onMounted, reactive, ref, watch} from "vue";
|
|
|
+import ModelDialog from "./model-dialog.vue";
|
|
|
+
|
|
|
+const {proxy} = getCurrentInstance()
|
|
|
+const props = defineProps({
|
|
|
+ show: {},
|
|
|
+})
|
|
|
+const state: any = reactive({
|
|
|
+ tab: 1,
|
|
|
+ loading: false,
|
|
|
+ text: '',
|
|
|
+ rulesList: [],
|
|
|
+ model: {
|
|
|
+ transfer: {},
|
|
|
+ show: false
|
|
|
+ }
|
|
|
+})
|
|
|
+const ruleProps = {
|
|
|
+ children: 'children'
|
|
|
+}
|
|
|
+const ref_rulesTree = ref()
|
|
|
+watch(() => props.show, (n) => {
|
|
|
+ if (n) {
|
|
|
+ initData()
|
|
|
+ }
|
|
|
+})
|
|
|
+const initData = () => {
|
|
|
+ state.loading = true
|
|
|
+ setTimeout(() => {
|
|
|
+ const arr = []
|
|
|
+ for (let i = 0; i <= 5; i++) {
|
|
|
+ const obj = {
|
|
|
+ id: i + '',
|
|
|
+ label: '模型' + i,
|
|
|
+ children: []
|
|
|
+ }
|
|
|
+ for (let k = 1; k <= i; k++) {
|
|
|
+ obj.children.push({
|
|
|
+ id: i + '-' + k,
|
|
|
+ label: '规则' + i + '-' + k
|
|
|
+ })
|
|
|
+ }
|
|
|
+ arr.push(obj)
|
|
|
+ }
|
|
|
+ state.rulesList = arr
|
|
|
+ state.loading = false
|
|
|
+ }, 1000)
|
|
|
+}
|
|
|
+const expendRules = () => {
|
|
|
+ const flag = JSON.parse(JSON.stringify(rulesExpandAllCpt.value))
|
|
|
+ ref_rulesTree.value.root.childNodes.forEach(v => v.expanded = !flag)
|
|
|
+}
|
|
|
+const rulesExpandAllCpt = computed(() => {
|
|
|
+ return ref_rulesTree.value?.root.childNodes.every(v => v.data.children?.length == 0 || v.expanded)
|
|
|
+})
|
|
|
+const onViewModel = (row) => {
|
|
|
+ console.log(row)
|
|
|
+ state.model.transfer = {
|
|
|
+ id: row.id + ''
|
|
|
+ }
|
|
|
+ state.model.show = true
|
|
|
+}
|
|
|
+onMounted(() => {
|
|
|
+ initData()
|
|
|
+})
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.config {
|
|
|
+ width: 300px;
|
|
|
+}
|
|
|
+</style>
|