<template>
    <div>
        <el-dialog
          title="高级查询"
          :visible="moreQueryVisible"
          @close="close"
          width="66%">
          <el-form
            inline
            ref="formData"
            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="logisticNo">
              <el-input v-model="formData.logisticNo"></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="waveNo">
              <el-input v-model="formData.waveNo"></el-input>
            </el-form-item>
            <el-form-item
              label="状态"
              prop="status">
              <el-select multiple v-model="formData.status" >
                <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="30"></el-option>
                <el-option label="完全分配" value="40"></el-option>
                <el-option label="部分拣货" value="50"></el-option>
                <el-option label="完全拣货" value="60"></el-option>
                <el-option label="部分发运" value="70"></el-option>
                <el-option label="完全发运" value="80"></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="出库单类型"
              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="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="订单时间">
              <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="getSTime">
              </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="oubWmsSkuCondition"
              :valueField.sync="formData.skuCode"
              :textField.sync="formData.skuName">
              </PublicQuery>
            </el-form-item>
            <el-form-item
              label="承运商">
              <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="供应商">
              <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-item
              label="项目名称">
              <PublicQuery
              title="项目名称"
              baseUrl="/oub_web/oubweb"
              cfgKey="customerBusinessItems"
              :valueField.sync="formData.businessItemCodes"
              :textField.sync="formData.businessItemName">
              </PublicQuery>
            </el-form-item>
            <el-form-item
              label="调入仓库">
              <PublicQuery
              title="调入仓库"
              baseUrl="/oub_web/oubweb"
              cfgKey="oubWmsWareHouse"
              :valueField.sync="formData.allocateInWhNames"
              :textField.sync="formData.allocateInWhs">
              </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('formData')">重置</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: '',
        status: [],
        ownerName: '',
        ownerCode: '',
        logisticNo: '',
        soType: [],
        suppqlierName: '',
        supplierCode: '',
        isEdiSend: '',
        isWv: '',
        skuName: '',
        skuCode: '',
        carrierName: '',
        carrierCode: '',
        businessItemName: '',
        businessItemCodes: '',
        allocateInWhNames: '',
        allocateInWhs: '',
        waveNo: '',
        orderTimeFm: time.formatTime(new Date(new Date() - 3600 * 1000 * 24 * 7)),
        orderTimeTo: time.formatTime(new Date()),
      },

      pickerOptions2: {
        shortcuts: [today, yesterday, week, month, twoMonths, threeMonths]
      },
      date1: '',
      date2: '',

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

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

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

    // 提交表单
    submitForm () {
      this.format()
      this.$emit('toGetList', this.formData)
      this.$refs['formData'].resetFields()
    },

    // 重置表单
    resetForm () {
      this.$refs['formData'].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>
