Explorar el Código

fixed:提示不能使用alert,使用ElMessage

zhaozy25 %!s(int64=3) %!d(string=hace) años
padre
commit
4e79ab7d41

+ 45 - 26
2022/aiot-evaluate/src/views/settings/ApiResourceManagement.vue

@ -132,11 +132,6 @@ const pageData = ref({
132 132
  }],
133 133
  tableAttrs: {
134 134
    'row-key': 'name'
135
  },
136
  page: {
137
    num: 1,
138
    size: 25,
139
    total: 100
140 135
  }
141 136
});
142 137
@ -298,10 +293,9 @@ const getPermissionData = async (params) => {
298 293
    .then((res) => {
299 294
      console.log('资源数据:', res.data.data);
300 295
      pageData.value.tableData = res.data.data;
301
      pageData.value.page.total = res;
302 296
    })
303
    .catch((err) => {
304
      console.log(err);
297
    .catch((e) => {
298
      ElMessage.error('获取资源数据失败');
305 299
    });
306 300
};
307 301
getPermissionData();
@ -337,8 +331,8 @@ const getClientData = async () => {
337 331
        }
338 332
      });
339 333
    })
340
    .catch((err) => {
341
      console.log(err);
334
    .catch((e) => {
335
      ElMessage.error('获取应用数据失败');
342 336
    });
343 337
};
344 338
getClientData();
@ -349,13 +343,12 @@ const createPermission = async (params) => {
349 343
    .then((res) => {
350 344
      console.log(res);
351 345
      getPermissionData();
346
      cancelDialog();
352 347
    })
353
    .catch((error) => {
354
      alert(error);
348
    .catch((e) => {
349
      ElMessage.error('新建API资源失败');
355 350
    })
356
    .finally(() => {
357
      cancelDialog();
358
    });
351
    .finally(() => {});
359 352
};
360 353
361 354
// 更新API资源
@ -365,13 +358,12 @@ const changePermission = async (params) => {
365 358
    .then((res) => {
366 359
      console.log(res);
367 360
      getPermissionData();
361
      cancelDialog();
368 362
    })
369
    .catch((error) => {
370
      alert(error);
363
    .catch((e) => {
364
      ElMessage.error('更新API资源失败');
371 365
    })
372
    .finally(() => {
373
      cancelDialog();
374
    });
366
    .finally(() => {});
375 367
};
376 368
377 369
// 删除API资源
@ -382,8 +374,8 @@ const deletePermission = async(code) => {
382 374
    .then((res) => {
383 375
      console.log(res);
384 376
    })
385
    .catch((error) => {
386
      alert(error);
377
    .catch((e) => {
378
      ElMessage.error('删除API资源失败');
387 379
    })
388 380
    .finally(() => {
389 381
      getPermissionData();
@ -398,8 +390,8 @@ const queryByType = async (param) => {
398 390
      console.log(res.data.data);
399 391
      pageData.value.tableData.value = res.data.data;
400 392
    })
401
    .catch((err) => {
402
      console.log(err);
393
    .catch((e) => {
394
      ElMessage.error('根据Type查询Api资源失败');
403 395
    });
404 396
};
405 397
@ -408,8 +400,18 @@ function addApi () {
408 400
  dialogData.value.drawerData.isOpen = true;
409 401
  dialogData.value.drawerData.type = 'new';
410 402
  dialogData.value.drawerData.title = '新建API资源';
411
  dialogData.value.forms.map((item) => {
403
  dialogData.value?.forms.map((item) => {
412 404
    item.value = '';
405
    if (item.name === 'type') {
406
      item.value = 1;
407
      dialogData.value?.forms.map((item) => {
408
        if (item.name === 'uri') {
409
          item.value = '';
410
          item.label = '';
411
          item.type = '';
412
        }
413
      });
414
    }
413 415
  });
414 416
}
415 417
@ -420,7 +422,6 @@ function editRow (row) {
420 422
  dialogData.value.drawerData.isOpen = true;
421 423
  console.log(row);
422 424
  dialogData.value.forms.map((item) => {
423
    // console.log(item);
424 425
    if (item.name === 'id') {
425 426
      item.value = row.id;
426 427
    }
@ -486,6 +487,24 @@ function confirmDialog (value) {
486 487
487 488
const changeEvent = (form) => {
488 489
  console.log(form);
490
  if (form.name === 'type') {
491
    if (form.value === 1) {
492
      dialogData.value?.forms.map((item) => {
493
        if (item.name === 'uri') {
494
          item.value = '';
495
          item.label = '';
496
          item.type = '';
497
        }
498
      });
499
    } else if (form.value === 2) {
500
      dialogData.value?.forms.map((item) => {
501
        if (item.name === 'uri') {
502
          item.label = '资源路径';
503
          item.type = 'input';
504
        }
505
      });
506
    }
507
  }
489 508
};
490 509
491 510
const blurEvent = (form) => {

+ 16 - 18
2022/aiot-evaluate/src/views/settings/ApplicationManagement.vue

@ -237,8 +237,8 @@ const getClientData = async () => {
237 237
      console.log('应用数据:', res.data.data);
238 238
      pageData.value.tableData = res.data.data;
239 239
    })
240
    .catch((err) => {
241
      console.log(err);
240
    .catch((e) => {
241
      ElMessage.error('获取应用数据失败');
242 242
    });
243 243
};
244 244
// getClientData();
@ -261,8 +261,8 @@ const getRoleData = async () => {
261 261
        }
262 262
      });
263 263
    })
264
    .catch((err) => {
265
      console.log(err);
264
    .catch((e) => {
265
      ElMessage.error('获取角色数据失败');
266 266
    });
267 267
};
268 268
getRoleData();
@ -274,13 +274,12 @@ const createClient = async (params) => {
274 274
    .then((res) => {
275 275
      console.log(res);
276 276
      getClientData();
277
      cancelDialog();
277 278
    })
278
    .catch((error) => {
279
      alert(error);
279
    .catch((e) => {
280
      ElMessage.error('新建应用失败');
280 281
    })
281
    .finally(() => {
282
      cancelDialog();
283
    });
282
    .finally(() => {});
284 283
};
285 284
286 285
// 更新应用
@ -290,13 +289,12 @@ const changeClient = async(params) => {
290 289
    .then((res) => {
291 290
      console.log(res);
292 291
      getClientData();
292
      cancelDialog();
293 293
    })
294
    .catch((error) => {
295
      alert(error);
294
    .catch((e) => {
295
      ElMessage.error('更新应用失败');
296 296
    })
297
    .finally(() => {
298
      cancelDialog();
299
    });
297
    .finally(() => {});
300 298
};
301 299
302 300
// 删除应用
@ -306,8 +304,8 @@ const deleteClient = async(clientId) => {
306 304
    .then((res) => {
307 305
      console.log(res);
308 306
    })
309
    .catch((error) => {
310
      alert(error);
307
    .catch((e) => {
308
      ElMessage.error('删除应用失败');
311 309
    })
312 310
    .finally(() => {
313 311
      getClientData();
@ -323,8 +321,8 @@ const listClientPage = async (params) => {
323 321
      pageData.value.tableData = res.data.data.records;
324 322
      pageData.value.page.total = res.data.data.total;
325 323
    })
326
    .catch((err) => {
327
      console.log(err);
324
    .catch((e) => {
325
      ElMessage.error('查询应用失败');
328 326
    });
329 327
};
330 328
const param = {

+ 24 - 29
2022/aiot-evaluate/src/views/settings/RoleManagement.vue

@ -64,7 +64,7 @@ const pageData = ref({
64 64
    {
65 65
      label: '角色编码',
66 66
      name: 'roleCode',
67
      'min-width': '220',
67
      'min-width': '200',
68 68
      fixed: true
69 69
    },
70 70
    {
@ -75,18 +75,18 @@ const pageData = ref({
75 75
    {
76 76
      label: '所属应用',
77 77
      name: 'clientId',
78
      'min-width': '300'
78
      'min-width': '200'
79 79
    },
80 80
    {
81 81
      label: '角色描述',
82 82
      name: 'roleDescription',
83
      'min-width': '300'
83
      'min-width': '200'
84 84
    },
85 85
    {
86 86
      label: '操作',
87 87
      type: 'custom',
88 88
      name: 'custom',
89
      width: '180',
89
      width: '240',
90 90
      fixed: 'right'
91 91
    }
92 92
  ],
@ -114,7 +114,7 @@ const pageData = ref({
114 114
  },
115 115
  {
116 116
    name: 'authorize',
117
    onClick: author,
117
    onClick: authorize,
118 118
    label: '授权',
119 119
    // 是否有边框线
120 120
    isLine: false,
@ -245,8 +245,8 @@ const getRoleData = async () => {
245 245
      console.log('角色数据:', res.data.data);
246 246
      pageData.value.tableData = res.data.data;
247 247
    })
248
    .catch((err) => {
249
      console.log(err);
248
    .catch((e) => {
249
      ElMessage.error('获取角色数据失败');
250 250
    });
251 251
};
252 252
// getRoleData();
@ -280,8 +280,8 @@ const getClientData = async () => {
280 280
        }
281 281
      });
282 282
    })
283
    .catch((err) => {
284
      console.log(err);
283
    .catch((e) => {
284
      ElMessage.error('获取应用数据失败');
285 285
    });
286 286
};
287 287
getClientData();
@ -294,17 +294,15 @@ const createRole = async (params) => {
294 294
      console.log(res);
295 295
      if (res.data.code === 200) {
296 296
        getRoleData();
297
        cancelDialog();
297 298
      } else {
298
        alert(res.message);
299
        ElMessage.error(res.data.data.message);
299 300
      }
300
      cancelDialog();
301 301
    })
302
    .catch((error) => {
303
      alert(error);
302
    .catch((e) => {
303
      ElMessage.error('新建角色失败');
304 304
    })
305
    .finally(() => {
306
      cancelDialog();
307
    });
305
    .finally(() => {});
308 306
};
309 307
// 更新角色
310 308
const updateRole = async(params) => {
@ -314,16 +312,15 @@ const updateRole = async(params) => {
314 312
      console.log(res);
315 313
      if (res.data.code === 200) {
316 314
        getRoleData();
315
        cancelDialog();
317 316
      } else {
318
        alert(res.message);
317
        ElMessage.error(res.data.data.message);
319 318
      }
320 319
    })
321
    .catch((error) => {
322
      alert(error);
320
    .catch((e) => {
321
      ElMessage.error('更新角色失败');
323 322
    })
324
    .finally(() => {
325
      cancelDialog();
326
    });
323
    .finally(() => {});
327 324
};
328 325
// 删除角色
329 326
const deleteRole = async(roleCode) => {
@ -332,8 +329,8 @@ const deleteRole = async(roleCode) => {
332 329
    .then((res) => {
333 330
      console.log(res);
334 331
    })
335
    .catch((error) => {
336
      console.log(error);
332
    .catch((e) => {
333
      ElMessage.error('删除角色失败');
337 334
    })
338 335
    .finally(() => {
339 336
      getRoleData();
@ -348,8 +345,8 @@ const listRolePage = async(params) => {
348 345
      pageData.value.tableData = res.data.data.records;
349 346
      pageData.value.page.total = res.data.data.total;
350 347
    })
351
    .catch((err) => {
352
      console.log(err);
348
    .catch((e) => {
349
      ElMessage.error('查询角色失败');
353 350
    });
354 351
};
355 352
const param = {
@ -376,9 +373,7 @@ function editRow(row) {
376 373
  dialogData.value.drawerData.isOpen = true;
377 374
  dialogData.value.drawerData.type = 'edit';
378 375
  dialogData.value.drawerData.title = '编辑角色';
379
  // console.log(row);
380 376
  dialogData.value.forms.map((item) => {
381
    // console.log(item);
382 377
    if (item.name === 'roleCode') {
383 378
      item.value = row.roleCode;
384 379
      item.attrs.disabled = true;
@ -421,7 +416,7 @@ function deleteRow(row) {
421 416
}
422 417
423 418
// 授权按钮
424
function author(row) {
419
function authorize(row) {
425 420
  console.log(row);
426 421
}
427 422