iscs bas 状态管理代码调整 生成uid代码调整 组件代码调整

This commit is contained in:
joylink_cuiweidong 2020-01-17 17:27:11 +08:00
parent 7987f6bd12
commit 0bb7b11271
9 changed files with 122 additions and 43 deletions

View File

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

View File

@ -3,6 +3,7 @@ import * as matrix from 'zrender/src/core/matrix';
import deviceType from '../constant/deviceType';
import deviceRender from '../constant/deviceRender';
import store from '@/store';
import { deepClone } from '@/utils/index';
export function createTransform(opts) {
let transform = matrix.create();
@ -116,9 +117,9 @@ function updateIscsListByDevice(iscs, name, device) {
if (list) {
const index = list.findIndex(elem => { return elem.code == device.code; });
if (index >= 0) {
device._dispose ? list.splice(index, 1) : list[index] = device;
device._dispose ? list.splice(index, 1) : list[index] = deepClone(device);
} else {
list.push(device);
list.push(deepClone(device));
}
} else {
iscs[name] = [device];
@ -127,7 +128,7 @@ function updateIscsListByDevice(iscs, name, device) {
}
export function updateIscsData(device) {
const iscsData = store.getters['iscs/iscs'];
const iscsData = store.state.iscs;
switch (device._type) {
case deviceType.vidiconList :
updateIscsListByDevice(iscsData, 'vidiconList', device);

View File

@ -1,5 +1,5 @@
import Vue from 'vue';
import {updateIscsData } from '@/iscs/utils/parser';
/**
* iscs状态数据
*/
@ -45,12 +45,89 @@ const iscs = {
} else {
return [];
}
},
frozenPumpList:(state)=>{
if (state.iscs && state.iscs.frozenPumpList) {
return state.iscs.frozenPumpList;
} else {
return [];
}
},
airConditionerList:(state)=>{
if (state.iscs && state.iscs.airConditionerList) {
return state.iscs.airConditionerList;
} else {
return [];
}
},
tunnelFanList:(state)=>{
if (state.iscs && state.iscs.tunnelFanList) {
return state.iscs.tunnelFanList;
} else {
return [];
}
},
orbitalVentilatorList:(state)=>{
if (state.iscs && state.iscs.orbitalVentilatorList) {
return state.iscs.orbitalVentilatorList;
} else {
return [];
}
},
smookProofFdList:(state)=>{
if (state.iscs && state.iscs.smookProofFdList) {
return state.iscs.smookProofFdList;
} else {
return [];
}
},
chillerList:(state)=>{
if (state.iscs && state.iscs.chillerList) {
return state.iscs.chillerList;
} else {
return [];
}
},
coolTowerList:(state)=>{
if (state.iscs && state.iscs.coolTowerList) {
return state.iscs.coolTowerList;
} else {
return [];
}
},
fireDamperList:(state)=>{
if (state.iscs && state.iscs.fireDamperList) {
return state.iscs.fireDamperList;
} else {
return [];
}
},
jetFanList:(state)=>{
if (state.iscs && state.iscs.jetFanList) {
return state.iscs.jetFanList;
} else {
return [];
}
},
ventilatorList:(state)=>{
if (state.iscs && state.iscs.ventilatorList) {
return state.iscs.ventilatorList;
} else {
return [];
}
}
},
mutations: {
iscsRender: (state, devices) => {
Vue.prototype.$iscs && Vue.prototype.$iscs.render(devices);
if (devices && devices.length) {
if (state.iscs) {
devices.forEach(elem => { updateIscsData(elem); });
}
if (Vue.prototype.$iscs) {
Vue.prototype.$iscs.render(devices);
}
}
},
setIscsData: (state, iscs) => {
state.iscs = iscs;
@ -73,8 +150,10 @@ const iscs = {
if (!(models instanceof Array)) {
models = [models];
}
commit('iscsRender', models);
resolve(models);
});
},
setUpdateDeviceData: ({ commit }, models) => {

View File

@ -22,6 +22,8 @@
</div>
</template>
<script>
import { mapGetters } from 'vuex';
import {getUID} from '@/iscs/utils/Uid';
export default {
name:'FireDamper',
data() {
@ -52,7 +54,9 @@ export default {
};
},
computed:{
...mapGetters('iscs', [
'fireDamperList'
])
},
watch:{
'$store.state.ibp.rightClickCount': function (val) {
@ -81,7 +85,7 @@ export default {
y: this.form.y
},
_type: 'FireDamper',
code: this.isUpdate ? this.form.code : this.generateCode(),
code: this.isUpdate ? this.form.code : getUID('FireDamper', this.fireDamperList),
width: this.form.width,
color:'#00ff00'
};
@ -118,10 +122,6 @@ export default {
};
this.$emit('deleteDataModel', fireDamperModel );
this.initPage();
},
generateCode() {
const mydate = new Date();
return 'fireDamper_' + mydate.getDay() + mydate.getHours() + mydate.getMinutes() + mydate.getSeconds() + mydate.getMilliseconds() + Math.round(Math.random() * 10000);
}
}
};

View File

@ -28,6 +28,8 @@
</div>
</template>
<script>
import { mapGetters } from 'vuex';
import {getUID} from '@/iscs/utils/Uid';
export default {
name:'FrozenPump',
data() {
@ -62,7 +64,9 @@ export default {
};
},
computed:{
...mapGetters('iscs', [
'frozenPumpList'
])
},
watch:{
'$store.state.ibp.rightClickCount': function (val) {
@ -92,7 +96,7 @@ export default {
y: this.form.y
},
_type: 'FrozenPump',
code: this.isUpdate ? this.form.code : this.generateCode(),
code: this.isUpdate ? this.form.code : getUID('FrozenPump', this.frozenPumpList),
width: this.form.width,
color:'#00ff00',
pumpType:this.form.type
@ -132,10 +136,6 @@ export default {
};
this.$emit('deleteDataModel', frozenPumpModel );
this.initPage();
},
generateCode() {
const mydate = new Date();
return 'frozenPump_' + mydate.getDay() + mydate.getHours() + mydate.getMinutes() + mydate.getSeconds() + mydate.getMilliseconds() + Math.round(Math.random() * 10000);
}
}
};

View File

@ -22,6 +22,8 @@
</div>
</template>
<script>
import { mapGetters } from 'vuex';
import {getUID} from '@/iscs/utils/Uid';
export default {
name:'JetFan',
data() {
@ -52,7 +54,9 @@ export default {
};
},
computed:{
...mapGetters('iscs', [
'jetFanList'
])
},
watch:{
'$store.state.ibp.rightClickCount': function (val) {
@ -81,7 +85,7 @@ export default {
y: this.form.y
},
_type: 'JetFan',
code: this.isUpdate ? this.form.code : this.generateCode(),
code: this.isUpdate ? this.form.code : getUID('JetFan', this.jetFanList),
width: this.form.width,
color:'#00ff00'
};
@ -118,10 +122,6 @@ export default {
};
this.$emit('deleteDataModel', jetFanModel );
this.initPage();
},
generateCode() {
const mydate = new Date();
return 'jetFan_' + mydate.getDay() + mydate.getHours() + mydate.getMinutes() + mydate.getSeconds() + mydate.getMilliseconds() + Math.round(Math.random() * 10000);
}
}
};

View File

@ -22,6 +22,8 @@
</div>
</template>
<script>
import { mapGetters } from 'vuex';
import {getUID} from '@/iscs/utils/Uid';
export default {
name:'OrbitalVentilator',
data() {
@ -52,7 +54,9 @@ export default {
};
},
computed:{
...mapGetters('iscs', [
'orbitalVentilatorList'
])
},
watch:{
'$store.state.ibp.rightClickCount': function (val) {
@ -81,7 +85,7 @@ export default {
y: this.form.y
},
_type: 'OrbitalVentilator',
code: this.isUpdate ? this.form.code : this.generateCode(),
code: this.isUpdate ? this.form.code : getUID('OrbitalVentilator', this.orbitalVentilatorList),
width: this.form.width,
color:'#00ff00'
};
@ -118,10 +122,6 @@ export default {
};
this.$emit('deleteDataModel', orbitalVentilatorModel );
this.initPage();
},
generateCode() {
const mydate = new Date();
return 'orbitalVentilator_' + mydate.getDay() + mydate.getHours() + mydate.getMinutes() + mydate.getSeconds() + mydate.getMilliseconds() + Math.round(Math.random() * 10000);
}
}
};

View File

@ -22,6 +22,8 @@
</div>
</template>
<script>
import { mapGetters } from 'vuex';
import {getUID} from '@/iscs/utils/Uid';
export default {
name:'TunnelFan',
data() {
@ -52,7 +54,9 @@ export default {
};
},
computed:{
...mapGetters('iscs', [
'tunnelFanList'
])
},
watch:{
'$store.state.ibp.rightClickCount': function (val) {
@ -81,7 +85,7 @@ export default {
y: this.form.y
},
_type: 'TunnelFan',
code: this.isUpdate ? this.form.code : this.generateCode(),
code: this.isUpdate ? this.form.code : getUID('TunnelFan', this.tunnelFanList),
width: this.form.width,
color:'#00ff00'
};
@ -91,7 +95,6 @@ export default {
return false;
}
});
},
initPage() {
this.isUpdate = false;
@ -118,10 +121,6 @@ export default {
};
this.$emit('deleteDataModel', tunnelFanModel );
this.initPage();
},
generateCode() {
const mydate = new Date();
return 'tunnelFan_' + mydate.getDay() + mydate.getHours() + mydate.getMinutes() + mydate.getSeconds() + mydate.getMilliseconds() + Math.round(Math.random() * 10000);
}
}
};

View File

@ -22,6 +22,8 @@
</div>
</template>
<script>
import { mapGetters } from 'vuex';
import {getUID} from '@/iscs/utils/Uid';
export default {
name:'Ventilator',
data() {
@ -52,7 +54,9 @@ export default {
};
},
computed:{
...mapGetters('iscs', [
'ventilatorList'
])
},
watch:{
'$store.state.ibp.rightClickCount': function (val) {
@ -81,7 +85,7 @@ export default {
y: this.form.y
},
_type: 'Ventilator',
code: this.isUpdate ? this.form.code : this.generateCode(),
code: this.isUpdate ? this.form.code : getUID('Ventilator', this.ventilatorList),
width: this.form.width,
color:'#00ff00'
};
@ -118,10 +122,6 @@ export default {
};
this.$emit('deleteDataModel', chillerModel );
this.initPage();
},
generateCode() {
const mydate = new Date();
return 'ventilator_' + mydate.getDay() + mydate.getHours() + mydate.getMinutes() + mydate.getSeconds() + mydate.getMilliseconds() + Math.round(Math.random() * 10000);
}
}
};