<!--质检记录-->
<template>
  <div class="center">
      <el-row class="toptitle">
      <el-col :span="12">
        <h2 class="bg-left title">质检记录</h2>
      </el-col>
      <el-col :span="12" class="bg-right">
        <el-button type="primary" size="small" @click="returnsales()">
          <img width="6" height="10" style="vertical-align: bottom; margin-right: 3px"
            src="../../../public/img/lujing.png" alt="" />返回
        </el-button>
      </el-col>
    </el-row>
    <BaseHeaderLayout :leftSpan="12">
      <template slot="right">
        <ws-select style='margin-right:10px;width:400px;' v-model="warehouseName" placeholder="" @change="selecttaskType"
          :value="searchType">
          <ws-option v-for="item in warehouseList" :key="item.value" :label="item.value" :value="item.value"
            style="color: #8890b1;" />
        </ws-select>
        <div></div>
        <ws-input class='findinput' @keyup.enter.native="find()" v-model="searchKeyWord" placeholder="可按业务编号、合同编号、车牌号查找"
          clearable maxlength="500" type="input"></ws-input>
        <ws-button class="find" type="primary" @click="find()"><img width="16" height="16" style="
              vertical-align: text-top;
              position: relative;
              top: 0px;
              left: -8px;
            " src="../../../public/img/sousuo.png" alt="" /></ws-button>
      </template>
    </BaseHeaderLayout>
    <el-table :data="inspect" style="width: 100%; margin-top: 20px" ref="inspect" border height="calc(100vh - 30vh)">
      <el-table-column type="index" label="序号" width="50">
        <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="number" label="业务编号">
        <span slot-scope="scope">{{scope.row.weighingManagement?scope.row.weighingManagement.number:""}}</span>
      </el-table-column>
      <el-table-column prop="contractNo" label="合同编号/移库编号" width="122"></el-table-column>
      <el-table-column prop="carNumber" label="车牌号"></el-table-column>
      <el-table-column prop="goodsName" label="货名"></el-table-column>
      <el-table-column prop="waterContent" label="水分（%）"></el-table-column>
      <el-table-column prop="type" label="类型"></el-table-column>
      <el-table-column prop="binNumber" label="仓位号"></el-table-column>
      <el-table-column prop="qualityInspector" label="质检员"></el-table-column>
      <el-table-column prop="updateDate" label="质检时间"></el-table-column>
      <el-table-column prop="status" label="状态"></el-table-column>
      <el-table-column width="300" label="操作">
        <template slot-scope="scope">
            <!-- v-if="scope.row.status == '已质检'" -->
          <span v-hasPermission=" `outbound.acquisitionQualityOut.view`">
            <el-button @click="qualityInspection(scope.row)">查看</el-button>
          </span>
           <!-- v-if="scope.row.status == '已称毛重' || !scope.row.status" -->
          <span  v-hasPermission=" `outbound.acquisitionQualityOut.edit`">
            <el-button @click="print(scope.row)">打印</el-button>
          </span>
        </template>
      </el-table-column>
    </el-table>
    <div style="text-align: center;">
      <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage"
        :page-size="deptCircularPage.pageSize" layout="total, sizes, prev, pager, next, jumper"
        :total="deptBudgetTotal">
      </el-pagination>
    </div>
  </div>
</template>
<script>
  import {
    selectWarehouseSelf,
    getinspectList,
  } from '@/model/outboundManagement/index'

  export default {
    components: {},
    watch: {},
    data() {
      return {
        //分页
        currentPage: 1,
        pageSize: 10,
        deptCircularPage: {},
        deptBudgetTotal: 0,
        managementType: 3,
        searchKeyWord: '',
        taskTypeList: [],
        searchType: 0,
        warehouseName: '',
        inspect: [],
        warehouseList: [],
        cangid: '', //仓库id
        statusType:'1'
      }
    },
    activated() {
      this.selectWarehouse()
      this.showType = this.isShow
    },
    methods: {
        returnsales(){
            this.$router.go(-1)
        },
      find() {
        this.getList()
      },
      print(row){
           window.open('../../../static/outInspectionPrint.html?type=2&dataList=' + JSON.stringify(row))
      },
      qualityInspection(row) {
        //查看
        this.$router.push({
          path: 'qualityInspection',
          query: {
            cangid: this.cangid,
            id: row.id,
            warehouseName: this.warehouseName,
            count: this.warehouseCount,
            warehouseNo: this.warehouseNo,
            contractNo: row.contractNo,
            binNumber: row.binNumber,
            carNumber: row.carNumber,
            storageTagNo: row.storageTagNo,
            goodsName: row.goodsName
          },
        })
      },
      selecttaskType(e) {
        for (let i = 0; i < this.warehouseList.length; i++) {
          if (this.warehouseList[i].value == e) {
            this.cangid = this.warehouseList[i].cangid
          }
        }
        this.getList()
      },
      handleSizeChange(val) {
        console.log(`每页 ${val} 条`)
        this.pageSize = val
        this.getList()
      },
      handleCurrentChange(val) {
        this.currentPage = val
        console.log(`当前页: ${val}`)
        this.getList()
      },
      selectWarehouse() {
        selectWarehouseSelf({
            compId: localStorage.getItem('ws-pf_compId'),
          })
          .toPromise()
          .then((response) => {
            this.warehouseList = []
            for (let i = 0; i < response.length; i++) {
              this.warehouseList.push({
                value: response[i].warehouseName,
                warehouseId: response[i].id,
              })
            }
            if(this.$route.query.warehouseName){
              this.warehouseName = this.$route.query.warehouseName
            }else{
                this.warehouseName = response[0].warehouseName
            }
            this.getList()
          })
      },
      getList() {
        getinspectList({
            compId: localStorage.getItem('ws-pf_compId'),
            currentPage: this.currentPage,
            pageSize: this.pageSize,
            searchKeyWord: this.searchKeyWord,
            // statusType:this.statusType,
            qualityType:"2",
            warehouseName: this.warehouseName,
            managementType: this.managementType,
          })
          .toPromise()
          .then((response) => {
            this.inspect = response.records
            this.deptBudgetTotal = response.total
          })
      },
    },
  }
</script>
<style lang="scss" scoped>
//   .title {
//     font-size: 20px;
//     font-weight: 600;
//     margin: 20px 0 0 20px;
//   }

  .tit {
    font-size: 16px;
    font-weight: 600;
    margin: 20px;
  }

  .ws-info-table {
    border: none;
  }

  .ws-info-table .el-form-item {
    width: 50%;
    border: none;
  }

  /deep/.ws-info-table .el-form-item .el-form-item__label {
    width: 30%;
    text-align: center;
    background: #ffffff;
    color: #8890b1;
  }

  /deep/.ws-info-table .el-form-item .el-form-item__content {
    border: none;
  }

  /deep/.el-table .el-table__header .cell,
  .el-table .el-table__body .cell {
    text-align: center;
  }

  /deep/.el-table--enable-row-transition .el-table__body td {
    text-align: center;
  }

  /deep/.base_header_layout .find.el-button--primary {
    width: 30px;
    border-top-left-radius: 0px;
    border-bottom-left-radius: 0px;
  }

  /deep/.base_header_layout .findinput input {
    border-top-right-radius: 0px;
    border-bottom-right-radius: 0px;
  }
  .toptitle {
    background: #f6f7fc;
    .bg-left {
    padding-left: 30px;
  }

  .bg-right {
    text-align: right;
    padding: 16px 20px;
  }
  .title {
    position: relative;
  }

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