修改信号机构建关系逻辑,修改创建逻辑区段偏移量数据逻辑

This commit is contained in:
zyy 2019-12-23 17:14:38 +08:00
parent 72c4bd0bd0
commit c1f41b4299
3 changed files with 41 additions and 41 deletions

View File

@ -94,7 +94,7 @@ export default {
const list = []; const list = [];
if (val && val.length) { if (val && val.length) {
for (let i = 0; i < val.length; i++) { for (let i = 0; i < val.length; i++) {
list.push({ label: val[i].uniqueName, value: val[i].code }); list.push({ label: val[i].name + '(' + val[i].code + ')', value: val[i].code });
} }
this.queryForm.queryObject.signalCode.config.data = list; this.queryForm.queryObject.signalCode.config.data = list;
} }
@ -137,9 +137,10 @@ export default {
const list = data.list; const list = data.list;
if (list) { if (list) {
list.map(elem => { list.map(elem => {
that.$convertSpecifiedField(elem, that.mapList, 'id', 'name', ['mapId']);
elem.code = elem.signalCode; elem.code = elem.signalCode;
elem.signalCode = that.formatName(elem.signalCode); that.$convertSpecifiedField(elem, that.mapList, 'id', 'name', ['mapId']);
that.$convertSpecifiedField(elem, this.signalList, 'code', 'name', ['signalCode']);
elem.signalCode = `${elem.signalCode}(${elem.code})`;
}); });
} }
} }

View File

@ -84,7 +84,7 @@ export default {
}); });
const lineLength = lengthFact / totalNum; // const lineLength = lengthFact / totalNum; //
this.tableData.forEach((ele, index) => { this.tableData.forEach((ele, index) => {
models = [...models, ...this.createLogicalSections(Number(ele.num), sectionPoints[index], sectionPoints[index + 1], this.editModel, counts, lineLength)]; models = [...models, ...this.createLogicalSections(Number(ele.num), sectionPoints[index], sectionPoints[index + 1], this.editModel, counts, lineLength, totalNum)];
allNotZeros = Number(ele.num) && allNotZeros; allNotZeros = Number(ele.num) && allNotZeros;
count += Number(ele.num); count += Number(ele.num);
logicSectionNumList.push(Number(ele.num)); logicSectionNumList.push(Number(ele.num));
@ -116,7 +116,7 @@ export default {
row.num = 0; row.num = 0;
}, },
// //
createLogicalSections(num, beg, end, model, counts, lineLength) { createLogicalSections(num, beg, end, model, counts, lineLength, totalNum) {
const models = []; const models = [];
const triangle = new JTriangle(beg, end); const triangle = new JTriangle(beg, end);
const offset = Math.sqrt(triangle.abspowz) / num; const offset = Math.sqrt(triangle.abspowz) / num;
@ -125,15 +125,14 @@ export default {
{ x: beg.x + triangle.getCos(offset * i), y: beg.y + triangle.getSin(offset * i) }, { x: beg.x + triangle.getCos(offset * i), y: beg.y + triangle.getSin(offset * i) },
{ x: beg.x + triangle.getCos(offset * (i + 1)), y: beg.y + triangle.getSin(offset * (i + 1)) } { x: beg.x + triangle.getCos(offset * (i + 1)), y: beg.y + triangle.getSin(offset * (i + 1)) }
]; ];
const param = this.addLogicalSection(model, points, counts + i, lineLength); const param = this.addLogicalSection(model, points, counts + i, lineLength, totalNum);
param.lengthFact = Number(model.lengthFact) / num;
models.push(param); models.push(param);
this.addList.push(param); this.addList.push(param);
} }
return models; return models;
}, },
// //
addLogicalSection(model, points, index, lineLength) { addLogicalSection(model, points, index, lineLength, totalNum) {
const data = { const data = {
_type: 'Section', _type: 'Section',
code: getUID('T', [...this.sectionList, ...this.addList]), code: getUID('T', [...this.sectionList, ...this.addList]),
@ -181,7 +180,7 @@ export default {
kmRangeLeft: model.kmRangeLeft, kmRangeLeft: model.kmRangeLeft,
region: model.region, region: model.region,
logicSectionStartOffset: Math.floor(lineLength * index), logicSectionStartOffset: Math.floor(lineLength * index),
logicSectionEndOffset: Math.floor(lineLength * (index + 1)), logicSectionEndOffset: index + 1 != totalNum ? Math.floor(lineLength * (index + 1)) : model.lengthFact,
relevanceSectionList: [] relevanceSectionList: []
}; };
if (this.isDelimiter) { if (this.isDelimiter) {

View File

@ -17,7 +17,7 @@
<create-signal ref="createSignal" :field="field" @signalSectionCode="signalSectionCode" @updateMapModel="updateMapModel" /> <create-signal ref="createSignal" :field="field" @signalSectionCode="signalSectionCode" @updateMapModel="updateMapModel" />
</el-tab-pane> </el-tab-pane>
<el-tab-pane class="view-control" label="批量操作" name="three"> <el-tab-pane class="view-control" label="批量操作" name="three">
<el-form ref="mark" label-width="130px" :model="addModel" size="mini" :rules="addRules"> <el-form ref="mark" label-width="130px" :model="addModel" size="mini">
<el-form-item label="左右偏移值" prop="number"> <el-form-item label="左右偏移值" prop="number">
<el-input v-model="addModel.number" style="width: 178px;" /> <el-input v-model="addModel.number" style="width: 178px;" />
</el-form-item> </el-form-item>
@ -99,11 +99,6 @@ export default {
}, },
addModel: { addModel: {
number: 2 number: 2
},
addRules: {
number: [
{ required: true, message: '请输入左右偏移量', trigger: 'blur', min: 0 }
]
} }
}; };
}, },
@ -308,42 +303,47 @@ export default {
}, },
// //
editAll() { editAll() {
this.$refs['mark'].validate((valid) => { if (this.addModel.number != '') {
if (valid) { const models = [];
const models = []; this.questionList = [];
this.questionList = []; this.signalList.forEach(item => {
this.signalList.forEach(item => { const signalModel = deepAssign({}, item);
const signalModel = deepAssign({}, item); const section = this.findSection(signalModel);
const section = this.findSection(signalModel); if (section.code && item.sectionCode != section.code) {
if (section.code && item.sectionCode != section.code) { signalModel.sectionCode = section.code;
signalModel.sectionCode = section.code; }
if (!section.code) {
this.questionList.push(`${item.name}(${item.code}) 信号机位置可能不正确,请手动调试归属区段及偏移量.`);
}
signalModel.sectionOffset = this.addModel.number;
if (signalModel.right) {
if (section.lengthFact) {
signalModel.sectionOffset = Math.abs(Number(section.lengthFact) - this.addModel.number);
} }
if (!section.code) { }
this.questionList.push(`${item.name}(${item.code}) 信号机位置可能不正确,请手动调试归属区段及偏移量.`); models.push(signalModel);
} if (this.editModel.code == signalModel.code) {
signalModel.sectionOffset = this.addModel.number; this.editModel.sectionCode = signalModel.sectionCode;
if (signalModel.right) { }
if (section.lengthFact) { });
signalModel.sectionOffset = Math.abs(Number(section.lengthFact) - this.addModel.number); this.$emit('updateMapModel', models);
} this.$message.success('数据构建成功!');
} this.deviceSelect();
models.push(signalModel);
}); } else {
this.$emit('updateMapModel', models); this.$message('请输入偏移量');
this.$message.success('数据构建成功!'); }
}
});
}, },
// //
findSection(signal) { findSection(signal) {
// 01 02 // 01 02
let model = {}; let model = {};
this.sectionList.forEach(section => { this.sectionList.forEach(section => {
if (!signal.right && section.type != '02') { if (!signal.right && section.type != '02' && section.type != '04') {
if (section.points[0].x == signal.position.x && Math.abs(section.points[0].y - signal.position.y) <= 20) { if (section.points[0].x == signal.position.x && Math.abs(section.points[0].y - signal.position.y) <= 20) {
model = section; model = section;
} }
} else if (signal.right && section.type != '02') { } else if (signal.right && section.type != '02' && section.type != '04') {
if (section.points[section.points.length - 1].x == signal.position.x && Math.abs(section.points[section.points.length - 1].y - signal.position.y) <= 20) { if (section.points[section.points.length - 1].x == signal.position.x && Math.abs(section.points[section.points.length - 1].y - signal.position.y) <= 20) {
model = section; model = section;
} }