Skip to content

Commit e6f8dd3

Browse files
committed
feat/model-driven
1 parent 33b07b1 commit e6f8dd3

4 files changed

Lines changed: 20 additions & 102 deletions

File tree

packages/builtinComponent/src/components/BaseForm.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,18 @@ const queryApi = ({ currentPage, pageSize, data } = {}) => {
151151
if (!apiInfo) {
152152
return undefined
153153
}
154+
// 处理查询参数
155+
const params = Object.fromEntries(pageModel.value.parameters.map((item) => [item.prop, null]))
154156
return getMetaApi(META_SERVICE.Http)
155157
.post(apiInfo.url, {
156158
currentPage: currentPage || 1,
157159
pageSize: pageSize || 10,
158160
nameEn: formModel.value.nameEn,
159161
nameCn: formModel.value.nameCn,
160-
params: data || modelData.value
162+
params: {
163+
...params,
164+
...(data || modelData.value)
165+
}
161166
})
162167
.then((res) => {
163168
return res

packages/builtinComponent/src/components/BasePage.vue

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,6 @@ const insertApi = (data = addFormData.value) => {
305305
return getMetaApi(META_SERVICE.Http)
306306
.post(apiInfo.url, { nameEn: pageModel.value.nameEn, params: data })
307307
.then((res) => {
308-
console.log(res)
309308
Notify({
310309
type: 'success',
311310
message: '新增成功',
@@ -332,7 +331,6 @@ const updateApi = (data = addFormData.value) => {
332331
params: { id }
333332
})
334333
.then((res) => {
335-
console.log(res)
336334
Notify({
337335
type: 'success',
338336
message: '修改成功',
@@ -350,16 +348,20 @@ const queryApi = ({ currentPage, pageSize, data } = {}) => {
350348
if (!apiInfo) {
351349
return undefined
352350
}
351+
// 处理查询参数
352+
const params = Object.fromEntries(pageModel.value.parameters.map((item) => [item.prop, null]))
353353
return getMetaApi(META_SERVICE.Http)
354354
.post(apiInfo.url, {
355355
currentPage: currentPage || 1,
356356
pageSize: pageSize || 10,
357357
nameEn: pageModel.value.nameEn,
358358
nameCn: pageModel.value.nameCn,
359-
params: data
359+
params: {
360+
...params,
361+
...data
362+
}
360363
})
361364
.then((res) => {
362-
console.log(res)
363365
tableData.value = res.list
364366
pagerState.total = res.total
365367
emit('update:tableData', tableData.value)
@@ -378,7 +380,6 @@ const deleteApi = (evidence) => {
378380
return getMetaApi(META_SERVICE.Http)
379381
.post(apiInfo.url, { ...evidence, nameEn: pageModel.value.nameEn })
380382
.then((res) => {
381-
console.log(res)
382383
Notify({
383384
type: 'success',
384385
message: '已删除',

packages/builtinComponent/src/components/BaseTable.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,18 @@ const queryApi = (
207207
if (!apiInfo) {
208208
return undefined
209209
}
210+
// 处理查询参数
211+
const params = Object.fromEntries(tableModel.value.parameters.map((item) => [item.prop, null]))
210212
return getMetaApi(META_SERVICE.Http)
211213
.post(apiInfo.url, {
212214
currentPage: currentPage || 1,
213215
pageSize: pageSize || 10,
214216
nameEn: tableModel.value.nameEn,
215217
nameCn: tableModel.value.nameCn,
216-
params: data
218+
params: {
219+
...params,
220+
...data
221+
}
217222
})
218223
.then((res) => {
219224
tableData.value = res.list

packages/configurator/src/nested-property-configurator/NestedPropertyConfigurator.vue

Lines changed: 2 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
<template>
22
<div class="object-group-container">
3-
<button @click="insertApi">新增</button>
4-
<button @click="updateApi">修改</button>
5-
<button @click="queryApi">查询</button>
6-
<button @click="deleteApi">删除</button>
73
<div class="overall-conf-wrap">
84
<component
95
:is="CodeConfigurator"
@@ -31,8 +27,7 @@
3127
<script>
3228
import { ref, computed } from 'vue'
3329
import { ConfigItem } from '@opentiny/tiny-engine-common'
34-
35-
import { getConfigurator, getMetaApi, META_SERVICE } from '@opentiny/tiny-engine-meta-register'
30+
import { getConfigurator } from '@opentiny/tiny-engine-meta-register'
3631
3732
export default {
3833
name: 'NestedPropertyConfigurator',
@@ -47,90 +42,6 @@ export default {
4742
},
4843
emits: ['update:modelValue'],
4944
setup(props, { emit }) {
50-
const insertApi = () => {
51-
return getMetaApi(META_SERVICE.Http)
52-
.post('/platform-center/api/model-data/insertApi', {
53-
nameEn: 'staff',
54-
params: {
55-
id: 122,
56-
name: 'leon',
57-
status: '1'
58-
}
59-
})
60-
.then((res) => {
61-
console.log(res)
62-
Notify({
63-
type: 'success',
64-
message: '新增成功',
65-
position: 'top-right'
66-
})
67-
return res
68-
})
69-
.catch((err) => {
70-
throw new Error(err)
71-
})
72-
}
73-
74-
const updateApi = () => {
75-
return getMetaApi(META_SERVICE.Http)
76-
.post('/platform-center/api/model-data/updateApi', {
77-
nameEn: 'staff',
78-
data: {
79-
name: 'jeff',
80-
status: '1'
81-
},
82-
params: { id: 122 }
83-
})
84-
.then((res) => {
85-
console.log(res)
86-
Notify({
87-
type: 'success',
88-
message: '修改成功',
89-
position: 'top-right'
90-
})
91-
return res
92-
})
93-
.catch((err) => {
94-
throw new Error(err)
95-
})
96-
}
97-
98-
const queryApi = () => {
99-
return getMetaApi(META_SERVICE.Http)
100-
.post('/platform-center/api/model-data/queryApi', {
101-
currentPage: 1,
102-
pageSize: 10,
103-
nameEn: 'staff',
104-
nameCn: '员工',
105-
params: {
106-
name: null
107-
}
108-
})
109-
.then((res) => {
110-
console.log(res)
111-
return res
112-
})
113-
.catch((err) => {
114-
throw new Error(err)
115-
})
116-
}
117-
118-
const deleteApi = () => {
119-
return getMetaApi(META_SERVICE.Http)
120-
.post('/platform-center/api/model-data/deleteApi', { id: 122, nameEn: 'staff' })
121-
.then((res) => {
122-
console.log(res)
123-
Notify({
124-
type: 'success',
125-
message: '已删除',
126-
position: 'top-right'
127-
})
128-
return res
129-
})
130-
.catch((err) => {
131-
throw new Error(err)
132-
})
133-
}
13445
const CodeConfigurator = getConfigurator('CodeConfigurator')
13546
const bindValue = ref(props.meta.widget.props?.modelValue)
13647
const properties = computed(() => {
@@ -159,11 +70,7 @@ export default {
15970
bindValue,
16071
properties,
16172
onOptionsUpdate,
162-
itemChange,
163-
insertApi,
164-
queryApi,
165-
deleteApi,
166-
updateApi
73+
itemChange
16774
}
16875
}
16976
}

0 commit comments

Comments
 (0)