<template>
  <a-modal
    centered
    class="productPricingEdit-modal"
    :footer="null"
    :maskClosable="false"
    title="编辑价格"
    v-model="isShow"
    @cancle="isShow=false"
    :width="800">
    <!-- 编辑价格 -->
    <div>
      <a-form-model
        id="productPricingEdit-form"
        ref="ruleForm"
        :model="form"
        :rules="rules"
        :label-col="formItemLayout.labelCol"
        :wrapper-col="formItemLayout.wrapperCol"
      >
        <a-form-model-item label="成本价" prop="supplierName">
          50.00
        </a-form-model-item>
        <a-form-model-item label="省级价" prop="supplierName">
          <a-input-number
            id="productPricingEdit-storageQuantity"
            v-model="form.storageQuantity"
            :precision="2"
            :min="1"
            :max="999999"
            placeholder="请输入"
            style="width: 100%;" />
        </a-form-model-item>
        <a-form-model-item label="市级价" prop="supplierName">
          <a-input-number
            id="productPricingEdit-storageQuantity"
            v-model="form.storageQuantity"
            :precision="2"
            :min="1"
            :max="999999"
            placeholder="请输入"
            style="width: 100%;" />
        </a-form-model-item>
        <a-form-model-item label="特约价" prop="supplierName">
          <a-input-number
            id="productPricingEdit-storageQuantity"
            v-model="form.storageQuantity"
            :precision="2"
            :min="1"
            :max="999999"
            placeholder="请输入"
            style="width: 100%;" />
        </a-form-model-item>
        <a-form-model-item label="终端价" prop="supplierName">
          <a-input-number
            id="productPricingEdit-storageQuantity"
            v-model="form.storageQuantity"
            :precision="2"
            :min="1"
            :max="999999"
            placeholder="请输入"
            style="width: 100%;" />
        </a-form-model-item>
        <a-form-model-item label="车主价" prop="supplierName">
          <a-input-number
            id="productPricingEdit-storageQuantity"
            v-model="form.storageQuantity"
            :precision="2"
            :min="1"
            :max="999999"
            placeholder="请输入"
            style="width: 100%;" />
        </a-form-model-item>
        <a-form-model-item label="变更原因">
          <a-select placeholder="请选择" id="productPricingEdit-storageQuantity" allowClear v-model="form.storageQuantity">
            <a-select-option v-for="item in brandData" :key="item.salesChannelNo" :value="item.salesChannelNo">{{ item.salesChannelName }}</a-select-option>
          </a-select>
        </a-form-model-item>
      </a-form-model>
      <div class="btn-cont">
        <a-button type="primary" id="product-pricing-modal-save" @click="handleSave">保存</a-button>
        <a-button id="product-pricing-modal-cancel" @click="isShow = false" style="margin-left: 100px;">取消</a-button>
      </div>
    </div>
  </a-modal>
</template>

<script>
// import { dealerProductDetail } from '@/api/dealerProduct'
export default {
  name: 'ProductPricingEditModal',
  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">
  .productPricingEdit-modal{
    .ant-modal-body {
      padding: 40px 40px 24px;
    }
    .btn-cont {
      text-align: center;
      margin: 35px 0 30px;
    }
  }
</style>
