| | |
| | | :style="fullscreen?'':'height:'+height" |
| | | :isEdit="true" |
| | | :formItems="formItems" |
| | | :formData="form"> |
| | | :formData="form" |
| | | :initValue="paramVOS.initvalue" |
| | | @getFormData="getFormData"> |
| | | </basic-form> |
| | | <ui-view ref="uiViewRef" v-else-if="paramVOS.context" |
| | | :key="'AddEditDialog-'+type" |
| | |
| | | :sourceData="sourceData" |
| | | :dataStore="dataStore" |
| | | :paramVOS="paramVOS" |
| | | @getFormData="getFormData" |
| | | ></ui-view> |
| | | <div v-if="showSave" class="dialog-footer avue-dialog__footer"> |
| | | <el-button type="primary" plain size="small" @click="saveHandler">保 存</el-button> |
| | | <el-button type="primary" plain size="small" @click="formSave" v-if="paramVOS.form">保 存</el-button> |
| | | <el-button type="primary" plain size="small" @click="contextSave" v-else>保 存</el-button> |
| | | <el-button size="small" @click="dialogClose">取 消</el-button> |
| | | <el-button size="small" @click="resetValue" v-if="paramVOS.form">重 置</el-button> |
| | | </div> |
| | |
| | | |
| | | <script> |
| | | import uiView from "@/views/base/UIContentViewerInDialog" |
| | | import {parseEventByUrl} from "@/actions/base/BaseAction" |
| | | import {getFormDefineById,dataForm} from "@/api/base/ui"; |
| | | import {addSave,editSave} from "@/api/base/actions" |
| | | import {validatenull} from "@/util/validate" |
| | |
| | | showSave:this.paramVOS.customBtn || true, |
| | | span:12, |
| | | formItems:[], |
| | | form:{} |
| | | form:{}, |
| | | btmDefaultKeys : ['oid', 'id', 'name', 'description', 'revisionoid', 'nameoid', 'btmname', 'lastr', 'firstr', 'lastv', 'firstv', 'creator', 'createtime', 'lastModifier', 'lastmodifytime', 'revisionrule', 'revisionseq', 'revisionvalue', 'versionrule', 'versionseq', 'versionvalue', 'lcstatus', 'ts', 'owner', 'checkinby', 'checkintime', 'checkoutby', 'checkouttime', 'copyfromversion', 'secretgrade'], |
| | | linkDefaultKeys :['oid','creator','createtime','lastmodifier','lastmodifytime','f_oid','foid','f_revisionoid','frevisionoid','f_nameoid','fnameoid','f_btmname','fbtmname','t_oid','toid','t_revisionoid','trevisionoid','t_nameoid','tnameoid','t_btmname','tbtmname','ts'] |
| | | |
| | | } |
| | | }, |
| | | computed:{ |
| | |
| | | created() { |
| | | }, |
| | | watch: { |
| | | sourceData: { |
| | | paramVOS: { |
| | | handler(val) { |
| | | if (this.paramVOS.form) { |
| | | this.onLoad(); |
| | |
| | | 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; |
| | | } |
| | |
| | | formDefineId: this.paramVOS.form, |
| | | oid: this.dataStore[0].oid |
| | | }, sourceDataMap), this.paramVOS.getdataurl, this.paramVOS.getdatamethod).then(res => { |
| | | this.form = res.data.obj; |
| | | this.form=res.data.obj; |
| | | this.loading = false; |
| | | }).catch(error => { |
| | | this.$message.error(error); |
| | |
| | | |
| | | } |
| | | }, |
| | | saveHandler() { |
| | | if(this.paramVOS.form){ |
| | | this.$refs.formRef.validate((valid, done) => { |
| | | if (valid) { |
| | | this.saveValue(this.form) |
| | | contextSave(){ |
| | | const useDataType=this.paramVOS["useDataType"] || "form";//使用ui上下文中的哪个类型数据,默认form。值:form、tree、table、TreeTable |
| | | for(let key in this.$refs.uiViewRef.data){ |
| | | if(this.$refs.uiViewRef.data[key].type== useDataType){ |
| | | this.form=this.$refs.uiViewRef.data[key].data; |
| | | this.formDefineId=this.$refs.uiViewRef.data[key].DefineVO.id; |
| | | if (this.paramVOS.savebeforeevent) { |
| | | var urlobj = parseEventByUrl(this.paramVOS.savebeforeevent,null,null,'doAction'); |
| | | import("../"+urlobj.jsPath+".js").then(module => { |
| | | module[urlobj.methodName]({ |
| | | paramVOS: this.paramVOS, |
| | | dataStore: this.dataStore, |
| | | sourceData:this.sourceData |
| | | },this.formSaveHandle); |
| | | }) |
| | | } else { |
| | | |
| | | this.formSaveHandle(); |
| | | } |
| | | }); |
| | | }else{ |
| | | //this.$refs.uiViewRef. |
| | | debugger; |
| | | if(this.saveCallback){ |
| | | this.saveCallback({}); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | }, |
| | | saveValue(savedata){ |
| | | if(this.type=="add"){ |
| | | addSave(savedata,this.paramVOS.url,this.paramVOS.method).then(() => { |
| | | this.$message({ |
| | | formSave() { |
| | | let that=this; |
| | | this.$refs.formRef.validate((valid, done) => { |
| | | if (valid) { |
| | | this.formDefineId=this.paramVOS.form; |
| | | if (this.paramVOS.savebeforeevent) { |
| | | var urlobj = parseEventByUrl(this.paramVOS.savebeforeevent,null,null,'doAction'); |
| | | import("../"+urlobj.jsPath+".js").then(module => { |
| | | module[urlobj.methodName]({ |
| | | paramVOS: this.paramVOS, |
| | | dataStore: this.dataStore, |
| | | sourceData:this.sourceData |
| | | },that.formSaveHandle); |
| | | }) |
| | | } else { |
| | | that.formSaveHandle(); |
| | | } |
| | | } else { |
| | | return false; |
| | | } |
| | | }); |
| | | }, |
| | | formSaveHandle(){ |
| | | let that=this; |
| | | let formValues = this.getValues(); |
| | | if(formValues.otherValue.releaseFileOids){ |
| | | formValues.otherValue.releaseFileOids=formValues.otherValue.releaseFileOids.split(','); |
| | | } |
| | | if (!formValues.defaultValues.btmname) { |
| | | formValues.defaultValues.btmname = this.paramVOS.type; |
| | | } |
| | | let datas = { |
| | | formDefineId: this.formDefineId, |
| | | preEvent: this.paramVOS.preevent, |
| | | afterEvent: this.paramVOS.afterevent, |
| | | beforeServerEvent: this.paramVOS.beforeserverevent, |
| | | afterServerEvent: this.paramVOS.afterserverevent, |
| | | releaseFileOids: formValues.otherValue.releaseFileOids||[], |
| | | data: formValues.otherValue |
| | | } |
| | | Object.assign(datas, formValues.defaultValues); |
| | | if(that.type=="add"){ |
| | | addSave(datas,that.paramVOS.url,that.paramVOS.method).then(() => { |
| | | that.$message({ |
| | | type: "success", |
| | | message: "保存成功!" |
| | | }); |
| | | if(this.saveCallback){ |
| | | this.saveCallback(savedata); |
| | | if(that.saveCallback){ |
| | | that.saveCallback(that.type,that.form); |
| | | } |
| | | this.dialogClose(); |
| | | }).error((e) => { |
| | | this.$message.error(e||"保存失败") |
| | | that.dialogClose(); |
| | | }); |
| | | }else{ |
| | | editSave(savedata,this.paramVOS.url,this.paramVOS.method).then(() => { |
| | | this.$message({ |
| | | editSave(that.form,that.paramVOS.url,that.paramVOS.method).then(() => { |
| | | that.$message({ |
| | | type: "success", |
| | | message: "修改成功!" |
| | | }); |
| | | if(this.saveCallback){ |
| | | this.saveCallback(savedata); |
| | | if(that.saveCallback){ |
| | | that.saveCallback(that.type,that.form); |
| | | } |
| | | this.dialogClose(); |
| | | }).error((e) => { |
| | | this.$message.error(e||"修改失败") |
| | | that.dialogClose(); |
| | | }); |
| | | } |
| | | }, |
| | | getValues(){ |
| | | let defaultValues = {}, otherValue = {}; |
| | | for (var key in this.form) { |
| | | if (this.btmDefaultKeys.indexOf(key.toLowerCase()) > -1) { |
| | | defaultValues[key] = this.form[key]; |
| | | } else { |
| | | otherValue[key] = this.form[key]; |
| | | } |
| | | } |
| | | return { |
| | | defaultValues:defaultValues, |
| | | otherValue:otherValue |
| | | } |
| | | }, |
| | | resetValue() { |
| | | if (this.paramVOS.form) { |
| | | this.$refs.formRef.resetFields(); |
| | | } |
| | | }, |
| | | getFormData(form) { |
| | | this.form = form; |
| | | } |
| | | } |
| | | } |