<template>
<el-dialog
  width="70%"
  class="more-query"
  title="高级查询"
  :visible="showMore"
  @close="close"
>
  <el-form
    inline
    label-position="top"
    :model="query"
    ref="queryForm"
  >
    <!--公用查询框-->
    <template v-for="item in publicQueries">
      <el-form-item :key="item.valueField" :label="item.label" :prop="item.valueField">
        <PublicQuery
          :title="item.label"
          :cfgKey="item.cfgKey"
          :baseUrl="baseUrl"
          :valueField.sync="query[item.valueField]"
          :textField.sync="item.textField === undefined ? false : query[item.textField]"
        ></PublicQuery>
      </el-form-item>
    </template>

    <el-form-item label="批次号" prop="lotNum">
      <el-input v-model="query.lotNum"></el-input>
    </el-form-item>
    <el-form-item label="跟踪号" prop="traceId">
      <el-input v-model="query.traceId"></el-input>
    </el-form-item>
  </el-form>
  <div class="more-query__btn">
    <el-button v-auth="50300040103" type="primary" @click="submitForm">查询</el-button>
    <el-button v-auth="50300040104" @click="resetForm('queryForm')">重置</el-button>
  </div>
</el-dialog>
</template>

<script>
import * as shortcuts from '@/config/shortcuts'
export default {
  props: ['showMore', 'query'],
  created () {
  },
  mounted () {
  },

  data () {
    return {
      baseUrl: '/inv_web/invweb', // 多条件基础URL
      publicQueries: [
        { label: '货主', valueField: 'ownerCode', cfgKey: 'invWmsCustomer' },
        { label: '商品', valueField: 'skuCode', cfgKey: 'invWmsSku' },
        { label: '库位', valueField: 'locCode', cfgKey: 'invWmsLoc' },
      ],
      pickerOptions: {
        shortcuts: { ...shortcuts }
      },
    }
  },
  methods: {
    // 关闭弹窗
    close () {
      this.$emit('close')
    },
    // 提交表单
    submitForm () {
      this.$emit('toGetList', this.query)
      this.close()
    },
    // 重置表单
    resetForm (formName) {
      this.$refs[formName].resetFields()
    },
  },
}
</script>

<style lang="scss" scoped>
</style>
