From 75f043dfa6660716364e66ee0b3cf99f44255686 Mon Sep 17 00:00:00 2001 From: DYL0109 <dn18191638832@163.com> Date: 星期三, 16 四月 2025 19:20:36 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/develop1.0' into dyl_dev --- zhitan-vue/src/views/modelconfiguration/businessmodel/businessModel.vue | 607 ++++++++++++++++++++++++++++-------------------------- 1 files changed, 314 insertions(+), 293 deletions(-) diff --git a/zhitan-vue/src/views/modelconfiguration/businessmodel/businessModel.vue b/zhitan-vue/src/views/modelconfiguration/businessmodel/businessModel.vue index 9ae49db..9598c1d 100644 --- a/zhitan-vue/src/views/modelconfiguration/businessmodel/businessModel.vue +++ b/zhitan-vue/src/views/modelconfiguration/businessmodel/businessModel.vue @@ -1,158 +1,171 @@ <template> - <div class="page"> - <div class="page-container"> - <div class="page-container-left"> - <div class="tree page-box"> - <!-- <CardHeader class="mb20">鏁版嵁妯″瀷绠$悊</CardHeader> --> - <div class="select-box mb20"> - <el-select v-model="modelData" placeholder="璇烽�夋嫨妯″瀷" filterable @change="changeModel"> - <el-option v-for="model in modelInfoOptions" :key="model.modelCode" :label="model.modelName" - :value="model.modelCode" /> - </el-select> - <el-icon @click="handleModel"> - <Setting /> - </el-icon> - </div> - <!-- <el-input v-model="filterText" style="width: 240px" placeholder="杈撳叆鍏抽敭瀛楄繘琛岃繃婊�" class="mb10" /> --> - <div class="tree-box" v-loading="treeLoading"> - <el-link icon="el-icon-plus" style="margin-top: 8px;width:100%" @click="addNode" - v-if="treeData.length === 0">娣诲姞鏍硅妭鐐� - </el-link> - <template v-else> - <el-tree ref="treeRef" :props="defaultProps" :data="treeData" node-key="id" - highlight-current :filter-node-method="filterNode" - :default-expanded-keys="treeExpandData" :expand-on-click-node="false" - @node-click="changeNode" accordion> - <template #default="{ node, data }"> - <span> - <el-tooltip v-if="node.label.length > 6" class="item" effect="dark" - :content="node.label" placement="top-end"> - <span>{{ node.label.slice(0, 6) + "..." }}</span> - </el-tooltip> - <span v-else id="b">{{ node.label }}</span> - </span> - <span class="node-opt"> - <el-link title="鏂板涓嬬骇鑺傜偣" icon="Plus" @click="() => addNode(node, data)"> - </el-link> - <el-link title="淇敼鑺傜偣" icon="EditPen" @click="() => editNode(node, data)"> - </el-link> - <el-link title="鍒犻櫎鑺傜偣" icon="Delete" @click="() => delNode(node, data)"> - </el-link> - </span> - </template> - </el-tree> - </template> - </div> - </div> - </div> - <div class="page-container-right"> - <div class="mb20 mt20 ml20 tab-box"> - <div class="tab-li" :class="tab == 1 ? 'is-tab' : ''" @click="handleTab('1')"> - 璁¢噺鍣ㄥ叿閰嶇疆淇℃伅 - </div> - <div class="tab-li" :class="tab == 2 ? 'is-tab' : ''" @click="handleTab('2')"> - 缁熻鎸囨爣 - </div> - <div class="tab-li" :class="tab == 3 ? 'is-tab' : ''" @click="handleTab('3')"> - 閲囬泦鎸囨爣 - </div> - <!-- <el-radio-group v-model="tab"> + <div class="page"> + <div class="page-container"> + <div class="page-container-left"> + <div class="tree page-box"> + <!-- <CardHeader class="mb20">鏁版嵁妯″瀷绠$悊</CardHeader> --> + <div class="select-box mb20"> + <el-select v-model="modelData" placeholder="璇烽�夋嫨妯″瀷" filterable @change="changeModel"> + <el-option + v-for="model in modelInfoOptions" + :key="model.modelCode" + :label="model.modelName" + :value="model.modelCode" + /> + </el-select> + <el-icon @click="handleModel"> + <Setting /> + </el-icon> + </div> + <!-- <el-input v-model="filterText" style="width: 240px" placeholder="杈撳叆鍏抽敭瀛楄繘琛岃繃婊�" class="mb10" /> --> + <div class="tree-box" v-loading="treeLoading"> + <el-link + icon="el-icon-plus" + style="margin-top: 8px; width: 100%" + @click="addNode" + v-if="treeData.length === 0" + >娣诲姞鏍硅妭鐐� + </el-link> + <template v-else> + <el-tree + ref="treeRef" + :props="defaultProps" + :data="treeData" + node-key="id" + highlight-current + :filter-node-method="filterNode" + :default-expanded-keys="treeExpandData" + :expand-on-click-node="false" + @node-click="changeNode" + accordion + > + <template #default="{ node, data }"> + <span> + <el-tooltip + v-if="node.label.length > 6" + class="item" + effect="dark" + :content="node.label" + placement="top-end" + > + <span>{{ node.label.slice(0, 6) + "..." }}</span> + </el-tooltip> + <span v-else id="b">{{ node.label }}</span> + </span> + <span class="node-opt"> + <el-link title="鏂板涓嬬骇鑺傜偣" icon="Plus" @click="() => addNode(node, data)"> </el-link> + <el-link title="淇敼鑺傜偣" icon="EditPen" @click="() => editNode(node, data)"> </el-link> + <el-link title="鍒犻櫎鑺傜偣" icon="Delete" @click="() => delNode(node, data)"> </el-link> + </span> + </template> + </el-tree> + </template> + </div> + </div> + </div> + <div class="page-container-right"> + <div class="tab-box"> + <div class="tab-li" :class="tab == 1 ? 'is-tab' : ''" @click="handleTab('1')">璁¢噺鍣ㄥ叿閰嶇疆淇℃伅</div> + <div class="tab-li" :class="tab == 2 ? 'is-tab' : ''" @click="handleTab('2')">缁熻鎸囨爣</div> + <div class="tab-li" :class="tab == 3 ? 'is-tab' : ''" @click="handleTab('3')">閲囬泦鎸囨爣</div> + <!-- <el-radio-group v-model="tab"> <el-radio-button label="1" @click="handleTab('1')"> 璁惧閰嶇疆</el-radio-button> <el-radio-button label="2" @click="handleTab('2')"> 閲囬泦鎸囨爣</el-radio-button> </el-radio-group>--> - </div> - <BaseCard :title="currentNode ? currentNode.label + '--鑺傜偣閰嶇疆' : '鏆傛棤鑺傜偣閰嶇疆'"> - <div> - <div class="content-box" v-if="tab == '1'"> - <deviceConfig ref='deviceConfigRef' /> - </div> - <div class="content-box" v-if="tab == '2'"> - <statisticalIndicators ref='statisticalIndicatorsRef' /> - </div> - <div class="content-box" v-if="tab == '3'"> - <collectIndicators ref='collectIndicatorsRef' /> - </div> - </div> - </BaseCard> - </div> </div> - - <treeNodeModal ref="treeNodeModalRef" @getList="getTreeList" :modelCode="modelData" - @addTreeList="addTreeList" @addTreeSelectList="addTreeSelectList" /> - <modelManagementModal ref="modelManagementModalRef" @selectTreeFun="searchList" /> - + <BaseCard :title="currentNode ? currentNode.label + '--鑺傜偣閰嶇疆' : '鏆傛棤鑺傜偣閰嶇疆'"> + <div> + <div class="content-box" v-if="tab == '1'"> + <deviceConfig ref="deviceConfigRef" /> + </div> + <div class="content-box" v-if="tab == '2'"> + <statisticalIndicators ref="statisticalIndicatorsRef" /> + </div> + <div class="content-box" v-if="tab == '3'"> + <collectIndicators ref="collectIndicatorsRef" /> + </div> + </div> + </BaseCard> + </div> </div> + + <treeNodeModal + ref="treeNodeModalRef" + @getList="getTreeList" + :modelCode="modelData" + @addTreeList="addTreeList" + @addTreeSelectList="addTreeSelectList" + /> + <modelManagementModal ref="modelManagementModalRef" @selectTreeFun="searchList" /> + </div> </template> <script setup> -import treeNodeModal from './components/TreeNodeModal.vue' -import modelManagementModal from './components/modelManagement/modelManagement' -import { listModel } from '@/api/modelConfiguration/businessModel' -import { treeList, delModelNode, hasEnergyIndex, } from '@/api/modelConfiguration/indexWarehouse' -import deviceConfig from './components/deviceConfig/DeviceConfig.vue' -import collectIndicators from './components/collectIndicators/CollectIndicators.vue' -import statisticalIndicators from './components/statisticalIndicators/statisticalIndicators.vue' -import { nextTick } from 'vue'; +import treeNodeModal from "./components/TreeNodeModal.vue" +import modelManagementModal from "./components/modelManagement/modelManagement" +import { listModel } from "@/api/modelConfiguration/businessModel" +import { treeList, delModelNode, hasEnergyIndex } from "@/api/modelConfiguration/indexWarehouse" +import deviceConfig from "./components/deviceConfig/DeviceConfig.vue" +import collectIndicators from "./components/collectIndicators/CollectIndicators.vue" +import statisticalIndicators from "./components/statisticalIndicators/statisticalIndicators.vue" +import { nextTick } from "vue" let { proxy } = getCurrentInstance() let modelManagementModalRef = ref(null) let treeLoading = ref(true) //妯″瀷绠$悊 function handleModel() { - if (modelManagementModalRef.value) { - modelManagementModalRef.value.handleOpen() - } + if (modelManagementModalRef.value) { + modelManagementModalRef.value.handleOpen() + } } let modelData = ref(null) let modelInfoOptions = ref([]) //涓嬫媺鍒楄〃 //鑾峰彇涓嬫媺鍒楄〃 function searchList(flag) { - listModel({ isShow: 1 }).then(response => { - modelInfoOptions.value = response.data; - if (flag) { - if (modelInfoOptions.value.length > 0) { - modelData.value = modelInfoOptions.value[0].modelCode; - getTreeList(modelData.value) - } - } - }); + listModel({ isShow: 1 }).then((response) => { + modelInfoOptions.value = response.data + if (flag) { + if (modelInfoOptions.value.length > 0) { + modelData.value = modelInfoOptions.value[0].modelCode + getTreeList(modelData.value) + } + } + }) } searchList(true) - //涓嬫媺閫変腑瑙﹀彂鏍戝垪琛� function changeModel(item) { - // console.log('changeModel', item) - getTreeList(item) + // console.log('changeModel', item) + getTreeList(item) } let treeRef = ref(null) let treeData = ref([]) const defaultProps = ref({ - children: 'children', - label: 'label', + children: "children", + label: "label", }) //妫�绱㈡爲 -let filterText = ref('') +let filterText = ref("") const filterNode = (value, data) => { - if (!value) return true - return data.label.includes(value) + if (!value) return true + return data.label.includes(value) } watch(filterText, (val) => { - // 妫�鏌reeRef.value鏄惁鏄竴涓湁鏁堢殑ElTree瀹炰緥 - if (treeRef.value && typeof treeRef.value.filter === 'function') { - // 璋冪敤filter鏂规硶 - treeRef.value.filter(val); - } else { - // treeRef.value鏃犳晥锛屽鐞嗛敊璇� - console.error('error'); - } -}); - - + // 妫�鏌reeRef.value鏄惁鏄竴涓湁鏁堢殑ElTree瀹炰緥 + if (treeRef.value && typeof treeRef.value.filter === "function") { + // 璋冪敤filter鏂规硶 + treeRef.value.filter(val) + } else { + // treeRef.value鏃犳晥锛屽鐞嗛敊璇� + console.error("error") + } +}) let currentNode = ref(null) let treeExpandData = ref([]) @@ -163,156 +176,153 @@ //鑾峰彇鏍戝垪琛� function getTreeList(modelCode) { - treeLoading.value = true - treeList({ modelCode }).then(res => { - treeLoading.value = false - let { data } = res - treeData.value = data; - let chooseNode = null; - if (data.length > 0) { - if (data[0].children && data[0].children.length !== 0 && isFirstLeafNode.value) { - if (data[0].children[0].children && data[0].children[0].children.length !== 0) { - chooseNode = data[0].children[0].children[0]; - } else { - chooseNode = data[0].children[0]; - } - } else { - chooseNode = data[0]; - } - currentNode.value = chooseNode; - treeExpandData.value.push(chooseNode.id); - nextTick(() => { - treeRef.value.setCurrentKey(chooseNode.id); - if (tab.value == 1 && deviceConfigRef.value) { - deviceConfigRef.value.getList(chooseNode) - } - if (tab.value == 2 && statisticalIndicatorsRef.value) { - statisticalIndicatorsRef.value.getList(chooseNode) - } - if (tab.value == 3 && collectIndicatorsRef.value) { - collectIndicatorsRef.value.getList(chooseNode) - } - }); + treeLoading.value = true + treeList({ modelCode }).then((res) => { + treeLoading.value = false + let { data } = res + treeData.value = data + let chooseNode = null + if (data.length > 0) { + if (data[0].children && data[0].children.length !== 0 && isFirstLeafNode.value) { + if (data[0].children[0].children && data[0].children[0].children.length !== 0) { + chooseNode = data[0].children[0].children[0] + } else { + chooseNode = data[0].children[0] } - }) + } else { + chooseNode = data[0] + } + currentNode.value = chooseNode + treeExpandData.value.push(chooseNode.id) + nextTick(() => { + treeRef.value.setCurrentKey(chooseNode.id) + if (tab.value == 1 && deviceConfigRef.value) { + deviceConfigRef.value.getList(chooseNode) + } + if (tab.value == 2 && statisticalIndicatorsRef.value) { + statisticalIndicatorsRef.value.getList(chooseNode) + } + if (tab.value == 3 && collectIndicatorsRef.value) { + collectIndicatorsRef.value.getList(chooseNode) + } + }) + } + }) } //鏂板鍚庢洿鏂版爲鍒楄〃 function addTreeList(newChild) { - treeData.value.push(newChild) + treeData.value.push(newChild) } //鏂板鎴愬姛鍚庢洿鏂伴粯璁ら�変腑,骞惰Е鍙戞柟娉� function addTreeSelectList(addedNode, newChild) { - treeExpandData.value.push(addedNode.nodeId) - nextTick(() => { - treeRef.value.setCurrentNode(newChild) - currentNode.value = newChild; - if (tab.value == 1) { - if (deviceConfigRef.value) { - deviceConfigRef.value.getList(newChild) - } - } - if (tab.value == 2) { - if (statisticalIndicatorsRef.value) { - statisticalIndicatorsRef.value.getList(newChild) - } - } - if (tab.value == 3) { - - if (collectIndicatorsRef.value) { - collectIndicatorsRef.value.getList(newChild) - } - } - }) - + treeExpandData.value.push(addedNode.nodeId) + nextTick(() => { + treeRef.value.setCurrentNode(newChild) + currentNode.value = newChild + if (tab.value == 1) { + if (deviceConfigRef.value) { + deviceConfigRef.value.getList(newChild) + } + } + if (tab.value == 2) { + if (statisticalIndicatorsRef.value) { + statisticalIndicatorsRef.value.getList(newChild) + } + } + if (tab.value == 3) { + if (collectIndicatorsRef.value) { + collectIndicatorsRef.value.getList(newChild) + } + } + }) } //鏍戠偣鍑� function changeNode(data, node, ev) { - console.log('鏍戠偣鍑�', data) - currentNode.value = data; - if (tab.value == 1) { - if (deviceConfigRef.value) { - deviceConfigRef.value.getList(data) - } + console.log("鏍戠偣鍑�", data) + currentNode.value = data + if (tab.value == 1) { + if (deviceConfigRef.value) { + deviceConfigRef.value.getList(data) } - if (tab.value == 2) { - if (statisticalIndicatorsRef.value) { - statisticalIndicatorsRef.value.getList(data) - } + } + if (tab.value == 2) { + if (statisticalIndicatorsRef.value) { + statisticalIndicatorsRef.value.getList(data) } - if (tab.value == 3) { - if (collectIndicatorsRef.value) { - collectIndicatorsRef.value.getList(data) - } + } + if (tab.value == 3) { + if (collectIndicatorsRef.value) { + collectIndicatorsRef.value.getList(data) } + } } let treeNodeModalRef = ref(null) function addNode(node, data) { - if (treeNodeModalRef.value) { - console.log('treeNodeModalRef', node, data) - treeNodeModalRef.value.handleOpen(node, data, true) - } + if (treeNodeModalRef.value) { + console.log("treeNodeModalRef", node, data) + treeNodeModalRef.value.handleOpen(node, data, true) + } } function editNode(node, data) { - if (treeNodeModalRef.value) { - treeNodeModalRef.value.handleOpen(node, data, false) - } + if (treeNodeModalRef.value) { + treeNodeModalRef.value.handleOpen(node, data, false) + } } function delNode(node, data) { - if (data.children && data.children.length > 0) { - proxy.$modal.msgWarning('鍖呭惈瀛愯妭鐐癸紝涓嶈兘杩涜鍒犻櫎锛�') - return + if (data.children && data.children.length > 0) { + proxy.$modal.msgWarning("鍖呭惈瀛愯妭鐐癸紝涓嶈兘杩涜鍒犻櫎锛�") + return + } + + hasEnergyIndex(data.id).then((response) => { + if (response.data) { + proxy.$modal.msgWarning("褰撳墠鑺傜偣涓嬪瓨鍦ㄦ寚鏍囷紝涓嶈兘杩涜鍒犻櫎锛�") + } else { + proxy.$modal + .confirm('鏄惁纭鍒犻櫎鍚嶄负"' + data.label + '"鐨勮妭鐐�?', "璀﹀憡", { + confirmButtonText: "纭畾", + cancelButtonText: "鍙栨秷", + type: "warning", + }) + .then(function () { + return delModelNode(data.id) + }) + .then(() => { + let parent = node.parent + let children = parent.data.children || parent.data + let index = children.findIndex((d) => d.id === data.id) + children.splice(index, 1) + + nextTick(() => { + if (parent.data && parent.data.id) { + changeNode(parent.data) + } else { + changeNode(null) + } + }) + proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛") + }) + .catch(function () {}) } - - hasEnergyIndex(data.id).then(response => { - if (response.data) { - proxy.$modal.msgWarning('褰撳墠鑺傜偣涓嬪瓨鍦ㄦ寚鏍囷紝涓嶈兘杩涜鍒犻櫎锛�') - } else { - proxy.$modal.confirm('鏄惁纭鍒犻櫎鍚嶄负"' + data.label + '"鐨勮妭鐐�?', '璀﹀憡', { - confirmButtonText: '纭畾', - cancelButtonText: '鍙栨秷', - type: 'warning' - }) - .then(function () { - return delModelNode(data.id) - }) - .then(() => { - let parent = node.parent - let children = parent.data.children || parent.data - let index = children.findIndex(d => d.id === data.id) - children.splice(index, 1) - - nextTick(() => { - if (parent.data && parent.data.id) { - changeNode(parent.data) - } else { - changeNode(null) - } - }) - proxy.$modal.msgSuccess('鍒犻櫎鎴愬姛') - }) - .catch(function () { - }) - } - }) + }) } -let tab = ref('1') +let tab = ref("1") function handleTab(value) { - tab.value = value - nextTick(() => { - if (value == 1 && deviceConfigRef.value) { - deviceConfigRef.value.getList(currentNode.value) - } - if (value == 2 && statisticalIndicatorsRef.value) { - statisticalIndicatorsRef.value.getList(currentNode.value) - } - if (value == 3 && collectIndicatorsRef.value) { - collectIndicatorsRef.value.getList(currentNode.value) - } - }); - + tab.value = value + nextTick(() => { + if (value == 1 && deviceConfigRef.value) { + deviceConfigRef.value.getList(currentNode.value) + } + if (value == 2 && statisticalIndicatorsRef.value) { + statisticalIndicatorsRef.value.getList(currentNode.value) + } + if (value == 3 && collectIndicatorsRef.value) { + collectIndicatorsRef.value.getList(currentNode.value) + } + }) } </script> @@ -320,77 +330,88 @@ @import "@/assets/styles/page.scss"; .page-box { - height: calc(100vh - 145px); + height: calc(100vh - 145px); - .tree-box { - height: calc(100% - 70px); - overflow-y: auto !important; + .tree-box { + height: calc(100% - 70px); + overflow-y: auto !important; + } + + .select-box { + display: flex; + align-items: center; + + :deep .el-icon { + color: #fff; + margin: 0 10px 0 15px; + font-size: 20px; + // &:hover{ + // color: #3371EB; + // } } + } - .select-box { - display: flex; - align-items: center; + .node-opt { + flex: 1; + text-align: right; + margin-right: 5px; - :deep .el-icon { - color: #fff; - margin: 0 10px 0 15px; - font-size: 20px; - // &:hover{ - // color: #3371EB; - // } - } + :deep .el-icon { + color: #fff; + margin-right: 5px; } - - .node-opt { - flex: 1; - text-align: right; - margin-right: 5px; - - :deep .el-icon { - color: #fff; - margin-right: 5px; - } - } - - + } } :deep .el-tabs__nav-wrap:after { - background: transparent; + background: transparent; } :deep .el-tabs__item { - color: #fff; - font-size: 20px; - padding: 0 20px; + color: #fff; + font-size: 20px; + padding: 0 20px; - &.is-active, - &:hover { - color: #999 !important; - } + &.is-active, + &:hover { + color: #999 !important; + } } .tab-box { - display: flex; - align-items: center; + display: flex; + align-items: center; + color: #fff; + border-bottom: 1px solid #3371eb; + margin-right: 20px; + margin-left: 15px; + font-size: 15px; + + .tab-li { + cursor: pointer; + border: 1px solid #3371eb; + padding: 8px 20px; + border-radius: 5px 5px 0 0; + } + + .is-tab { + background: #3371eb; color: #fff; - border-bottom: 1px solid #3371EB; - margin-right: 20px; + } +} +.themeDark { + .tab-box { + color: #fff; + } +} - .tab-li { - cursor: pointer; - border: 1px solid #3371EB; - padding: 10px 25px; - border-radius: 5px 5px 0 0; - } - - .is-tab { - background: #3371EB; - } +.themeLight { + .tab-box { + color: #333; + } } .content-box { - height: calc(100vh - 306px) !important; - + height: calc(100vh - 306px) !important; } </style> -- Gitblit v1.9.3