<template>
  <div>
    <p>说明：以下信息来自钉钉</p>
    <a-spin :spinning="spinning" tip="Loading...">
      <div style="margin-bottom:10px;" v-for="item in list" :key="item.businessId">
        <div style="margin-bottom:10px;font-weight:bold;">提审时间：{{ item.createTime }}</div>
        <a-table
          class="sTable fixPagination"
          ref="table"
          size="small"
          :rowKey="(record) => record.businessId"
          :columns="columns"
          :dataSource="item.taskVOList"
          :scroll="{ y: 500 }"
          :pagination="false"
          bordered>
        </a-table>
      </div>
    </a-spin>
  </div>
</template>

<script>
import { STable } from '@/components'
import { getProcessInstanceList } from '@/api/expenseManagement'
export default {
  name: 'AuditDetail',
  components: { STable },
  props: {
    openModal: {
      type: Boolean,
      default: false
    },
    itemSn: {
      type: [Number, String],
      default: ''
    },
    businessType: {
      type: [Number, String],
      default: ''
    }
  },
  data () {
    return {
      spinning: false,
      columns: [{ title: '序号', dataIndex: 'no', width: '8%', align: 'center' },
        { title: '人员姓名', width: '12%', dataIndex: 'userName', align: 'center', customRender: function (text) { return text || '--' } },
        { title: '人员类型', dataIndex: 'userType', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
        { title: '状态', dataIndex: 'state', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
        { title: '审批意见', dataIndex: 'remark', width: '20%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
        { title: '附件', dataIndex: 'hasAttachments', width: '20%', align: 'center', customRender: function (text) { return text != '0' ? '请在钉钉中查看附件内容' : '--' } },
        { title: '操作时间', dataIndex: 'date', width: '20%', align: 'center', customRender: function (text) { return text || '--' } }],
      list: []
    }
  },
  methods: {
    clearTable () {
      this.list = []
    },
    refresh () {
      this.getData()
    },
    getData () {
      this.spinning = true
      getProcessInstanceList({ businessType: this.businessType, businessSn: this.itemSn }).then(res => {
        if (res.status == 200) {
          this.list = res.data
          this.list.map(item => {
            item.taskVOList.map((a, index) => a.no = index + 1)
          })
        }
        this.spinning = false
      })
    }
  }
}
</script>

<style>
</style>
