feat: 添加参数校验并调整导线数量操作逻辑
在main.py中添加gc_x和h_arm长度校验 在ParameterForm.vue中修改导线数量操作逻辑,仅允许1或3条导线
This commit is contained in:
@@ -128,10 +128,10 @@
|
||||
/>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<q-btn flat round color="primary" icon="add" @click="addHArm" :disable="params.parameter.h_arm.length >= 4" />
|
||||
<q-btn flat round color="primary" icon="add" @click="addHArm" :disable="params.parameter.h_arm.length >= 4" v-show="params.parameter.h_arm.length === 2" />
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<q-btn flat round color="negative" icon="remove" @click="removeHArm" :disable="params.parameter.h_arm.length <= 2" />
|
||||
<q-btn flat round color="negative" icon="remove" @click="removeHArm" :disable="params.parameter.h_arm.length <= 2" v-show="params.parameter.h_arm.length === 4" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -152,10 +152,10 @@
|
||||
/>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<q-btn flat round color="primary" icon="add" @click="addGcX" :disable="params.parameter.gc_x.length >= 4" />
|
||||
<q-btn flat round color="primary" icon="add" @click="addGcX" :disable="params.parameter.gc_x.length >= 4" v-show="params.parameter.gc_x.length === 2" />
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<q-btn flat round color="negative" icon="remove" @click="removeGcX" :disable="params.parameter.gc_x.length <= 2" />
|
||||
<q-btn flat round color="negative" icon="remove" @click="removeGcX" :disable="params.parameter.gc_x.length <= 2" v-show="params.parameter.gc_x.length === 4" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -396,41 +396,49 @@ watch(
|
||||
}
|
||||
)
|
||||
|
||||
// 数组操作函数(最多3条导线,即数组最多4个元素:1地线+3导线)
|
||||
// 数组操作函数(导线数量只能是1或3条,即数组长度为2或4:1地线+导线)
|
||||
// 两个数组同步增减
|
||||
const addHArm = () => {
|
||||
if (params.parameter.h_arm.length < 4) {
|
||||
if (params.parameter.h_arm.length === 2) {
|
||||
// 从1条导线增加到3条导线,添加2个元素
|
||||
const last = params.parameter.h_arm[params.parameter.h_arm.length - 1] || 100
|
||||
params.parameter.h_arm.push(last - 20)
|
||||
params.parameter.h_arm.push(last - 20, last - 40)
|
||||
// 同步增加 gc_x
|
||||
const lastX = params.parameter.gc_x[params.parameter.gc_x.length - 1] || 10
|
||||
params.parameter.gc_x.push(lastX)
|
||||
params.parameter.gc_x.push(lastX, lastX)
|
||||
}
|
||||
}
|
||||
|
||||
const removeHArm = () => {
|
||||
if (params.parameter.h_arm.length > 2) {
|
||||
if (params.parameter.h_arm.length === 4) {
|
||||
// 从3条导线减少到1条导线,移除2个元素
|
||||
params.parameter.h_arm.pop()
|
||||
params.parameter.h_arm.pop()
|
||||
// 同步删除 gc_x
|
||||
params.parameter.gc_x.pop()
|
||||
params.parameter.gc_x.pop()
|
||||
}
|
||||
}
|
||||
|
||||
const addGcX = () => {
|
||||
if (params.parameter.gc_x.length < 4) {
|
||||
if (params.parameter.gc_x.length === 2) {
|
||||
// 从1条导线增加到3条导线,添加2个元素
|
||||
const lastX = params.parameter.gc_x[params.parameter.gc_x.length - 1] || 10
|
||||
params.parameter.gc_x.push(lastX)
|
||||
params.parameter.gc_x.push(lastX, lastX)
|
||||
// 同步增加 h_arm
|
||||
const last = params.parameter.h_arm[params.parameter.h_arm.length - 1] || 100
|
||||
params.parameter.h_arm.push(last - 20)
|
||||
params.parameter.h_arm.push(last - 20, last - 40)
|
||||
}
|
||||
}
|
||||
|
||||
const removeGcX = () => {
|
||||
if (params.parameter.gc_x.length > 2) {
|
||||
if (params.parameter.gc_x.length === 4) {
|
||||
// 从3条导线减少到1条导线,移除2个元素
|
||||
params.parameter.gc_x.pop()
|
||||
params.parameter.gc_x.pop()
|
||||
// 同步删除 h_arm
|
||||
params.parameter.h_arm.pop()
|
||||
params.parameter.h_arm.pop()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user