<template>
  <a-modal
    :title="title"
    :width="width"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭">
    <a-spin :spinning="confirmLoading">
      <a-form :form="form">

        <a-form-item label="付款企业" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <!--          <a-input-search placeholder="请选择付款企业" v-decorator="[ 'company_name', validatorRules.company_name]" disabled-->
          <!--                          @search="onSearch">-->
          <!--            <a-button slot="enterButton">选择</a-button>-->
          <!--          </a-input-search>-->
          <!--          <j-select-user-by-dep v-model="userRealName"></j-select-user-by-dep>-->
        </a-form-item>

        <a-form-item label="服务商" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <!--          <j-dict-select-tag v-model="formData.user" placeholder="请选择用户" dictCode="sys_user,realname,id"/>-->
        </a-form-item>

        <a-form-item label="账户余额" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <span>2019</span>
        </a-form-item>

        <a-form-item label="付款明细" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-row type="flex" justify="center" align="middle">
            <a-col>
              <a-upload
                v-decorator="[
          'upload',
        ]"
                name="logo"
                :customRequest="normFile"
                list-type="picture"
              >
                <a-button>
                  <a-icon type="upload"/>
                  请选择上传付款明细
                </a-button>
              </a-upload>
            </a-col>
            <a-col>
              <a download="">下载模版</a>
            </a-col>
          </a-row>
        </a-form-item>

      </a-form>
    </a-spin>
    <HlgPaymentCompanyListModal ref="CompanyList" @ok="getCompany"></HlgPaymentCompanyListModal>
  </a-modal>
</template>

<script>

  import { httpAction } from '@/api/manage'
  import pick from 'lodash.pick'
  import JDate from '@/components/jeecg/JDate'
  import HlgPaymentCompanyListModal from './HlgPaymentCompanyListModal'

  export default {
    name: 'HlgPaymentImportModal',
    components: {
      JDate,
      HlgPaymentCompanyListModal
    },
    data() {
      return {
        fileList: [],
        form: this.$form.createForm(this),
        title: '操作',
        width: 800,
        visible: false,
        is_show: true,
        model: {},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 }
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 }
        },

        confirmLoading: false,
        validatorRules: {
          company_name: { rules: [{ required: true, message: '请输入账户姓名!' }] },
          idcardNumber: { rules: [{ required: true, message: '请输入身份证号!' }] },
          cardNumber: { rules: [{ required: true, message: '请输入银行卡号!' }] },
          bnkflg: { rules: [{ required: true, validator: this.checkBnkflg }] }
          // eacbnk: { rules: [{ required: is_show, message: '请输入他行开户行!' }] },
          // rcveaa: { rules: [{ required: is_show, message: '请输入他行开户地址!' }] }
        },
        url: {
          add: '/hlgpayment/hlgPaymentDetail/add',
          edit: '/hlgpayment/hlgPaymentDetail/edit'
        }

      }
    },
    created() {
    },
    methods: {
      add() {
        this.edit({})
      },
      edit(record) {
        this.form.resetFields()
        this.model = Object.assign({}, record)
        this.visible = true
      },
      close() {
        this.$emit('close')
        this.$destroyAll()
        this.visible = false
      },
      handleOk() {
        const that = this
        // 触发表单验证
        this.form.validateFields((err, values) => {
          if (!err) {

          }
        })
      },

      onSearch() {
        this.$refs.CompanyList.add()
        this.$refs.CompanyList.title = '企业列表'
        this.$refs.CompanyList.disableSubmit = false
      },
      handleChange(value) {
        console.log(value)
      },
      handleCancel() {
        this.close()
      },
      beforeUpload(file) {
        this.fileList = [...this.fileList, file]
        console.log(this.fileList)
        return false
      },
      normFile(info) {
        console.log(info)
        if (info.test) {
          this.$error({
            title: '导入失败',
            content: '单次付款明细不能超过999条',
            okText: '确定'
          })
        }

        if (info.test2) {
          this.$confirm({
            title: '提示',
            content: '您的公司在2019.11.10支付过相同人数相同金额的付款单，是否要继续导入？',
            okText: '继续导入',
            onOk: () => {
              //do something
            },
            onCancel: () => {
              this.$destroyAll()
            }
          })
        }

      },
      getCompany(data) {
        console.log(data)
      }


    }
  }
</script>