<template>
  <a-modal
    centered
    class="purchaseBaseLimitEdit-modal"
    :footer="null"
    :maskClosable="false"
    title="编辑价格"
    v-model="isShow"
    @cancle="isShow=false"
    :width="800">
    <div>
      <a-form-model
        id="purchaseBaseLimitEdit-form"
        ref="ruleForm"
        :model="form"
        :rules="rules"
        :label-col="formItemLayout.labelCol"
        :wrapper-col="formItemLayout.wrapperCol"
      >
      </a-form-model>
      <div class="btn-cont">
        <a-button type="primary" id="purchaseBaseLimitEdit-save" @click="handleSave">保存</a-button>
        <a-button id="purchaseBaseLimitEdit-cancel" @click="isShow = false" style="margin-left: 100px;">取消</a-button>
      </div>
    </div>
  </a-modal>
</template>

<script>
// import { dealerProductDetail } from '@/api/dealerProduct'
export default {
  name: 'PurchaseBaseLimitEditModal',
  props: {
    openModal: { //  弹框显示状态
      type: Boolean,
      default: false
    },
    itemId: {
      type: [Number, String],
      default: ''
    }
  },
  computed: {
    productTypeName () {
      const productTypeName1 = this.detailsData.productTypeName1 ? this.detailsData.productTypeName1 : ''
      const productTypeName2 = this.detailsData.productTypeName2 ? ' > ' + this.detailsData.productTypeName2 : ''
      const productTypeName3 = this.detailsData.productTypeName3 ? ' > ' + this.detailsData.productTypeName3 : ''
      return productTypeName1 + productTypeName2 + productTypeName3
    }
  },
  data () {
    return {
      isShow: this.openModal, //  是否打开弹框
      formItemLayout: {
        labelCol: { span: 4 },
        wrapperCol: { span: 16 }
      },
      detailsData: null, //  详情数据
      form: {
        storageQuantity: ''
      },
      rules: {
        supplierName: [
          { required: true, message: '请输入供应商名称', trigger: 'blur' }
        ]
      },
      brandData: []
    }
  },
  methods: {
    //  获取详情
    getDetail () {
      // dealerProductDetail({ id: this.itemId }).then(res => {
      //   if (res.status == 200) {
      //     this.detailsData = res.data
      //   } else {
      //     this.detailsData = null
      //   }
      // })
    },
    // 保存
    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">
  .purchaseBaseLimitEdit-modal{
    .ant-modal-body {
      padding: 40px 40px 24px;
    }
    .btn-cont {
      text-align: center;
      margin: 35px 0 30px;
    }
  }
</style>
