5555 </tiny-col >
5656 </tiny-row >
5757 </tiny-form >
58- <div >
58+ <div class = " operator-group " >
5959 <tiny-button type =" primary" :size =" pageState?.size" @click =" addRow" > 新增 </tiny-button >
6060 <tiny-button :size =" pageState?.size" @click =" search" > 搜索 </tiny-button >
6161 <tiny-button :size =" pageState?.size" @click =" resetSearchForm" > 重置 </tiny-button >
@@ -179,7 +179,7 @@ import {
179179 Notify
180180} from ' @opentiny/vue'
181181import * as tinyVueIcon from ' @opentiny/vue-icon'
182- import { getMetaApi , META_SERVICE } from ' @opentiny/tiny-engine-meta-register '
182+ import axios from ' axios '
183183
184184const props = defineProps ({
185185 style: {
@@ -302,9 +302,17 @@ const insertApi = (data = addFormData.value) => {
302302 if (! apiInfo) {
303303 return undefined
304304 }
305- return getMetaApi ( META_SERVICE . Http )
305+ return axios
306306 .post (apiInfo .url , { nameEn: pageModel .value .nameEn , params: data })
307307 .then ((res ) => {
308+ if (res .data .error ) {
309+ Notify ({
310+ type: ' error' ,
311+ message: res .data .error .message ,
312+ position: ' top-right'
313+ })
314+ return
315+ }
308316 Notify ({
309317 type: ' success' ,
310318 message: ' 新增成功' ,
@@ -322,15 +330,27 @@ const updateApi = (data = addFormData.value) => {
322330 if (! apiInfo) {
323331 return undefined
324332 }
325- const id = data .id
326- delete data .id
327- return getMetaApi (META_SERVICE .Http )
333+ const requestData = {}
334+ pageModel .value .parameters .forEach ((item ) => {
335+ if (data[item .prop ]) {
336+ requestData[item .prop ] = data[item .prop ]
337+ }
338+ })
339+ return axios
328340 .post (apiInfo .url , {
329341 nameEn: pageModel .value .nameEn ,
330- data: data ,
331- params: { id }
342+ data: requestData ,
343+ params: { id: data . id }
332344 })
333345 .then ((res ) => {
346+ if (res .data .error ) {
347+ Notify ({
348+ type: ' error' ,
349+ message: res .data .error .message ,
350+ position: ' top-right'
351+ })
352+ return
353+ }
334354 Notify ({
335355 type: ' success' ,
336356 message: ' 修改成功' ,
@@ -350,7 +370,7 @@ const queryApi = (data = formData.value) => {
350370 }
351371 // 处理查询参数
352372 const params = Object .fromEntries (pageModel .value .parameters .map ((item ) => [item .prop , null ]))
353- return getMetaApi ( META_SERVICE . Http )
373+ return axios
354374 .post (apiInfo .url , {
355375 currentPage: pagerState .currentPage || 1 ,
356376 pageSize: pagerState .pageSize || 10 ,
@@ -362,8 +382,16 @@ const queryApi = (data = formData.value) => {
362382 }
363383 })
364384 .then ((res ) => {
365- tableData .value = res .list
366- pagerState .total = res .total
385+ if (res .data .error ) {
386+ Notify ({
387+ type: ' error' ,
388+ message: res .data .error .message ,
389+ position: ' top-right'
390+ })
391+ return
392+ }
393+ tableData .value = res .data .data .list
394+ pagerState .total = res .data .data .total
367395 emit (' update:tableData' , tableData .value )
368396 return res
369397 })
@@ -377,14 +405,23 @@ const deleteApi = (evidence) => {
377405 if (! apiInfo) {
378406 return undefined
379407 }
380- return getMetaApi ( META_SERVICE . Http )
408+ return axios
381409 .post (apiInfo .url , { ... evidence, nameEn: pageModel .value .nameEn })
382410 .then ((res ) => {
411+ if (res .data .error ) {
412+ Notify ({
413+ type: ' error' ,
414+ message: res .data .error .message ,
415+ position: ' top-right'
416+ })
417+ return
418+ }
383419 Notify ({
384420 type: ' success' ,
385421 message: ' 已删除' ,
386422 position: ' top-right'
387423 })
424+ queryApi ()
388425 return res
389426 })
390427 .catch ((err ) => {
@@ -440,6 +477,7 @@ const initEditFormData = () => {
440477
441478const resetSearchForm = () => {
442479 initSearchFormData ()
480+ queryApi ()
443481}
444482
445483const addRow = () => {
@@ -534,4 +572,8 @@ defineExpose({
534572 text- align: center;
535573 line- height: 40px ;
536574}
575+
576+ .operator - group {
577+ margin- bottom: 10px ;
578+ }
537579< / style>
0 commit comments