<template>
  <a-modal
    :title="title"
    :width="width"
    :visible="visible"
    :bodyStyle="bodyStyle"
    :confirmLoading="confirmLoading"
    :maskClosable="false"
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭">
    <a-spin :spinning="confirmLoading">
      <a-table
        style="margin-bottom: 4px"
        :columns="goodsColumns"
        :pagination="false"
        :dataSource="dataSource">

      </a-table>
    </a-spin>
  </a-modal>
</template>

<script>

  import { httpAction } from '@/api/manage'
  import pick from 'lodash.pick'
  import JDate from '@/components/jeecg/JDate'
  import JUpload from '@/components/jeecg/JUpload'
  import JSelectDepart from '@/components/jeecgbiz/JSelectDepart'
  import JDictSelectTag from '@/components/dict/JDictSelectTag'
  import Vue from 'vue'
  import { ACCESS_TOKEN } from '@/store/mutation-types'
  import DetailList from '@/components/tools/DetailList'
  const FILE_TYPE_ALL = "all"
  const FILE_TYPE_PDF = 'pdf'
  const uidGenerator = () => {
    return '-' + parseInt(Math.random() * 10000 + 1, 10)
  }
  const getFileName = (path) => {
    if (path.lastIndexOf('\\') >= 0) {
      let reg = new RegExp('\\\\', 'g')
      path = path.replace(reg, '/')
    }
    return path.substring(path.lastIndexOf('/') + 1)
  }
  const DetailListItem = DetailList.Item
  export default {
    name: 'HwPaymentExportErrorModal',
    components: {
      JDate,
      JUpload,
      JSelectDepart,
      JDictSelectTag,
      DetailList,
      DetailListItem,
    },
    data() {
      return {
        uploadAction: window._CONFIG['domianURL'] + '/hpSys/common/ossUpload',
        urlDownload: window._CONFIG['domianURL'] + '/hpSys/common/ossDownload',
        headers: {},
        fileList: [],
        form: this.$form.createForm(this),
        title: '操作',
        width: 600,
        bodyStyle: {
          padding: '12px',
          height: (window.innerHeight * 0.42) + 'px',
          'overflow-y': 'auto'
        },
        visible: false,
        model: {},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 }
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 }
        },
        accept:'.pdf',
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          fileUpload: window._CONFIG['domianURL'] + '/hpSys/common/ossUpload',
          edit: '/requiremanager/hwRequirement/edit'
        },
        goodsColumns: [
          {
            title: '错误项',
            dataIndex: 'id',
            key: 'id'
          },
          {
            title: '身份证号',
            dataIndex: 'idcardNumber',
            key: 'order'
          },
          {
            title: '错误原因',
            dataIndex: 'reason',
            key: 'reason'
          }
        ],
        /* 数据源 */
        dataSource:[],
      }
    },

    watch: {
      value(val) {
        this.initFileList(val)
      }
    },
    created() {
      const token = Vue.ls.get(ACCESS_TOKEN)
      this.headers = { 'X-Access-Token': token }

    },
    methods: {
      add() {
        this.edit({})
      },
      edit(record) {
        this.model={}
        this.form.resetFields()
        this.model = JSON.parse(record)
        console.log(typeof this.model)
        this.visible = true
        this.dataSource = this.model;
      },
      close() {
        this.$emit('close')
        this.visible = false
      },
      handleOk(){
        this.close()
      },
      handleCancel() {
        this.close()
      },

    }
  }
</script>
<style scoped>
  .ant-form-item{
    margin-bottom:3px!important;
  }

  td{
    text-align: center;
    width: 30%;
  }
</style>