<template>
    <div class="routerWapper">
        <div class="portalDetailTitle" v-if="$route.name=='receiptList'">
			<span class="title">预约列表</span>
		</div>
        <div v-if="$route.name=='receiptList'" class="layoutMargin layoutPadding">
            <div class="portalTableOperates">
                <a-table bordered class="portalTable" :dataSource="receiptList" :columns="columns" size="small" :pagination="pagination" rowKey="id">
                    <span slot="homeDate" slot-scope="text,record" align="center">
                        {{!!record.homeDate? record.homeDate.split(' ')[0]: ''}} 
                    </span>
                </a-table>
            </div>
        </div>
    </div>
</template>

<script>
export default {
  data() {
    return {
      receiptList: [],
      pagination: {//分页
        pageNo: 1,
        pageSize: 10,
        total: 10,
        current: 1,
        defaultCurrent: 1,
        showQuickJumper: true,
        onChange: this.pageChange
      },
      columns: [
        {
          title: '报修人',
          dataIndex: 'reportorName',
          align: 'center',
          key: 'reportorName',
        },
        {
          title: '报修地址',
          dataIndex: 'address',
          align: 'center',
          key: 'address',
        },
        {
          title: '报修部位',
          dataIndex: 'place',
          align: 'center',
          key: 'place',
        },
        {
          title: '报修问题',
          dataIndex: 'dscr',
          align: 'center',
          key: 'dscr',
        },
        {
          title: '上门日期',
          dataIndex: 'homeDate',
          align: 'center',
          key: 'homeDate',
          scopedSlots: {
            customRender: 'homeDate',
          },
        },
        {
          title: '上门时间',
          dataIndex: 'homeTime',
          align: 'center',
          key: 'homeTime',
        },
      ]
    }
  },
  mounted() {
    this.getList()
  },
  methods: {
    getList() {
      this.$ajax.get({
        url: this.$api.GET_RESERVATION_LIST,
        params: {
          pageNo: this.pagination.current,
          pageSize: this.pagination.pageSize,
          homeDate_desc: 'desc'
        }
      }).then(res => {
        if (res.code == 200) {
          //先获取全部的自定义字段列表 
          this.receiptList = this.$com.confirm(res, 'data.content', [])
          this.pagination.total=res.data.totalRows
          // console.log(this.extList)
        }
      })
    },
    pageChange(val) {
      this.pagination.pageNo = val
      this.pagination.current = val
      this.getList()
    },
  }
}
</script>