<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="ldNo">
              <el-input v-model="formData.ldNo"></el-input>
            </el-form-item>
            <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="driver">
              <el-input v-model="formData.driver"></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="soStatus">
              <el-select multiple v-model="formData.soStatus">
                <el-option label="完全拣货" value="60"></el-option>
                <el-option label="完全发运" value="80"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item
              label="装车类型"
              prop="ldType">
              <el-select multiple v-model="formData.ldType">
                <el-option label="无限制" value="FREE"></el-option>
                <el-option label="按承运商" value="CARRIER"></el-option>
                <el-option label="按线路" value="LINE"></el-option>
                <el-option label="按收货人" value="CONSIGNEE"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item
              label="车型"
              prop="vehichleType">
              <el-select multiple v-model="formData.vehichleType">
                 <el-option label="牵引车" value="TR"></el-option>
                <el-option label="大型车辆" value="VE"></el-option>
                <el-option label="小型车辆" value="HI"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item
              label="修改人">
              <PublicQuery
              title="修改人"
              baseUrl="/oub_web/oubweb"
              cfgKey="oubWmsOperator"
              :valueField.sync="formData.Modifier"
              :textField.sync="formData.modifierLoginName">
              </PublicQuery>
            </el-form-item>
            <el-form-item
              label="创建人">
              <PublicQuery
              title="创建人"
              baseUrl="/oub_web/oubweb"
              cfgKey="oubWmsOperator"
              :valueField.sync="formData.Creator"
              :textField.sync="formData.creatorLoginName">
              </PublicQuery>
            </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="getfmLdTime">
              </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="gettoLdTime">
              </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="getdeliverTime">
              </el-date-picker>
            </el-form-item>
            <el-form-item
              label="创建时间">
              <el-date-picker
                v-model="date4"
                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="date5"
                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>
          <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'
console.log(week)
export default {
  data () {
    return {
      formData: {
        ldNo: '',
        soNo: '',
        vehicleNo: '',
        driver: '',
        soStatus: '',
        status: [],
        ldType: [],
        vehichleType: [],
        Modifier: '',
        modifierLoginName: '',
        creatorLoginName: '',
        Creator: '',
        fmLdTimeFm: '', // 装车开始时间
        fmLdTimeTo: '',
        toLdTimeFm: '', // 装车结束时间
        toLdTimeTo: '',
        deliverTimeFm: '', // 装车交接时间
        deliverTimeTo: '',
        createTimeFm: '', // 创建时间
        createTimeTo: '',
        modifyTimeFm: '', // 修改时间
        modifyTimeTo: '',
      },
      date1: '',
      date2: '',
      date3: '',
      date4: '',
      date5: '',
      pickerOptions2: {
        shortcuts: [today, yesterday, week, month, twoMonths, threeMonths]
      },
    }
  },
  mounted () {
  },
  props: {
    moreQueryVisible: Boolean
  },
  methods: {

    // 获得时间
    // 装车开始
    getfmLdTime (val) {
      this.formData.fmLdTimeFm = val[0]
      this.formData.fmLdTimeTo = val[1]
    },
    // 装车结束
    gettoLdTime (val) {
      this.formData.toLdTimeFm = val[0]
      this.formData.toLdTimeTo = val[1]
    },
    // 装车交接
    getdeliverTime (val) {
      this.formData.deliverTimeFm = val[0]
      this.formData.deliverTimeTo = 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>
