diff --git a/src/jmapNew/utils/Uid.js b/src/jmapNew/utils/Uid.js index 012960c10..ae4719ad7 100644 --- a/src/jmapNew/utils/Uid.js +++ b/src/jmapNew/utils/Uid.js @@ -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. } diff --git a/src/utils/baseUrl.js b/src/utils/baseUrl.js index 79d1c6346..1e9afea51 100644 --- a/src/utils/baseUrl.js +++ b/src/utils/baseUrl.js @@ -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; } diff --git a/src/views/newMap/newMapdraft/mapoperate/section.vue b/src/views/newMap/newMapdraft/mapoperate/section.vue index 73e17db32..88d6e74df 100644 --- a/src/views/newMap/newMapdraft/mapoperate/section.vue +++ b/src/views/newMap/newMapdraft/mapoperate/section.vue @@ -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, diff --git a/src/views/newMap/newMapdraft/mapoperate/signal/create.vue b/src/views/newMap/newMapdraft/mapoperate/signal/create.vue index 849859d7f..7295bddeb 100644 --- a/src/views/newMap/newMapdraft/mapoperate/signal/create.vue +++ b/src/views/newMap/newMapdraft/mapoperate/signal/create.vue @@ -81,8 +81,8 @@