<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="query[item.textField]"
        ></PublicQuery>
      </el-form-item>
    </template>
    <!--输入框-->
    <template v-for="item in inputs">
      <el-form-item :key="item.prop" :label="item.label" :prop="item.prop">
        <el-input v-model="query[item.prop]"></el-input>
      </el-form-item>
    </template>
    <el-form-item label="历史时间">
      <el-date-picker
        v-model="query.tranTime"
        value-format="yyyy-MM-dd 00:00:00"
      ></el-date-picker>
    </el-form-item>
  </el-form>
  <div class="more-query__btn">
    <el-button v-auth="50940050103" type="primary" @click="submitForm">查询</el-button>
    <el-button v-auth="50940050104" @click="reset">重置</el-button>
  </div>
</el-dialog>
</template>

<script>
import { time } from 'apec-fe-utils'
import * as shortcuts from '@/config/shortcuts'

export default {
  props: ['showMore'],
  created () {
  },
  mounted () {
  },

  data () {
    return {
      query: {}, // 查询条件
      baseUrl: '/enp_web/enpweb',
      pickerOptions: {
        shortcuts: { ...shortcuts }
      },
      inputs: [
        { label: '批次号', prop: 'lot' },
        { label: '跟踪号', prop: 'fmid' },
      ],
      publicQueries: [
        { label: '货主', valueField: 'ownerCode', textField: 'ebcuNameCn', cfgKey: 'enpWmsCustomer', rowData: {} },
        { label: '商品', valueField: 'skuCode', textField: 'skuName', cfgKey: 'enpWmsSkuCode', rowData: {} },
        { label: '仓库', valueField: 'projectIds', textField: 'cdwhName', cfgKey: 'enpWmsShareWareHouse', rowData: {} },
        { label: '库位从', valueField: 'locFrom', cfgKey: 'enpWmsLoc', rowData: {} },
        { label: '库位到', valueField: 'locTo', cfgKey: 'enpWmsLoc', rowData: {} },
      ],
    }
  },
  methods: {
    // 关闭弹窗
    close () {
      this.$emit('close')
    },
    // 提交表单
    submitForm () {
      this.$emit('toGetList', this.query)
      this.close()
    },
    // 重置表单
    reset () {
      this.$refs.queryForm.resetFields()
    },
  },
}
</script>

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