<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="费用ID" prop="feeId">
              <el-input v-model="formData.feeId"></el-input>
            </el-form-item>
            <el-form-item label="费用名称" prop="feeNameCode">
                <PublicQuery
                title="费用名称"
                single
                :rowData.sync="feeData"
                cfgKey="chgWmsFeeName"
                baseUrl="/chg_web/chgweb"
                :valueField.sync="formData.feeNameCode"
                :textField.sync="formData.feeName"></PublicQuery>
            </el-form-item>
            <el-form-item label="费用类别" prop="feeType">
                <el-select multiple v-model="formData.feeType" >
                    <el-option label="运输费用" value="TRANSPORT_CHARGE"></el-option>
                    <el-option label="特殊费用" value="SPECIAL_CHARGE"></el-option>
                    <el-option label="增值服务费用" value="APPENDED_CHARGE"></el-option>
                    <el-option label="服务费用" value="SERVICE_CHARGE"></el-option>
                    <el-option label="全部" value="ALL"></el-option>
                    <el-option label="理赔费用" value="CLAIM_CHARGE"></el-option>
                    <el-option label="实际报账费用" value="DRIVER_REIMBURSE"></el-option>
                    <el-option label="库存费用" value="KCFY"></el-option>
                </el-select>
            </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-select>
            </el-form-item>
              <el-form-item label="费用种类" prop="feeCategory">
                <el-select multiple  v-model="formData.feeCategory"  >
                    <el-option label="入库费用" value="INBOUND"></el-option>
                    <el-option label="出库费用" value="OUTBOUND"></el-option>
                    <el-option label="库存费用" value="INVENTORY"></el-option>
                    <el-option label="服务增值费用" value="VAS"></el-option>
                    <el-option label="特殊费用" value="SPECIAL"></el-option>
                    <el-option label="管理费用" value="MANAGE"></el-option>
                </el-select>
            </el-form-item>
              <el-form-item label="作业环节" prop="tranType">
                <el-select multiple  v-model="formData.tranType"  >
                    <el-option label="取消加工父件入库" value="CKIN"></el-option>
                    <el-option label="取消加工子件出库" value="CKOUT"></el-option>
                    <el-option label="取消加工转移" value="CKTF"></el-option>
                    <el-option label="取消移动" value="CMV"></el-option>
                    <el-option label="取消调整" value="CAD"></el-option>
                    <el-option label="取消转移" value="CTF"></el-option>
                    <el-option label="取消补货" value="CRP"></el-option>
                    <el-option label="取消质检转移" value="CQTF"></el-option>
                    <el-option label="收货" value="RCV"></el-option>
                    <el-option label="取消收货" value="CRCV"></el-option>
                    <el-option label="上架" value="PA"></el-option>
                    <el-option label="拣货" value="PK"></el-option>
                    <el-option label="打包" value="PACK"></el-option>
                    <el-option label="发货" value="SP"></el-option>
                    <el-option label="取消发货" value="CSP"></el-option>
                    <el-option label="调整" value="AD"></el-option>
                    <el-option label="移动" value="MV"></el-option>
                    <el-option label="转移" value="TF"></el-option>
                    <el-option label="补货" value="RP"></el-option>
                    <el-option label="装车移动" value="LD"></el-option>
                    <el-option label="收货" value="QTF"></el-option>
                    <el-option label="质检转移" value="CRCV"></el-option>
                    <el-option label="加工父件入库" value="KIN"></el-option>
                    <el-option label="加工子件出库" value="KOUT"></el-option>
                    <el-option label="加工转移" value="KTF"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="计费基准" prop="chargeBase">
                <el-select multiple v-model="formData.chargeBase"  >
                    <el-option label="库位" value="LOC"></el-option>
                    <el-option label="实际托" value="ACT_PALLET"></el-option>
                    <el-option label="计算托" value="CALC_PALLET"></el-option>
                    <el-option label="箱" value="CASE"></el-option>
                    <el-option label="数量EA" value="QTY"></el-option>
                    <el-option label="体积" value="CUBIC"></el-option>
                    <el-option label="重量" value="WEIGHT"></el-option>
                    <el-option label="计费吨" value="RT"></el-option>
                    <el-option label="固定费用" value="CONSTANT"></el-option>
                    <el-option label="实际重量" value="ACT_WEIGHT"></el-option>
                    <el-option label="货值" value="COST"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="币别" prop="currency">
                <el-select multiple v-model="formData.currency"  >
                    <el-option label="美元" value="USD"></el-option>
                    <el-option label="欧元" value="EUR"></el-option>
                    <el-option label="人民币" value="CNY"></el-option>
                    <el-option label="新加坡元" value="SGD"></el-option>
                    <el-option label="新台币" value="NTD"></el-option>
                    <el-option label="USD" value="USD"></el-option>
                    <el-option label="CNY" value="CNY"></el-option>
                    <el-option label="EUR" value="EUR"></el-option>
                    <el-option label="SG$" value="SG$"></el-option>
                    <el-option label="NTD" value="NTD"></el-option>
                    <el-option label="ESM" value="ESM"></el-option>
                    <el-option label="RMB" value="RMB"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="舍入类型" prop="roundingType">
                <el-select multiple v-model="formData.roundingType">
                    <el-option label="四舍五入" value="ROUND"></el-option>
                    <el-option label="向上取整" value="CEIL"></el-option>
                    <el-option label="向下取整" value="FLOOR"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="单据类型" prop="orderType">
                <el-select multiple v-model="formData.orderType" >
                    <el-option label="入库单" value="ASN"></el-option>
                    <el-option label="出库单" value="SO"></el-option>
                    <el-option label="装车单" value="LD"></el-option>
                    <el-option label="调整单" value="AD"></el-option>
                    <el-option label="转移单" value="TF"></el-option>
                    <el-option label="质检单" value="QC"></el-option>
                    <el-option label="加工单" value="KIT"></el-option>
                    <el-option label="补货单" value="RP"></el-option>
                    <el-option label="移动单" value="MV"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="单据号" prop="orderNo">
                <el-input v-model="formData.orderNo"></el-input>
            </el-form-item>
            <el-form-item label="交易ID" prop="tranId">
                <el-input v-model="formData.tranId"></el-input>
            </el-form-item>
            <el-form-item label="货主" prop="ownerCode">
                <PublicQuery
                title="货主"
                single
                :rowData.sync="ownerData"
                cfgKey="chgWmsFeeName"
                baseUrl="/chg_web/chgweb"
                :valueField.sync="formData.ownerCode"
                :textField.sync="formData.ownerName"></PublicQuery>
            </el-form-item>
            <el-form-item label="商品" prop="skuCode">
                <PublicQuery
                title="商品"
                single
                :rowData.sync="skuData"
                cfgKey="chgWmsFeeName"
                baseUrl="/chg_web/chgweb"
                :valueField.sync="formData.skuCode"
                :textField.sync="formData.skuName"></PublicQuery>
            </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="receivePay">
              <el-select  v-model="formData.receivePay" >
                    <el-option label="收入" value="RECEIVE"></el-option>
                    <el-option label="支出" value="PAY"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="合同编号" prop="contractNo">
                <el-input v-model="formData.contractNo" ></el-input>
            </el-form-item>
            <el-form-item label="费用时间" prop="feeDate">
                <el-date-picker
                v-model="date"
                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>
          <div class="more-query-btn">
            <el-button v-auth="50600030103" type="primary" @click="submitForm">查询</el-button>
            <el-button v-auth="50600030104" @click="resetForm">重置</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: {
        feeType: [],
        status: [],
        feeCategory: [],
        tranType: [],
        chargeBase: [],
        currency: [],
        roundingType: [],
        orderType: []
      },
      ownerData: {},
      feeData: {},
      skuData: {},
      pickerOptions2: {
        shortcuts: [today, yesterday, week, month, twoMonths, threeMonths]
      },
      date: '',
    }
  },
  props: {
    moreQueryVisible: Boolean
  },
  methods: {

    // 获得生效时间
    getTime1 (val) {
      this.formData.feeDateFm = val[0]
      this.formData.feeDateTo = 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>
