@@ -218,8 +218,8 @@ export default {
218218 this .applications = data .applications || [];
219219 })
220220 },
221- deleteFavoriteApp (favouritesId , index ){
222- api .fetch (` /dss/workspaces/${ this .workspaceId } /favorites/${ favouritesId } ` , ' delete' ).then (data => {
221+ deleteFavoriteApp (favoriteId , index ){
222+ api .fetch (` /dss/workspaces/${ this .workspaceId } /favorites/${ favoriteId } ` , ' delete' ).then (data => {
223223 this .favoriteApps .splice (index, 1 );
224224 })
225225 },
@@ -228,14 +228,20 @@ export default {
228228 this .$refs .dynamicForm .validate ((valid ) => {
229229 if (valid) {
230230 // this.addAppLoading = true;
231+ const menuApplicationId = parseInt (this .formDynamic .selectApp , 10 );
232+ const favoriteApp = this .findFavoriteAppsByMenuId (menuApplicationId);
233+ if (favoriteApp) {
234+ return this .$Message .error (` ${ this .$t (' message.workSpace.home.repeat' )} ` );
235+ }
231236 this .show = false ;
232- api .fetch (` /dss/workspaces/${ this .workspaceId } /favorites` , {menuApplicationId: parseInt ( this . formDynamic . selectApp , 10 ) },' post' ).then (data => {
237+ api .fetch (` /dss/workspaces/${ this .workspaceId } /favorites` , {menuApplicationId: menuApplicationId },' post' ).then (data => {
233238 const app = this .findAppByApplicationId (this .formDynamic .selectApp )
234239 this .favoriteApps .push ({
235240 ... app,
236- " id" : data .favouritesId ,
241+ " id" : data .favoriteId ,
237242 " menuApplicationId" : app .id , // application表里的id
238- })
243+ });
244+
239245 })
240246 }
241247 });
@@ -247,6 +253,12 @@ export default {
247253 return result;
248254 },
249255
256+ findFavoriteAppsByMenuId (menuId ){
257+ const arr = this .favoriteApps ;
258+ const result = arr .find (item => item .menuApplicationId == menuId);
259+ return result;
260+ },
261+
250262 flatApps (){
251263 const arr = [];
252264 this .applications .forEach (item => {
0 commit comments