<template>
    <div>
        <el-dialog
          title="高级查询"
          :visible="moreQueryVisible"
          @close="close"
          width="66%">
          <el-form
            inline
            ref="queryForm"
            label-position="top"
            :model="formData">
            <el-form-item
              label="库区编码"
              prop="zoneCode">
              <el-input v-model="formData.zoneCode"></el-input>
            </el-form-item>
            <el-form-item
              label="库区名称"
              prop="zoneName">
              <el-input v-model="formData.zoneName"></el-input>
            </el-form-item>
            <el-form-item
              label="备注"
              prop="remark">
              <el-input v-model="formData.remark"></el-input>
            </el-form-item>
            <el-form-item
              label="库区类型"
              prop="type">
              <el-select multiple v-model="formData.type">
                <el-option label="平面仓库区" value="1"></el-option>
                <el-option label="货架仓库区" value="2"></el-option>
                <el-option label="高架仓库区" value="3"></el-option>
                <el-option label="重力式货架库区" value="4"></el-option>
                <el-option label="堆垛机货架库区" value="5"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item
              label="所属区域"
              prop="areaCode">
              <PublicQuery
              title="所属区域"
              baseUrl="/bd_web/bdweb"
              cfgKey="bdWmsArea"
              :valueField.sync="formData.areaCode"
              :textField.sync="formData.areaName">
              </PublicQuery>
            </el-form-item>
          </el-form>
          <div class="more-query-btn">
            <el-button v-auth="50400020103" type="primary" @click="submitForm">查询</el-button>
            <el-button v-auth="50400020104" @click="resetForm('queryForm')">重置</el-button>
          </div>
        </el-dialog>
    </div>
</template>
<script>
export default {
  data () {
    return {
      formData: {
        zoneCode: '',
        zoneName: '',
        remark: '',
        areaCode: '',
        areaName: '',
        type: []
      },
    }
  },
  mounted () {
  },
  props: {
    moreQueryVisible: Boolean
  },
  methods: {

    // 关闭弹窗
    close () {
      this.$emit('close')
    },

    // 提交表单
    submitForm () {
      this.format()
      this.$emit('toGetList', this.formData)
      this.$refs['queryForm'].resetFields()
    },

    // 重置表单
    resetForm () {
      this.$refs['queryForm'].resetFields()
    },

    // 格式化对象数据
    format () {
      for (const key in this.formData) {
        if (this.formData.hasOwnProperty(key)) {
          const element = this.formData[key]
          if (Array.isArray(element)) {
            this.formData[key] = element.join(',')
          }
        }
      }
      return this.formData
    }
  }
}
</script>
