Commit 85ba568f by 吴斌

fix:修改权重不成功的bug

parent 98e737d6
<?xml version="1.0" encoding="utf-8"?> ++ /dev/null
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 17.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="90px" height="50px" viewBox="0 0 90 50" enable-background="new 0 0 90 50" xml:space="preserve">
<linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="45" y1="1.044341e-005" x2="45" y2="50">
<stop offset="0.0056" style="stop-color:#717071"/>
<stop offset="0.1763" style="stop-color:#9E9E9F"/>
<stop offset="0.3483" style="stop-color:#C8C9CA"/>
<stop offset="0.5219" style="stop-color:#FFFFFF"/>
<stop offset="0.6946" style="stop-color:#DBDCDC"/>
<stop offset="0.7395" style="stop-color:#D7D8D8"/>
<stop offset="0.7841" style="stop-color:#CBCCCC"/>
<stop offset="0.8284" style="stop-color:#B8B8B9"/>
<stop offset="0.836" style="stop-color:#B4B4B5"/>
<stop offset="1" style="stop-color:#6B6A6A"/>
</linearGradient>
<path fill="url(#SVGID_1_)" stroke="#C8C9CA" stroke-width="0.1877" stroke-miterlimit="10" d="M87.442,0.224L45.738,23.568
c-0.371,0.208-0.609,0.522-0.738,0.867c-0.129-0.345-0.366-0.659-0.738-0.867L2.558,0.224C1.421-0.412,0,0.383,0,1.656v46.688
c0,1.273,1.421,2.068,2.558,1.432l41.704-23.344c0.371-0.208,0.609-0.522,0.738-0.867c0.129,0.345,0.366,0.659,0.738,0.867
l41.704,23.344C88.579,50.412,90,49.617,90,48.344V1.656C90,0.383,88.579-0.412,87.442,0.224z"/>
</svg>
...@@ -14,13 +14,14 @@ ...@@ -14,13 +14,14 @@
</el-form> </el-form>
<div class="flex justify-center"> <div class="flex justify-center">
<el-checkbox @change="highlightPath(key)" v-model="value.highlight">高亮</el-checkbox> <el-checkbox @change="highlightPath(key)" v-model="value.highlight">高亮</el-checkbox>
<el-button type="primary" @click="computeData(pathNodesMap, analyzeResult)" class="ml-4">确定</el-button> <el-button type="primary" @click="analyzeCompute" class="ml-4">确定</el-button>
</div> </div>
</el-collapse-item> </el-collapse-item>
</el-collapse> </el-collapse>
</el-scrollbar> </el-scrollbar>
<div class="w-full h-32 bg-red-200"> <div class="w-full h-32 bg-red-200">
<div class="mb-2 mt-0 text-xl font-medium leading-tight text-primary">分析结果</div> <div class="mb-2 mt-0 text-xl font-medium leading-tight text-primary">分析结果</div>
<!-- <div>{{analyzeResult}}</div>-->
<div v-for="(value, key) in analyzeResult" class="flex"> <div v-for="(value, key) in analyzeResult" class="flex">
<div>{{nodeMap[key].data.name}}: {{value}}</div> <div>{{nodeMap[key].data.name}}: {{value}}</div>
</div> </div>
...@@ -49,9 +50,10 @@ const props = defineProps({ ...@@ -49,9 +50,10 @@ const props = defineProps({
}) })
let pathNodesMap = ref<Record<string, any>>({}) let pathNodesMap = ref<Record<string, any>>({})
let analyzeResult = ref<any>({}) let analyzeResult = ref<any>(null)
watch(()=>props.paths, (newValue) => { watch(()=>props.paths, (newValue) => {
pathNodesMap.value = {}
newValue.forEach((path:any) => { newValue.forEach((path:any) => {
let pathNode:any[] = [] let pathNode:any[] = []
let pathNodeName:string[] = [] let pathNodeName:string[] = []
...@@ -63,9 +65,14 @@ watch(()=>props.paths, (newValue) => { ...@@ -63,9 +65,14 @@ watch(()=>props.paths, (newValue) => {
'nodeKeys':path, 'nodesName': pathNodeName, "nodes": pathNode, 'highlight': false, 'weight': 1/props.paths.length 'nodeKeys':path, 'nodesName': pathNodeName, "nodes": pathNode, 'highlight': false, 'weight': 1/props.paths.length
} }
}) })
computeData(pathNodesMap.value, analyzeResult) analyzeCompute()
}); });
function analyzeCompute(){
computeData(pathNodesMap.value, analyzeResult)
}
function highlightPath(pathIndex:string){ function highlightPath(pathIndex:string){
let path:number[] = pathNodesMap.value[pathIndex].nodeKeys let path:number[] = pathNodesMap.value[pathIndex].nodeKeys
cancelHighlightLink(props.myDiagram) cancelHighlightLink(props.myDiagram)
...@@ -75,6 +82,4 @@ function highlightPath(pathIndex:string){ ...@@ -75,6 +82,4 @@ function highlightPath(pathIndex:string){
} }
} }
} }
</script> </script>
\ No newline at end of file
...@@ -157,7 +157,6 @@ export function highlightLink(from:number, to:number, myDiagram:any){ ...@@ -157,7 +157,6 @@ export function highlightLink(from:number, to:number, myDiagram:any){
model.set(item, "color", "red") model.set(item, "color", "red")
} }
}) })
console.log(linkDataArray);
} }
export function cancelHighlightLink(myDiagram:any){ export function cancelHighlightLink(myDiagram:any){
...@@ -177,7 +176,6 @@ export function computeData(pathNodesMap:any, analyzeResult:any){ ...@@ -177,7 +176,6 @@ export function computeData(pathNodesMap:any, analyzeResult:any){
console.log("compute", pathNodesMap); console.log("compute", pathNodesMap);
for (let key in pathNodesMap){ for (let key in pathNodesMap){
let path = pathNodesMap[key] let path = pathNodesMap[key]
console.log(path.nodeKeys)
for (let node of path.nodes){ for (let node of path.nodes){
if (node.data.key in nodesDataMap){ if (node.data.key in nodesDataMap){
let currentNodeIndex = path.nodes.indexOf(node) let currentNodeIndex = path.nodes.indexOf(node)
...@@ -186,7 +184,6 @@ export function computeData(pathNodesMap:any, analyzeResult:any){ ...@@ -186,7 +184,6 @@ export function computeData(pathNodesMap:any, analyzeResult:any){
} }
let lastNode = path.nodes[currentNodeIndex-1] let lastNode = path.nodes[currentNodeIndex-1]
nodesDataMap[node.data.key]['predict'] += lastNode.data.press * path.weight nodesDataMap[node.data.key]['predict'] += lastNode.data.press * path.weight
console.log("predict", nodesDataMap[node.data.key]['predict'], lastNode.data.press, path.weight);
} }
else{ else{
nodesDataMap[node.data.key] = {'predict': 0, 'real': node.data.press} nodesDataMap[node.data.key] = {'predict': 0, 'real': node.data.press}
...@@ -213,5 +210,6 @@ export function computeData(pathNodesMap:any, analyzeResult:any){ ...@@ -213,5 +210,6 @@ export function computeData(pathNodesMap:any, analyzeResult:any){
analyzeResult.value[key] = "压力正常" analyzeResult.value[key] = "压力正常"
} }
} }
console.log(analyzeResult.value)
return nodesDataMap return nodesDataMap
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment