Skip to content

Commit 940d3c0

Browse files
committed
Merge branch 'feat/model' of https://github.com/betterdancing/tiny-engine into feat/model
2 parents e768ac2 + e126088 commit 940d3c0

3 files changed

Lines changed: 39 additions & 36 deletions

File tree

packages/builtinComponent/src/components/BaseForm.vue

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{{ item.label }}
1111
</div>
1212
</template>
13-
<div v-if="item?.isModel && item.defaultValue !== null">
13+
<div v-if="item.isModel && item.defaultValue !== null">
1414
<tiny-form label-width="100" label-position="left" :model="modelData[item.prop]">
1515
<tiny-row>
1616
<tiny-col
@@ -49,7 +49,7 @@
4949
</div>
5050
</template>
5151
<script setup>
52-
import { ref, defineProps, defineEmits, defineExpose, computed, watch, reactive } from 'vue'
52+
import { ref, defineProps, defineExpose, computed, watch, reactive } from 'vue'
5353
import {
5454
Form as TinyForm,
5555
FormItem as TinyFormItem,
@@ -91,9 +91,7 @@ const props = defineProps({
9191
}
9292
})
9393
94-
const modelData = ref({})
95-
96-
const emit = defineEmits(['update:modelValue'])
94+
const modelData = ref()
9795
9896
const formRef = ref(null)
9997
@@ -205,19 +203,19 @@ watch(
205203
(value) => {
206204
if (value) {
207205
modelData.value = props.modelValue
208-
} else {
209-
initFormData()
210206
}
211207
},
212208
{ deep: true, immediate: true }
213209
)
214210
215211
watch(
216-
() => modelData.value,
217-
(value) => {
218-
emit('update:modelValue', value)
212+
() => props.serviceModel,
213+
() => {
214+
if (!modelData.value) {
215+
initFormData()
216+
}
219217
},
220-
{ deep: true }
218+
{ immediate: true }
221219
)
222220
223221
const exposedData = {

packages/builtinComponent/src/components/BasePage.vue

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@
157157
</div>
158158
</template>
159159
<script setup>
160-
import { ref, defineProps, defineEmits, defineExpose, computed, reactive, watch, useAttrs, onMounted } from 'vue'
160+
import { ref, computed, reactive, watch, useAttrs, onMounted } from 'vue'
161161
import {
162162
Form as TinyForm,
163163
FormItem as TinyFormItem,
@@ -220,19 +220,19 @@ const props = defineProps({
220220
type: Object
221221
}
222222
})
223-
224223
const emit = defineEmits(['update:searchFormData', 'update:tableData', 'update:editFormData'])
225224
226225
const formRef = ref(null)
227226
228227
const colNumber = computed(() => 12 / props.layout)
228+
229229
const insideColNumber = computed(() => (props.layout === 1 ? 6 : 12))
230230
231231
const pageModel = computed(() => props.serviceModel)
232232
233-
const formData = ref({})
233+
const formData = ref()
234234
235-
const addFormData = ref({})
235+
const addFormData = ref()
236236
237237
const boxVisibility = ref(false)
238238
@@ -431,7 +431,7 @@ const initEditFormData = () => {
431431
]
432432
})
433433
)
434-
emit('update:editFormData', formData.value)
434+
emit('update:editFormData', addFormData.value)
435435
}
436436
437437
const resetSearchForm = () => {
@@ -478,8 +478,6 @@ watch(
478478
(value) => {
479479
if (value) {
480480
formData.value = props.searchFormData
481-
} else {
482-
initSearchFormData()
483481
}
484482
},
485483
{ deep: true, immediate: true }
@@ -490,13 +488,24 @@ watch(
490488
(value) => {
491489
if (value) {
492490
addFormData.value = props.editFormData
493-
} else {
494-
initEditFormData()
495491
}
496492
},
497493
{ deep: true, immediate: true }
498494
)
499495
496+
watch(
497+
() => props.serviceModel,
498+
() => {
499+
if (!formData.value) {
500+
initSearchFormData()
501+
}
502+
if (!addFormData.value) {
503+
initEditFormData()
504+
}
505+
},
506+
{ immediate: true }
507+
)
508+
500509
onMounted(() => {
501510
queryApi()
502511
})

packages/builtinComponent/src/components/BaseTable.vue

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@
44
<template v-else>
55
<tiny-grid ref="gridRef" :data="tableData" v-bind="gridState">
66
<tiny-grid-column v-if="gridState.selectedEnabled" type="selection" width="60"></tiny-grid-column>
7-
<template v-for="item in gridColumns" :key="item.prop">
8-
<tiny-grid-column :field="item.prop" :title="item.label" :editor="item.editor"></tiny-grid-column>
9-
</template>
7+
<tiny-grid-column
8+
v-for="item in gridColumns"
9+
:key="item.prop"
10+
:field="item.prop"
11+
:title="item.label"
12+
:editor="item.editor"
13+
></tiny-grid-column>
14+
1015
<tiny-grid-column v-if="gridState.rowOperationEnabled" field="operation" title="操作">
1116
<template #default="data">
1217
<tiny-button
@@ -15,7 +20,7 @@
1520
type="text"
1621
@click="operate?.handler(data.row, data.rowIndex, exposedData)"
1722
>
18-
<div v-if="operate?.itemVisible">
23+
<div v-if="operate.itemVisible">
1924
<tiny-popover
2025
v-if="gridState.useIconOperation && operate.icon"
2126
width="auto"
@@ -43,7 +48,7 @@
4348
</div>
4449
</template>
4550
<script setup>
46-
import { defineProps, defineEmits, defineExpose, computed, ref, reactive, watch, useAttrs } from 'vue'
51+
import { defineProps, defineExpose, computed, ref, reactive, useAttrs } from 'vue'
4752
import {
4853
Grid as TinyGrid,
4954
GridColumn as TinyGridColumn,
@@ -93,8 +98,6 @@ const props = defineProps({
9398
}
9499
})
95100
96-
const emit = defineEmits(['update:modelValue'])
97-
98101
const attrs = useAttrs()
99102
100103
const gridRef = ref()
@@ -147,7 +150,8 @@ const rowOperationList = computed(() => {
147150
return props.rowOperations?.value.map((operate) => {
148151
return {
149152
...operate,
150-
icon: operate.icon ? tinyVueIcon?.[operate.icon]() : ''
153+
icon: operate.icon ? tinyVueIcon?.[operate.icon]() : '',
154+
itemVisible: 'itemVisible' in operate ? operate.itemVisible : true
151155
}
152156
})
153157
})
@@ -237,14 +241,6 @@ const deleteApi = (evidence) => {
237241
})
238242
}
239243
240-
watch(
241-
() => tableData.value,
242-
(value) => {
243-
emit('update:modelValue', value)
244-
},
245-
{ deep: true }
246-
)
247-
248244
const exposedData = {
249245
tableData: () => tableData.value,
250246
gridRef,

0 commit comments

Comments
 (0)