wangrong
2026-08-30 761e5c5fa871959f60e15c971c8d83f2b53d0af5
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<script lang="ts" setup>
import icon_searchOutline_outlined from '@/assets/svg/icon_search-outline_outlined.svg'
import { ref, PropType, watch } from 'vue'
import { useI18n } from '@/hooks/web/useI18n'
import { propTypes } from '@/utils/propTypes'
import { ElTable } from 'element-plus-secondary'
import { fieldType } from '@/utils/attr'
import { type Field } from './util'
import { iconFieldMap } from '@/components/icon-group/field-list'
 
const { t } = useI18n()
const props = defineProps({
  fieldList: {
    type: Array as PropType<Field[]>,
    default: () => []
  },
  node: propTypes.object.def({})
})
const emit = defineEmits(['checkedFields'])
const multipleTableRef = ref<InstanceType<typeof ElTable>>()
const search = ref('')
const checkAll = ref(false)
const isIndeterminate = ref(true)
const handleCheckAllChange = (val: boolean) => {
  fieldSearchList.value.forEach(ele => {
    ele.checked = val
  })
  const org = fieldSearchList.value.map(ele => ele.originName)
  if (val) {
    multipleSelection.value = [
      ...multipleSelection.value.filter(ele => !org.includes(ele.originName)),
      ...fieldSearchList.value
    ]
  } else {
    multipleSelection.value = multipleSelection.value.filter(ele => !org.includes(ele.originName))
  }
  isIndeterminate.value = false
  emit('checkedFields', multipleSelection.value)
}
 
const fieldSearchList = ref([])
 
const multipleSelection = ref<Field[]>([])
const checkChange = () => {
  handleSelectionChange(fieldSearchList.value.filter(ele => ele.checked))
}
const handleSelectionChange = val => {
  const checkedCount = val.length
  checkAll.value = checkedCount === fieldSearchList.value.length
  isIndeterminate.value = checkedCount > 0 && checkedCount < fieldSearchList.value.length
  multipleSelection.value = props.fieldList.filter(ele => ele.checked)
  emit('checkedFields', multipleSelection.value)
}
watch(
  search,
  val => {
    if (val.trim() !== '') {
      fieldSearchList.value = props.fieldList.filter(ele =>
        ele.originName.toLocaleLowerCase().includes(val.trim().toLocaleLowerCase())
      )
    } else {
      fieldSearchList.value = props.fieldList
    }
    handleSelectionChange(fieldSearchList.value.filter(ele => ele.checked))
  },
  {
    immediate: true
  }
)
 
watch(
  () => props.fieldList,
  () => {
    fieldSearchList.value = props.fieldList
    handleSelectionChange(fieldSearchList.value.filter(ele => ele.checked))
  }
)
</script>
 
<template>
  <div class="field-block-style">
    <div class="field-block-option">
      <span class="option-field"
        >{{ $t('dataset.field_select') }}({{ multipleSelection.length }}/{{
          fieldList.length
        }})</span
      >
      <el-input
        v-model="search"
        :placeholder="$t('auth.search_by_field')"
        clearable
        class="option-input"
      >
        <template #prefix>
          <el-icon>
            <Icon name="icon_search-outline_outlined"
              ><icon_searchOutline_outlined class="svg-icon"
            /></Icon>
          </el-icon>
        </template>
      </el-input>
    </div>
    <div class="field-block-body">
      <el-table
        header-cell-class-name="header-cell"
        ref="multipleTableRef"
        :data="fieldSearchList"
        style="width: 100%"
        @selection-change="handleSelectionChange"
      >
        <el-table-column align="center" width="55">
          <template #header>
            <el-checkbox
              v-model="checkAll"
              :indeterminate="isIndeterminate"
              @change="handleCheckAllChange"
            />
          </template>
          <template #default="scope">
            <el-checkbox @change="checkChange" v-model="scope.row.checked" />
          </template>
        </el-table-column>
        <el-table-column :label="t('dataset.origin_name')">
          <template #default="scope">
            <el-icon>
              <Icon
                ><component
                  class="svg-icon"
                  :class="`field-icon-${fieldType[scope.row.deType]}`"
                  :is="iconFieldMap[fieldType[scope.row.deType]]"
                ></component
              ></Icon>
            </el-icon>
            {{ scope.row.originName }}
          </template>
        </el-table-column>
        <el-table-column property="description" :label="t('deDataset.description')" />
      </el-table>
    </div>
  </div>
</template>
 
<style lang="less" scoped>
.field-block-style {
  height: 100%;
  width: 100%;
  font-family: var(--de-custom_font, 'PingFang');
  .field-block-body {
    height: 327px;
    overflow-y: auto;
  }
  .field-origin-style {
    display: flex;
    margin-left: 12px;
    width: 140px;
    align-items: center;
    font-size: 14px;
    font-weight: 500;
    color: var(--deTextSecondary, #646a73);
  }
  .field-style {
    width: 140px;
    display: inline-block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: pre;
    font-size: 14px;
    font-weight: 500;
    color: var(--deTextSecondary, #646a73);
  }
  .field-block-option {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
  }
  .option-field {
    font-size: 14px;
    font-weight: 400;
    color: var(--deTextSecondary, #646a73);
  }
  .option-input {
    width: 200px;
  }
}
</style>
 
<style lang="less">
.field-block-body {
  .cell {
    display: flex;
    align-items: center;
    .ed-icon {
      font-size: 14px;
      margin-right: 5.25px;
    }
  }
}
</style>