iscs 生成uid代码调整

This commit is contained in:
joylink_cuiweidong 2020-01-19 13:49:55 +08:00
parent 0bb7b11271
commit d957ea049b
8 changed files with 66 additions and 56 deletions

View File

@ -6,6 +6,7 @@ import Painter from './painter';
import deviceType from './constant/deviceType';
import {calculateDCenter, createBoundingRect, deviceFactory} from './utils/parser';
import { updateIscsData } from './utils/parser';
import store from '@/store';
const renderer = 'canvas';
const devicePixelRatio = 1;
@ -120,7 +121,7 @@ class Iscs {
(list || []).forEach(elem => {
const code = elem.code;
const type = elem._type;
updateIscsData(elem);
// updateIscsData(store.state.iscs, elem);
const oDevice = this.iscsDevice[code] || deviceFactory(type, elem);
const nDevice = deviceFactory(type, Object.assign(oDevice.model || {}, elem));
delete this.iscsDevice[code];

View File

@ -2,7 +2,7 @@ export function getUID(type, list) {
if (list && list.length > 0) {
const lastCode = list[list.length - 1].code;
const num = lastCode.split(type + '_')[1];
return type + `_${num + 1}`;
return type + `_${parseInt(num) + 1}`;
} else {
return type + `_1`;
}

View File

@ -112,85 +112,94 @@ export function parser(data) {
return iscsDevice;
}
function updateIscsListByDevice(iscs, name, device) {
var list = iscs[name];
if (list) {
function updateIscsListByDevice(state, name, device) {
// var list = iscs[name];
const list = state.iscs[name];
if (list && list instanceof Array) {
const index = list.findIndex(elem => { return elem.code == device.code; });
if (index >= 0) {
device._dispose ? list.splice(index, 1) : list[index] = deepClone(device);
} else {
list.push(deepClone(device));
if (device._dispose) {
index >= 0 && list.splice(index, 1); // 删除
} else if (!list[index]) {
list.push(deepClone(device)); // 新增
} else if (index >= 0) {
list[index] = deepClone(device); // item map 数据 model 页面表单数据
}
// if (index >= 0) {
// device._dispose ? list.splice(index, 1) : list[index] = deepClone(device);
// } else {
// list.push(deepClone(device));
// }
} else {
iscs[name] = [device];
// list[name] = [device];
state.iscs[name] = [device];
}
return list;
// return list;
}
export function updateIscsData(device) {
const iscsData = store.state.iscs;
export function updateIscsData(state, device) {
// const state = store.state;
switch (device._type) {
case deviceType.vidiconList :
updateIscsListByDevice(iscsData, 'vidiconList', device);
case deviceType.Vidicon :
updateIscsListByDevice(state, 'vidiconList', device);
break;
case deviceType.vidiconCloudList :
updateIscsListByDevice(iscsData, 'vidiconCloudList', device);
case deviceType.VidiconCloud :
updateIscsListByDevice(state, 'vidiconCloudList', device);
break;
case deviceType.ManualAlarmButton :
updateIscsListByDevice(iscsData, 'manualAlarmButtonList', device);
updateIscsListByDevice(state, 'manualAlarmButtonList', device);
break;
case deviceType.FireHydranAlarmButton:
updateIscsListByDevice(iscsData, 'fireHydranAlarmButtonList', device);
updateIscsListByDevice(state, 'fireHydranAlarmButtonList', device);
break;
case deviceType.GasFireControl:
updateIscsListByDevice(iscsData, 'gasFireControlList', device);
updateIscsListByDevice(state, 'gasFireControlList', device);
break;
case deviceType.SmokeDetector:
updateIscsListByDevice(iscsData, 'smokeDetectorList', device);
updateIscsListByDevice(state, 'smokeDetectorList', device);
break;
case deviceType.TemperatureDetector:
updateIscsListByDevice(iscsData, 'temperatureDetectorList', device);
updateIscsListByDevice(state, 'temperatureDetectorList', device);
break;
case deviceType.PlatformScreenDoor:
updateIscsListByDevice(iscsData, 'platformScreenDoorList', device);
updateIscsListByDevice(state, 'platformScreenDoorList', device);
break;
case deviceType.FrozenPump :
updateIscsListByDevice(iscsData, 'frozenPumpList', device);
updateIscsListByDevice(state, 'frozenPumpList', device);
break;
case deviceType.Ventilator :
updateIscsListByDevice(iscsData, 'ventilatorList', device);
updateIscsListByDevice(state, 'ventilatorList', device);
break;
case deviceType.Chiller :
updateIscsListByDevice(iscsData, 'chillerList', device);
updateIscsListByDevice(state, 'chillerList', device);
break;
case deviceType.CoolTower :
updateIscsListByDevice(iscsData, 'coolTowerList', device);
updateIscsListByDevice(state, 'coolTowerList', device);
break;
case deviceType.EndDoor:
updateIscsListByDevice(iscsData, 'endDoorList', device);
updateIscsListByDevice(state, 'endDoorList', device);
break;
case deviceType.BorderRadius:
updateIscsListByDevice(iscsData, 'borderRadius', device);
updateIscsListByDevice(state, 'borderRadius', device);
break;
case deviceType.AirConditioner:
updateIscsListByDevice(iscsData, 'airConditionerList', device);
updateIscsListByDevice(state, 'airConditionerList', device);
break;
case deviceType.OrbitalVentilator:
updateIscsListByDevice(iscsData, 'orbitalVentilatorList', device);
updateIscsListByDevice(state, 'orbitalVentilatorList', device);
break;
case deviceType.JetFan:
updateIscsListByDevice(iscsData, 'jetFanList', device);
updateIscsListByDevice(state, 'jetFanList', device);
break;
case deviceType.TunnelFan:
updateIscsListByDevice(iscsData, 'tunnelFanList', device);
updateIscsListByDevice(state, 'tunnelFanList', device);
break;
case deviceType.FireDamper:
updateIscsListByDevice(iscsData, 'fireDamperList', device);
updateIscsListByDevice(state, 'fireDamperList', device);
break;
case deviceType.SmookProofFd:
updateIscsListByDevice(iscsData, 'smookProofFdList', device);
updateIscsListByDevice(state, 'smookProofFdList', device);
break;
}
store.dispatch('iscs/setIscsData', iscsData);
// store.dispatch('iscs/setIscsData', state.iscs);
}

View File

@ -33,84 +33,84 @@ const iscs = {
return state.updateDeviceData;
},
vidiconList: (state) => {
if (state.iscs && state.iscs.vidiconList) {
if (state.iscs) {
return state.iscs.vidiconList;
} else {
return [];
}
},
vidiconCloudList: (state) => {
if (state.iscs && state.iscs.vidiconCloudList) {
if (state.iscs.vidiconCloudList) {
return state.iscs.vidiconCloudList;
} else {
return [];
}
},
frozenPumpList:(state)=>{
if (state.iscs && state.iscs.frozenPumpList) {
if (state.iscs.frozenPumpList) {
return state.iscs.frozenPumpList;
} else {
return [];
}
},
airConditionerList:(state)=>{
if (state.iscs && state.iscs.airConditionerList) {
if (state.iscs.airConditionerList) {
return state.iscs.airConditionerList;
} else {
return [];
}
},
tunnelFanList:(state)=>{
if (state.iscs && state.iscs.tunnelFanList) {
if (state.iscs.tunnelFanList) {
return state.iscs.tunnelFanList;
} else {
return [];
}
},
orbitalVentilatorList:(state)=>{
if (state.iscs && state.iscs.orbitalVentilatorList) {
if (state.iscs.orbitalVentilatorList) {
return state.iscs.orbitalVentilatorList;
} else {
return [];
}
},
smookProofFdList:(state)=>{
if (state.iscs && state.iscs.smookProofFdList) {
if (state.iscs.smookProofFdList) {
return state.iscs.smookProofFdList;
} else {
return [];
}
},
chillerList:(state)=>{
if (state.iscs && state.iscs.chillerList) {
if (state.iscs.chillerList) {
return state.iscs.chillerList;
} else {
return [];
}
},
coolTowerList:(state)=>{
if (state.iscs && state.iscs.coolTowerList) {
if (state.iscs.coolTowerList) {
return state.iscs.coolTowerList;
} else {
return [];
}
},
fireDamperList:(state)=>{
if (state.iscs && state.iscs.fireDamperList) {
if (state.iscs.fireDamperList) {
return state.iscs.fireDamperList;
} else {
return [];
}
},
jetFanList:(state)=>{
if (state.iscs && state.iscs.jetFanList) {
if (state.iscs.jetFanList) {
return state.iscs.jetFanList;
} else {
return [];
}
},
ventilatorList:(state)=>{
if (state.iscs && state.iscs.ventilatorList) {
if (state.iscs.ventilatorList) {
return state.iscs.ventilatorList;
} else {
return [];
@ -122,7 +122,7 @@ const iscs = {
iscsRender: (state, devices) => {
if (devices && devices.length) {
if (state.iscs) {
devices.forEach(elem => { updateIscsData(elem); });
devices.forEach(elem => { updateIscsData(state, elem); });
}
if (Vue.prototype.$iscs) {
Vue.prototype.$iscs.render(devices);

View File

@ -43,7 +43,7 @@ export default {
},
watch: {
$route(val) {
this.iscsChange();
}
},
created() {

View File

@ -65,7 +65,7 @@ export default {
},
computed:{
...mapGetters('iscs', [
'frozenPumpList'
'iscs'
])
},
watch:{
@ -96,7 +96,7 @@ export default {
y: this.form.y
},
_type: 'FrozenPump',
code: this.isUpdate ? this.form.code : getUID('FrozenPump', this.frozenPumpList),
code: this.isUpdate ? this.form.code : getUID('FrozenPump', this.iscs.frozenPumpList),
width: this.form.width,
color:'#00ff00',
pumpType:this.form.type

View File

@ -49,14 +49,14 @@ export default {
},
computed: {
...mapGetters('iscs', [
'vidiconList'
'iscs'
])
},
methods: {
onSubmit(form) {
this.$refs.form.validate((valid) => {
if (valid) {
const Uid = getUID('Vidicon', this.vidiconList);
const Uid = getUID('Vidicon', this.iscs.vidiconList);
const model = {
_type: 'Vidicon',
code: Uid,

View File

@ -45,14 +45,14 @@ export default {
},
computed: {
...mapGetters('iscs', [
'vidiconCloudList'
'iscs'
])
},
methods: {
onSubmit(form) {
this.$refs.form.validate((valid) => {
if (valid) {
const Uid = getUID('VidiconCloud', this.vidiconCloudList);
const Uid = getUID('VidiconCloud', this.iscs.vidiconCloudList);
const model = {
_type: 'VidiconCloud',
code: Uid,