/**
 * 常用 table formatter 方法
 */
export default {
  methods: {
    timeFormatter(row: string, column: any, cellValue: string) {
      // 日期时间
      // temp.json 20210226113627 -> 2021-02-26 11:36:27
      if (cellValue && cellValue.length >= 14) {
        const pattern = /(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/;
        return cellValue.replace(pattern, '$1-$2-$3 $4:$5:$6');
      } else {
        return cellValue || '';
      }
    },
    statusFormatter(row: any, column: any, cellValue: any) {
      if (cellValue === '0') {
        return '正常';
      } else if (cellValue === '1') {
        return '停用';
      } else if (cellValue === '2') {
        return '锁定';
      } else {
        return cellValue;
      }
    },
  },
};
