<template>
  <div style="margin-bottom: 20px;">
    <Card :padding="30" style="height: 258px;width: 796px;">
      <p slot="title">
        <Icon type="ios-film-outline"></Icon>
        待办事项
      </p>
      <a href="#" slot="extra" @click.prevent="toUpcomingList">
        <Icon type="ios-loop-strong"></Icon>
        更多
      </a>
      <ul>
        <li v-for="item in dataList" style="margin-bottom: 8px;">
          <p @click.prevent="toUpcomingList" href="#" style="cursor:pointer">
            <span style="float: left">{{ item.processVariables.busTitle }}</span>
            <span style="float: right">{{ item.processVariables.startTime }}</span>
          </p>
        </li>
      </ul>
    </Card>
  </div>
</template>

<script>
  import { TOKEN_KEY, getToken, getRefreshToken } from '../../bc-libs/token-util'
  import { getWorkflowUpcomingPage, getWorkflowUpcomingList, getWorkflowTaskList } from '../workflow-api'

  let $this
  export default {
    name: 'workflowUpcomingCard',
    components: {
    },
    data () {
      return {
        searchForm: {},
        pageNo: 1,
        pageSize: 5,
        dataList: [],
        loading: true,
        sortParams: [], //[{title: 姓名, orderStr: 降序, sortKey: name, order: -}]
        getList: getWorkflowUpcomingList,
      }
    },
    methods: {
      toUpcomingList () {
        this.$router.push({
          name: 'my-upcoming-list'
        })
      },
      reloadData () {
        //表格加载中效果
        this.loading = true
        //处理表单查询参数及分页
        let page_params = { 'pageSize': this.pageSize, 'pageNo': this.pageNo}
        let params = Object.assign({}, page_params, this.searchForm) // 这样不会改变原对象
        //加入系统条件,现在只能查询当前系统的流程
        params.systemCode = this.$config.systemCode
        getWorkflowUpcomingPage(params).then(res => {
          if (res.data.datas && res.data.datas.length > 0) {
            this.dataList = res.data.datas
          } else {
            this.dataList = []
          }
          this.loading = false
        }).catch(err => {
          this.dataList = []
          this.$Message.error('查询失败！')
          console.log(err)
        })
      },
    },
    mounted () {
      this.reloadData()
      $this = this
    },
    created () {
    }
  }
</script>

<style>

</style>
