修改命名规则
This commit is contained in:
parent
3c4f803df2
commit
824b4ca414
@ -1,4 +1,3 @@
|
||||
var base = 0;
|
||||
|
||||
/**
|
||||
* @public
|
||||
@ -6,21 +5,27 @@ var base = 0;
|
||||
* @return {string}
|
||||
*/
|
||||
export function getUID(type, list) {
|
||||
if (list && list.length) {
|
||||
const code = [(type || ''), base++, Math.random().toFixed(5)].join('_');
|
||||
let count = 0;
|
||||
for (let index = 0; index < list.length; index++) {
|
||||
count++;
|
||||
if (list[index].code == code) {
|
||||
this.getUID(type, list);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (count == list.length) {
|
||||
return code;
|
||||
}
|
||||
// if (list && list.length) {
|
||||
let name = '';
|
||||
if (type == 'T') {
|
||||
name = list.length ? Number(list[list.length - 1].code.replace('T', '')) + 1 : list.length + 1;
|
||||
} else {
|
||||
return [(type || ''), base++, Math.random().toFixed(5)].join('_');
|
||||
name = Math.floor((Math.random() * 100000) + 1);
|
||||
}
|
||||
const code = [(type || ''), name].join('');
|
||||
let count = 0;
|
||||
for (let index = 0; index < list.length; index++) {
|
||||
count++;
|
||||
if (list[index].code == code) {
|
||||
this.getUID(type, list);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (count == list.length) {
|
||||
return code;
|
||||
}
|
||||
// } else {
|
||||
// return [(type || ''), Math.floor((Math.random() * 100000) + 1)].join('');
|
||||
// }
|
||||
// use Math.random to make id as unique as possible.
|
||||
}
|
||||
|
@ -3,11 +3,11 @@ export function getBaseUrl() {
|
||||
let BASE_API;
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
// BASE_API = 'https://joylink.club/jlcloud';
|
||||
// BASE_API = 'https://test.joylink.club/jlcloud';
|
||||
BASE_API = 'https://test.joylink.club/jlcloud';
|
||||
// BASE_API = 'http://192.168.3.5:9000'; // 袁琪
|
||||
// BASE_API = 'http://192.168.3.6:9000'; // 旭强
|
||||
// BASE_API = 'http://192.168.3.41:9000'; // 张赛
|
||||
BASE_API = 'http://192.168.3.82:9000'; // 杜康
|
||||
// BASE_API = 'http://192.168.3.82:9000'; // 杜康
|
||||
} else {
|
||||
BASE_API = process.env.VUE_APP_BASE_API;
|
||||
}
|
||||
|
@ -290,7 +290,7 @@ export default {
|
||||
addModel: {
|
||||
code: '',
|
||||
splitNumber: 2,
|
||||
trainPosType: '', // 列车所在方向
|
||||
trainPosType: '上方', // 列车所在方向
|
||||
splitOffsetMax: 15
|
||||
},
|
||||
operationModel: { // 区段集中站列表
|
||||
@ -767,7 +767,7 @@ export default {
|
||||
addLogicalSection(model, points, index, middleOffset) {
|
||||
const data = {
|
||||
_type: 'Section',
|
||||
code: getUID('Section', this.sectionList),
|
||||
code: getUID('T', this.sectionList),
|
||||
name: String.fromCharCode(index + 'A'.charCodeAt()),
|
||||
parentCode: model.code,
|
||||
axleShow: false,
|
||||
@ -869,8 +869,8 @@ export default {
|
||||
},
|
||||
// 创建区段
|
||||
create() {
|
||||
const uid = getUID('Section', this.sectionList);
|
||||
const uname = 'T' + this.sectionList.length;
|
||||
const uid = getUID('T', this.sectionList);
|
||||
const uname = 'T' + (Number(this.sectionList.length) + 1);
|
||||
const model = {
|
||||
_type: 'Section',
|
||||
code: uid,
|
||||
@ -1061,10 +1061,11 @@ export default {
|
||||
const modelX = (selected.points[selected.points.length - 1].x - selected.points[0].x) / this.addModel.splitNumber; // x 平均值
|
||||
const modelY = (selected.points[selected.points.length - 1].y - selected.points[0].y) / this.addModel.splitNumber; // y 平均值
|
||||
for (let index = 1; index <= this.addModel.splitNumber; index++) {
|
||||
const uid = getUID('T', [...this.sectionList, ...models]);
|
||||
const model = {
|
||||
_type: 'Section',
|
||||
code: getUID('Section', this.sectionList),
|
||||
name: `${selected.name}_${'index'}`,
|
||||
code: uid,
|
||||
name: `${selected.name}_${index}`,
|
||||
type: '01',
|
||||
parentCode: '',
|
||||
axleShow: selected.axleShow,
|
||||
@ -1160,7 +1161,7 @@ export default {
|
||||
}
|
||||
|
||||
if (rsection && lsection) {
|
||||
const uid = getUID('Section', this.sectionList);
|
||||
const uid = getUID('T', this.sectionList);
|
||||
const model = {
|
||||
_type: 'Section',
|
||||
code: uid,
|
||||
|
@ -81,8 +81,8 @@
|
||||
</template>
|
||||
<script>
|
||||
import { mapGetters } from 'vuex';
|
||||
import { getUID } from '@/jmap/utils/Uid';
|
||||
import JTriangle from '@/jmap/utils/JTriangle';
|
||||
import { getUID } from '@/jmapNew/utils/Uid';
|
||||
import JTriangle from '@/jmapNew/utils/JTriangle';
|
||||
export default {
|
||||
name: 'SignalCreate',
|
||||
props: {
|
||||
@ -155,7 +155,7 @@ export default {
|
||||
this.$refs['make'].validate((valid) => {
|
||||
if (valid) {
|
||||
if (this.addModel.sectionCode) {
|
||||
const uid = getUID('Singal');
|
||||
const uid = getUID('Singal', this.signalList);
|
||||
var model = {
|
||||
_type: 'Signal',
|
||||
code: uid,
|
||||
|
@ -315,7 +315,7 @@ export default {
|
||||
const uname = 'W' + section.name.replace('T', '');
|
||||
const model = {
|
||||
_type: 'Switch',
|
||||
code: getUID('Switch', this.switchList),
|
||||
code: getUID('W', this.switchList),
|
||||
name: uname,
|
||||
nameShow: true,
|
||||
timeoutShow: true,
|
||||
@ -355,7 +355,7 @@ export default {
|
||||
const uname = 'switch_' + section.name.replace('section_', '');
|
||||
const model = {
|
||||
_type: 'Switch',
|
||||
code: getUID('Switch', this.switchList),
|
||||
code: getUID('W', this.switchList),
|
||||
name: uname,
|
||||
nameShow: true,
|
||||
timeoutShow: true,
|
||||
@ -491,7 +491,7 @@ export default {
|
||||
if (!parentSectionModel) { // 找不到父元素删除
|
||||
let uid;
|
||||
if (!elem['uid']) {
|
||||
uid = getUID('Section', this.sectionList);
|
||||
uid = getUID('T', this.sectionList);
|
||||
elem['uid'] = uid;
|
||||
}
|
||||
sectiona.parentCode = elem['uid'];
|
||||
@ -598,7 +598,7 @@ export default {
|
||||
},
|
||||
createSwitchSectionManual() {
|
||||
const models = [];
|
||||
const uid = getUID('Section', this.sectionList);
|
||||
const uid = getUID('T', this.sectionList);
|
||||
this.fromData.relevanceSectionList.forEach(item => {
|
||||
const section = deepAssign({}, this.$store.getters['map/getDeviceByCode'](item));
|
||||
section.parentCode = uid;
|
||||
|
Loading…
Reference in New Issue
Block a user