ipCell.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <template>
  2. <div class="cell">
  3. <div class="ellipsis" style="width: 100%; text-align: left;" v-for="(list, index) in [whitelist, blacklist]">
  4. <span class="title">{{ index == 0 ? '白名单:' : '黑名单:' }}</span>
  5. <span class="item" v-for="item in list" :key="item">{{item}}</span>
  6. <span class="item" v-if="list.length <= 0">--</span>
  7. </div>
  8. <div class="action">
  9. <el-link type="info" @click="handleEdit" style="color: #167AF0; line-height: 18px;" >
  10. {{ blacklist.length > 0 ? '查看详情' : '添加IP'}}
  11. </el-link>
  12. </div>
  13. </div>
  14. <IpForm ref="IpFormRef" />
  15. </template>
  16. <script setup>
  17. import { ref, watch } from 'vue';
  18. const IpForm = defineAsyncComponent(() => import('./ipForm.vue'));
  19. const props = defineProps(['ipList']);
  20. const blacklist = ref([]);
  21. const whitelist = ref([]);
  22. const IpFormRef = ref();
  23. watch(
  24. () => props.ipList,
  25. (newVal) => {
  26. blacklist.value = [];
  27. whitelist.value = [];
  28. let temp = '';
  29. (newVal || []).forEach(item => {
  30. if (item.sourceType == 2) {
  31. temp = item.startIp + (item.endIp ? '/' + item.endIp.split('.').pop() : '');
  32. } else {
  33. temp = item.groupName;
  34. }
  35. item.ipType == 1 ? blacklist.value.push(temp) : whitelist.value.push(temp);
  36. });
  37. },
  38. { immediate: true }
  39. );
  40. // 修改域名弹窗
  41. const handleEdit = () => {
  42. IpFormRef.value.openDialog(props.ipList);
  43. };
  44. </script>
  45. <style scoped lang="scss">
  46. .cell {
  47. padding: 10px 0;
  48. // .flex {
  49. // display: flex;
  50. // flex-wrap: wrap;
  51. // margin-bottom: 5px;
  52. // }
  53. .title {
  54. text-align: left;
  55. line-height: 14px;
  56. height: 14px;
  57. margin-right: 15px;
  58. padding: 4px 0;
  59. }
  60. .item {
  61. width: auto;
  62. box-sizing: border-box;
  63. padding: 4px 0;
  64. text-align: left;
  65. margin-right: 15px;
  66. color: #646464;
  67. line-height: 14px;
  68. }
  69. .action {
  70. width: 100%;
  71. text-align: left;
  72. }
  73. .ellipsis {
  74. display: -webkit-box; /* 使用弹性盒子布局 */
  75. -webkit-box-orient: vertical; /* 垂直方向排列 */
  76. -webkit-line-clamp: 2; /* 限制显示的行数 */
  77. overflow: hidden; /* 隐藏超出部分 */
  78. text-overflow: ellipsis; /* 超出时显示省略号 */
  79. word-break: break-word; /* 允许单词断行(可选) */
  80. }
  81. }
  82. </style>