|
|
|
@ -13,7 +13,7 @@ |
|
|
|
|
<el-button @click="router.push('/program')">上一步</el-button> |
|
|
|
|
<el-button @click="onUndo">撤回</el-button> |
|
|
|
|
<el-button @click="onRedo">恢复</el-button> |
|
|
|
|
<el-button @click="clearLocalStorage">清除缓存</el-button> |
|
|
|
|
<el-button @click="clearLocalStorage">重做</el-button> |
|
|
|
|
|
|
|
|
|
<el-button @click="onSave">保存</el-button> |
|
|
|
|
<el-button @click="onTip">步骤提示</el-button> |
|
|
|
@ -73,7 +73,7 @@ import setzijie from "./components/setzijie.vue"; |
|
|
|
|
import { ElMessage } from "element-plus"; |
|
|
|
|
import tipView from "@/assets/images/guanxitu.png"; |
|
|
|
|
import { useRouter } from "vue-router"; |
|
|
|
|
import useSettingStore from "@/store/modules/setting"; |
|
|
|
|
import useSettingStore from "@/store/modules/setting"; |
|
|
|
|
import { setStepEvent } from "@/utils/setStep"; |
|
|
|
|
import { formatDate } from "@/utils"; |
|
|
|
|
let graph = null; |
|
|
|
@ -822,7 +822,7 @@ onMounted(() => { |
|
|
|
|
}, 1000); |
|
|
|
|
const zoom = window.outerWidth / window.innerWidth; |
|
|
|
|
console.log("缩放比例为:", zoom); |
|
|
|
|
if(zoom > 1) { |
|
|
|
|
if (zoom > 1) { |
|
|
|
|
ElMessage.error("当前浏览器缩放比例过大,通过Ctrl+滚轮调整比例"); |
|
|
|
|
// graph.zoom(-0.5); |
|
|
|
|
} |
|
|
|
@ -841,50 +841,51 @@ const onUndo = () => { |
|
|
|
|
const onRedo = () => { |
|
|
|
|
graph.redo(); |
|
|
|
|
}; |
|
|
|
|
const wenduCode = "float a;a=1000000*M*S/W;T+(1-exp(-t/a))*100+T0;if(T>=100){T=100;}"; |
|
|
|
|
const shiduCode = "float b;a=10000*S0/W1;R+(1-exp(-t1/b))*100+R0;if(R>=100){R=100;}"; |
|
|
|
|
const step3Time = formatDate(new Date()) |
|
|
|
|
const wenduCode = |
|
|
|
|
"float a;a=1000000*M*S/W;T+(1-exp(-t/a))*100+T0;if(T>=100){T=100;}"; |
|
|
|
|
const shiduCode = |
|
|
|
|
"float b;a=10000*S0/W1;R+(1-exp(-t1/b))*100+R0;if(R>=100){R=100;}"; |
|
|
|
|
const step3Time = formatDate(new Date()); |
|
|
|
|
const onSave = () => { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log(removeDuplicateEdges(formatEdges()), standardData); |
|
|
|
|
// return |
|
|
|
|
if (standardData.length !== removeDuplicateEdges(formatEdges()).length) |
|
|
|
|
return ElMessage.error("请完善数据"); |
|
|
|
|
validateRelationships(standardData, formatEdges()); |
|
|
|
|
if(settingStore.wenduCode != wenduCode){ |
|
|
|
|
if (settingStore.wenduCode != wenduCode) { |
|
|
|
|
return ElMessage.error("温度代码编写错误"); |
|
|
|
|
} |
|
|
|
|
if(settingStore.shiduCode != shiduCode){ |
|
|
|
|
if (settingStore.shiduCode != shiduCode) { |
|
|
|
|
return ElMessage.error("湿度代码编写错误"); |
|
|
|
|
} |
|
|
|
|
setStepEvent(3, step3Time); |
|
|
|
|
settingStore.activeStepIndex =4 |
|
|
|
|
settingStore.activeStepIndex = 4; |
|
|
|
|
ElMessage.success("保存成功"); |
|
|
|
|
settingStore.setValue( true,'saveRoute'); |
|
|
|
|
localStorage.setItem('saveRoute',true) |
|
|
|
|
settingStore.setValue(true, "saveRoute"); |
|
|
|
|
localStorage.setItem("saveRoute", true); |
|
|
|
|
settingStore.setValue(true, "experimentPreservation"); |
|
|
|
|
localStorage.setItem("experimentPreservation", "true"); |
|
|
|
|
router.push('/program') |
|
|
|
|
router.push("/program"); |
|
|
|
|
// const data = graph.toJSON(); |
|
|
|
|
// console.log(data); |
|
|
|
|
// const edges = graph.getEdges(); |
|
|
|
|
// console.log(formatEdges()); |
|
|
|
|
}; |
|
|
|
|
function removeDuplicateEdges(edges) { |
|
|
|
|
const seen = new Set(); |
|
|
|
|
return edges.filter(edge => { |
|
|
|
|
// 生成唯一键,无视 source 和 target 的顺序 |
|
|
|
|
const key = edge.source < edge.target |
|
|
|
|
? `${edge.source}-${edge.target}` |
|
|
|
|
: `${edge.target}-${edge.source}`; |
|
|
|
|
const seen = new Set(); |
|
|
|
|
return edges.filter((edge) => { |
|
|
|
|
// 生成唯一键,无视 source 和 target 的顺序 |
|
|
|
|
const key = |
|
|
|
|
edge.source < edge.target |
|
|
|
|
? `${edge.source}-${edge.target}` |
|
|
|
|
: `${edge.target}-${edge.source}`; |
|
|
|
|
|
|
|
|
|
if (seen.has(key)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
seen.add(key); |
|
|
|
|
return true; |
|
|
|
|
}); |
|
|
|
|
if (seen.has(key)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
seen.add(key); |
|
|
|
|
return true; |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
const formatEdges = () => { |
|
|
|
|
const edges = graph.getEdges(); |
|
|
|
@ -1157,8 +1158,10 @@ function loadFromLocalStorage() { |
|
|
|
|
return JSON.parse(localStorage.getItem(SESSION_KEY)) || []; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function clearLocalStorage() { |
|
|
|
|
async function clearLocalStorage() { |
|
|
|
|
localStorage.removeItem(SESSION_KEY); |
|
|
|
|
await setStepEvent(3, step3Time, true); |
|
|
|
|
|
|
|
|
|
window.location.reload(); |
|
|
|
|
} |
|
|
|
|
</script> |
|
|
|
|