<template>
  <el-button
    size="small"
    type="primary"
    class="ele-btn-icon"
    style="margin-left: 5px"
    :disabled="disabled"
    @click="warehouseShow = true"
    >批量设置仓库

    <ele-modal
      custom-class="ele-dialog-form long-dialog-form"
      :centered="true"
      :visible.sync="warehouseShow"
      title="设置仓库"
      :close-on-click-modal="false"
      width="600px"
      :maxable="true"
      :resizable="true"
      :append-to-body="true"
    >
      <div>
        仓库名称：
        <el-select v-model="warehouseId" placeholder="请选择">
          <el-option
            v-for="item in warehouseList"
            :key="item.id"
            :label="item.name"
            :value="item.id"
          >
          </el-option>
        </el-select>
      </div>
      <div slot="footer" class="footer">
        <el-button type="primary" @click="warehouseChangeAll"
          >确认选择</el-button
        >

        <el-button @click="warehouseShow = false">返回</el-button>
      </div>
    </ele-modal>
  </el-button>
</template>
<script>
  import { getWarehouseList } from '@/api/saleManage/saleorder';
  export default {
    components: {},
    data() {
      return {
        warehouseShow: false,
        warehouseId: '',
        warehouseList: []
      };
    },
    props: {
      disabled: {
        default: true,
        type: Boolean
      }
    },
    created() {
      getWarehouseList().then((res) => {
        this.warehouseList = res;
      });
    },
    computed: {},
    methods: {
      warehouseChangeAll() {
        if (!this.warehouseId) {
          return this.$message.error('请先选择仓库');
        }
        const data = this.warehouseList.find(
          (item) => item.id == this.warehouseId
        );
        this.$emit('success', data);
        this.cancel();
      },
      cancel() {
        this.warehouseShow = false;
      }
    }
  };
</script>

<style scoped lang="scss"></style>
