Merge branch 'yly' into test
This commit is contained in:
commit
8bf8b0b742
@ -125,6 +125,9 @@
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-collapse-item>
|
||||
<el-collapse-item title="批量计算区段长度" name="8">
|
||||
<el-button class="sectionSetting" @click="calculateSectionLength" type="primary" size="small">设置</el-button>
|
||||
</el-collapse-item>
|
||||
</el-collapse>
|
||||
</div>
|
||||
</template>
|
||||
@ -424,6 +427,24 @@ export default {
|
||||
}
|
||||
models.push(deepAssign(section, { _type: 'Section' }));
|
||||
this.$emit('updateMapModel', models);
|
||||
},
|
||||
calculateSectionLength(){
|
||||
const precisionOf = num => num.toString().split('.').pop().length
|
||||
this.$confirm('确认设置所有区段的实际长度吗?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(()=>{
|
||||
this.sectionList.forEach(section => {
|
||||
const { kmMin, kmMax } = section
|
||||
if (typeof kmMin === 'number' && typeof kmMax === 'number') {
|
||||
const precision = Math.max(precisionOf(kmMin), precisionOf(kmMax))
|
||||
section.lengthFact = Number((kmMax - kmMin).toFixed(precision))
|
||||
}
|
||||
})
|
||||
this.$emit('updateMapModel', this.sectionList)
|
||||
this.$message.success('区段长度设置成功!')
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user