<template>
  <a-modal
    centered
    class="bulkReturnGoods-basicInfo-modal"
    :footer="null"
    :maskClosable="false"
    title="新增散件退货单"
    v-model="isShow"
    @cancle="isShow = false"
    width="80%">
    <a-form-model
      id="bulkReturnGoods-basicInfo-form"
      ref="ruleForm"
      :model="form"
      :rules="rules"
      :label-col="formItemLayout.labelCol"
      :wrapper-col="formItemLayout.wrapperCol">
      <a-form-model-item label="供应商" prop="name">
        <a-select
          v-model="form.name"
          placeholder="请选择"
          allowClear
          :showSearch="true"
          option-filter-prop="children"
          :filter-option="filterOption">
          <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-item label="是否抓单" prop="type">
        <a-radio-group v-model="form.type">
          <a-radio value="a">是</a-radio>
          <a-radio value="b">否</a-radio>
        </a-radio-group>
      </a-form-model-item>
      <a-form-model-item label="备注" prop="remarks">
        <a-textarea id="bulkReturnGoods-basicInfo-remarks" :maxLength="120" v-model="form.remarks" placeholder="请输入备注(最多120个字符)" allowClear />
      </a-form-model-item>
    </a-form-model>
    <div class="btn-cont">
      <a-button type="primary" id="bulkReturnGoods-basicInfo-modal-save" @click="handleSave">保存</a-button>
      <a-button id="bulkReturnGoods-basicInfo-modal-back" @click="isShow = false" style="margin-left: 15px;">取消</a-button>
    </div>
  </a-modal>
</template>

<script>
import { VSelect } from '@/components'
export default {
  name: 'BulkReturnGoodsBasicInfoModal',
  components: { VSelect },
  props: {
    openModal: {
      //  弹框显示状态
      type: Boolean,
      default: false
    }
  },
  data () {
    return {
      isShow: this.openModal, //  是否打开弹框
      formItemLayout: {
        labelCol: { span: 6 },
        wrapperCol: { span: 16 }
      },
      form: {
        type: 'a',
        name: undefined, // 仓库名称
        sort: '' //  排序
      },
      rules: {
        name: [{ required: true, message: '请选择调出产品类型', trigger: 'change' }]
      },
      brandData: [] //  供应商  下拉数据
    }
  },
  methods: {
    //  保存
    handleSave () {
      this.isShow = false
      this.$emit('ok')
    },
    filterOption (input, option) {
      return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
    }
  },
  watch: {
    //  父页面传过来的弹框状态
    openModal (newValue, oldValue) {
      this.isShow = newValue
    },
    //  重定义的弹框状态
    isShow (newValue, oldValue) {
      if (!newValue) {
        this.$emit('close')
      }
    }
  }
}
</script>

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