代码调整

This commit is contained in:
joylink_cuiweidong 2021-04-08 11:23:24 +08:00
parent 73caf6074b
commit 26ed24d339

View File

@ -21,7 +21,7 @@
</el-tabs> </el-tabs>
<div class="bottomBtnGroup"> <div class="bottomBtnGroup">
<el-button v-show="!selected" type="primary" size="small" @click="onSubmit">添加</el-button> <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="warning" size="small" @click="onModify">修改</el-button>
<el-button v-show="selected" type="danger" size="small" @click="onDelete">删除</el-button> <el-button v-show="selected" type="danger" size="small" @click="onDelete">删除</el-button>
</div> </div>
</el-card> </el-card>
@ -52,7 +52,7 @@ export default {
}, },
widthLeft: Number(localStore.get('LeftWidth')) || 450, widthLeft: Number(localStore.get('LeftWidth')) || 450,
draftShow: false, draftShow: false,
selected: null, selected: null,
enabledTab:'', enabledTab:'',
showDeleteButton:false, showDeleteButton:false,
elementList:[] elementList:[]
@ -85,45 +85,45 @@ export default {
}, },
onSelectTab() { onSelectTab() {
}, },
onSelected(val) { onSelected(val) {
if (val) { if (val) {
this.selected = JSON.parse(JSON.stringify(val)); this.selected = JSON.parse(JSON.stringify(val));
} 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) {
let formModel=this.$refs['dataform'+this.enabledTab][0].formModel; const formModel = this.$refs['dataform' + this.enabledTab][0].formModel;
let newModel=JSON.parse(JSON.stringify(formModel)); const newModel = JSON.parse(JSON.stringify(formModel));
newModel.type = this.enabledTab; newModel.type = this.enabledTab;
newModel.code = utils.getUID(this.enabledTab) newModel.code = utils.getUID(this.enabledTab);
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}}]);
} }
}); });
}, },
onModify() { onModify() {
this.$refs['dataform'+this.enabledTab][0].$refs['form'].validate((valid) => { this.$refs['dataform' + this.enabledTab][0].$refs['form'].validate((valid) => {
if (valid) { if (valid) {
let 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;
this.$refs.iscsCanvas.doAction([{model, action: {shapeType: shapeType.Element, order: orders.UPDATE}}]); this.$refs.iscsCanvas.doAction([{model, action: {shapeType: shapeType.Element, order: orders.UPDATE}}]);
} }
}); });
}, },
onDelete(){ onDelete() {
this.$refs['dataform'+this.enabledTab][0].$refs['form'].validate((valid) => { this.$refs['dataform' + this.enabledTab][0].$refs['form'].validate((valid) => {
if (valid) { if (valid) {
let 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;
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.$refs['dataform'+this.enabledTab][0].init(); this.$refs['dataform' + this.enabledTab][0].init();
this.selected = null; this.selected = null;
} }
}); });
} }
} }
}; };