Skip to content

Commit 9daa93e

Browse files
committed
fix/model-driven
1 parent c12c321 commit 9daa93e

4 files changed

Lines changed: 62 additions & 28 deletions

File tree

packages/builtinComponent/src/components/BasePage.vue

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,12 +322,16 @@ const updateApi = (data = addFormData.value) => {
322322
if (!apiInfo) {
323323
return undefined
324324
}
325-
const id = data.id
326-
delete data.id
325+
const requestData = {}
326+
pageModel.value.parameters.forEach((item) => {
327+
if (data[item.prop]) {
328+
requestData[item.prop] = data[item.prop]
329+
}
330+
})
327331
return axios
328332
.post(apiInfo.url, {
329333
nameEn: pageModel.value.nameEn,
330-
data: data,
334+
data: requestData,
331335
params: { id }
332336
})
333337
.then((res) => {
@@ -385,6 +389,7 @@ const deleteApi = (evidence) => {
385389
message: '已删除',
386390
position: 'top-right'
387391
})
392+
queryApi()
388393
return res
389394
})
390395
.catch((err) => {

packages/builtinComponent/src/components/BaseTable.vue

Lines changed: 48 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ import {
6060
DatePicker as TinyDatePicker,
6161
Numeric as TinyNumeric,
6262
Pager as TinyPager,
63-
Popover as TinyPopover
63+
Popover as TinyPopover,
64+
Notify
6465
} from '@opentiny/vue'
6566
import * as tinyVueIcon from '@opentiny/vue-icon'
6667
import axios from 'axios'
@@ -174,25 +175,7 @@ const insertApi = (data = {}) => {
174175
})
175176
}
176177
177-
const updateApi = (data) => {
178-
const apiInfo = props.modelApis.find((api) => api.nameEn === 'updateApi')
179-
if (!apiInfo) {
180-
return undefined
181-
}
182-
const id = data.id
183-
delete data.id
184-
return axios
185-
.post(apiInfo.url, {
186-
nameEn: tableModel.value.nameEn,
187-
data: data,
188-
params: { id }
189-
})
190-
.catch((err) => {
191-
throw new Error(err)
192-
})
193-
}
194-
195-
const queryApi = (data) => {
178+
const queryApi = (data = {}) => {
196179
const apiInfo = props.modelApis.find((api) => api.nameEn === 'queryApi')
197180
if (!apiInfo) {
198181
return undefined
@@ -220,14 +203,56 @@ const queryApi = (data) => {
220203
})
221204
}
222205
206+
const updateApi = (data) => {
207+
const apiInfo = props.modelApis.find((api) => api.nameEn === 'updateApi')
208+
if (!apiInfo) {
209+
return undefined
210+
}
211+
const requestData = {}
212+
tableModel.value.parameters.forEach((item) => {
213+
if (data[item.prop]) {
214+
requestData[item.prop] = data[item.prop]
215+
}
216+
})
217+
return axios
218+
.post(apiInfo.url, {
219+
nameEn: tableModel.value.nameEn,
220+
data: requestData,
221+
params: { id: data.id }
222+
})
223+
.then((res) => {
224+
Notify({
225+
type: 'success',
226+
message: '修改成功',
227+
position: 'top-right'
228+
})
229+
queryApi()
230+
return res
231+
})
232+
.catch((err) => {
233+
throw new Error(err)
234+
})
235+
}
236+
223237
const deleteApi = (evidence) => {
224238
const apiInfo = props.modelApis.find((api) => api.nameEn === 'deleteApi')
225239
if (!apiInfo) {
226240
return undefined
227241
}
228-
return axios.post(apiInfo.url, { ...evidence, nameEn: tableModel.value.nameEn }).catch((err) => {
229-
throw new Error(err)
230-
})
242+
return axios
243+
.post(apiInfo.url, { ...evidence, nameEn: tableModel.value.nameEn })
244+
.then((res) => {
245+
Notify({
246+
type: 'success',
247+
message: '已删除',
248+
position: 'top-right'
249+
})
250+
queryApi()
251+
return res
252+
})
253+
.catch((err) => {
254+
throw new Error(err)
255+
})
231256
}
232257
233258
const exposedData = {

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
</div>
6262
</template>
6363
<script setup>
64-
import { ref, reactive, computed, defineProps, defineEmits, watch } from 'vue'
64+
import { ref, reactive, computed, defineProps, defineEmits, watch, onMounted } from 'vue'
6565
import {
6666
Button as TinyButton,
6767
Popover as TinyPopover,
@@ -219,6 +219,10 @@ watch(
219219
}
220220
}
221221
)
222+
223+
onMounted(() => {
224+
getModel()
225+
})
222226
</script>
223227
224228
<style lang="less" scoped>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
</template>
4040
<script>
4141
import { ref, watch, nextTick } from 'vue'
42-
import { Button, Collapse, CollapseItem } from '@opentiny/vue'
42+
import { Button, Collapse, CollapseItem, Notify } from '@opentiny/vue'
4343
import { PluginSetting, ButtonGroup, SvgButton } from '@opentiny/tiny-engine-common'
4444
import { useLayout } from '@opentiny/tiny-engine-meta-register'
4545
import ModelBasicForm from './ModelBasicForm.vue'

0 commit comments

Comments
 (0)