Skip to content

Commit c6ac20d

Browse files
committed
fix/model-driven-bugs
1 parent 5c4b141 commit c6ac20d

4 files changed

Lines changed: 58 additions & 37 deletions

File tree

packages/common/js/import-map.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"@vueuse/shared": "${VITE_CDN_DOMAIN}/@vueuse/shared${versionDelimiter}9.6.0${fileDelimiter}/index.mjs",
1010
"axios": "${VITE_CDN_DOMAIN}/axios${versionDelimiter}1.0.0${fileDelimiter}/dist/esm/axios.js",
1111
"@opentiny/tiny-engine-i18n-host": "${VITE_CDN_DOMAIN}/@opentiny/tiny-engine-i18n-host${versionDelimiter}^2${fileDelimiter}/dist/lowcode-design-i18n-host.es.js",
12-
"@opentiny/tiny-engine-builtin-component": "${VITE_CDN_DOMAIN}/@opentiny/tiny-engine-builtin-component${versionDelimiter}^2.9.0${fileDelimiter}/dist/index.mjs",
12+
"@opentiny/tiny-engine-builtin-component": "${VITE_CDN_DOMAIN}/@opentiny/tiny-engine-builtin-component${versionDelimiter}^2.10.0-alpha.2${fileDelimiter}/dist/index.mjs",
1313
"vue-demi": "${VITE_CDN_DOMAIN}/vue-demi${versionDelimiter}0.13.11${fileDelimiter}/lib/index.mjs",
1414
"pinia": "${VITE_CDN_DOMAIN}/pinia${versionDelimiter}2.0.22${fileDelimiter}/dist/pinia.esm-browser.js",
1515
"@opentiny/vue": "${VITE_CDN_DOMAIN}/@opentiny/vue-runtime${versionDelimiter}~3.20${fileDelimiter}/dist3/tiny-vue-pc.mjs",

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
<tiny-icon-edit @click="openPopover(item, index)"></tiny-icon-edit>
6060
</div>
6161
</div>
62+
<div v-else class="model-api-empty">当前还未选择模型</div>
6263
</template>
6364
<script setup>
6465
import { ref, reactive, computed, defineProps, defineEmits, watch, onMounted } from 'vue'
@@ -84,10 +85,6 @@ const props = defineProps({
8485
type: Object,
8586
default: () => ({})
8687
},
87-
buttonText: {
88-
type: String,
89-
default: '选择模型方法'
90-
},
9188
// 协议类型
9289
renderType: {
9390
type: String,
@@ -316,4 +313,8 @@ onMounted(() => {
316313
}
317314
}
318315
}
316+
317+
.model-api-empty {
318+
color: var(--te-common-text-secondary);
319+
}
319320
</style>

packages/configurator/src/model-common/ModelSelect.vue

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
</div>
3333
</template>
3434
<script>
35-
import { ref, reactive, computed, watch } from 'vue'
35+
import { ref, reactive, watch } from 'vue'
3636
import { Search, Grid, GridColumn, Pager } from '@opentiny/vue'
3737
import { iconSearch } from '@opentiny/vue-icon'
3838
import { getModelList } from '../model-common/http'
@@ -51,9 +51,6 @@ export default {
5151
type: Number,
5252
default: 10
5353
},
54-
data: {
55-
type: Object
56-
},
5754
isShow: {
5855
type: Boolean,
5956
default: false
@@ -75,25 +72,15 @@ export default {
7572
// 搜索
7673
const searchWords = ref('')
7774
78-
const selectedModel = computed(() => props.data)
79-
8075
const selectModel = async (data) => {
8176
currentSelectedModel.value = await handleSelectedModelParameters(data.row)
8277
emit('modelSelect', currentSelectedModel.value)
8378
}
8479
8580
const getModels = () => {
86-
if (selectedModel.value) {
87-
searchWords.value = selectedModel.value.name
88-
}
8981
getModelList(pagerState.currentPage, { nameCn: searchWords.value }).then(async (res) => {
9082
modelList.value = res.records
9183
pagerState.total = res.total
92-
if (selectedModel.value) {
93-
const radioRow = res.records.find((item) => item.id === selectedModel.value.id)
94-
modelListRef.value.setRadioRow(radioRow)
95-
await selectModel({ row: radioRow })
96-
}
9784
})
9885
}
9986

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

Lines changed: 51 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,15 @@
1919
</div>
2020
<div class="model-wrap">
2121
<div class="model-groups">
22-
<model-select @model-select="getModel" :data="modelDetail" :isShow="isShow"></model-select>
22+
<model-select @model-select="getModel" :isShow="isShow"></model-select>
2323
</div>
2424
<div class="model-parameters">
25+
<div v-if="selectedModel?.name" class="bind-model-info">
26+
<span class="bind-info-title"
27+
>当前选中的模型:
28+
<span class="bind-info-name">{{ selectedModel?.name }} | {{ selectedModel?.nameEn }}</span>
29+
</span>
30+
</div>
2531
<tiny-grid :data="selectedModel?.parameters || []" min-height="296" max-height="560">
2632
<tiny-grid-column field="prop" title="字段名" show-overflow> </tiny-grid-column>
2733
<tiny-grid-column field="label" title="标签名" show-overflow></tiny-grid-column>
@@ -38,7 +44,7 @@
3844
>已绑定:
3945
<span class="bind-info-name">{{ modelDetail?.name }} | {{ modelDetail?.nameEn }}</span>
4046
</span>
41-
<svg-icon name="delete"></svg-icon>
47+
<svg-icon name="delete" @click="unbindModel"></svg-icon>
4248
</div>
4349
</template>
4450
</tiny-popover>
@@ -186,6 +192,7 @@ import { iconUpWard, iconDownWard, iconClose, iconEdit } from '@opentiny/vue-ico
186192
import { defineEmits, defineProps, ref, reactive, nextTick, computed, watch, onMounted } from 'vue'
187193
import { VueDraggableNext } from 'vue-draggable-next'
188194
import { ButtonGroup } from '@opentiny/tiny-engine-common'
195+
import { useCanvas, useModal } from '@opentiny/tiny-engine-meta-register'
189196
import MetaListItem from './MetaListItem.vue'
190197
import ModelSelect from '../model-common/ModelSelect.vue'
191198
import MetaChildItem from '../operator-group-configurator/MetaChildItem.vue'
@@ -222,7 +229,7 @@ const isShow = ref(false)
222229
const searchUnused = ref('')
223230
const searchValue = ref('')
224231
225-
const selectedModel = ref()
232+
const selectedModel = ref(null)
226233
const originModelData = ref()
227234
228235
const getModel = (data) => {
@@ -283,10 +290,12 @@ const state = reactive({
283290
})
284291
285292
const openPopover = () => {
293+
selectedModel.value = modelDetail.value
286294
isShow.value = true
287295
}
288296
289297
const closePopover = () => {
298+
selectedModel.value = null
290299
isShow.value = false
291300
}
292301
@@ -304,6 +313,26 @@ const setModel = async () => {
304313
closePopover()
305314
}
306315
316+
// 解除模型绑定
317+
const unbindModel = () => {
318+
useModal().confirm({
319+
title: '提示',
320+
message: '移除绑定将清除所有绑定的模型信息,是否继续?',
321+
exec: () => {
322+
const currentSchema = useCanvas().getCurrentSchema()
323+
const { clearSelect } = useCanvas().canvasApi.value
324+
delete currentSchema.props.serviceModel
325+
delete currentSchema.props.modelApis
326+
useCanvas().operateNode({
327+
type: 'updateAttributes',
328+
id: currentSchema.id,
329+
value: { props: currentSchema.props }
330+
})
331+
clearSelect()
332+
}
333+
})
334+
}
335+
307336
const editItem = (data) => {
308337
state.currentIndex = data.index
309338
}
@@ -401,21 +430,6 @@ onMounted(() => {
401430
}
402431
.model-name-warp {
403432
border: 1px solid var(--ti-lowcode-component-input-border-color);
404-
405-
.bind-model-info {
406-
display: flex;
407-
justify-content: space-between;
408-
align-items: center;
409-
gap: 8px;
410-
line-height: 28px;
411-
412-
.bind-info-title {
413-
color: var(--te-common-text-secondary);
414-
.bind-info-name {
415-
font-weight: 600;
416-
}
417-
}
418-
}
419433
}
420434
.meta-model-title {
421435
color: #808080;
@@ -496,6 +510,21 @@ onMounted(() => {
496510
}
497511
}
498512
}
513+
514+
.bind-model-info {
515+
display: flex;
516+
justify-content: space-between;
517+
align-items: center;
518+
gap: 8px;
519+
line-height: 28px;
520+
521+
.bind-info-title {
522+
color: var(--te-common-text-secondary);
523+
.bind-info-name {
524+
font-weight: 600;
525+
}
526+
}
527+
}
499528
.model-title {
500529
display: flex;
501530
justify-content: space-between;
@@ -531,6 +560,10 @@ onMounted(() => {
531560
.model-parameters {
532561
width: 280px;
533562
padding: 12px;
563+
564+
.tiny-grid {
565+
margin-top: 8px;
566+
}
534567
}
535568
}
536569
</style>

0 commit comments

Comments
 (0)