//货权明细
<template>
  <div class="container">
    <div class="center">
      <el-row style='margin-bottom:10px;'>
        <el-col :span="6">
          <!-- <el-button style="margin-left:10px" @click="typeChange('')" type="primary">导出</el-button> -->
        </el-col>
        <el-col :span="18">
          <div style='margin-left:10px;' class="datascreen">
            <div style="display:inline-block;width:50;">
              <el-date-picker value-format='yyyy-MM-dd' v-model="value" type="daterange" align="right" unlink-panels range-separator="至"
              start-placeholder="开始日期" end-placeholder="结束日期" :picker-options="pickerOptions" class="data_css" @change="changeDate" >
            </el-date-picker></div>
            <el-input placeholder="可按业务编号、合同编号、客户查找" class="input_css" v-model="searchKeyWord"></el-input>
            <el-button class="find" type="primary" @click="find()"><img width="16" height="16" style="left: -8px;"
                src="../../../public/img/sousuo.png" alt="" /></el-button>
          </div>
        </el-col>
      </el-row>
      <el-row style='margin-bottom:10px;'>
        <el-col :span="18">
          <el-button style="margin-left:10px" @click="typeChange('')" :type="searchType == ''?'primary':''">全部</el-button>
          <el-button @click="typeChange(2)" :type="searchType == 2?'primary':''">转入</el-button>
          <el-button @click="typeChange(1)" :type="searchType == 1?'primary':''">转出</el-button>
        </el-col>
        <el-col style="text-align:right;padding-right:10px;" :span="6">
          <el-button @click="handlerecord" type="primary">客户操作记录</el-button>
          <el-button @click="rollin" type="primary">货权转入</el-button>
        </el-col>
      </el-row>
      <div class="fromdata">
        <el-table :data="tableData" stripe style="width: 100%" @selection-change="handleSelectionChange">
          <el-table-column type="index" label="序号">
            <template scope="scope">
              <span v-if="scope.$index < 9">0{{ scope.$index + 1 }}</span>
              <span v-else>{{ scope.$index + 1 }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="transferOutNo" label="业务编号">
          </el-table-column>
          <el-table-column prop="relationReceiveNo" label="关联业务编号">
            <template scope="scope">
              <span v-if="scope.row.transferFlag==1"></span>
              <span v-if="scope.row.transferFlag==2">{{scope.row.relationReceiveNo}}</span>
            </template>
          </el-table-column>
          <el-table-column prop="outContractNo" label="合同编号"></el-table-column>
          <el-table-column prop="customer" label="客户">
            <template scope="scope">
              <span v-if="scope.row.transferFlag==1">{{scope.row.receiveCompName}}</span>
              <span v-if="scope.row.transferFlag==2">{{scope.row.customer}}</span>
            </template>
          </el-table-column>
          <el-table-column width="120" prop="warehouseName" label="库点名称">
          </el-table-column>
           <el-table-column width="150" prop="settlementPrice" label="仓位">
            <template scope="scope">
              <el-button @click="lookbinNumber(scope.row)" type="text">查看</el-button>
            </template>
          </el-table-column>
          <el-table-column width="120" prop="signingDate" label="类型">
            <template scope="scope">

             <span v-if="scope.row.transferFlag==1">转出</span>
             <span v-if="scope.row.transferFlag==2">转入</span>
            </template>
          </el-table-column>
          <el-table-column width="120" prop="agent" label="经办人">
          </el-table-column>
          <el-table-column width="200" prop="agent" label="期初粮款数据（元）">
            <template scope="scope">
              应付{{scope.row.amountIngPayable}}-已付{{scope.row.amountEdPayable}}=未付{{scope.row.amountNotPayable}}
            </template>
          </el-table-column>
          <el-table-column width="120" prop="transferOutWeight" label="重量（吨）">
          </el-table-column>
          <el-table-column width="120" prop="avgCost" label="成本（元/吨）">
            <template scope="scope">
              <span v-if="scope.row.transferFlag==1">{{scope.row.salePrice}}</span>
              <span v-if="scope.row.transferFlag==2">{{scope.row.avgCost}}</span>
            </template>
          </el-table-column>
          <el-table-column width="120" prop="updateDate" label="日期">
          </el-table-column>
        </el-table>
      </div>
      <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage"
        style="text-align:center" :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper" :total="deptBudgetTotal">
      </el-pagination>
      <el-dialog width='50%' :visible.sync="binNumbershow" :title="'仓位详情-'+(currectData.transferFlag==1?'转出':'')" top="20vh">
        <div class="flex"><div>仓位号</div><div>重量（吨）</div></div>
        <div class="flex" v-for="item in currectData.cargoPositionDetailsList">
          <div>{{ item.binNumber }}</div>
          <div>{{ item.weight }}</div>
        </div>
      </el-dialog>
    </div>
  </div>
</template>
<script>

import {
  getroll
} from '@/model/warehouse/index'
  export default {
    components: {},
    data() {
      return {
        value: '',
        tableData: [],
        show:false,
        deptBudgetTotal: 0,
        currentPage: 1,
        pageSize: 10,
        agreementType:'',
        deptCircularPage: {},
        searchType:'',
        searchKeyWord:'',
        startDate:'',
        endDate:'',
        tableData:{},
        datalist:{},
        currectData:{},
        compId:localStorage.getItem('ws-pf_compId'),
        binNumbershow:false,
      }
    },
    activated() {
      this.getList()
    },
    methods: {
      lookbinNumber(item){
        this.currectData=item
        this.binNumbershow=true
      },
      typeChange(num){
        this.searchType=num
        this.getList()
      },
      handleClose1(){
        this.show=false
      },
      returnsales(){
        this.$router.go(-1)
      },
      handleSelectionChange(val) {
        this.multipleSelection = val;
      },
      handlerecord(){
        this.$router.push({path:'customerrecord'})
      },
      rollin(){
        this.$router.push({path:'goodsrollIn'})
      },

      async getList() {
         var response=await getroll({
            // warehouseType: 1,
            startDate:this.startDate,
            endDate:this.endDate,
            searchKeyWord:this.searchKeyWord,
            currentPage: this.currentPage,
            pageSize:this.pageSize ,
            searchType:this.searchType,
            
            dropFlag:0,
            compId:localStorage.getItem('ws-pf_compId'),
          })
          .toPromise()
            this.tableData = response.records
           this.deptBudgetTotal = response.total
      },

      changeDate(){
        if(this.value){
          this.startDate = this.value[0]
          this.endDate = this.value[1]
        }
        this.getList()
      },
      pickerOptions() {},
      find() {
        this.getList()

      },
      handleSizeChange(val) {
        console.log(`每页 ${val} 条`)
        this.pageSize = val
        this.getList()
      },
      handleCurrentChange(val) {
        this.currentPage = val
        console.log(`当前页: ${val}`)
        this.getList()
      },
    },
  }
</script>
<style lang="scss" scoped>
 table,
      table tr th,
      table tr td {
        border: 2px solid #333333;
        padding: 5px 0;
        height: 55px;
      }

      .content {
        width: 1000px;
        padding: 70px 20px 20px 20px;
        font-size: 22px;
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
      }

      table {
        width: 100%;
        text-align: center;
        border-collapse: collapse;
        border: 3px solid #333333;
      }

      .col-bgc {
        background: #f6f7fb;
      }

  .container {
    background: #E8ECF6;
  }

  .center {
    margin: 0 auto;
    background: #ffffff;
    height: calc(100vh - 13vh);
    border-radius: 4px;
    padding: 20px 0;

    /deep/.el-table td,
    /deep/.el-table th {
      text-align: center;
    }
  }

  .row_top {
    background: #F6F7FC;
    border-radius: 4px;
    margin-bottom: 10px;

    .bg-left {
      padding-left: 30px;
    }

    .bg-right {
      padding-right: 10px;
      text-align: right;
    }

    .title {
      position: relative;
    }

    .title::before {
      content: '';
      display: inline-block;
      width: 5px;
      height: 30px;
      background: #5473e8;
      position: absolute;
      left: 0;
    }
  }

  .datascreen {
    display: flex;

    .data_css {
      width: 40%;
    }

    .input_css {
      width: 50%;
      margin: 0 10px;
    }

    .find {
      margin-right: 10px;
    }
  }

  .fromdata {
    margin: 20px 0;
    overflow-y: scroll;
    height: 546px;
  }
  .top_info{
    margin: 10px 0 0 10px;
    min-width: 712px;
    .info_css{
      margin-right: 20px;
    }
  }
  .bg-right{
    padding-top:15px;
  }
  .el-icon-connection{
    color:#409eff;
  }
  .flex{
    display:flex;justify-content: space-between;
  }
</style>