<template>
  <a-modal
    :title="modalTitle"
    :width="1200"
    :visible="visible"
    :confirmLoading="confirmLoading"
    class="ant-modal2"
    @cancel="handleCancel"
  >
    <div class="table-operator" style="margin-bottom: 8px;">
    </div>
    <a-table
      bordered
      :data-source="data"
      :columns="columns"
      tableLayout="auto"
      rowKey="id"
      :row-selection="rowSelection">
    </a-table>
  </a-modal>
</template>

<script>
import { historySbInfoScrapForAudit } from '@/api/sb/info'

export default {
  name: 'ActHistoryModal',
  components: {
  },
  data () {
    return {
      confirmLoading: false,
      modalTitle: null,
      form: this.$form.createForm(this),
      visible: false,
      maskClosable: false,
      model: null,
      storeId: null,
      typeMap: {},
      userList: {},
      storeTreeDate: [],
      rowSelection: {
        onChange: (selectedRowKeys, selectedRows) => {
          this.selectedRowKeys = selectedRowKeys
          this.selectedRows = selectedRows
        }
      },
      // 表头
      columns: [
        {
          title: '序号',
          dataIndex: 'index',
          customRender: (text, record, index) => {
            return `${index + 1}`
          }
        },
        {
          title: '开始时间',
          dataIndex: 'startTime'
        },
        {
          title: '结束时间',
          dataIndex: 'endTime'
        },
        {
          title: '审批人',
          dataIndex: 'userName'
        },
        {
          title: '审批节点名称',
          dataIndex: 'name'
        },
        {
          title: '流程变量',
          dataIndex: 'result'
        },
        {
          title: '审批意见',
          dataIndex: 'approveComment'
        }
      ],
      data: [],
      user: this.$store.getters.userInfo,
      selectedRowKeys: [],
      selectedRows: [],
      options: {
        rowSelection: {
          selectedRowKeys: this.selectedRowKeys
        }
      }
    }
  },
  props: {
  },
  created () {
    // 下拉框map
    this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.ACTIVITI_USER_MODEL_TYPE)
  },
  methods: {
    base (record) {
      this.visible = true
      this.model = record
      this.modalTitle = '节点设置'
      historySbInfoScrapForAudit({ id: record.processInstanceId }).then(res => {
        this.data = res.data
      })
    },
    handleOk () {
      this.visible = true
      this.base(this.model)
    },
    handleCancel (values) {
      this.visible = false
      this.confirmLoading = false
      this.data = []
      this.form.resetFields()
      if (this.BaseTool.Object.isNotBlank(values)) {
        this.$emit('ok', values)
      } else {
        this.$emit('ok')
      }
    }
  }
}
</script>
