diff --git a/business-css/frontend/src/components/antvx6/adddevice.vue b/business-css/frontend/src/components/antvx6/adddevice.vue index 6c882d4..c757e8f 100644 --- a/business-css/frontend/src/components/antvx6/adddevice.vue +++ b/business-css/frontend/src/components/antvx6/adddevice.vue @@ -120,7 +120,7 @@ function confirmDevice(){ // 确定添加设备 } addDevices(params).then((res:any) => { if(res == true){ - emit('closeAdddevice', selectedDevice.value) + emit('closeAdddevice', params) } }); } @@ -213,8 +213,6 @@ function addClick() { - - diff --git a/business-css/frontend/src/components/antvx6/changesettings.vue b/business-css/frontend/src/components/antvx6/changesettings.vue new file mode 100644 index 0000000..4f38908 --- /dev/null +++ b/business-css/frontend/src/components/antvx6/changesettings.vue @@ -0,0 +1,369 @@ + + + + + + + + diff --git a/business-css/frontend/src/components/antvx6/index.vue b/business-css/frontend/src/components/antvx6/index.vue index 56e5f61..7354b39 100644 --- a/business-css/frontend/src/components/antvx6/index.vue +++ b/business-css/frontend/src/components/antvx6/index.vue @@ -35,7 +35,7 @@ import line6 from '@/assets/x6/line6.png' import AdddeviceModel from './adddevice.vue'; import EditdeviceModel from './editdevice.vue'; import MaterialModels from './materialmodel.vue'; - +import ChangesettingsModels from './changesettings.vue'; const emit = defineEmits([ 'closeAntvx6']); @@ -639,7 +639,6 @@ graph.on('blank:mouseup', (e) => { }, }), ) - console.log(imageNodes) stencil.load(imageNodes, 'group2') // 创建管线节点 @@ -858,51 +857,7 @@ function copyNode() { // 复制节点 function closeAntvx6() { emit('closeAntvx6') } -function saveDesign() { // 保存设计 - try { - // 获取画布内容并转换为JSON - const designData:any = graph.toJSON() - let cells = [] - if(designData !=null && designData.cells.length>0){ - cells = designData.cells - } - const topology = { - projectId: projectInfo.value.projectId, - name: projectInfo.value.name, - devices:[], - pipelines:[], - systemboundaries:[], - globalDisplay:{ - device:{ - showProperties:[] - }, - material:{ - showProperties:[] - }, - - }, - designData:cells - } - // 添加保存信息 - const saveData = { - projectId: projectInfo.value.projectId, - topology: JSON.stringify(topology) - } - updateProjects(saveData).then((res:any) => { - if(res === true){ - ElMessage({ - type: "success", - message: "保存成功", - }); - } - }); - // 返回保存的数据 - return saveData - } catch (error) { - console.error('保存设计失败:', error) - return null - } -} + function revokeClick(){ graph.undo() } @@ -989,14 +944,180 @@ function dialogMaterialModel(){ // 关闭物料信息弹窗 } function closeMaterialModel(e:any){ // 关闭物料信息弹窗 if(e == false){ - isEditdevice.value = false; + isMaterialModel.value = false; return } selectedMaterial.value = e let retrievedNode:any = graph.getCellById(nodeId.value) retrievedNode.store.data.materialInfo = e - isEditdevice.value = false; + isMaterialModel.value = false; +} + +const isChangesettings = ref(false) +const changesettingsData:any = ref([]) // 是否变动设置 +function dialogChangesettings(){ // 关闭变动设置弹窗 + isChangesettings.value = false; +} +function ChangesettingsClick(){ // 打开变动设置弹窗 + changesettingsData.value = [] + if(selectedNode.value.store.data.deviceInfo == null){ + ElMessage({ + type: "error", + message: "请先添加设备信息", + }); + return + } + if(selectedNode.value.store.data.materialInfo == null){ + ElMessage({ + type: "error", + message: "请先添加物料信息", + }); + return + } + deviceInfo.value = selectedNode.value.store.data.deviceInfo + materialInfo.value = selectedNode.value.store.data.materialInfo + + if(selectedNode.value.store.data.changesettings != null){ + changesettingsData.value = selectedNode.value.store.data.changesettings + } + + nodeId.value = selectedNode.value.id + if(materialInfo.value != null){ + deviceTypetype.value = materialInfo.value.type + } + isChangesettings.value = true; +} + +function closeChangesettingsModel(e:any){ // 关闭变动设置弹窗 + if(e == false){ + isChangesettings.value = false; + return + } + selectedMaterial.value = e + let retrievedNode:any = graph.getCellById(nodeId.value) + retrievedNode.store.data.changesettings = e + isChangesettings.value = false; +} + +function setFormulaInit(formula:any) { + // const formula = "【(圆柱槽B)*0.2+(环形槽A)*1.0+0.5】"; + // 匹配*号后、+或)前的数字(支持整数和小数) + const regex = /\*(\d+\.?\d*)/g; + const coefficients = []; + let match; + + // 循环提取所有匹配项 + while ((match = regex.exec(formula)) !== null) { + coefficients.push(parseFloat(match[1])); // 转为数字类型 + } + console.log(coefficients); // 输出: [0.2, 1.0] + return coefficients + +} + +function getBias(formula:any){ + // 从后往前找最后一个+的位置 + const lastPlusIndex = formula.lastIndexOf('+'); + // 从+的位置后截取到】之前 + const constantStr = formula.slice(lastPlusIndex + 1, -1); + const constant = parseFloat(constantStr); + return constant +} + + +function saveDesign() { // 保存设计 + try { + // 获取画布内容并转换为JSON + const designData:any = graph.toJSON() + let cells:any = [] + if(designData !=null && designData.cells.length>0){ + cells = designData.cells + } + let devices = [] + for(let i=0;i 0){ + for(let j=0;j { + if(res === true){ + ElMessage({ + type: "success", + message: "保存成功", + }); + } + }); + // 返回保存的数据 + return saveData + } catch (error) { + console.error('保存设计失败:', error) + return null + } } @@ -1062,7 +1183,7 @@ function closeMaterialModel(e:any){ // 关闭物料信息弹窗
图标 图标 - 图标 + 图标 图标 图标 @@ -1100,20 +1221,17 @@ function closeMaterialModel(e:any){ // 关闭物料信息弹窗 :deviceTypetype="deviceTypetype" ref="Editdevice" @closeEditdevice="closeEditdevice"/> - - - - - + + + + + + +
diff --git a/business-css/frontend/src/components/antvx6/materialmodel.vue b/business-css/frontend/src/components/antvx6/materialmodel.vue index fccec7c..7f7ba6b 100644 --- a/business-css/frontend/src/components/antvx6/materialmodel.vue +++ b/business-css/frontend/src/components/antvx6/materialmodel.vue @@ -215,7 +215,7 @@ function handleClick(item:any, index:any){ for(let i = 0; i < tempData.length; i++){ let attr = tempData[i] ingredientData.value.push({ - key: attr.name, + key: attr.key, value: attr.value, unit: attr.unit, }) @@ -443,6 +443,7 @@ function confirmMaterial(){ font-style: normal; font-size: 14px; color: #333333; + cursor: pointer; } .choiceMateria-left-item:hover{ background-color: #f5f8ff;