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

<script>
import { STable } from '@/components'
import { getProcessInstance } 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: 'approvalName', align: 'center', customRender: function (text) { return text || '--' } },
        { title: '人员类型', dataIndex: 'processTaskType', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
        { title: '状态', dataIndex: 'approvalStateDictValue', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
        { title: '审批意见', dataIndex: 'approvalOpinion', width: '20%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
        { title: '附件', dataIndex: 'attachmentNames', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
        { title: '操作时间', dataIndex: 'approvalTime', width: '20%', align: 'center', customRender: function (text) { return text || '--' } }],
      list: []
    }
  },
  methods: {
    clearTable () {
      this.list = []
    },
    refresh () {
      this.getData()
    },
    getData () {
      this.spinning = true
      getProcessInstance({ businessType: this.businessType, businessSn: this.itemSn }).then(res => {
        if (res.status == 200) {
          this.list = res.data
          this.list.map(item => {
            item.opinionList.map((a, index) => a.no = index + 1)
          })
        }
        this.spinning = false
      })
    }
  }
}
</script>

<style>
</style>
