|
39 | 39 | </p>
|
40 | 40 | </div> -->
|
41 | 41 | </div>
|
42 |
| - <div class="flex justify-between gap-[16px] text-gray-700 text-sm leading-[20px]"> |
| 42 | + <div class="flex justify-between gap-[16px] text-gray-700 text-sm leading-[20px] xl:flex-col"> |
43 | 43 | <div class="flex flex-col gap-[8px]">
|
44 |
| - <p>Subset</p> |
| 44 | + <p>{{ $t('all.subset') }}({{ numSubsets }})</p> |
45 | 45 | <el-select
|
46 | 46 | v-model="subset"
|
47 | 47 | @change="changeSubsetName"
|
48 | 48 | placeholder="Select"
|
49 | 49 | size="large"
|
50 |
| - class="!w-[350px] sm:!w-full"> |
| 50 | + class="!w-[330px] xl:!w-full"> |
| 51 | + <template #prefix> |
| 52 | + <span>{{ showRows }} {{ $t('all.rows') }}</span> |
| 53 | + </template> |
51 | 54 | <el-option
|
52 | 55 | v-for="item in datasetInfo"
|
53 | 56 | :key="item.config_name"
|
|
56 | 59 | </el-select>
|
57 | 60 | </div>
|
58 | 61 | <div v-if="splits" class="flex flex-col gap-[8px]">
|
59 |
| - <p>Split {{ numSplits }}</p> |
| 62 | + <p>{{ $t('all.split') }}({{ numSplits }})</p> |
60 | 63 | <el-select
|
61 | 64 | v-model="split"
|
62 | 65 | @change="changeSplitName"
|
63 | 66 | placeholder="Select"
|
64 | 67 | size="large"
|
65 |
| - class="!w-[350px] sm:!w-full"> |
| 68 | + class="!w-[330px] xl:!w-full"> |
| 69 | + <template #prefix> |
| 70 | + <span>{{ showRows }} {{ $t('all.rows') }}</span> |
| 71 | + </template> |
66 | 72 | <el-option
|
67 | 73 | v-for="item in splits"
|
68 | 74 | :key="item.name"
|
69 | 75 | :label="item.name"
|
70 |
| - :value="item.name" /> |
71 |
| - </el-select> |
| 76 | + :value="item.name"> |
| 77 | + </el-option> |
| 78 | + </el-select> |
72 | 79 | </div>
|
73 | 80 | </div>
|
74 | 81 | <!-- <div>
|
|
108 | 115 | </template>
|
109 | 116 |
|
110 | 117 | <script setup>
|
111 |
| - import { computed, onMounted, ref } from 'vue' |
| 118 | + import { computed, onMounted, ref, watch } from 'vue' |
112 | 119 | import { ElMessage } from 'element-plus'
|
113 | 120 | import { Search } from '@element-plus/icons-vue'
|
114 | 121 | import useFetchApi from '../../packs/useFetchApi'
|
115 | 122 | import CsgPagination from '../shared/CsgPagination.vue'
|
116 | 123 |
|
117 | 124 | const props = defineProps({
|
118 |
| - datasetInfo: Object, |
| 125 | + datasetInfo: { |
| 126 | + type: Array, |
| 127 | + default: [] |
| 128 | +
|
| 129 | + }, |
119 | 130 | namespacePath: String
|
120 | 131 | })
|
121 | 132 |
|
|
127 | 138 | const perPage = ref(4)
|
128 | 139 | const nameFilterInput = ref('')
|
129 | 140 | // 默认subset和split的值
|
130 |
| - const splits = ref(props.datasetInfo[0].splits) |
131 |
| - const subset = ref(props.datasetInfo[0].config_name) |
| 141 | + const splits = ref((props.datasetInfo && props.datasetInfo[0]?.splits) || []) |
| 142 | + const subset = ref(props.datasetInfo && props.datasetInfo[0]?.config_name || []) |
132 | 143 | const split = ref(splits.value[0]?.name || '')
|
133 |
| - const numSplits = ref(splits.value[0]?.num_examples || 0) |
| 144 | + const Rows = ref(splits.value[0]?.num_examples || 0) |
| 145 | +
|
| 146 | + const numSplits = computed(() => { |
| 147 | + return splits.value?.length || 0 |
| 148 | + }) |
| 149 | + const numSubsets = computed(() => { |
| 150 | + return props.datasetInfo?.length || 0 |
| 151 | + }) |
| 152 | +
|
| 153 | + watch(() => props.datasetInfo, (newValue) => { |
| 154 | + splits.value = (newValue && newValue[0]?.splits) || [] |
| 155 | + subset.value = (newValue && newValue[0]?.config_name) || [] |
| 156 | + split.value = splits.value[0]?.name || '' |
| 157 | + Rows.value = splits.value[0]?.num_examples || 0 |
| 158 | + }) |
134 | 159 |
|
135 | 160 | const tableData = computed(() => {
|
136 | 161 | if (!previewData.value?.rows || !previewData.value?.columns) {
|
|
148 | 173 | )
|
149 | 174 | })
|
150 | 175 |
|
| 176 | + const showRows = computed(() => { |
| 177 | + let result = '' |
| 178 | + if (Rows.value >= 1000000) { |
| 179 | + result = (Rows.value / 1000000).toFixed(1) + 'M'; |
| 180 | + } else if (Rows.value >= 1000) { |
| 181 | + result = (Rows.value / 1000).toFixed(1) + 'K'; |
| 182 | + } else { |
| 183 | + result = Rows.value; |
| 184 | + } |
| 185 | +
|
| 186 | + return result |
| 187 | + }) |
| 188 | +
|
151 | 189 | const toggleRow = (_row, _column, event) => {
|
152 | 190 | const row = event.target.closest('.el-table__row')
|
153 | 191 | row.classList.toggle('row-item-clamp')
|
154 | 192 | }
|
155 |
| - |
| 193 | +
|
156 | 194 | const changeSubsetName = (value) => {
|
157 | 195 | const filteredItem = props.datasetInfo.find(item => item.config_name === value)
|
158 |
| - splits.value = filteredItem ? filteredItem.data_files: null |
159 |
| - split.value = splits.value[0].name || '' |
160 |
| - numSplits.value = splits.value[0].num_examples || 0 |
| 196 | + splits.value = filteredItem ? filteredItem.splits: null |
| 197 | + subset.value = filteredItem ? filteredItem.config_name: null |
| 198 | + split.value = splits.value[0]?.name || '' |
| 199 | + Rows.value = splits.value[0]?.num_examples || 0 |
161 | 200 | currentPage.value = 1
|
162 | 201 | reloadRows()
|
163 | 202 | }
|
164 | 203 |
|
165 | 204 | const changeSplitName = (value) => {
|
166 | 205 | currentPage.value = 1
|
| 206 | + Rows.value = splits.value.find(item => item.name === value).num_examples |
167 | 207 | reloadRows()
|
168 | 208 | }
|
169 | 209 |
|
|
0 commit comments