<template>
    <div>
        <div class="mrg-b">
            <el-row>
                <el-col :span="21">
                <el-button v-auth="50800020105" type="primary" @click="handleCreate">执行越库</el-button>
                <el-button v-auth="50800020106" type="primary" @click="handleCancel">取消越库</el-button>
                <el-button v-auth="50800020107" type="primary" @click="handleDelete">删除越库任务(直接)</el-button>
                <el-button v-auth="50800020108" type="primary" @click="handleCancelMark">取消越库标记(分拨)</el-button>
                </el-col>
                <el-col :span="3">
                <!-- <el-col :span="16">
                    <el-input class="inline" v-model="query.ownerCode" @keyup.enter.native="handleSearch" placeholder="快捷查询(货主编码)"></el-input>
                    <el-input class="inline mrg-l" v-model="query.skuCode" @keyup.enter.native="handleSearch" placeholder="快捷查询(商品编码)"></el-input>
                </el-col> -->
                <el-col class="mrg-l">
                    <el-button v-auth="50800020102" type="primary" @click="handleMoreSearch">更多</el-button>
                    <el-button v-auth="50800020101" icon="el-icon-refresh" class="query__item" type="primary" @click="handleSearch" plain circle></el-button>
                    <el-button
                    v-if="false"
                      icon="el-icon-download"
                      type="primary"
                      @click="handleExcel"
                      plain
                      circle
                    ></el-button>
                </el-col>
                </el-col>
            </el-row>
        </div>
        <div class="inputBox">
            <el-form inline :model="formData" ref="formData" label-position="left">
                <el-form-item label="货主" prop="ownerCode">
                  <PublicQuery
                    title="货主"
                    baseUrl="/crd_web/crdweb"
                    cfgKey="crdWmsCustomer"
                    :valueField.sync="formData.ownerCode"
                    @change="handleOwnerCode"
                  ></PublicQuery>
                </el-form-item>
                <el-form-item label="商品" prop="skuCode">
                  <PublicQuery
                    title="商品"
                    baseUrl="/crd_web/crdweb"
                    cfgKey="crdWmsSkus"
                    :valueField.sync="formData.skuCode"
                    @change="handleOwnerCode"
                  ></PublicQuery>
                </el-form-item>
             </el-form>
        </div>

        <more-query
        :moreQueryVisible="moreQueryVisible"
        @close="moreQueryVisible=false"
        @toGetList="getQueryList">
        </more-query>

    </div>
</template>
<script>
import MoreQuery from './more-query'
export default {
  components: {
    MoreQuery
  },
  data () {
    return {
      query: {},
      moreQueryVisible: false,
      formData: {},
      moreData: {}
    }
  },
  props: {
    rows: Array
  },
  methods: {
    handleOwnerCode () {
      this.$emit('getList', this.formData)
    },
    // 检查是否选中行
    checkSelections () {
      if (!this.selectedIds) {
        this.$message.error('请选择记录')
        return false
      } else {
        return true
      }
    },

    // 搜索查询
    handleSearch () {
      this.$refs.formData.resetFields()
      this.$emit('getList')
    },

    // 更多查询数据
    getQueryList (query) {
      this.moreQueryVisible = false
      this.moreData = query
      this.$emit('getList', query)
    },

    // 更多搜索查询
    handleMoreSearch () {
      this.moreQueryVisible = true
    },

    // 执行越库
    handleCreate () {
      const url = this.$API.CrossDock.CrossDockTaskExcuteList.createCrossDock
      const param = { wmAsnDetailReceiveQueryBean: JSON.stringify(this.rows) }
      this.$https.post(url, param).then(res => { this.$emit('getList') })
    },
    // 取消越库
    handleCancel () {
      const url = this.$API.CrossDock.CrossDockTaskExcuteList.cancelCross
      const param = { wmAsnDetailReceiveQueryBean: JSON.stringify(this.rows) }
      this.$https.post(url, param).then(res => { this.$emit('getList') })
    },
    // 删除越库
    handleDelete () {
      const url = this.$API.CrossDock.CrossDockTaskExcuteList.delCrossDock
      const param = { wmAsnDetailReceiveQueryBean: JSON.stringify(this.rows) }
      this.$https.post(url, param).then(res => { this.$emit('getList') })
    },
    // 取消越库标记
    handleCancelMark () {
      const url = this.$API.CrossDock.CrossDockTaskExcuteList.cancelCrossDockMark
      const param = { wmAsnDetailReceiveQueryBean: JSON.stringify(this.rows) }
      this.$https.post(url, param).then(res => { this.$emit('getList') })
    },
    handleExcel () {
      const url = this.$API.CrossDock.CrossDockTaskExcuteList.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;
      }
    }
    .mrg-b{
        margin-bottom: 20px;
    }
    .mrg-l{
        margin-left:10px;
    }
  .query {
    &__operations {
      float: left;
    }
    &__retrieve {
      float: right;
      .el-input {
        max-width: 180px;
      }
    }
    &__item {
      margin-left: 10px;
    }

  }
    .inline{
    width: 47%
  }
</style>
