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

        <a-form-item label="需求名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'requirementName', validatorRules.requirementName]" placeholder="请输入需求名称"></a-input>
        </a-form-item>
        <a-form-item label="需求描述" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-textarea v-decorator="[ 'description', validatorRules.description]"
                      rows="4" placeholder="请输入需求描述"></a-textarea>
        </a-form-item>
        <a-form-item label="需求时间" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <j-date v-decorator="['requirementTime', validatorRules.requirementTime]" dateFormat="YYYY-MM-DD"
                  placeholder="请选择日期" style="width: 100%"/>
        </a-form-item>


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

<script>

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

  export default {
    name: 'HlgPaymentRelatedRequirementsModal',
    components: {
      JDate
    },
    data() {
      return {
        form: this.$form.createForm(this),
        title: '操作',
        width: 800,
        visible: false,
        model: {},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 }
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 }
        },
        confirmLoading: false,
        validatorRules: {
          requirementName: { rules: [{ required: true, message: '请输入需求名称!' }] },
          description: { rules: [{ required: true, message: '请输入需求描述!' }] },
          requirementTime: {}
        },
        url: {
          edit: '/hlgpayment/hlgPayment/relateRequirement'
        }

      }
    },
    created() {
    },
    methods: {
      add() {
        this.edit({})
      },
      edit(record) {
        this.form.resetFields()
        this.model = Object.assign({}, record)
        this.visible = true
        this.$nextTick(() => {
          this.form.setFieldsValue(pick(this.model,'requirementName','description','requirementTime'))
        })
      },
      close() {
        this.$emit('close')
        this.visible = false
      },
      handleOk() {
        const that = this
        that.close()
      },
      handleCancel() {
        this.close()
      }
    }
  }
</script>