<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="车牌号"
              prop="vehicleNo">
              <el-input v-model="formData.vehicleNo"></el-input>
            </el-form-item>
            <el-form-item
              label="销售计划单号"
              prop="saleNo">
              <el-input v-model="formData.saleNo"></el-input>
            </el-form-item>
            <el-form-item
              label="物流单号"
              prop="logisticNo">
              <el-input v-model="formData.logisticNo"></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="soType">
              <el-select multiple v-model="formData.soType">
                <el-option label="普通出库" value="PO"></el-option>
                <el-option label="调拨出库" value="AO"></el-option>
                <el-option label="退货出库" value="RO"></el-option>
                <el-option label="换货出库" value="EO"></el-option>
                <el-option label="排序出库" value="OO"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item
              label="拦截状态"
              prop="interceptStatus">
              <el-select multiple v-model="formData.interceptStatus" >
                <el-option label="无拦截" value="00"></el-option>
                <el-option label="拦截" value="10"></el-option>
                <el-option label="待归储" value="20"></el-option>
                <el-option label="拦截失败" value="90"></el-option>
                <el-option label="拦截成功" value="99"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item
              label="EDI是否已发送"
              prop="isEdiSend">
              <el-select v-model="formData.isEdiSend">
                <el-option label="是" value="Y"></el-option>
                <el-option label="否" value="N"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item
              label="是否生成订单波次"
              prop="isWv">
              <el-select v-model="formData.isWv">
                <el-option label="是" value="Y"></el-option>
                <el-option label="否" value="N"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item
              label="冻结状态"
              prop="holdStatus">
              <el-select multiple v-model="formData.holdStatus">
                <el-option label="无冻结" value="00"></el-option>
                <el-option label="冻结" value="99"></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="getTime1">
              </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="getTime2">
              </el-date-picker>
            </el-form-item>
            <el-form-item
              label="货主编码"
              prop="ownerName">
              <PublicQuery
              title="货主编码"
              baseUrl="/oub_web/oubweb"
              cfgKey="oubWmsCustomer"
              :valueField.sync="formData.ownerCode"
              :textField.sync="formData.ownerName">
              </PublicQuery>
            </el-form-item>
            <el-form-item
              label="商品"
              prop="skuName">
              <PublicQuery
              title="商品"
              baseUrl="/oub_web/oubweb"
              cfgKey="oubWmsSku"
              :valueField.sync="formData.skuCode"
              :textField.sync="formData.skuName">
              </PublicQuery>
            </el-form-item>
            <el-form-item
              label="承运商"
              prop="carrierName">
              <PublicQuery
              title="承运商"
              baseUrl="/oub_web/oubweb"
              cfgKey="OUB_TRANSPORT_SUPPLIER"
              :valueField.sync="formData.carrierCode"
              :textField.sync="formData.carrierName">
              </PublicQuery>
            </el-form-item>
            <el-form-item
              label="调出仓库"
              prop="allocateOutWhNames">
              <PublicQuery
              title="调出仓库"
              baseUrl="/oub_web/oubweb"
              cfgKey="oubWmsWareHouse"
              :valueField.sync="formData.allocateOutWhs"
              :textField.sync="formData.allocateOutWhNames">
              </PublicQuery>
            </el-form-item>
            <el-form-item
              label="供应商"
              prop="supplierName">
              <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: '',
        ownerName: '',
        ownerCode: '',
        saleNo: '',
        logisticNo: '',
        soType: [],
        interceptStatus: [],
        supplierName: '',
        supplierCode: '',
        isEdiSend: '',
        isWv: '',
        skuName: '',
        skuCode: '',
        carrierName: '',
        carrierCode: '',
        holdStatus: [],
        waveNo: '',
        allocateSoNo: '',
        fmETD: '',
        toETD: '',
        orderTimeFm: time.formatTime(new Date(new Date() - 3600 * 1000 * 24 * 7)),
        orderTimeTo: time.formatTime(new Date()),
        'page.currentPage': 1,
        'page.limitCount': 10
      },
      pickerOptions2: {
        shortcuts: [today, yesterday, week, month, twoMonths, threeMonths]
      },
      date1: [new Date(new Date() - 3600 * 1000 * 24 * 7), new Date()],
      date2: '',

    }
  },
  mounted () {
  },
  props: {
    moreQueryVisible: Boolean
  },
  methods: {

    // 获得时间
    getTime1 (val) {
      this.formData.orderTimeFm = val[0]
      this.formData.orderTimeTo = val[1]
    },

    getTime2 (val) {
      this.formData.fmETD = val[0]
      this.formData.toETD = val[1]
    },

    // 关闭弹窗
    close () {
      this.$emit('close')
    },

    // 提交表单
    submitForm () {
      this.format()
      this.$emit('toGetList', this.formData, 'more')
      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
    }
  },
  watch: {

  }
}
</script>
