<template>
  <a-modal
    centered
    class="productBrandEdit-modal"
    :footer="null"
    :maskClosable="false"
    :title="modalTit"
    v-model="isShow"
    @cancle="isShow=false"
    :width="800">
    <!-- 表单 -->
    <div>
      <a-form-model
        id="productBrandEdit-form"
        ref="ruleForm"
        :model="form"
        :rules="rules"
        :label-col="formItemLayout.labelCol"
        :wrapper-col="formItemLayout.wrapperCol"
      >
        <a-form-model-item label="产品品牌名称" prop="name">
          <a-input
            id="productBrandEdit-name"
            :maxLength="30"
            v-model="form.name"
            placeholder="请输入产品品牌名称(最多30个字符)"
            allowClear />
        </a-form-model-item>
      </a-form-model>
      <div class="btn-cont">
        <a-button type="primary" id="product-brand-edit-modal-save" @click="handleSave">保存</a-button>
        <a-button id="product-brand-edit-modal-back" @click="isShow = false" style="margin-left: 15px;">返回列表</a-button>
      </div>
    </div>
  </a-modal>
</template>

<script>
import { STable } from '@/components'
export default {
  name: 'productBrandEditModal',
  components: { STable },
  props: {
    openModal: { //  弹框显示状态
      type: Boolean,
      default: false
    },
    itemId: {
      type: [Number, String],
      default: ''
    }
  },
  computed: {
    modalTit () {
      return (this.itemId ? '编辑' : '新增') + '产品品牌'
    }
  },
  data () {
    return {
      isShow: this.openModal, //  是否打开弹框
      detailsData: null, //  品牌数据
      formItemLayout: {
        labelCol: { span: 6 },
        wrapperCol: { span: 16 }
      },
      form: {
        name: '', // 产品品牌名称
      },
      rules: {
        name: [
          { required: true, message: '请输入产品品牌名称', trigger: 'blur' }
        ],
      }
    }
  },
  methods: {
    //  获取详情
    getDetail(){
      
    },
    //  保存
    handleSave(){
      
    },
  },
  watch: {
    //  父页面传过来的弹框状态
    openModal (newValue, oldValue) {
      this.isShow = newValue
    },
    //  重定义的弹框状态
    isShow (newValue, oldValue) {
      if (!newValue) {
        this.$emit('close')
      }
    },
    itemId (newValue, oldValue) {
      if (this.isShow && newValue) {
        this.getDetail()
      }
    }
  }
}
</script>

<style lang="less">
  .productBrandEdit-modal{
    .ant-modal-body {
    	padding: 40px 40px 24px;
    }
    .btn-cont {
    	text-align: center;
    	margin: 35px 0 10px;
    }
  }
</style>
