<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="/kit_web/kitweb"
              cfgKey="kitWmsCustomer"
              :valueField.sync="formData.ownerCode"
              :textField.sync="formData.ownerName">
              </PublicQuery>
            </el-form-item>
            <el-form-item
              label="父件编码"
              prop="parentSkuCode">
              <el-input v-model="formData.parentSkuCode"></el-input>
            </el-form-item>
            <el-form-item
              label="组合件类型"
              prop="kitType">
              <el-select v-model="formData.kitType">
                <el-option label="组合加工(A=B+C)" value="COM"></el-option>
                <el-option label="辅料加工(A=A+辅料)" value="ACC"></el-option>
                <el-option label="增值加工(A=A)" value="VA"></el-option>
              </el-select>
            </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="isKitting">
              <el-select multiple v-model="formData.isKitting">
                <el-option label="是" value="Y"></el-option>
                <el-option label="否" value="N"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item
              label="齐套管理类型"
              prop="kittingType">
              <el-select v-model="formData.kittingType">
                <el-option label="商品齐套" value="MK"></el-option>
                <el-option label="序列号齐套" value="SK"></el-option>
              </el-select>
            </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: {
        kitType: [],
        isKitting: [],
        kittingType: []
      },
    }
  },
  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>
