ny
昨天 282fbc6488f4e8ceb5fda759f963ee88fbf7b999
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<script lang="ts" setup>
import { computed, ref } from 'vue';
 
import { ExclamationCircleFilled } from '@ant-design/icons-vue';
 
const props = defineProps({
  errorList: { type: Array as PropType<any[]>, default: () => [] },
});
const emit = defineEmits(['select']);
const visible = ref<boolean>(false);
defineExpose({ setVisible });
 
const getErrorList = computed(() => convertArrayToTree(props.errorList));
 
/**
 * 将errorList转成树
 * @param list  errorList
 */
function convertArrayToTree(list) {
  const newList: any[] = [];
  list.map((item) => {
    const index = newList.findIndex((o) => o.id === item.id);
    if (index === -1) {
      newList.push({ title: item.title, id: item.id, children: [{ errorInfo: item.errorInfo }] });
    } else {
      newList[index].children.push({ errorInfo: item.errorInfo });
    }
    return item;
  });
  return newList;
}
function handleSelect(id) {
  setVisible(false);
  emit('select', id);
}
function setVisible(data) {
  visible.value = !!data;
}
</script>
<template>
  <a-popover
    v-model:open="visible"
    trigger="click"
    placement="bottom"
    overlay-class-name="error-contain jnpf-flow-common-popover"
    :bordered="false"
    arrow-point-at-center
    v-if="getErrorList.length">
    <template #content>
      <div class="w-[355px]">
        <div class="error-title"><ExclamationCircleFilled class="error-icon" />内容不完善,校验失败!</div>
        <div class="error-content">
          <div class="error-item" v-for="(item, index) in getErrorList" :key="index">
            <div class="error-sub-item error-top">
              <div class="title" :title="item.title">{{ item.title }}</div>
              <div>
                <span>{{ item.children.length }}</span>
                项
              </div>
            </div>
            <div class="error-sub-item error-bottom" v-for="(child, childIndex) in item.children" :key="childIndex">
              <div class="title" :title="child.errorInfo">{{ child.errorInfo }}</div>
              <div class="write" v-if="item?.id" @click="handleSelect(item.id)">去填写</div>
            </div>
          </div>
        </div>
      </div>
    </template>
    <a-button shape="round" class="error-tips-button">
      {{ getErrorList.length || 0 }}项不完善<i class="icon-ym icon-ym-unfold font ml-[5px] text-[10px]"></i>
    </a-button>
  </a-popover>
</template>
<style lang="scss">
.error-tips-button {
  display: flex;
  align-items: center;
 
  &:hover i {
    color: var(--primary-color);
  }
 
  i {
    color: var(--text-color-label);
  }
}
 
.error-contain {
  .ant-popover-inner {
    padding: unset !important;
    overflow: hidden;
    border-radius: 8px;
  }
 
  .ant-popover-arrow::before {
    background: #fdc6c6 !important;
  }
 
  .error-title {
    display: flex;
    align-items: center;
    height: 46px;
    padding: 0 26px;
    font-size: 16px;
    font-weight: bold;
    color: var(--text-color-base);
    background: linear-gradient(26deg, #fceaea 0%, #fdc6c6 100%);
 
    .error-icon {
      margin-right: 4px;
      color: var(--error-color);
    }
  }
 
  .error-content {
    max-height: 300px;
    padding: 8px 26px;
    overflow: auto;
 
    .error-item {
      display: flex;
      flex-direction: column;
 
      .error-sub-item {
        display: flex;
        justify-content: space-between;
        line-height: 35px;
 
        .title {
          flex: 1;
          min-width: 0;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }
      }
 
      .error-top {
        .title {
          font-weight: bold;
        }
 
        span {
          color: var(--error-color);
        }
      }
 
      .error-bottom {
        .title {
          color: var(--text-color-label);
        }
 
        .write {
          flex-shrink: 0;
          margin-left: 10px;
          color: var(--primary-color);
          cursor: pointer;
        }
      }
    }
  }
}
</style>