| | |
| | | class="avue-dialog avue-dialog--top" |
| | | :destroy-on-close="true" |
| | | @close="dialogClose"> |
| | | <basic-form ref="formRef" v-if="paramVOS.form"> |
| | | <basic-form ref="formRef" v-if="paramVOS.form" |
| | | :span="span" |
| | | :formItems="formItems" |
| | | :formData="form"> |
| | | </basic-form> |
| | | <ui-view ref="uiViewRef" v-else-if="paramVOS.content || paramVOS.context" |
| | | :btmType="paramVOS.type" |
| | |
| | | |
| | | <script> |
| | | import uiView from "@/views/base/UIContentViewerInDialog" |
| | | import {dataForm} from "@/api/base/ui"; |
| | | import {addSave} from "@/api/base/actions" |
| | | import {getFormDefineById,dataForm} from "@/api/base/ui"; |
| | | import {addSave,editSave} from "@/api/base/actions" |
| | | |
| | | export default { |
| | | name: "AddEditDialog", |
| | |
| | | data(){ |
| | | return { |
| | | type:"add", |
| | | visible:false |
| | | visible:false, |
| | | span:12, |
| | | formItems:[], |
| | | form:{} |
| | | } |
| | | }, |
| | | computed:{ |
| | |
| | | this.visible = false; |
| | | }, |
| | | onLoad: function () { |
| | | if (Object.keys(this.sourceData).length > 0 && this.isShow) { |
| | | if (Object.keys(this.sourceData).length > 0) { |
| | | this.loading = true; |
| | | dataForm(this.params).then(res => { |
| | | this.form = res.data.obj; |
| | | this.loading = false; |
| | | getFormDefineById(this.paramVOS.type,this.paramVOS.form).then(result => { |
| | | this.formItems=result.data.obj.items; |
| | | this.span=result.data.obj.columnOneRow?(24/result.data.obj.columnOneRow) : 12; |
| | | |
| | | if (this.paramVOS.initvalue) { |
| | | this.form=this.paramVOS.initvalue; |
| | | } |
| | | if(this.type=="edit"){ |
| | | //加载表单数据 |
| | | dataForm(this.params,this.paramVOS.getdataurl,this.paramVOS.getdatamethod).then(res => { |
| | | this.form = res.data.obj; |
| | | this.loading = false; |
| | | }).catch(error => { |
| | | this.$message.error(error); |
| | | this.loading = false; |
| | | }); |
| | | } |
| | | }).catch(error => { |
| | | this.$message.error(error); |
| | | this.loading = false; |
| | | }); |
| | | |
| | | } |
| | | }, |
| | | saveHandler() { |
| | | this.$refs.formRef.validate((valid, done) => { |
| | | if (valid) { |
| | | addSave(this.paramVOS.url,this.paramVOS.method,this.form).then(() => { |
| | | this.$message({ |
| | | type: "success", |
| | | message: "创建成功!" |
| | | if(this.type=="add"){ |
| | | addSave(this.form,this.paramVOS.url,this.paramVOS.method).then(() => { |
| | | this.$message({ |
| | | type: "success", |
| | | message: "保存成功!" |
| | | }); |
| | | if(this.saveCallback){ |
| | | this.saveCallback(); |
| | | } |
| | | this.dialogClose(); |
| | | }).error((e) => { |
| | | this.$message.error(e||"保存失败") |
| | | }); |
| | | if(this.saveCallback){ |
| | | this.saveCallback(); |
| | | } |
| | | this.dialogClose(); |
| | | }).error((e) => { |
| | | this.$message.error(e||"创建失败") |
| | | }); |
| | | |
| | | }else{ |
| | | editSave(this.form,this.paramVOS.url,this.paramVOS.method).then(() => { |
| | | this.$message({ |
| | | type: "success", |
| | | message: "修改成功!" |
| | | }); |
| | | if(this.saveCallback){ |
| | | this.saveCallback(); |
| | | } |
| | | this.dialogClose(); |
| | | }).error((e) => { |
| | | this.$message.error(e||"修改失败") |
| | | }); |
| | | } |
| | | } else { |
| | | |
| | | } |
| | |
| | | </script> |
| | | |
| | | <style scoped> |
| | | |
| | | .avue-dialog__footer{ |
| | | margin-bottom: 20px; |
| | | } |
| | | </style> |