<template>

  <a-modal
    :title="title"
    :width="600"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭"
    switchFullscreen
  >
    <a-spin :spinning="confirmLoading">
      <a-form-model
        :model="dataForm"
        :rules="dataRule"
        ref="dataForm"
        label-width="180px">
        <a-row :gutter="20">
          <a-col :span="24">
            <a-form-model-item label="模型名称" prop="name">
              <a-input v-model="dataForm.name" :disabled="disaform" placeholder="模型名称"></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="20">
          <a-col :span="24">
            <a-form-model-item label="模型标识" prop="key">
              <a-input v-model="dataForm.key" :disabled="disaform" placeholder="模型标识"></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="20">
          <a-col :span="24">
            <a-form-model-item label="模型描述" prop="description">
              <a-input v-model="dataForm.description" :disabled="disaform" placeholder="模型描述"></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </a-spin>
  </a-modal>
</template>

<script>
  import { postAction } from '@/api/manage'

  export default {
    name: 'ActivitiModelModal',
    components: { },
    data() {
      return {
        title: '新增',
        visible: false,
        dataForm: {},
        confirmLoading: false,
        disaform: false,
        dataRule: {
          name: [{ required: true, message: '请输入模型名称!' }],
          key: [{ required: true, message: '请输入模型key!' }]
          }
      }
    },
    computed: {

    },
    created() {
    },
    mounted() {

    },
    methods: {

      add () {
          this.visible = true
        },
        edit (record) {
          this.visible = true
          this.dataForm = Object.assign({}, record)
        },
        close () {
          this.$emit('close')
          this.visible = false
        },
        // 确定
        handleOk() {
          console.log('确定', this.dataForm)
          this.$refs.dataForm.validate(valid => {
            if (valid) {
              let url = 'act/remodel/save'
              postAction(url, this.dataForm).then(res => {
                console.log('res', res)
                if (res.success) {
                  this.$message.success(res.message)
                } else {
                  this.$message.error(res.message)
                }
                 this.visible = false
                 this.$emit('getModels')
              })
          } else {
              return false
            }
          })
        },
        // 关闭
        handleCancel() {
          this.close()
        }

    }
}
</script>

<style>
</style>
