<!--质检管理-->
<template>
  <div>
    <BaseHeaderLayout :leftSpan="12">
      <template slot="right">
        <ws-select
          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
          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="780"
    >
      <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="contractNo" label="合同编号"></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="bulkDensity" label="容重(克/升)"></el-table-column>
      <el-table-column prop="waterContent" label="水分（%）"></el-table-column>
      <el-table-column prop="binNumber" label="仓位号"></el-table-column>
      <el-table-column prop="storageTagNo" 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">
          <span v-if="scope.row.status == '已质检'"><el-button @click="qualityInspection(scope.row, 2)">查看</el-button></span>
          <span v-if="scope.row.status == '已称皮重' || scope.row.status == '' || scope.row.status == null"><el-button @click="qualityInspection(scope.row, 1)">质检</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,

      searchKeyWord: '',
      taskTypeList: [],
      searchType: 0,
      warehouseName: '',
      inspect: [],
      warehouseList: [],
      cangid: '', //仓库id
    }
  },
  activated() {
    this.getList()
  },
  methods: {
    find(){
     this.getList()
    },
    qualityInspection(row, index) {
      //添加/查看
      console.log(row.id, 'id值')
      this.$router.push({
        path: 'qualityInspection',
        query: { type: index, 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) {
      console.log(e)
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`)
      this.pageSize = val
      this.getList()
    },
    handleCurrentChange(val) {
      this.currentPage = val
      console.log(`当前页: ${val}`)
      this.getList()
    },
    getList() {
      selectWarehouseSelf({
        compId: sessionStorage.getItem('ws-pf_compId'),
      })
        .toPromise()
        .then((response) => {
          this.warehouseList = []
          for (let i = 0; i < response.length; i++) {
            this.warehouseList.push({
              // valueKey: i,
              value: response[i].warehouseName,
              id: response[i].id,
            })
          }
          this.warehouseName = response[0].warehouseName
          this.cangid = response[0].id
        })

      getinspectList({
        compId: sessionStorage.getItem('ws-pf_compId'),
        currentPage: this.currentPage,
        pageSize: this.pageSize,
        searchKeyWord: this.searchKeyWord,
        warehouseName: this.warehouseName,
      })
        .toPromise()
        .then((response) => {
          // for (let i = 0; i < response.length; i++) {
          //   this.warehouseList.push({
          //     valueKey: i,
          //     value: response[i].warehouseName,
          //     id:response[i].id
          //   })
          // }
          // this.searchTypeText = response[0].warehouseName
          // this.id = response[0].id
          // console.log(response)
          this.inspect = response.records
          console.log(this.inspect,'容重')
          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;
}
</style>
