<template>
  <div class="outboundManage">
    <div class="head-title">
      出库管理
      <el-button style="float:right" size="small" @click="outapplyfor" type="primary">出库申请
      </el-button>
    </div>
    <div class="content">
      <el-table :data="tableData" v-loading="loading" border style="width: 100%"
        @selection-change="handleSelectionChange">
        <el-table-column type="selection" width="55" style="text-align:center;">
        </el-table-column>
        <el-table-column prop="OrderNo" label="订单号" width="220">
        </el-table-column>
        <el-table-column prop="GoodsName" label="商品名称">
        </el-table-column>
        <el-table-column prop="Specification" label="商品规格">
        </el-table-column>
        <el-table-column prop="Number" label="购买数量" width="150px">
        </el-table-column>
      </el-table>
      
    </div>
    <!-- 选择是否公账 -->
    <el-dialog title="请选择" :visible.sync="choiceFin" width="400px">
      
      <span slot="footer" class="dialog-footer">
        <el-button size="small" @click="choiceFin=false">取消</el-button>
        <el-button type="primary" size="small" @click="setFince()">确定</el-button>
      </span>
    </el-dialog>

  </div>
</template>

<script>
  export default {
    data() {
      return {
        loading: false,
        choiceFin: false,
       tableData:[],
       outobj:{
           ID:0,
           WarehouseOutGoodsList:[],
       }
      }
    },
    created() {},
    mounted() {
      this.getList();
    },
    methods: {
 
      getList() {
      
        this.loading = true;
        this.assetsApipost("/api/WarehouseOut/GetNoOutOrderGoodsList", {SupplierId:0}, res => {
          this.loading = false;
          if (res.data.resultCode == 1) {
            this.tableData = res.data.data;
          }else{
            this.Error(res.data.message);
          }
        })
      },
      handleCurrentChange(val) {
        this.msg.pageIndex = val;
        this.getList();
      },
      
      handleSelectionChange(val) {
        var selectRow = JSON.parse(JSON.stringify(val));
        let array= [];
        selectRow.forEach(x => {
            let obj = {}
            obj.OrderGoodsId = x.Id;
            array.push(obj)
        });
        this.outobj.WarehouseOutGoodsList = array;

      },
      outapplyfor(){
          if (this.outobj.WarehouseOutGoodsList.length == 0) {
            this.Info('请选择商品');
            return
         } 
         this.loading = true;
        this.assetsApipost("/api/WarehouseOut/SetWarehouseOutApply", this.outobj, res => {
          this.loading = false;
          if (res.data.resultCode == 1) {
            this.Success(res.data.message);
            this.outobj.WarehouseOutGoodsList = []
            this.getList();
          }else{
            this.Error(res.data.message);
          }
        })


      }
   

    }
  };

</script>
<style>
  .outboundManage .content {
    background: #fff;
    margin-top: 10px;
    padding: 20px;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
  }

</style>
