@@ -156,6 +156,14 @@ const methodBasicData = reactive({
156156const selectedModel = ref ()
157157const selectedFunction = ref ()
158158
159+ const getModel = async () => {
160+ const modelId = useCanvas ().getCurrentSchema ().props ? .serviceModel ? .id
161+ if (modelId) {
162+ selectedModel .value = await getModelDetail (modelId)
163+ methodBasicData .method = ' post'
164+ }
165+ }
166+
159167const openPopover = () => {
160168 isShow .value = true
161169 getModel ()
@@ -165,17 +173,6 @@ const closePopover = () => {
165173 isShow .value = false
166174}
167175
168- const getModel = () => {
169- const modelId = useCanvas ().getCurrentSchema ().props ? .serviceModel ? .id
170- if (modelId) {
171- getModelDetail (modelId).then (res => {
172- console .log (res)
173- })
174- selectedModel .value = useCanvas ().getCurrentSchema ().props .serviceModel
175- methodBasicData .method = ' post'
176- }
177- }
178-
179176const setModelFunction = async () => {
180177 ruleFormRef .value .validate ().then (() => {
181178 if (modelValue .value .find ((item ) => item .name === selectedFunction .value .name )) {
@@ -211,20 +208,18 @@ const selectModelFunction = (data) => {
211208
212209watch (
213210 () => useCanvas ().getCurrentSchema ().props .serviceModel ,
214- (model ) => {
215- console .log (model)
211+ async (model ) => {
216212 if (model) {
217- getModel ()
218- // modelValue.value = model.method.map((api) => {
219- // return {
220- // url: `${model.baseUrl}/${api.nameEn}`,
221- // method: 'post',
222- // name: api.name,
223- // nameEn: api.nameEn
224- // }
225- // })
226- // 添加增删改查方法
227- // emit('update:modelValue', modelValue.value)
213+ await getModel ()
214+ modelValue .value = selectedModel .value .method .map ((api ) => {
215+ return {
216+ url: ` ${ model .baseUrl } /${ api .nameEn } ` ,
217+ method: ' post' ,
218+ name: api .name ,
219+ nameEn: api .nameEn
220+ }
221+ })
222+ emit (' update:modelValue' , modelValue .value )
228223 }
229224 }
230225)
0 commit comments