修改变更关系

This commit is contained in:
limengnan 2026-01-22 10:58:03 +08:00
parent 223f815b15
commit 7896f303b4
3 changed files with 92 additions and 24 deletions

View File

@ -160,6 +160,21 @@ const props = defineProps({
type: Object, type: Object,
default: {} default: {}
}, },
formula: {
required: false,
type: String,
default: ''
},
formulaData: {
required: false,
type: Array,
default: []
},
deviceMaterialData: {
required: false,
type: Array,
default: []
},
}) })
const isAcitve = ref(-1); const isAcitve = ref(-1);
@ -185,10 +200,10 @@ function handleClick(item:any, index:any){
for(let key in item){ for(let key in item){
if(getName(key).name != '' && item[key] != '' && item[key] != null){ if(getName(key).name != '' && item[key] != '' && item[key] != null){
attributeList.value.push({ attributeList.value.push({
name: '('+getName(key).name +')', name: getName(key).name ,
key: getName(key).key, key: getName(key).key,
type: getName(key).type, type: getName(key).type,
parentName : getName(key).type == 'device' ? '('+item.deviceName +')' : '('+item.materialName +')', parentName : getName(key).type == 'device' ? item.deviceName : item.materialName ,
parentId : getName(key).type == 'device' ? item.deviceId : item.materialId parentId : getName(key).type == 'device' ? item.deviceId : item.materialId
}) })
} }
@ -213,7 +228,7 @@ function selectedClick(item:any, index:any){
let tempData:any = [] let tempData:any = []
formulaData.value.forEach((element:any) => { formulaData.value.forEach((element:any) => {
if(element.parentName != null){ if(element.parentName != null){
tempData.push(element.parentName) tempData.push("(" + element.parentName +'.'+ element.name+")" )
}else{ }else{
tempData.push(element) tempData.push(element)
} }
@ -225,15 +240,18 @@ function selectedClick(item:any, index:any){
onMounted(() => { onMounted(() => {
gettableData(); gettableData();
formula.value = props.formula
formulaData.value = props.formulaData
}); });
;
function selectedSymbolClick(name:any){ function selectedSymbolClick(name:any){
formulaData.value.push(name) formulaData.value.push(name)
let tempData:any = [] let tempData:any = []
formulaData.value.forEach((element:any) => { formulaData.value.forEach((element:any) => {
if(element.parentName != null){ if(element.parentName != null){
tempData.push(element.parentName) tempData.push("(" + element.parentName +'.'+ element.name+")" )
}else{ }else{
tempData.push(element) tempData.push(element)
} }
@ -246,7 +264,7 @@ function delClick(index:any){
let tempData:any = [] let tempData:any = []
formulaData.value.forEach((element:any) => { formulaData.value.forEach((element:any) => {
if(element.parentName != null){ if(element.parentName != null){
tempData.push(element.parentName) tempData.push("(" + element.parentName +'.'+ element.name+")" )
}else{ }else{
tempData.push(element) tempData.push(element)
} }
@ -254,6 +272,7 @@ function delClick(index:any){
}); });
formula.value = tempData.join('') formula.value = tempData.join('')
} }
// const deviceMaterialData:any = ref([])
function confirmClick(){ function confirmClick(){
let deviceMaterialData:any = [] let deviceMaterialData:any = []
formulaData.value.forEach((element:any) => { formulaData.value.forEach((element:any) => {
@ -307,12 +326,12 @@ function confirmClick(){
<div @click="selectedSymbolClick(1)">1</div> <div @click="selectedSymbolClick(1)">1</div>
<div @click="selectedSymbolClick(2)">2</div> <div @click="selectedSymbolClick(2)">2</div>
<div @click="selectedSymbolClick(3)">3</div> <div @click="selectedSymbolClick(3)">3</div>
<div @click="selectedSymbolClick(3)">-</div> <div @click="selectedSymbolClick(' - ')">-</div>
</div> </div>
<div class="calculator-box"> <div class="calculator-box">
<div style="width: 220px;" @click="selectedSymbolClick(0)">0</div> <div style="width: 220px;" @click="selectedSymbolClick(0)">0</div>
<div @click="selectedSymbolClick('.')">.</div> <div @click="selectedSymbolClick('.')">.</div>
<div @click="selectedSymbolClick('+')">+</div> <div @click="selectedSymbolClick(' + ')">+</div>
</div> </div>
<div class="formula-viewbox"> <div class="formula-viewbox">
{{ formula }} {{ formula }}

View File

@ -206,9 +206,20 @@ function confirmTableClick(){ // 确认变动公式设置
tableData.value[tableIndex.value].deviceMaterialData = formulaInfo.value.deviceMaterialData tableData.value[tableIndex.value].deviceMaterialData = formulaInfo.value.deviceMaterialData
isDialogFormula.value = false isDialogFormula.value = false
} }
const formula:any = ref('')
const formulaData:any = ref([])
const isChangeDialogsettings:any = ref(false) // const isChangeDialogsettings:any = ref(false) //
function openChangeDialogsettings(){ // function openChangeDialogsettings(){ //
formula.value = ''
formulaData.value = []
if(tableData.value[tableIndex.value].formula !=null && tableData.value[tableIndex.value].formula != ""){
formula.value = tableData.value[tableIndex.value].formula
}
if(tableData.value[tableIndex.value].formulaData !=null && tableData.value[tableIndex.value].formulaData != ""){
formulaData.value = tableData.value[tableIndex.value].formulaData
}
isChangeDialogsettings.value = true isChangeDialogsettings.value = true
} }
@ -328,6 +339,7 @@ function closeChangeDialogsettings(e:any){ // 变动公式值设置关闭
<el-dialog v-model="isChangeDialogsettings" :close-on-click-modal="false" :modal="false" draggable <el-dialog v-model="isChangeDialogsettings" :close-on-click-modal="false" :modal="false" draggable
:before-close="dialogChangeDialogsettings" title="变动公式值设置" append-to-body width="1280px" class="materialmodel-dialog-box"> :before-close="dialogChangeDialogsettings" title="变动公式值设置" append-to-body width="1280px" class="materialmodel-dialog-box">
<ChangeDialogsettings v-if="isChangeDialogsettings" :projectInfo="projectInfo" <ChangeDialogsettings v-if="isChangeDialogsettings" :projectInfo="projectInfo"
:formula = "formula" :formulaData= "formulaData"
@closeChangeDialogsettings="closeChangeDialogsettings" /> @closeChangeDialogsettings="closeChangeDialogsettings" />
</el-dialog> </el-dialog>

View File

@ -100,6 +100,9 @@ onMounted(() => {
graph = new Graph({ graph = new Graph({
container: document.getElementById('graph-container') as HTMLElement, container: document.getElementById('graph-container') as HTMLElement,
grid: true, grid: true,
background: {
color: '#ffffff' // Set a solid color background instead of an image
},
mousewheel: { mousewheel: {
enabled: true, enabled: true,
zoomAtMousePosition: true, zoomAtMousePosition: true,
@ -789,9 +792,9 @@ function preWork() {
.x6-widget-stencil-title{ .x6-widget-stencil-title{
display: none; display: none;
} }
#graph-container { .x6-container-editbox #graph-container {
width: calc(100% - 180px); width: calc(100% - 180px);
height: 100%; height: 100% !important;
background-color: #f1f3fe; background-color: #f1f3fe;
} }
.x6-widget-stencil { .x6-widget-stencil {
@ -860,10 +863,14 @@ function closeAntvx6() {
} }
function revokeClick(){ function revokeClick(){
graph.undo() if (graph.canUndo()) {
graph.undo()
}
} }
function removeClick(){ function removeClick(){
graph.clearCells(); if (graph.canRedo()) {
graph.redo()
}
} }
function bigClick(){ function bigClick(){
graph.zoom(0.1) graph.zoom(0.1)
@ -919,6 +926,7 @@ function closeEditdevice(e:any){ // 关闭编辑设备弹窗
let retrievedNode:any = graph.getCellById(nodeId.value) let retrievedNode:any = graph.getCellById(nodeId.value)
retrievedNode.store.data.deviceInfo = e retrievedNode.store.data.deviceInfo = e
isEditdevice.value = false; isEditdevice.value = false;
saveDesign()
} }
function dialogEditdevice(){ // function dialogEditdevice(){ //
@ -1006,13 +1014,18 @@ function closeChangesettingsModel(e:any){ // 关闭变动设置弹窗
function setFormulaInit(formula:any) { function setFormulaInit(formula:any) {
// const formula = "(B)*0.2+(A)*1.0+0.5"; // const formula = "(B)*0.2+(A)*1.0+0.5";
// *+) // *+)
const regex = /\*(\d+\.?\d*)/g; const regex = /([\*\/])(\d+\.?\d*)/g;
const coefficients = []; const coefficients = [];
let match; let match;
// //
while ((match = regex.exec(formula)) !== null) { while ((match = regex.exec(formula)) !== null) {
coefficients.push(parseFloat(match[1])); // if(!isNaN(parseFloat(match[1]))){
coefficients.push(parseFloat(match[1])); //
}else if(!isNaN(parseFloat(match[2]))){
coefficients.push(parseFloat(match[2])); //
}
} }
console.log(coefficients); // : [0.2, 1.0] console.log(coefficients); // : [0.2, 1.0]
return coefficients return coefficients
@ -1022,10 +1035,20 @@ function setFormulaInit(formula:any) {
function getBias(formula:any){ function getBias(formula:any){
// + // +
// + // +
const regex = /\+(\d+\.?\d*)$/; if (formula.includes(' - ')){
const match = formula.match(regex); const parts = formula.split(' - ');
const constant = parseFloat(match[1]); // .gitignore
return constant return parseFloat('-' + parts.pop().toLowerCase()) ;
};
if (formula.includes(' + ')){
const parts = formula.split(' + ');
// .gitignore
return parseFloat('+' + parts.pop().toLowerCase()) ;
};
return 0
//
} }
@ -1051,10 +1074,20 @@ function saveDesign() { // 保存设计
let tempSources = [] let tempSources = []
for(let k=0;k<setFormulaInit(cells[i].changesettings[j].formula).length;k++){ for(let k=0;k<setFormulaInit(cells[i].changesettings[j].formula).length;k++){
// name: '('+getName(key).name +')',
// key: getName(key).key,
// type: getName(key).type,
// parentName : getName(key).type == 'device' ? '('+item.deviceName +')' : '('+item.materialName +')',
// parentId : getName(key).type == 'device' ? item.deviceId : item.materialId
if(cells[i].changesettings[j].deviceMaterialData[k] == null){
return
}
tempSources.push({ tempSources.push({
entityType: 'material', //B entityType: cells[i].changesettings[j].deviceMaterialData[k].type, //B
entityId: cells[i].materialInfo.materialId , //materialId : cdeeca2e-1e0c-4bdd-b946-f347c104752c entityId: cells[i].changesettings[j].deviceMaterialData[k].parentId , //materialId : cdeeca2e-1e0c-4bdd-b946-f347c104752c
property: name, // g/L property: cells[i].changesettings[j].deviceMaterialData[k].key, // g/L
coefficient: setFormulaInit(cells[i].changesettings[j].formula)[k], //0.2 coefficient: setFormulaInit(cells[i].changesettings[j].formula)[k], //0.2
delay: { enabled: true, time: delay, unit: 's' } // 5 delay: { enabled: true, time: delay, unit: 's' } // 5
}) })
@ -1086,7 +1119,7 @@ function saveDesign() { // 保存设计
}) })
} }
} }
console.log(devices)
const topology = { const topology = {
projectId: projectInfo.value.projectId, projectId: projectInfo.value.projectId,
name: projectInfo.value.name, name: projectInfo.value.name,
@ -1127,7 +1160,7 @@ function saveDesign() { // 保存设计
</script> </script>
<template> <template>
<div class="app-layout" @click="isMenuShow = false"> <div class="app-layout x6-container-editbox" @click="isMenuShow = false">
<!-- <div class="toolbar"> <!-- <div class="toolbar">
<div class="style-group"> <div class="style-group">
<h4>实线</h4> <h4>实线</h4>
@ -1540,4 +1573,8 @@ function saveDesign() { // 保存设计
box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.1); box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.1);
cursor: pointer; cursor: pointer;
} }
.x6-graph-grid {
background-image: none !important;
}
</style> </style>