# Conflicts:
#	src/views/iscs_new/iscsDraw/index.vue
This commit is contained in:
ival 2021-04-09 17:14:09 +08:00
commit 3739fcc4ac

View File

@ -14,16 +14,27 @@
@click="onSave"
>保存</el-button>
</div>
<el-tabs v-model="enabledTab" class="card" type="card" @tab-click="onSelectTab">
<el-tab-pane v-for="(element,index) in elementList" :key="index" :label="element.name" :name="element.type" :lazy="true">
<data-form :ref="'dataform'+element.type" :form="element" :form-model="element.model" :rules="element.rules" />
<el-tabs id="cardTab" v-model="cardTab" class="card" type="border-card" @tab-click="onSelectCardTab">
<el-tab-pane label="元素绘制" name="first">
<el-tabs v-model="enabledTab" class="card" type="card" @tab-click="onSelectTab">
<el-tab-pane v-for="(element,index) in elementList" :key="index" :label="element.name" :name="element.type" :lazy="true">
<data-form :ref="'dataform'+element.type" :form="element" :form-model="element.model" />
</el-tab-pane>
</el-tabs>
<div class="bottomBtnGroup">
<el-button v-show="!selected" type="primary" size="small" @click="onSubmit">添加</el-button>
<el-button v-show="selected" type="warning" size="small" @click="onModify">修改</el-button>
<el-button v-show="selected" type="danger" size="small" @click="onDelete">删除</el-button>
</div>
</el-tab-pane>
<el-tab-pane label="状态编辑" name="second">
<el-tabs v-model="statusTab" class="card" type="card" @tab-click="onSelectTab">
<el-tab-pane v-for="(composeElem,index) in composeElemList" :key="index" :label="composeElem.name" :name="composeElem.code" :lazy="true">
<table-form :ref="'tableform'+composeElem.code" :state-list="composeElem.stateList" />
</el-tab-pane>
</el-tabs>
</el-tab-pane>
</el-tabs>
<div class="bottomBtnGroup">
<el-button v-show="!selected" type="primary" size="small" @click="onSubmit">添加</el-button>
<el-button v-show="selected" type="warning" size="small" @click="onModify">修改</el-button>
<el-button v-show="selected" type="danger" size="small" @click="onDelete">删除</el-button>
</div>
</el-card>
</div>
</div>
@ -34,6 +45,7 @@ import localStore from 'storejs';
import iscsCanvas from './iscsCanvas';
import formBuilder from '@/iscs_new/core/form/formBuilder';
import DataForm from '../components/dataForm';
import TableForm from '../components/tableForm';
import orders from '@/iscs_new/utils/orders';
import * as utils from '@/iscs_new/utils/utils';
import Idb from '../utils/indexedDb.js';
@ -43,7 +55,8 @@ export default {
name: 'IscsView',
components: {
iscsCanvas,
DataForm
DataForm,
TableForm
},
data() {
return {
@ -55,8 +68,11 @@ export default {
draftShow: false,
selected: null,
enabledTab:'',
cardTab:'first',
statusTab:'',
showDeleteButton:false,
elementList:[]
elementList:[],
composeElemList:[]
};
},
computed:{
@ -73,6 +89,7 @@ export default {
this.composeName = this.$route.query.composeName;
this.elementList = formBuilder.buildFormList();
this.enabledTab = this.elementList[0].type;
this.getComposeElemList();
},
methods: {
onIscsChange(mode, system, part) {
@ -80,47 +97,47 @@ export default {
// this.$refs.iscsPlate.drawIscsInit();
},
onSave() {
const id = this.$route.query.id;
const name = this.$route.query.name||"<模型名称>";
const type = this.$route.query.type||"<模型类型>";
const source = this.$iscs.getSource();
if (id && source) {
const elementList = source.elementList.map(el => {
return this.$iscs.getShapeByCode(el.code).model;
});
const composeList = source.composeList.map(el => {
return this.$iscs.getShapeByCode(el.code).model;
});
const rect = elementList.reduce((temp,el) => {
const shape = this.$iscs.getShapeByCode(el.code);
return shape&&temp? temp.union(shape.getBoundingRect().clone()): shape.getBoundingRect()
}, null);
const position = rect? [(rect.x + rect.width)/2, (rect.y + rect.height)/2]: [0,0];
const model = { id, name, type, elementList, composeList, position };
Idb.delete('composeList', model.id);
Idb.write('composeList', model);
Idb.list('composeList').then(list => {
console.log(list)
})
}
const id = this.$route.query.id;
const name = this.$route.query.name || '<模型名称>';
const type = this.$route.query.type || '<模型类型>';
const source = this.$iscs.getSource();
if (id && source) {
const elementList = source.elementList.map(el => {
return this.$iscs.getShapeByCode(el.code);
});
const shapeList = elementList.map(el => el.model);
const rect = elementList.reduce(
(temp, el) => el && temp ? temp.union(el.getBoundingRect().clone()) : el.getBoundingRect(), null);
const position = rect ? [(rect.x + rect.width) / 2, (rect.y + rect.height) / 2] : [0, 0];
const model = { id, name, type, shapeList, position };
Idb.delete('composeList', model.id);
Idb.write('composeList', model);
Idb.list('composeList').then(list => {
console.log(list);
});
}
},
onSelectTab() {
this.selected = null;
},
onSelected(em) {
if (em.model) {
this.selected = utils.deepClone(em.model);
const elem = this.elementList.find(el => el.type == this.selected.type);
if (elem) {
elem.model = this.selected;
this.enabledTab=this.selected.type;
}
} else {
this.selected = null;
}
},
onSubmit(){
this.$refs['dataform'+this.enabledTab][0].$refs['form'].validate((valid) => {
onSelectCardTab() {
},
onSelected(em) {
if (em.model) {
this.selected = JSON.parse(JSON.stringify(em.model));
const elem = this.elementList.find(el => el.type == this.selected.type);
if (elem) {
elem.model = this.selected;
this.enabledTab = this.selected.type;
}
} else {
this.selected = null;
this.clear(this.enabledTab);
}
},
onSubmit() {
this.$refs['dataform' + this.enabledTab][0].$refs['form'].validate((valid) => {
if (valid) {
const formModel = this.$refs['dataform' + this.enabledTab][0].formModel;
const newModel = utils.deepClone(formModel);
@ -130,6 +147,7 @@ export default {
newModel.stateList = [];
this.$refs.iscsCanvas.doAction([{model: newModel, action: {shapeType: shapeType.Element, order: orders.Add}}]);
this.clear(this.enabledTab);
this.getComposeElemList();
}
});
},
@ -154,12 +172,21 @@ export default {
model.name = this.selected.name;
this.$refs.iscsCanvas.doAction([{model, action: {shapeType: shapeType.Element, order: orders.Delete}}]);
this.clear(this.enabledTab);
this.getComposeElemList();
}
});
},
clear(enabledTab) {
this.$refs['dataform' + enabledTab][0].init();
this.selected = null;
},
getComposeElemList() {
const source = this.$iscs.getSource();
if (source.elementList) {
this.composeElemList = source.elementList;
this.statusTab = this.composeElemList[0].code;
}
}
}
};
@ -176,6 +203,28 @@ export default {
height: 100%;
overflow: auto;
padding-bottom:30px;
&::-webkit-scrollbar {
width: 6px;
height: 6px;
// height: 110px;
background-color: #FFFFFF;
}
&::-webkit-scrollbar-track {
// box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
border-radius: 10px;
background-color: #FFFFFF;;
}
&::-webkit-scrollbar-thumb {
border-radius: 10px;
// box-shadow: inset 0 0 6px rgba(0,0,0,.3);
background-color: #eaeaea;
}
&::-webkit-scrollbar-thumb:hover {
border-radius: 5px;
// box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
background: rgba(0,0,0,0.4);
}
}
.map-view {
@ -260,4 +309,7 @@ export default {
height: 100%;
overflow: hidden;
}
#cardTab .el-tabs__content{
padding:0px;
}
</style>