iView Table Colums定義 - daniel-qa/Vue GitHub Wiki

  • Table 表格

alt

  • Colums 定義
// 操作紀錄表格欄位設定
operationLogColumns: [
  {
    title: '日期',
    key: 'time',
    align: 'center',
    width: 180,
    render: (h, params) => {
      const timestamp = params.row.time;
      if (!timestamp) return h('span', '-');
      const date = new Date(timestamp);
      const year = date.getFullYear();
      const month = String(date.getMonth() + 1).padStart(2, '0');
      const day = String(date.getDate()).padStart(2, '0');
      const hours = String(date.getHours()).padStart(2, '0');
      const minutes = String(date.getMinutes()).padStart(2, '0');
      const formattedDate = `${year}/${month}/${day} ${hours}:${minutes}`;
      return h('span', {
        style: {
          color: '#2d8cf0',
          cursor: 'pointer'
        }
      }, formattedDate);
    }
  },
  {
    title: '人員',
    key: 'name',
    align: 'center',
    width: 180,
    render: (h, params) => {
      const name = params.row.name || '-';
      const tmdId = params.row.tmdId || '';
      return h('span', `${name}(${tmdId})`);
    }
  },
  {
    title: '操作紀錄',
    key: 'msg',
    align: 'left',
    minWidth: 500,
    render: (h, params) => {
      return h('span', params.row.msg || '-');
    }
  }
]