| | |
| | | import type { MdmItemApi } from '#/api/mdm/item'; |
| | | import type { MesMdItemTypeApi } from '#/api/mes/md/item/type'; |
| | | |
| | | import { ref } from 'vue'; |
| | | import { computed, ref } from 'vue'; |
| | | |
| | | import { confirm, Page, useVbenModal } from '#/packages/effects/common-ui/src'; |
| | | import { downloadFileFromBlobPart, isEmpty } from '#/packages/utils/src'; |
| | |
| | | |
| | | // 分类列表缓存 |
| | | const categoryList = ref<MesMdItemTypeApi.ItemType[]>([]); |
| | | |
| | | const TAG_COLORS = [ |
| | | 'green', |
| | | 'orange', |
| | | 'blue', |
| | | 'purple', |
| | | 'cyan', |
| | | 'magenta', |
| | | 'geekblue', |
| | | 'volcano', |
| | | 'gold', |
| | | 'lime', |
| | | ] as const; |
| | | |
| | | /** 分类ID → 颜色映射(基于分类在列表中的索引循环分配) */ |
| | | const categoryColorMap = computed(() => { |
| | | const map = new Map<number, string>(); |
| | | categoryList.value.forEach((item, index) => { |
| | | map.set(item.id!, TAG_COLORS[index % TAG_COLORS.length]!); |
| | | }); |
| | | return map; |
| | | }); |
| | | |
| | | /** 获取分类Tag颜色 */ |
| | | function getCategoryColor(categoryId?: number): string { |
| | | if (!categoryId) return ''; |
| | | return categoryColorMap.value.get(categoryId) || ''; |
| | | } |
| | | |
| | | /** 获取分类名称 */ |
| | | function getCategoryName(categoryId?: number) { |
| | |
| | | /> |
| | | </template> |
| | | <template #categoryName="{ row }"> |
| | | <Tag v-if="row.categoryId === 1" color="green">{{ getCategoryName(row.categoryId) }}</Tag> |
| | | <Tag v-else-if="row.categoryId === 2" color="orange">{{ getCategoryName(row.categoryId) }}</Tag> |
| | | <Tag v-else-if="row.categoryId === 3" color="blue">{{ getCategoryName(row.categoryId) }}</Tag> |
| | | <Tag v-else-if="row.categoryId === 4" color="purple">{{ getCategoryName(row.categoryId) }}</Tag> |
| | | <Tag v-else-if="row.categoryId === 5" color="cyan">{{ getCategoryName(row.categoryId) }}</Tag> |
| | | <Tag v-if="getCategoryColor(row.categoryId)" :color="getCategoryColor(row.categoryId)">{{ getCategoryName(row.categoryId) }}</Tag> |
| | | <span v-else>{{ getCategoryName(row.categoryId) }}</span> |
| | | </template> |
| | | <template #isBatchManaged="{ row }"> |