<template>
<div>
  <el-row class="query">
    <div class="query__retrieve">
      <!-- <el-input
        v-model="query.fastOwnerCode"
        placeholder="快捷查询（货主编码/货主名称）"
        @keyup.enter.native="toGetList(query)"
      ></el-input>
      <el-input
        class="query__item"
        v-model="query.fastSkuCode"
        placeholder="快捷查询（商品编码/商品名称）"
        @keyup.enter.native="toGetList(query)"
      ></el-input> -->
      <el-button v-auth="50300040102" class="query__item" type="primary" @click="moreQuery">更多</el-button>
      <el-button v-auth="50300040101" icon="el-icon-refresh" class="query__item" type="primary" @click="handelGetList" plain circle></el-button>
      <el-button v-auth="50100030101" icon="el-icon-download" v-if="false" type="primary" @click="handleExcel" plain circle></el-button>
      <MoreQuery
        :query="query"
        :showMore="showMore"
        @close="showMore = false"
        @toGetList="toGetList"
      ></MoreQuery>
    </div>
  </el-row>
  <div class="inputBox">
    <el-form inline :model="formDate" ref="formDate" label-position="left">
      <el-form-item label="货主编码" prop="fastOwnerCode">
         <el-input
          v-model="formDate.fastOwnerCode"
          placeholder="快捷查询（货主编码/货主名称）"
          @keyup.enter.native="toGetList(formDate)"
        ></el-input>
      </el-form-item>
      <el-form-item
        label="商品编码"
        prop="fastSkuCode">
         <el-input
            v-model="formDate.fastSkuCode"
            placeholder="快捷查询（商品编码/商品名称）"
            @keyup.enter.native="toGetList(formDate)"
          ></el-input>
      </el-form-item>
      <el-form-item
        label="库位 "
        prop="locCode">
        <PublicQuery
        title="库位编码"
        baseUrl="/inv_web/invweb"
        cfgKey="invWmsLoc"
        :valueField.sync="formDate.locCode"
        @change="handleSearch(formDate)">
        </PublicQuery>
      </el-form-item>
      <el-form-item label="批次号" prop="lotNum">
        <el-input v-model="formDate.lotNum" @keyup.enter.native="toGetList(formDate)"></el-input>
      </el-form-item>
    </el-form>
  </div>
</div>

</template>

<script>
import MoreQuery from './MoreQuery'
export default {
  components: { MoreQuery },
  props: ['selectedIds'],
  created () {
  },
  mounted () {
  },

  data () {
    return {
      query: {
        movementNo: '',
      }, // 查询条件
      formDate: {},
      showMore: false, // 显示更多查询
      moreData: {}
    }
  },
  methods: {
    handelGetList () {
      this.$refs.formDate.resetFields()
      this.$emit('getList')
    },
    handleSearch (formDate) {
      this.$emit('getList', formDate)
    },
    // 检查是否有勾选
    checkSelections () {
      if (!this.selectedIds) {
        this.$message.error('请选择记录')
        return false
      } else {
        return true
      }
    },
    // todo: 新增按钮
    toAdd () {
      if (this.checkSelections()) {

      }
    },
    // 删除, 已与operate合并, 要加确认弹窗再说
    toDelete () {
      if (this.checkSelections()) {

      }
    },
    // 对移动任务进行操作, 更多按钮也在这里
    operateConfirm (type) {
      if (this.checkSelections()) {
        const url = this.$API.inventory.movement[type]
        const param = {
          movementNos: this.selectedIds
        }
        this.$https.post(url, param)
          .then(data => {
            console.log('操作成功', data)
            this.toGetList()
          })
      }
    },
    // 查询
    toGetList (formDate) {
      this.moreData = formDate
      this.$emit('getList', formDate)
    },
    // 点击更多查询
    moreQuery () {
      this.showMore = true
    },
    handleExcel () {
      const url = this.$API.inventory.movement.getList
      const options = this.moreData
      this.$exportExcel(url, options)
    },
  },
}
</script>

<style lang="scss" scoped>
 .inputBox {
      width: 100%;
      border: 1px solid #d1d5db;
      margin-top: 10px;
      margin-bottom: 10px;
      border-radius: 10px;
      padding-bottom: 10px;
      padding-left: 10px;
      .el-form-item {
        margin-bottom: 0px;
        margin-top: 10px;
      }
  }
  .query {
    &__operations {
      float: left;
    }
    &__retrieve {
      float: right;
      .el-input {
        max-width: 180px;
      }
    }
    &__item {
      margin-left: 10px;
    }
  }
</style>
