Skip to content

Commit 0423cd1

Browse files
committed
fix/model-driven-bugs
1 parent 01485bc commit 0423cd1

7 files changed

Lines changed: 95 additions & 67 deletions

File tree

packages/configurator/src/model-api-configurator/ModelApiConfigurator.vue

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,33 @@
66
:visible-arrow="false"
77
:popper-class="['option-popper', 'fixed-left']"
88
:offset="isSecond ? 652 : 0"
9-
width="860"
9+
width="640"
1010
>
1111
<div class="model-function-wrap">
1212
<div class="model-title">
1313
<span>选择模型方法</span>
1414
<div class="right">
15-
<tiny-button @click="closePopover">取消</tiny-button>
16-
<tiny-button type="primary" @click="setModelFunction" :disabled="!selectedFunction">确定</tiny-button>
17-
<tiny-icon-close class="tiny-svg-size" @click="closePopover"></tiny-icon-close>
15+
<button-group>
16+
<tiny-button type="primary" @click="setModelFunction" :disabled="!selectedFunction">确定</tiny-button>
17+
<tiny-icon-close class="tiny-svg-size" @click="closePopover"></tiny-icon-close>
18+
</button-group>
1819
</div>
1920
</div>
2021
<div class="model-set-wrap">
2122
<div class="model-param-wrap" v-if="selectedFunction">
2223
<tiny-form
2324
ref="ruleFormRef"
24-
:model="methodBasicData"
25+
:model="selectedFunction"
2526
:rules="methodBasicData.rules"
2627
label-width="100px"
2728
label-position="left"
2829
>
2930
<tiny-form-item label="请求URL" prop="url">
30-
<tiny-input v-model="methodBasicData.url"></tiny-input>
31+
<tiny-input v-model="selectedFunction.url"></tiny-input>
3132
</tiny-form-item>
3233
<tiny-form-item label="请求方式" prop="method">
3334
<tiny-select
34-
v-model="methodBasicData.method"
35+
v-model="selectedFunction.method"
3536
:disabled="methodDisabled"
3637
:options="methodBasicData.options"
3738
></tiny-select>
@@ -74,6 +75,7 @@ import {
7475
} from '@opentiny/vue'
7576
import { iconClose, iconEdit } from '@opentiny/vue-icon'
7677
import { useCanvas } from '@opentiny/tiny-engine-meta-register'
78+
import { ButtonGroup } from '@opentiny/tiny-engine-common'
7779
import { getModelDetail } from '../model-common/http'
7880
import ParamsBindGrid from './ParamsBindGrid.vue'
7981
@@ -188,7 +190,7 @@ const setModelApis = () => {
188190
}
189191
: null
190192
})
191-
.filter(api !== null)
193+
.filter((api) => api !== null)
192194
emit('update:modelValue', modelValue.value)
193195
}
194196

packages/configurator/src/model-api-configurator/ParamsBindGrid.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
<template>
22
<tiny-grid :data="data" :tree-config="{ children: 'children', indent: 6 }">
3-
<tiny-grid-column type="index" title="序号" width="60" align="left"></tiny-grid-column>
4-
<tiny-grid-column field="prop" title="字段" width="140" tree-node></tiny-grid-column>
3+
<tiny-grid-column field="prop" title="字段" width="100" tree-node></tiny-grid-column>
54
<tiny-grid-column field="type" title="类型" width="60"></tiny-grid-column>
6-
<tiny-grid-column field="description" show-overflow title="描述" width="100"></tiny-grid-column>
5+
<tiny-grid-column field="description" show-overflow title="描述" width="80"></tiny-grid-column>
76
<tiny-grid-column field="required" title="是否必填" width="66">
87
<template #default="data">
98
<span>{{ data.row?.required ? '是' : '否' }}</span>

packages/configurator/src/model-configurator/ModelConfigurator.vue

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
<div class="model-title">
1212
<span>绑定模型数据</span>
1313
<div class="right">
14-
<tiny-button type="primary" plain @click="setModel"> 确认 </tiny-button>
15-
<tiny-icon-close class="tiny-svg-size" @click="closePopover"></tiny-icon-close>
14+
<button-group>
15+
<tiny-button type="primary" @click="setModel"> 确认 </tiny-button>
16+
<tiny-icon-close class="tiny-svg-size" @click="closePopover"></tiny-icon-close>
17+
</button-group>
1618
</div>
1719
</div>
1820
<div class="model-wrap">
@@ -21,7 +23,7 @@
2123
</div>
2224
<div class="model-parameters">
2325
<tiny-grid :data="selectedModel?.parameters || []" min-height="296" max-height="560">
24-
<tiny-grid-column field="prop" title="字段名" width="180"> </tiny-grid-column>
26+
<tiny-grid-column field="prop" title="字段名" show-overflow> </tiny-grid-column>
2527
<tiny-grid-column field="label" title="标签名" show-overflow></tiny-grid-column>
2628
<tiny-grid-column field="originType" title="类型" show-overflow></tiny-grid-column>
2729
</tiny-grid>
@@ -179,6 +181,7 @@ import {
179181
import { iconUpWard, iconDownWard, iconClose, iconEdit } from '@opentiny/vue-icon'
180182
import { defineEmits, defineProps, ref, reactive, nextTick, computed, watch, onMounted } from 'vue'
181183
import { VueDraggableNext } from 'vue-draggable-next'
184+
import { ButtonGroup } from '@opentiny/tiny-engine-common'
182185
import MetaListItem from './MetaListItem.vue'
183186
import ModelSelect from '../model-common/ModelSelect.vue'
184187
import MetaChildItem from '../operator-group-configurator/MetaChildItem.vue'
@@ -502,12 +505,12 @@ onMounted(() => {
502505
border: 1px solid #e6e6e6;
503506
border-radius: 4px;
504507
.model-groups {
505-
width: 380px;
508+
width: 280px;
506509
padding: 12px;
507510
border-right: 1px solid #e6e6e6;
508511
}
509512
.model-parameters {
510-
width: 380px;
513+
width: 280px;
511514
padding: 12px;
512515
}
513516
}

packages/plugins/model-manager/src/Main.vue

Lines changed: 55 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
@close="pluginPanelClosed"
88
>
99
<template #header>
10-
<svg-button class="add-icon" name="add" placement="bottom" tips="新建模型" @click="handleAddModel"></svg-button>
1110
<svg-button
1211
class="flow-download-icon"
1312
name="flow-download"
@@ -17,6 +16,7 @@
1716
></svg-button>
1817
</template>
1918
<template #content>
19+
<tiny-button class="add-model" @click="handleAddModel"> <svg-icon name="add"></svg-icon>新建模型 </tiny-button>
2020
<div class="model-manager-search" clearable placeholder="搜索">
2121
<tiny-search v-model="localKeyword">
2222
<template #prefix>
@@ -30,16 +30,26 @@
3030
v-for="model in filteredModels"
3131
:key="model.id"
3232
:class="['model-item', { active: selectedModel?.id === model.id }]"
33-
@click="selectModel(model)"
3433
>
35-
<div class="model-info">
36-
<div class="model-name">{{ model.nameCn }}</div>
37-
<div class="model-english-name">{{ model.nameEn }}</div>
38-
<div class="model-desc">{{ model.description || '暂无描述' }}</div>
34+
<div class="item-label">
35+
<div class="item-name">
36+
<svg-icon name="plugin-icon-data" class="plugin-icon-data"> </svg-icon>
37+
{{ model.nameCn }}
38+
</div>
39+
<div class="item-handler">
40+
<svg-button
41+
class="set-page"
42+
:hoverBgColor="false"
43+
tips="设置模型"
44+
name="setting"
45+
@mousedown.stop.prevent="selectModel(model)"
46+
>
47+
</svg-button>
48+
</div>
3949
</div>
40-
<div class="model-actions">
50+
<!-- <div class="model-actions">
4151
<svg-icon name="delete" @click.stop="handleDeleteModel(model)"></svg-icon>
42-
</div>
52+
</div> -->
4353
</div>
4454
</template>
4555
<search-empty :isShow="!models.length" />
@@ -49,6 +59,7 @@
4959
<model-setting
5060
:model="selectedModel"
5161
:models="models"
62+
@deleteCallback="handleDeleteModel"
5263
@editCallback="editCallback"
5364
@exportModel="exportModel"
5465
></model-setting>
@@ -57,7 +68,7 @@
5768

5869
<script setup>
5970
import { ref, reactive, provide, computed, onMounted } from 'vue'
60-
import { TinySearch, Modal } from '@opentiny/vue'
71+
import { TinySearch, Modal, TinyButton } from '@opentiny/vue'
6172
import { IconSearch } from '@opentiny/vue-icon'
6273
import { PluginPanel, SvgButton, SearchEmpty } from '@opentiny/tiny-engine-common'
6374
import { useLayout } from '@opentiny/tiny-engine-meta-register'
@@ -193,7 +204,10 @@ onMounted(async () => {
193204
.plugin-modelmanager {
194205
height: 100%;
195206
width: 280px;
196-
207+
.add-model {
208+
margin: 0 12px 12px 12px;
209+
width: calc(100% - 24px);
210+
}
197211
.model-manager-search {
198212
padding: 0 12px 12px 12px;
199213
}
@@ -206,44 +220,43 @@ onMounted(async () => {
206220
font-size: var(--te-base-font-size-base);
207221
208222
.model-item {
209-
padding: 10px;
210-
display: flex;
211-
flex-direction: row;
212-
justify-content: space-between;
223+
box-shadow: var(--te-datasource-tabs-border-color) 0, -1px;
224+
height: 24px;
225+
line-height: 24px;
213226
align-items: center;
214-
215-
&:hover {
216-
background-color: var(--te-model-manage-draggable-row-bg-color-hover);
217-
color: var(--te-model-manage-draggable-text-color);
218-
}
219-
227+
display: grid;
228+
padding: 0 12px;
229+
position: relative;
230+
color: var(--te-datasource-list-main-text-color);
231+
cursor: pointer;
232+
&:hover,
220233
&.active {
221-
background-color: var(--te-model-manage-draggable-row-bg-color-hover);
222-
color: var(--te-model-manage-draggable-text-color);
223-
}
224-
225-
svg {
226-
cursor: pointer;
227-
}
228-
229-
.model-info {
230-
.model-name {
231-
font-weight: 600;
232-
margin-bottom: 2px;
233-
font-size: 14px;
234+
background: var(--te-datasource-list-text-color-hover);
235+
.item-handler {
236+
display: inline-block;
234237
}
235-
.model-english-name {
236-
font-size: 11px;
237-
margin-bottom: 4px;
238-
font-family: monospace;
238+
}
239+
.item-label {
240+
overflow: hidden;
241+
text-overflow: ellipsis;
242+
display: flex;
243+
align-items: center;
244+
justify-content: space-between;
245+
color: var(--te-datasource-list-item-text-color);
246+
.item-name {
247+
display: flex;
248+
align-items: center;
239249
}
240-
.model-desc {
241-
font-size: 12px;
242-
color: var(--te-model-manage-tip-text-color);
243-
display: -webkit-box;
244-
overflow: hidden;
250+
.plugin-icon-data {
251+
color: var(--te-datasource-list-item-icon-color);
252+
margin-right: 8px;
245253
}
246254
}
255+
.item-handler {
256+
height: 24px;
257+
line-height: 24px;
258+
display: none;
259+
}
247260
}
248261
}
249262
}

packages/plugins/model-manager/src/components/FieldManager.vue

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<template>
22
<div class="section">
3-
<tiny-button class="add-field-btn" size="mini" @click="$emit('add-field')"> <svg-icon name="add"></svg-icon> 添加字段 </tiny-button>
3+
<tiny-button class="add-field-btn" size="mini" @click="$emit('add-field')">
4+
<svg-icon name="add"></svg-icon> 添加字段
5+
</tiny-button>
46
<div class="field-table">
57
<tiny-grid
68
:data="model.parameters"
@@ -10,7 +12,6 @@
1012
ref="fieldGrid"
1113
style="height: 100%"
1214
>
13-
<tiny-grid-column type="index" width="60" title="序号"></tiny-grid-column>
1415
<tiny-grid-column type="expand" width="20">
1516
<template #default="{ row }">
1617
<div v-if="row.type === 'Enum'" class="expand-content">
@@ -63,15 +64,15 @@
6364
</div>
6465
</template>
6566
</tiny-grid-column>
66-
<tiny-grid-column field="prop" title="字段名称" width="120">
67+
<tiny-grid-column field="prop" title="字段名称" width="100">
6768
<template #default="{ row }">
6869
<div v-if="row.isEditing" class="editing-cell">
6970
<tiny-input v-model="row.prop" placeholder="请输入字段名称" size="small" />
7071
</div>
7172
<div v-else class="readonly-cell">{{ row.prop || '点击编辑' }}</div>
7273
</template>
7374
</tiny-grid-column>
74-
<tiny-grid-column field="type" title="类型" width="110">
75+
<tiny-grid-column field="type" title="类型" width="80">
7576
<template #default="{ row }">
7677
<div v-if="row.isEditing" class="editing-cell">
7778
<tiny-select v-model="row.type" size="small" @change="handleTypeChange(row)">
@@ -86,7 +87,7 @@
8687
<div v-else class="readonly-cell">{{ getFieldTypeLabel(row.type) }}</div>
8788
</template>
8889
</tiny-grid-column>
89-
<tiny-grid-column field="defaultValue" title="默认值" width="120">
90+
<tiny-grid-column field="defaultValue" title="默认值" width="100">
9091
<template #default="{ row }">
9192
<div v-if="row.isEditing" class="editing-cell">
9293
<tiny-input v-model="row.defaultValue" placeholder="请输入默认值" size="small" />
@@ -102,7 +103,7 @@
102103
<div v-else class="readonly-cell"><tiny-checkbox v-model="row.required" disabled /></div>
103104
</template>
104105
</tiny-grid-column>
105-
<tiny-grid-column field="description" title="描述" width="120">
106+
<tiny-grid-column field="description" title="描述" width="100">
106107
<template #default="{ row }">
107108
<div v-if="row.isEditing" class="editing-cell">
108109
<tiny-input v-model="row.description" placeholder="请输入字段描述" size="small" />

packages/plugins/model-manager/src/components/ModelBasicForm.vue

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
<template>
22
<div class="section">
3-
<tiny-form ref="ruleFormRef" :model="localValue" :rules="rules">
3+
<tiny-form
4+
ref="ruleFormRef"
5+
:model="localValue"
6+
:rules="rules"
7+
label-width="120px"
8+
validate-type="text"
9+
:inline-message="true"
10+
:label-align="true"
11+
label-position="top"
12+
>
413
<div class="form-item">
514
<tiny-form-item label="中文名称" prop="nameCn">
615
<tiny-input v-model="localValue.nameCn" placeholder="请输入模型中文名称" />

packages/plugins/model-manager/src/components/ModelSetting.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<button-group>
1111
<tiny-button @click="$emit('exportModel', selectedModel?.id)">导出SQL</tiny-button>
1212
<tiny-button type="primary" @click="saveModel">保存</tiny-button>
13+
<svg-button name="delete" v-if="selectedModel?.id" @click="$emit('deleteCallback', selectedModel)"></svg-button>
1314
<svg-button name="close" @click="closeModelSettingPanel"></svg-button>
1415
</button-group>
1516
</template>
@@ -45,7 +46,7 @@ import ModelBasicForm from './ModelBasicForm.vue'
4546
import FieldManager from './FieldManager.vue'
4647
import { createModel, updateModel } from '../composable/useModelManager'
4748
48-
const isShow = ref(false)
49+
const isShow = ref(false)
4950
5051
export const openModelSettingPanel = () => {
5152
isShow.value = true
@@ -76,7 +77,7 @@ export default {
7677
default: () => []
7778
}
7879
},
79-
emits: ['editCallback', 'exportModel'],
80+
emits: ['editCallback', 'exportModel', 'deleteCallback'],
8081
setup(props, { emit }) {
8182
const { PLUGIN_NAME } = useLayout()
8283
const activeName = ref(['general', 'fields'])

0 commit comments

Comments
 (0)