<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="ownerCode">
              <PublicQuery
              title="货主编码"
              baseUrl="/bd_web/bdweb"
              cfgKey="bdWmsCustomer"
              :valueField.sync="formData.ownerCode"
              :textField.sync="formData.ownerName">
              </PublicQuery>
            </el-form-item>
            <el-form-item
              label="商品编码"
              prop="skuCode">
              <el-input v-model="formData.skuCode"></el-input>
            </el-form-item>
            <el-form-item
              label="商品名称"
              prop="skuName">
              <el-input v-model="formData.skuName"></el-input>
            </el-form-item>
            <el-form-item
              label="商品简称"
              prop="shortName">
              <el-input v-model="formData.shortName"></el-input>
            </el-form-item>
            <el-form-item
              label="快速录入码"
              prop="quickCode">
              <el-input v-model="formData.quickCode"></el-input>
            </el-form-item>
            <el-form-item
              label="商品条码"
              prop="barCode">
              <el-input v-model="formData.barCode"></el-input>
            </el-form-item>
            <el-form-item
              label="供应商条码"
              prop="supBarCode">
              <el-input v-model="formData.supBarCode"></el-input>
            </el-form-item>
            <el-form-item
              label="商品类型"
              prop="typeCode">
              <el-select multiple v-model="formData.typeCode">
                <el-option label="普货" value="MATERIAL_GENERAL_CARGO"></el-option>
                <el-option label="危险化学品" value="MATERIAL_DG"></el-option>
                <el-option label="剧毒品" value="MATERIAL_VIRULENT"></el-option>
                <el-option label="冷冻品" value="MATERIAL_PT"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item
              label="商品温层"
              prop="tempLevel">
              <el-select multiple v-model="formData.tempLevel">
                <el-option label="恒温" value="TT"></el-option>
                <el-option label="冷藏" value="RT"></el-option>
                <el-option label="冷冻" value="FT"></el-option>
                <el-option label="常温" value="NT"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item
              label="包装规格"
              prop="cdpaFormat">
              <PublicQuery
              title="包装规格"
              baseUrl="/bd_web/bdweb"
              cfgKey="bdWmsPackage"
              :valueField.sync="formData.packCode"
              :textField.sync="formData.cdpaFormat">
              </PublicQuery>
            </el-form-item>
          </el-form>
          <div class="more-query-btn">
            <el-button v-auth="50300030101" type="primary" @click="submitForm">查询</el-button>
            <el-button v-auth="50300030101" @click="resetForm('queryForm')">重置</el-button>
          </div>
        </el-dialog>
    </div>
</template>
<script>
export default {
  data () {
    return {
      formData: {
        ownerName: '',
        ownerCode: '',
        skuCode: '',
        skuName: '',
        shortName: '',
        quickCode: '',
        barCode: '',
        supBarCode: '',
        typeCode: [],
        tempLevel: [],
        packCode: '',
        cdpaFormat: ''
      },
    }
  },
  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>
