<template>
  <div>
    <EasyDataList ref="EasyDataList" :columnType="columnType" :dataSourceName="dataSourceName" model="list"
                  @editColumns="editColumns">
    </EasyDataList>
  </div>
</template>

<script>
import {formatDate} from "../../../lib/utils/dateUtils";
export default {
  name: "dataSourceView",
  data() {
    return {
      dataSourceName: '',
      expandedRowRenderKey: 'keyInfo',
      columnType: 'expand',
    }
  },
  created() {
    if (this.$route.params.dataSourceName) {
      console.log(this.$route.params)
      this.dataSourceName = this.$route.params.dataSourceName
    }
  },
  mounted() {
    this.initProps()
  },
  methods: {
    initProps() {
      this.formProps = {
        inline: true
      }
    },
    editColumns() {
      const columns = []
      //规则名称增加点击获取编号
      columns.push({
        label: '新增时间',
        width: 160,
        prop: 'createTime',
        formatter: (row, column, cellValue, index) => {
          if (cellValue && cellValue !== '') {
            let dateTime = new Date(cellValue)
            return formatDate(dateTime, 'yyyy-MM-dd hh:mm:ss')
          }
          return cellValue
        }
      })
      columns.push({
        label: '更新时间',
        align: "left",
        width: 160,
        prop: 'updateTime',
        formatter: (row, column, cellValue, index) => {
          if (cellValue && cellValue !== '') {
            let dateTime = new Date(cellValue)
            return formatDate(dateTime, 'yyyy-MM-dd hh:mm:ss')
          }
          return cellValue
        }
      })
      return columns
    },
  }
}
</script>

<style scoped>

</style>
