<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="soNo">
              <el-input v-model="formData.soNo"></el-input>
            </el-form-item>
            <el-form-item
              label="拣货任务ID"
              prop="allocId">
              <el-input v-model="formData.allocId"></el-input>
            </el-form-item>
            <el-form-item
              label="拣货波次单号"
              prop="pkNo">
              <el-input v-model="formData.pkNo"></el-input>
            </el-form-item>
            <el-form-item
              label="订单波次单号"
              prop="waveNo">
              <el-input v-model="formData.waveNo"></el-input>
            </el-form-item>
            <el-form-item
              label="批次号"
              prop="lotNum">
              <el-input v-model="formData.lotNum"></el-input>
            </el-form-item>
            <el-form-item
              label="源跟踪号"
              prop="traceId">
              <el-input v-model="formData.traceId"></el-input>
            </el-form-item>
            <el-form-item
              label="目标跟踪号"
              prop="toId">
              <el-input v-model="formData.toId"></el-input>
            </el-form-item>
            <el-form-item
              label="状态"
              prop="status">
              <el-select multiple v-model="formData.status">
                <el-option label="完全分配" value="40"></el-option>
                <el-option label="完全拣货" value="60"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item
              label="拣货时间">
              <el-date-picker
                v-model="date1"
                type="datetimerange"
                format="yyyy-MM-dd HH:mm"
                value-format="yyyy-MM-dd HH:mm:ss"
                :default-time="['00:00:00', '23:59:59']"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                :picker-options="pickerOptions2"
                @change="getpickTime">
              </el-date-picker>
            </el-form-item>
            <el-form-item
              label="创建时间">
              <el-date-picker
                v-model="date2"
                type="datetimerange"
                format="yyyy-MM-dd HH:mm"
                value-format="yyyy-MM-dd HH:mm:ss"
                :default-time="['00:00:00', '23:59:59']"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                :picker-options="pickerOptions2"
                @change="getcreateTime">
              </el-date-picker>
            </el-form-item>
            <el-form-item
              label="修改时间">
              <el-date-picker
                v-model="date3"
                type="datetimerange"
                format="yyyy-MM-dd HH:mm"
                value-format="yyyy-MM-dd HH:mm:ss"
                :default-time="['00:00:00', '23:59:59']"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                :picker-options="pickerOptions2"
                @change="getmodifyTime">
              </el-date-picker>
            </el-form-item>
            <el-form-item
              label="货主">
              <PublicQuery
              title="货主编码"
              baseUrl="/oub_web/oubweb"
              cfgKey="oubWmsCustomer"
              :valueField.sync="formData.ownerCode"
              :textField.sync="formData.ownerName">
              </PublicQuery>
            </el-form-item>
            <el-form-item
              label="商品">
              <PublicQuery
              title="商品"
              baseUrl="/oub_web/oubweb"
              cfgKey="oubWmsSku"
              :valueField.sync="formData.skuCode"
              :textField.sync="formData.skuName">
              </PublicQuery>
            </el-form-item>
            <el-form-item
              label="源库位">
              <PublicQuery
              title="源库位"
              baseUrl="/oub_web/oubweb"
              cfgKey="oubWmsLoc"
              :valueField.sync="formData.locCode">
              </PublicQuery>
            </el-form-item>
            <el-form-item
              label="目标库位">
              <PublicQuery
              title="目标库位"
              baseUrl="/oub_web/oubweb"
              cfgKey="oubWmsLoc"
              :valueField.sync="formData.toLoc">
              </PublicQuery>
            </el-form-item>
            <el-form-item
              label="拣货人">
              <PublicQuery
              title="拣货人"
              baseUrl="/oub_web/oubweb"
              cfgKey="oubWmsOperator"
              :valueField.sync="formData.pickOpName">
              </PublicQuery>
            </el-form-item>
            <el-form-item
              label="创建人">
              <PublicQuery
              title="创建人"
              baseUrl="/oub_web/oubweb"
              cfgKey="oubWmsOperator"
              :valueField.sync="formData.creatorLoginName">
              </PublicQuery>
            </el-form-item>
            <el-form-item
              label="修改人">
              <PublicQuery
              title="修改人"
              baseUrl="/oub_web/oubweb"
              cfgKey="oubWmsOperator"
              :valueField.sync="formData.modifierLoginName">
              </PublicQuery>
            </el-form-item>
            <el-form-item
              label="供应商">
              <PublicQuery
              title="供应商"
              baseUrl="/oub_web/oubweb"
              cfgKey="OUB_LSP_SERVICE_SUPPLIER"
              :valueField.sync="formData.supplierCode"
              :textField.sync="formData.supplierName">
              </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>
import { time } from 'apec-fe-utils'
import { today, yesterday, week, month, twoMonths, threeMonths } from '@/config/shortcuts'
export default {
  data () {
    return {
      formData: {
        soNo: '',
        allocId: '',
        pkNo: '',
        waveNo: '',
        lotNum: '',
        traceId: '',
        toId: '',
        status: [],
        pickTimeFm: '', // 拣货时间
        pickTimeTo: '',
        createTimeFm: '', // 创建时间
        createTimeTo: '',
        modifyTimeFm: '', // 修改时间
        modifyTimeTo: '',
        ownerName: '',
        ownerCode: '',
        locCode: '',
        skuName: '',
        skuCode: '',
        toLoc: '',
        pickOpName: '',
        creatorLoginName: '',
        modifierLoginName: '',
        supplierCode: '',
        supplierName: ''
      },

      pickerOptions2: {
        shortcuts: [today, yesterday, week, month, twoMonths, threeMonths]
      },
      date1: [new Date(new Date() - 3600 * 1000 * 24 * 7), new Date()],
      date2: '',
      date3: '',
    }
  },
  mounted () {
  },
  props: {
    moreQueryVisible: Boolean
  },
  methods: {

    // 获得时间
    getpickTime (val) {
      this.formData.pickTimeFm = val[0]
      this.formData.pickTimeTo = val[1]
    },
    getcreateTime (val) {
      this.formData.createTimeFm = val[0]
      this.formData.createTimeTo = val[1]
    },
    getmodifyTime (val) {
      this.formData.modifyTimeFm = val[0]
      this.formData.modifyTimeTo = val[1]
    },

    // 关闭弹窗
    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>
