|
|
@ -20,7 +20,7 @@ |
|
|
</slot> |
|
|
</slot> |
|
|
<mdp-dialog ref="formSetDialog"> |
|
|
<mdp-dialog ref="formSetDialog"> |
|
|
<template v-slot="{visible,data,dialog}"> |
|
|
<template v-slot="{visible,data,dialog}"> |
|
|
<el-form v-model="editForm" label-width="120px" label-position="right"> |
|
|
|
|
|
|
|
|
<el-form :model="editForm" label-width="120px" label-position="right" ref="editFormRef"> |
|
|
<el-form-item label="表单名称"> |
|
|
<el-form-item label="表单名称"> |
|
|
<el-input v-model="editForm.formName"></el-input> |
|
|
<el-input v-model="editForm.formName"></el-input> |
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
@ -40,7 +40,7 @@ |
|
|
<el-form-item label="表名" prop="tableName" :rules="{required:true,message:'此项必填',trigger:'change'}"> |
|
|
<el-form-item label="表名" prop="tableName" :rules="{required:true,message:'此项必填',trigger:'change'}"> |
|
|
<el-input v-model="editForm.tableName" placeholder="请保持与数据库表名一致"></el-input> |
|
|
<el-input v-model="editForm.tableName" placeholder="请保持与数据库表名一致"></el-input> |
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
<el-form-item label="存储字段"> |
|
|
|
|
|
|
|
|
<el-form-item label="数据存储字段"> |
|
|
<el-input v-model="editForm.dataField" placeholder="非驼峰命名,默认ext_infos对应数据库字段ext_infos"></el-input> |
|
|
<el-input v-model="editForm.dataField" placeholder="非驼峰命名,默认ext_infos对应数据库字段ext_infos"></el-input> |
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
</span> |
|
|
</span> |
|
|
@ -49,8 +49,11 @@ |
|
|
<el-form-item label="表名" prop="tableName" :rules="{required:true,message:'此项必填',trigger:'change'}"> |
|
|
<el-form-item label="表名" prop="tableName" :rules="{required:true,message:'此项必填',trigger:'change'}"> |
|
|
<el-input v-model="editForm.tableName" placeholder="请保持与数据库表名一致"></el-input> |
|
|
<el-input v-model="editForm.tableName" placeholder="请保持与数据库表名一致"></el-input> |
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
<el-form-item label="数据库用户" :rules="{required:true,message:'此项必填',trigger:'change'}"> |
|
|
|
|
|
<el-input v-model="editForm.tableOwner" ></el-input> |
|
|
|
|
|
|
|
|
<el-form-item label="数据源名称" :rules="{required:true,message:'此项必填',trigger:'change'}"> |
|
|
|
|
|
<mdp-select v-model="editForm.tableOwner" :load-fun="dataSourceList" ></mdp-select> |
|
|
|
|
|
</el-form-item> |
|
|
|
|
|
<el-form-item label="建表方式" :rules="{required:true,message:'此项必填',trigger:'change'}"> |
|
|
|
|
|
<mdp-select v-model="editForm.ctType" item-code="lcode_create_table_type"></mdp-select> |
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
</span> |
|
|
</span> |
|
|
<mdp-form-expand v-if="showExpand" label-width="120px" label-position="right" v-model="editForm.extInfos" :expand-id="expandId"></mdp-form-expand> |
|
|
<mdp-form-expand v-if="showExpand" label-width="120px" label-position="right" v-model="editForm.extInfos" :expand-id="expandId"></mdp-form-expand> |
|
|
@ -58,7 +61,7 @@ |
|
|
</template> |
|
|
</template> |
|
|
<template #footer="{visible,data,dialog}"> |
|
|
<template #footer="{visible,data,dialog}"> |
|
|
<el-row slot="footer" class="footer"> |
|
|
<el-row slot="footer" class="footer"> |
|
|
<el-button @click="dialog.close()">关闭</el-button> |
|
|
|
|
|
|
|
|
<el-button @click="$refs['formSetDialog'].close()">关闭</el-button> |
|
|
<el-button type="primary" @click="saveSubmit">确认</el-button> |
|
|
<el-button type="primary" @click="saveSubmit">确认</el-button> |
|
|
</el-row> |
|
|
</el-row> |
|
|
</template> |
|
|
</template> |
|
|
@ -77,6 +80,7 @@ import { mapGetters } from 'vuex' |
|
|
import { MdpFormMixin } from '@/components/mdp-ui/mixin/MdpFormMixin.js'; |
|
|
import { MdpFormMixin } from '@/components/mdp-ui/mixin/MdpFormMixin.js'; |
|
|
import FormField from '../formField/Index' |
|
|
import FormField from '../formField/Index' |
|
|
import MdpSource from '../source/Index' |
|
|
import MdpSource from '../source/Index' |
|
|
|
|
|
import {dataSourceList} from '@/api/mdp/lcode/dev' |
|
|
export default { |
|
|
export default { |
|
|
name:'formDefForm', |
|
|
name:'formDefForm', |
|
|
mixins:[MdpFormMixin], |
|
|
mixins:[MdpFormMixin], |
|
|
@ -128,7 +132,7 @@ export default { |
|
|
] |
|
|
] |
|
|
}, |
|
|
}, |
|
|
editForm: { |
|
|
editForm: { |
|
|
id:'',tableName:'',tableOwner:'',isCreateTable:'0',formName:'',userid:'',deptid:'',formType:'',isTemplate:'',bizType:'',ctime:'',branchId:'',categoryId:'',tagIds:'',tagNames:'',username:'',deptName:'',groupsJson:'',pks:'',dataType:'1',dataField:'extInfos' |
|
|
|
|
|
|
|
|
id:'',tableName:'',tableOwner:'',isCreateTable:'0',formName:'',userid:'',deptid:'',formType:'',isTemplate:'',bizType:'',ctime:'',branchId:'',categoryId:'',tagIds:'',tagNames:'',username:'',deptName:'',groupsJson:'',pks:'',dataType:'1',dataField:'ext_infos',ctType:'2' |
|
|
}, |
|
|
}, |
|
|
//增删改查(含批量)接口 |
|
|
//增删改查(含批量)接口 |
|
|
apis:{ |
|
|
apis:{ |
|
|
@ -143,6 +147,7 @@ export default { |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
|
|
|
dataSourceList, |
|
|
//由组件扩展添加其它的初始页面的逻辑(mounted+onOpen都会调用此函数,建议只添加公共逻辑) |
|
|
//由组件扩展添加其它的初始页面的逻辑(mounted+onOpen都会调用此函数,建议只添加公共逻辑) |
|
|
initCurrData(){ |
|
|
initCurrData(){ |
|
|
if(!this.formId){ |
|
|
if(!this.formId){ |
|
|
@ -206,49 +211,57 @@ export default { |
|
|
return true; |
|
|
return true; |
|
|
}, |
|
|
}, |
|
|
saveSubmit: function () { |
|
|
saveSubmit: function () { |
|
|
if(this.editForm.formName==''){ |
|
|
|
|
|
this.$notify({position:'bottom-left',showClose:true,message: '表单名称不能为空', type: 'error' }); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
var formFields=this.$refs.formFields.getFieldList(); |
|
|
|
|
|
if(formFields.length==0 ){ |
|
|
|
|
|
this.$notify({position:'bottom-left',showClose:true,message: '最少需要定义一个字段', type: 'error' }); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
this.$confirm('确认提交吗?', '提示', {}).then(() => { |
|
|
|
|
|
this.load.edit=true |
|
|
|
|
|
let formDef = Object.assign({}, this.editForm); |
|
|
|
|
|
if(this.currOpType=='add'){ |
|
|
|
|
|
formDef.deptid=this.userInfo.deptid |
|
|
|
|
|
formDef.branchId=this.userInfo.branchId |
|
|
|
|
|
|
|
|
this.$refs['editFormRef'].validate(valid=>{ |
|
|
|
|
|
if(valid==false){ |
|
|
|
|
|
this.$notify({position:'bottom-left',showClose:true,message: '表单验证不通过', type: 'error' }); |
|
|
|
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.$refs.formFields.setPrimaryKeys(); |
|
|
|
|
|
|
|
|
|
|
|
formFields.forEach((i,index)=>{i.seq=index}); |
|
|
|
|
|
var params={formDef:formDef,formFields:formFields}; |
|
|
|
|
|
if(!this.preParamCheck(params)){ |
|
|
|
|
|
this.load.edit=false |
|
|
|
|
|
|
|
|
if(this.editForm.formName==''){ |
|
|
|
|
|
this.$notify({position:'bottom-left',showClose:true,message: '表单名称不能为空', type: 'error' }); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
var func=this.apis.add |
|
|
|
|
|
if(this.currOpType=='edit'){ |
|
|
|
|
|
func=this.apis.edit |
|
|
|
|
|
|
|
|
var formFields=this.$refs.formFields.getFieldList(); |
|
|
|
|
|
if(formFields.length==0 ){ |
|
|
|
|
|
this.$notify({position:'bottom-left',showClose:true,message: '最少需要定义一个字段', type: 'error' }); |
|
|
|
|
|
return; |
|
|
} |
|
|
} |
|
|
func(params).then((res) => { |
|
|
|
|
|
this.load.edit=false |
|
|
|
|
|
var tips=res.data.tips; |
|
|
|
|
|
if(tips.isOk){ |
|
|
|
|
|
this.$mdp.removeFormFieldsCache(formDef.id) |
|
|
|
|
|
this.currOpType='edit' |
|
|
|
|
|
var data=res.data.data |
|
|
|
|
|
Object.assign(this.editForm,data.formDef) |
|
|
|
|
|
this.formFields=data.formFields |
|
|
|
|
|
this.afterSubmit(res,tips.isOk,this.currOpType); |
|
|
|
|
|
|
|
|
this.$confirm('确认提交吗?', '提示', {}).then(() => { |
|
|
|
|
|
this.load.edit=true |
|
|
|
|
|
let formDef = Object.assign({}, this.editForm); |
|
|
|
|
|
if(this.currOpType=='add'){ |
|
|
|
|
|
formDef.deptid=this.userInfo.deptid |
|
|
|
|
|
formDef.branchId=this.userInfo.branchId |
|
|
} |
|
|
} |
|
|
this.$notify({ position:'bottom-left',showClose:true, message: tips.msg, type: tips.isOk?'success':'error' }); |
|
|
|
|
|
}).catch( err =>this.load.edit=false); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.$refs.formFields.setPrimaryKeys(); |
|
|
|
|
|
|
|
|
|
|
|
formFields.forEach((i,index)=>{i.seq=index}); |
|
|
|
|
|
var params={formDef:formDef,formFields:formFields}; |
|
|
|
|
|
if(!this.preParamCheck(params)){ |
|
|
|
|
|
this.load.edit=false |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
var func=this.apis.add |
|
|
|
|
|
if(this.currOpType=='edit'){ |
|
|
|
|
|
func=this.apis.edit |
|
|
|
|
|
} |
|
|
|
|
|
func(params).then((res) => { |
|
|
|
|
|
this.load.edit=false |
|
|
|
|
|
var tips=res.data.tips; |
|
|
|
|
|
if(tips.isOk){ |
|
|
|
|
|
this.$mdp.removeFormFieldsCache(formDef.id) |
|
|
|
|
|
this.currOpType='edit' |
|
|
|
|
|
var data=res.data.data |
|
|
|
|
|
Object.assign(this.editForm,data.formDef) |
|
|
|
|
|
this.formFields=data.formFields |
|
|
|
|
|
this.afterSubmit(res,tips.isOk,this.currOpType); |
|
|
|
|
|
} |
|
|
|
|
|
this.$notify({ position:'bottom-left',showClose:true, message: tips.msg, type: tips.isOk?'success':'error' }); |
|
|
|
|
|
}).catch( err =>this.load.edit=false); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
goToFormDefIndex(){ |
|
|
goToFormDefIndex(){ |
|
|
this.$router.push({path:'/mdp/lcode/index'}) |
|
|
this.$router.push({path:'/mdp/lcode/index'}) |
|
|
|