ipCell.vue 2.4 KB

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