数据模型修改
This commit is contained in:
		| @@ -3,9 +3,9 @@ | ||||
|     <ai-title slot="title" :title="pageTitle" isShowBottomBorder isShowBack @back="back"/> | ||||
|     <template #content> | ||||
|       <el-form size="small" :model="form" label-width="80px" :rules="rules" ref="DataModelForm"> | ||||
|         <ai-card title="主表实体"> | ||||
|         <ai-card title="模型信息"> | ||||
|           <div flex> | ||||
|             <el-form-item label="主表" prop="name" class="fill"> | ||||
|             <el-form-item label="模型主体" prop="name" class="fill"> | ||||
|               <ai-select v-model="form.name" :selectList="entries" placeholder="指定主表实体模型,更换主表会清空设计模型" filterable @select="initMainModel" :disabled="isEdit"/> | ||||
|             </el-form-item> | ||||
|             <el-form-item label="模型别名" prop="alias" class="fill mar-l16"> | ||||
| @@ -15,7 +15,7 @@ | ||||
|         </ai-card> | ||||
|         <ai-card title="设计模型" panel> | ||||
|           <el-button slot="right" type="text" @click="fullscreen=true">全屏</el-button> | ||||
|           <el-form-item prop="json" label-width="0" class="diagram" :class="{fullscreen}"> | ||||
|           <el-form-item prop="config" label-width="0" class="diagram" :class="{fullscreen}"> | ||||
|             <div ref="DataModel" class="dataModel"/> | ||||
|             <div class="dndPanel pad-8"> | ||||
|               <div class="iconfont iconxinxiguanli pad-h8" v-text="`表实体`" @mousedown="handleAddModel"/> | ||||
| @@ -29,7 +29,7 @@ | ||||
|         <el-form class="pad-h16" :model="current" ref="ModelSettingForm" size="small" label-position="top"> | ||||
|           <template v-if="current.type=='model'"> | ||||
|             <el-form-item label="实体名称"> | ||||
|               <ai-select v-model="current.id" :selectList="entries" placeholder="请选择实体对象" filterable @select="changeModel"/> | ||||
|               <ai-select v-model="current.name" :selectList="entries" placeholder="请选择实体对象" filterable @select="changeModel"/> | ||||
|             </el-form-item> | ||||
|             <el-form-item label="实体属性"> | ||||
|               <ai-table :tableData="current.props" :colConfigs="currentCols" :is-show-pagination="false" tableSize="small" height="70vh"/> | ||||
| @@ -92,10 +92,10 @@ export default { | ||||
|       const {id} = this.$route.query | ||||
|       id && this.instance.post("/app/appdatamodel/queryDetailById", null, {params: {id}}).then(res => { | ||||
|         if (res?.data) { | ||||
|           const json = JSON.parse(res.data.config || null) | ||||
|           this.form = {...res.data, json} | ||||
|           const config = JSON.parse(res.data.config || null) | ||||
|           this.form = {...res.data, config} | ||||
|           this.$load(this.diagram).then(() => { | ||||
|             this.diagram.render(json) | ||||
|             this.diagram.render(config) | ||||
|             this.diagram.focusOn({id: this.form.name}) | ||||
|           }) | ||||
|         } | ||||
| @@ -162,29 +162,30 @@ export default { | ||||
|     }, | ||||
|     initMainModel(v) { | ||||
|       this.diagram.clearData() | ||||
|       if (!!v?.id) { | ||||
|       if (!!v?.tableName) { | ||||
|         this.getTableFields(v).then(list => { | ||||
|           this.diagram.addNode({ | ||||
|             type: 'main', | ||||
|             x: 200, | ||||
|             y: 60, | ||||
|             id: v.id, | ||||
|             properties: {id: v.id, props: list} | ||||
|             id: v.tableName, | ||||
|             properties: {id: v.tableName, props: list} | ||||
|           }) | ||||
|           this.diagram.focusOn({id: v.id}) | ||||
|           this.diagram.focusOn({id: v.tableName}) | ||||
|         }) | ||||
|       } | ||||
|     }, | ||||
|     changeModel(v) { | ||||
|       if (!!v?.id) { | ||||
|         this.current.name = v.id | ||||
|       if (!!v?.tableName) { | ||||
|         this.current.id = v.tableName | ||||
|         this.getTableFields(v).then((list = []) => this.current.props = list) | ||||
|       } | ||||
|     }, | ||||
|     getEntries() { | ||||
|       this.instance.get("/app/v2/api-docs").then(res => { | ||||
|         if (res?.definitions) { | ||||
|           this.entries = Object.entries(res.definitions).filter(([id]) => id?.startsWith("App"))?.map(([id, e]) => ({...e, id, label: id})) || [] | ||||
|           this.entries = Object.entries(res.definitions).filter(([id]) => id?.startsWith("App")) | ||||
|           ?.map(([id, e]) => ({...e, id, label: id, tableName: id.replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase()})) || [] | ||||
|         } | ||||
|       }) | ||||
|     }, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user