nativeUI页面table列表显示,render渲染函数

{
        key: 'type',
        title: $t('cmdType'),
        width: 150,
        align: 'center',
        render(t) {
            switch (t.type) {
                case 2:
                    return h('span', {
                        innerText: $t('setCmd'),
                    });
                case 3:
                    return h('span', {
                        innerText: $t('readCmd'),
                    });
                case 5:
                    return h('span', {
                        innerText: $t('timingCmd'),
                    });
            }
        },
    },
  {
        key: 'confirmed',
        title: $t('device respond'),
        width: 150,
        align: 'center',
        render(t) {
            return h(
                NTag,
                {
                    type: t.confirmed == 0 ? 'error' : 'success',
                },
                () => (t.confirmed == 0 ? $t('no-respond') : $t('responded')),
            );
        },
    },
  {
    key: 'status',
    title: $t('progress'),
    align: 'center',
    width: 120,
    render(t) {
      switch (t.status) {
        case 0:
          return h(
            NTag,
            {
              type: 'info',
            },
            () => $t('in-progress'),
          );
        case 1:
          return h(
            'div',
            {
              class: 'flex flex-col gap-y-2',
            },
            [
              h(
                NTag,
                {
                  type: 'error',
                  class: 'flex items-center justify-center ',
                },
                () => $t('program-error'),
              ),
              renderErrorMsg(t),
            ],
          );
        case 2:
          return h(
            NTag,
            {
              type: 'default',
            },
            () => $t('program-cancel'),
          );
        case 3:
          return h(
            NTag,
            {
              type: 'success',
            },
            () => $t('program-download-finish'),
          );
      }
    },
  },
posted @ 2024-02-19 11:42  饼MIN  阅读(142)  评论(0)    收藏  举报