# Conflicts:
#	src/views/iscs_new/iscsDraw/index.vue
This commit is contained in:
ival 2021-04-08 18:41:21 +08:00
commit a253ec5de5
3 changed files with 60 additions and 53 deletions

View File

@ -30,6 +30,7 @@
<template v-else-if="checkFieldType(item, 'Boolean')"> <template v-else-if="checkFieldType(item, 'Boolean')">
<el-switch <el-switch
v-model="formModel[styleGroup.code][item.prop]" v-model="formModel[styleGroup.code][item.prop]"
style="vertical-align: top;"
size="small" size="small"
:active-color="item.activeColor || '#409eff'" :active-color="item.activeColor || '#409eff'"
:inactive-color="item.inactiveColor || '#dcdfe6'" :inactive-color="item.inactiveColor || '#dcdfe6'"

View File

@ -82,46 +82,46 @@ export default {
// this.$refs.iscsPlate.drawIscsInit(); // this.$refs.iscsPlate.drawIscsInit();
}, },
onSave() { onSave() {
const id = this.$route.query.id; const id = this.$route.query.id;
const name = this.$route.query.name||"<模型名称>"; const name = this.$route.query.name || '<模型名称>';
const type = this.$route.query.type||"<模型类型>"; const type = this.$route.query.type || '<模型类型>';
const source = this.$iscs.getSource(); const source = this.$iscs.getSource();
if (id && source) { if (id && source) {
const shapeList = source.elementList.map(el => { const shapeList = source.elementList.map(el => {
return this.$iscs.getShapeByCode(el.code); return this.$iscs.getShapeByCode(el.code);
}); });
const rect = shapeList.reduce( const rect = shapeList.reduce(
(temp,el) => el&&temp? temp.union(el.getBoundingRect().clone()): el.getBoundingRect(), null); (temp, el) => el && temp ? temp.union(el.getBoundingRect().clone()) : el.getBoundingRect(), null);
const position = [(rect.x + rect.width)/2, (rect.y + rect.height)/2]; const position = [(rect.x + rect.width) / 2, (rect.y + rect.height) / 2];
const model = { id, name, type, shapeList, position }; const model = { id, name, type, shapeList, position };
console.log(model) console.log(model);
} }
}, },
onSelectTab() { onSelectTab() {
this.selected = null; this.selected = null;
}, },
onSelected(em) { onSelected(em) {
if (em.model) { if (em.model) {
this.selected = JSON.parse(JSON.stringify(em.model)); this.selected = JSON.parse(JSON.stringify(em.model));
const elem = this.elementList.find(el => el.code == this.selected.type); const elem = this.elementList.find(el => el.code == this.selected.type);
if (elem) { if (elem) {
elem.model = this.selected; elem.model = this.selected;
} }
} else { } else {
this.selected = null; this.selected = null;
} }
}, },
onSubmit(){ onSubmit() {
this.$refs['dataform'+this.enabledTab][0].$refs['form'].validate((valid) => { this.$refs['dataform' + this.enabledTab][0].$refs['form'].validate((valid) => {
if (valid) { if (valid) {
const formModel = this.$refs['dataform' + this.enabledTab][0].formModel; const formModel = this.$refs['dataform' + this.enabledTab][0].formModel;
const newModel = JSON.parse(JSON.stringify(formModel)); const newModel = JSON.parse(JSON.stringify(formModel));
newModel.code = utils.getUID(this.enabledTab); newModel.code = utils.getUID(this.enabledTab);
newModel.type = this.enabledTab; newModel.type = this.enabledTab;
newModel.name = '<名称>'; newModel.name = '<名称>';
newModel.stateList = []; newModel.stateList = [];
this.$refs.iscsCanvas.doAction([{model: newModel, action: {shapeType: shapeType.Element, order: orders.ADD}}]); this.$refs.iscsCanvas.doAction([{model: newModel, action: {shapeType: shapeType.Element, order: orders.ADD}}]);
this.clear(this.enabledTab); this.clear(this.enabledTab);
} }
}); });
}, },
@ -131,9 +131,9 @@ export default {
const model = this.$refs['dataform' + this.enabledTab][0].formModel; const model = this.$refs['dataform' + this.enabledTab][0].formModel;
model.code = this.selected.code; model.code = this.selected.code;
model.type = this.selected.type; model.type = this.selected.type;
model.name = this.selected.name; model.name = this.selected.name;
this.$refs.iscsCanvas.doAction([{model, action: {shapeType: shapeType.Element, order: orders.UPDATE}}]); this.$refs.iscsCanvas.doAction([{model, action: {shapeType: shapeType.Element, order: orders.UPDATE}}]);
this.clear(this.enabledTab); this.clear(this.enabledTab);
} }
}); });
}, },
@ -143,16 +143,16 @@ export default {
const model = this.$refs['dataform' + this.enabledTab][0].formModel; const model = this.$refs['dataform' + this.enabledTab][0].formModel;
model.code = this.selected.code; model.code = this.selected.code;
model.type = this.selected.type; model.type = this.selected.type;
model.name = this.selected.name; model.name = this.selected.name;
this.$refs.iscsCanvas.doAction([{model, action: {shapeType: shapeType.Element, order: orders.DELETE}}]); this.$refs.iscsCanvas.doAction([{model, action: {shapeType: shapeType.Element, order: orders.DELETE}}]);
this.clear(this.enabledTab); this.clear(this.enabledTab);
} }
}); });
}, },
clear(enabledTab) { clear(enabledTab) {
this.$refs['dataform' + enabledTab][0].init(); this.$refs['dataform' + enabledTab][0].init();
this.selected = null; this.selected = null;
} }
} }
}; };
</script> </script>
@ -179,6 +179,9 @@ export default {
.mapPaint{ .mapPaint{
height: 100%; height: 100%;
overflow: hidden; overflow: hidden;
width:100%;
position:absolute;
left:0;top:0;
} }
.right-card{ .right-card{

View File

@ -101,7 +101,7 @@ export default {
} }
}, },
onSelectTab() { onSelectTab() {
this.selected = null; this.selected = null;
}, },
onSelected(em) { onSelected(em) {
if (em.model) { if (em.model) {
@ -120,12 +120,12 @@ export default {
if (valid) { if (valid) {
const formModel = this.$refs['dataform' + this.enabledTab][0].formModel; const formModel = this.$refs['dataform' + this.enabledTab][0].formModel;
const newModel = JSON.parse(JSON.stringify(formModel)); const newModel = JSON.parse(JSON.stringify(formModel));
newModel.code = utils.getUID(this.enabledTab); newModel.code = utils.getUID(this.enabledTab);
newModel.type = this.enabledTab; newModel.type = this.enabledTab;
newModel.name = '<名称>'; newModel.name = '<名称>';
newModel.stateList = []; newModel.stateList = [];
this.$refs.iscsCanvas.doAction([{model: newModel, action: {shapeType: shapeType.Element, order: orders.ADD}}]); this.$refs.iscsCanvas.doAction([{model: newModel, action: {shapeType: shapeType.Element, order: orders.ADD}}]);
this.clear(this.enabledTab); this.clear(this.enabledTab);
} }
}); });
}, },
@ -135,9 +135,9 @@ export default {
const model = this.$refs['dataform' + this.enabledTab][0].formModel; const model = this.$refs['dataform' + this.enabledTab][0].formModel;
model.code = this.selected.code; model.code = this.selected.code;
model.type = this.selected.type; model.type = this.selected.type;
model.name = this.selected.name; model.name = this.selected.name;
this.$refs.iscsCanvas.doAction([{model, action: {shapeType: shapeType.Element, order: orders.UPDATE}}]); this.$refs.iscsCanvas.doAction([{model, action: {shapeType: shapeType.Element, order: orders.UPDATE}}]);
this.clear(this.enabledTab); this.clear(this.enabledTab);
} }
}); });
}, },
@ -147,16 +147,16 @@ export default {
const model = this.$refs['dataform' + this.enabledTab][0].formModel; const model = this.$refs['dataform' + this.enabledTab][0].formModel;
model.code = this.selected.code; model.code = this.selected.code;
model.type = this.selected.type; model.type = this.selected.type;
model.name = this.selected.name; model.name = this.selected.name;
this.$refs.iscsCanvas.doAction([{model, action: {shapeType: shapeType.Element, order: orders.DELETE}}]); this.$refs.iscsCanvas.doAction([{model, action: {shapeType: shapeType.Element, order: orders.DELETE}}]);
this.clear(this.enabledTab); this.clear(this.enabledTab);
} }
}); });
}, },
clear(enabledTab) { clear(enabledTab) {
this.$refs['dataform' + enabledTab][0].init(); this.$refs['dataform' + enabledTab][0].init();
this.selected = null; this.selected = null;
} }
} }
}; };
</script> </script>
@ -183,6 +183,9 @@ export default {
.mapPaint{ .mapPaint{
height: 100%; height: 100%;
overflow: hidden; overflow: hidden;
width:100%;
position:absolute;
left:0;top:0;
} }
.right-card{ .right-card{