step.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <div
  3. class="step-layout"
  4. @click="emit('click')"
  5. :style="{ '--statusColor': currentColor }"
  6. >
  7. <div class="step-header">
  8. <span class="type">{{ item.name }}</span>
  9. <span class="title">{{ item.displayName }}</span>
  10. <span class="icons">
  11. <img src="./image/g.png" v-if="props.item.status === 'success'" />
  12. <img src="./image/x.png" v-else-if="props.item.status === 'error'" />
  13. <template v-if="'serviceTypeParallel' in item">
  14. <img src="./image/p.png" v-if="item.serviceTypeParallel" />
  15. <img src="./image/c.png" v-else />
  16. </template>
  17. </span>
  18. </div>
  19. <div class="step-hosts" v-if="item.hosts?.length">
  20. <span v-for="host in item.hosts" @click.stop="$emit('clickHost', host)">
  21. {{ host.host }}
  22. </span>
  23. </div>
  24. </div>
  25. </template>
  26. <script setup lang="ts">
  27. import { DataStep } from "../type";
  28. import { computed } from "vue";
  29. const props = defineProps<{ item: DataStep }>();
  30. const emit = defineEmits<{
  31. (e: "click"): void;
  32. (e: "clickHost", host: DataStep["hosts"][number]): void;
  33. }>();
  34. const defaultColor = "#d4f8c3";
  35. const colorMap = {
  36. success: "#30d567",
  37. error: "#ff4238",
  38. running: "#ecf752",
  39. waiting: "#89beb2",
  40. };
  41. const currentColor = computed(() =>
  42. props.item.status in colorMap ? colorMap[props.item.status] : defaultColor
  43. );
  44. </script>
  45. <style scoped lang="scss">
  46. .step-layout {
  47. border-radius: 8px;
  48. color: rgb(51, 51, 51);
  49. font-family: "微软雅黑";
  50. background-color: var(--pColor);
  51. max-width: 400px;
  52. min-width: 100px;
  53. text-align: center;
  54. overflow: hidden;
  55. cursor: pointer;
  56. }
  57. .step-header {
  58. display: flex;
  59. justify-content: space-between;
  60. align-items: center;
  61. font-size: 14px;
  62. padding: 8px 10px;
  63. background: #8ebeb2;
  64. .type {
  65. font-weight: bold;
  66. }
  67. .title {
  68. margin: 0 20px;
  69. }
  70. .icons {
  71. img {
  72. width: 20px;
  73. height: 20px;
  74. :not(:last-child) {
  75. margin-right: 5px;
  76. }
  77. }
  78. }
  79. }
  80. .step-hosts {
  81. padding: 5px;
  82. display: flex;
  83. justify-content: center;
  84. background: #fff;
  85. font-size: 12px;
  86. flex-wrap: wrap;
  87. span {
  88. padding: 6px 10px;
  89. border: 2px solid var(--statusColor);
  90. color: var(--statusColor);
  91. border-radius: 6px;
  92. cursor: pointer;
  93. margin: 5px;
  94. }
  95. }
  96. </style>