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