8 天以前 fdd158306bf6dc3584f5110a385323f4a8dfb463
src/adapter/vxe-table.ts
@@ -121,8 +121,9 @@
    // 表格配置项可以用 cellRender: { name: 'CellTag' },
    // props: { data: [{value, color}], labels?: {[value]: label} }
    // 也兼容 options 格式: [{ label, value, color }]
    // 支持两种匹配模式:
    //   1. 精确匹配: data 和 labels 中都是精确值 (状态/类型枚举)
    //   1. 精确匹配: data/labels/options 中都是精确值 (状态/类型枚举)
    //   2. 阈值匹配: data 为降序阈值, label 显示原始数值 (评分)
    vxeUI.renderer.add('CellTag', {
      renderTableDefault(renderOpts, params) {
@@ -130,15 +131,25 @@
        const { column, row } = params;
        const rawValue = row[column.field];
        // 兼容 options 格式,精确匹配显示文本与颜色
        const matchedOption = props?.options?.find(
          (item: any) =>
            item.value === rawValue || Number(item.value) === Number(rawValue),
        );
        // 查找显示文本
        let label = rawValue;
        if (props?.labels && rawValue !== undefined && rawValue !== null) {
        if (matchedOption) {
          label = matchedOption.label;
        } else if (props?.labels && rawValue !== undefined && rawValue !== null) {
          label = props.labels[rawValue] ?? rawValue;
        }
        // 查找颜色: 优先精确匹配,否则阈值匹配
        let color: string | undefined;
        if (props?.data) {
        if (matchedOption) {
          color = matchedOption.color;
        } else if (props?.data) {
          const exact = props.data.find(
            (item: any) => item.value === rawValue,
          );