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) { export function getUID(type, list) {
if (list.length) { if (list && list.length > 0) {
const lastCode = list[list.length - 1].code; const lastCode = list[list.length - 1].code;
const num = lastCode.split(type + '_')[1]; const num = lastCode.split(type + '_')[1];
return type + `_${num + 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 deviceType from '../constant/deviceType';
import deviceRender from '../constant/deviceRender'; import deviceRender from '../constant/deviceRender';
import store from '@/store'; import store from '@/store';
import { deepClone } from '@/utils/index';
export function createTransform(opts) { export function createTransform(opts) {
let transform = matrix.create(); let transform = matrix.create();
@ -116,9 +117,9 @@ function updateIscsListByDevice(iscs, name, device) {
if (list) { if (list) {
const index = list.findIndex(elem => { return elem.code == device.code; }); const index = list.findIndex(elem => { return elem.code == device.code; });
if (index >= 0) { if (index >= 0) {
device._dispose ? list.splice(index, 1) : list[index] = device; device._dispose ? list.splice(index, 1) : list[index] = deepClone(device);
} else { } else {
list.push(device); list.push(deepClone(device));
} }
} else { } else {
iscs[name] = [device]; iscs[name] = [device];
@ -127,7 +128,7 @@ function updateIscsListByDevice(iscs, name, device) {
} }
export function updateIscsData(device) { export function updateIscsData(device) {
const iscsData = store.getters['iscs/iscs']; const iscsData = store.state.iscs;
switch (device._type) { switch (device._type) {
case deviceType.vidiconList : case deviceType.vidiconList :
updateIscsListByDevice(iscsData, 'vidiconList', device); updateIscsListByDevice(iscsData, 'vidiconList', device);

View File

@ -1,5 +1,5 @@
import Vue from 'vue'; import Vue from 'vue';
import {updateIscsData } from '@/iscs/utils/parser';
/** /**
* iscs状态数据 * iscs状态数据
*/ */
@ -45,12 +45,89 @@ const iscs = {
} else { } else {
return []; 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: { mutations: {
iscsRender: (state, devices) => { 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) => { setIscsData: (state, iscs) => {
state.iscs = iscs; state.iscs = iscs;
@ -73,8 +150,10 @@ const iscs = {
if (!(models instanceof Array)) { if (!(models instanceof Array)) {
models = [models]; models = [models];
} }
commit('iscsRender', models); commit('iscsRender', models);
resolve(models); resolve(models);
}); });
}, },
setUpdateDeviceData: ({ commit }, models) => { setUpdateDeviceData: ({ commit }, models) => {

View File

@ -22,6 +22,8 @@
</div> </div>
</template> </template>
<script> <script>
import { mapGetters } from 'vuex';
import {getUID} from '@/iscs/utils/Uid';
export default { export default {
name:'FireDamper', name:'FireDamper',
data() { data() {
@ -52,7 +54,9 @@ export default {
}; };
}, },
computed:{ computed:{
...mapGetters('iscs', [
'fireDamperList'
])
}, },
watch:{ watch:{
'$store.state.ibp.rightClickCount': function (val) { '$store.state.ibp.rightClickCount': function (val) {
@ -81,7 +85,7 @@ export default {
y: this.form.y y: this.form.y
}, },
_type: 'FireDamper', _type: 'FireDamper',
code: this.isUpdate ? this.form.code : this.generateCode(), code: this.isUpdate ? this.form.code : getUID('FireDamper', this.fireDamperList),
width: this.form.width, width: this.form.width,
color:'#00ff00' color:'#00ff00'
}; };
@ -118,10 +122,6 @@ export default {
}; };
this.$emit('deleteDataModel', fireDamperModel ); this.$emit('deleteDataModel', fireDamperModel );
this.initPage(); 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> </div>
</template> </template>
<script> <script>
import { mapGetters } from 'vuex';
import {getUID} from '@/iscs/utils/Uid';
export default { export default {
name:'FrozenPump', name:'FrozenPump',
data() { data() {
@ -62,7 +64,9 @@ export default {
}; };
}, },
computed:{ computed:{
...mapGetters('iscs', [
'frozenPumpList'
])
}, },
watch:{ watch:{
'$store.state.ibp.rightClickCount': function (val) { '$store.state.ibp.rightClickCount': function (val) {
@ -92,7 +96,7 @@ export default {
y: this.form.y y: this.form.y
}, },
_type: 'FrozenPump', _type: 'FrozenPump',
code: this.isUpdate ? this.form.code : this.generateCode(), code: this.isUpdate ? this.form.code : getUID('FrozenPump', this.frozenPumpList),
width: this.form.width, width: this.form.width,
color:'#00ff00', color:'#00ff00',
pumpType:this.form.type pumpType:this.form.type
@ -132,10 +136,6 @@ export default {
}; };
this.$emit('deleteDataModel', frozenPumpModel ); this.$emit('deleteDataModel', frozenPumpModel );
this.initPage(); 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> </div>
</template> </template>
<script> <script>
import { mapGetters } from 'vuex';
import {getUID} from '@/iscs/utils/Uid';
export default { export default {
name:'JetFan', name:'JetFan',
data() { data() {
@ -52,7 +54,9 @@ export default {
}; };
}, },
computed:{ computed:{
...mapGetters('iscs', [
'jetFanList'
])
}, },
watch:{ watch:{
'$store.state.ibp.rightClickCount': function (val) { '$store.state.ibp.rightClickCount': function (val) {
@ -81,7 +85,7 @@ export default {
y: this.form.y y: this.form.y
}, },
_type: 'JetFan', _type: 'JetFan',
code: this.isUpdate ? this.form.code : this.generateCode(), code: this.isUpdate ? this.form.code : getUID('JetFan', this.jetFanList),
width: this.form.width, width: this.form.width,
color:'#00ff00' color:'#00ff00'
}; };
@ -118,10 +122,6 @@ export default {
}; };
this.$emit('deleteDataModel', jetFanModel ); this.$emit('deleteDataModel', jetFanModel );
this.initPage(); 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> </div>
</template> </template>
<script> <script>
import { mapGetters } from 'vuex';
import {getUID} from '@/iscs/utils/Uid';
export default { export default {
name:'OrbitalVentilator', name:'OrbitalVentilator',
data() { data() {
@ -52,7 +54,9 @@ export default {
}; };
}, },
computed:{ computed:{
...mapGetters('iscs', [
'orbitalVentilatorList'
])
}, },
watch:{ watch:{
'$store.state.ibp.rightClickCount': function (val) { '$store.state.ibp.rightClickCount': function (val) {
@ -81,7 +85,7 @@ export default {
y: this.form.y y: this.form.y
}, },
_type: 'OrbitalVentilator', _type: 'OrbitalVentilator',
code: this.isUpdate ? this.form.code : this.generateCode(), code: this.isUpdate ? this.form.code : getUID('OrbitalVentilator', this.orbitalVentilatorList),
width: this.form.width, width: this.form.width,
color:'#00ff00' color:'#00ff00'
}; };
@ -118,10 +122,6 @@ export default {
}; };
this.$emit('deleteDataModel', orbitalVentilatorModel ); this.$emit('deleteDataModel', orbitalVentilatorModel );
this.initPage(); 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> </div>
</template> </template>
<script> <script>
import { mapGetters } from 'vuex';
import {getUID} from '@/iscs/utils/Uid';
export default { export default {
name:'TunnelFan', name:'TunnelFan',
data() { data() {
@ -52,7 +54,9 @@ export default {
}; };
}, },
computed:{ computed:{
...mapGetters('iscs', [
'tunnelFanList'
])
}, },
watch:{ watch:{
'$store.state.ibp.rightClickCount': function (val) { '$store.state.ibp.rightClickCount': function (val) {
@ -81,7 +85,7 @@ export default {
y: this.form.y y: this.form.y
}, },
_type: 'TunnelFan', _type: 'TunnelFan',
code: this.isUpdate ? this.form.code : this.generateCode(), code: this.isUpdate ? this.form.code : getUID('TunnelFan', this.tunnelFanList),
width: this.form.width, width: this.form.width,
color:'#00ff00' color:'#00ff00'
}; };
@ -91,7 +95,6 @@ export default {
return false; return false;
} }
}); });
}, },
initPage() { initPage() {
this.isUpdate = false; this.isUpdate = false;
@ -118,10 +121,6 @@ export default {
}; };
this.$emit('deleteDataModel', tunnelFanModel ); this.$emit('deleteDataModel', tunnelFanModel );
this.initPage(); 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> </div>
</template> </template>
<script> <script>
import { mapGetters } from 'vuex';
import {getUID} from '@/iscs/utils/Uid';
export default { export default {
name:'Ventilator', name:'Ventilator',
data() { data() {
@ -52,7 +54,9 @@ export default {
}; };
}, },
computed:{ computed:{
...mapGetters('iscs', [
'ventilatorList'
])
}, },
watch:{ watch:{
'$store.state.ibp.rightClickCount': function (val) { '$store.state.ibp.rightClickCount': function (val) {
@ -81,7 +85,7 @@ export default {
y: this.form.y y: this.form.y
}, },
_type: 'Ventilator', _type: 'Ventilator',
code: this.isUpdate ? this.form.code : this.generateCode(), code: this.isUpdate ? this.form.code : getUID('Ventilator', this.ventilatorList),
width: this.form.width, width: this.form.width,
color:'#00ff00' color:'#00ff00'
}; };
@ -118,10 +122,6 @@ export default {
}; };
this.$emit('deleteDataModel', chillerModel ); this.$emit('deleteDataModel', chillerModel );
this.initPage(); this.initPage();
},
generateCode() {
const mydate = new Date();
return 'ventilator_' + mydate.getDay() + mydate.getHours() + mydate.getMinutes() + mydate.getSeconds() + mydate.getMilliseconds() + Math.round(Math.random() * 10000);
} }
} }
}; };