
<template>
  <div class="div1">

    <div class="div2" style="padding-bottom: 10px">
      <el-form ref="form" :model="param" label-width="80px">
        <el-row :gutter="24">
          <el-col :span="4">
            <el-form-item label="类型:">
              <el-select v-model="param.ct_code"  multiple filterable placeholder="请选择类型" style="width: 100%;">
                <el-option
                    v-for="item in typess"
                    :key="item.index"
                    :label="item.code"
                    :value="item.code"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="4">
            <el-form-item  label="是否在库:" >
              <el-select v-model="param.agvFlag"  placeholder="请选择是否在库"  >
                <el-option
                    v-for="item in agvFlag"
                    :key="item.label"
                    :label="item.values"
                    :value="item.label"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

        </el-row>

        <el-button type="success" @click="find">查找</el-button>
        <el-button type="success" @click="rest">重置</el-button>&nbsp;&nbsp;
      </el-form>
    </div>

    <el-table
        show-summary
        :summary-method="getSummaries"
        v-loading="this.tableloding"
        :height="MaxHeight"
        :header-cell-style="{background:'#000',color:'#fff'}"
        :data="tableData"
        id="educe-table"
        ref="tableData"
        style="width: 100%;">
      <el-table-column
          type="selection"
          width="55">
      </el-table-column>
      <el-table-column
          fixed
          label="序号"
          v-if="false"
          width="180">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.code }}</span>
        </template>
      </el-table-column>
      <el-table-column
          label="类型"
          >
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <span>{{ scope.row.code}}</span>
          </div>
        </template>
      </el-table-column>

      <el-table-column
          label="状态"
          >
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <span>{{ scope.row.STATUS}}</span>
          </div>
        </template>
      </el-table-column>

      <el-table-column
          label="是否在AGV库"
          >
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <span>{{ scope.row.agvFlag==1?'是':'否'}}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column
          label="箱子数"
          >
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <span>{{ scope.row.shu}}</span>
          </div>
        </template>
      </el-table-column>




    </el-table>
    <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="pageNum"
        :page-sizes="[ 50, 100, 200,500]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total">
    </el-pagination>
  </div>

</template>

<script>
export default {
  data() {
    return {
      tableloding: false,
      isShow:false,//是否展示全部搜索条件

      tableData: [],
      pageSize: 50,
      pageNum: 1,
      total: 3,
      param: {
        ct_code: [],
        agvFlag: '',
      },
      //类型
      typess: [],
      //是否
      agvFlag: [{
        values: '是',
        label: 1,
      },{
        values: '否',
        label: 0,
      }
      ],
    }
  },computed:{
    MaxHeight(){
      return  window.innerHeight - 240 +"px";
    }
  },
  mounted: function () {
    this.queryUser();
    this.Typess();
  },
  methods: {
    // 求和操作
    getSummaries(param) {
      const { columns, data } = param
      const sums = []
      columns.forEach((column, index) => {
        if (index === 4) {
          sums[index] = '汇总:' + 10;
        }
      })
      return sums
    },
    handleEdit(index, row) {
      console.log(index, row);
    },
    handleDelete(index, row) {
      console.log(index, row);
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      this.pageNum = 1;
      this.pageSize = val;
      this.queryUser();
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.pageNum = val;
      this.queryUser();
    },
    Typess(){
      this.$axios.post(this.$httpUrl + '/dcx/type', {

      }).then(res => res.data)
          .then(res => {
            if (res.code == 200) {
              this.typess = res.data;
            } else {
              this.$message.error('获取数据失败');
            }
            // eslint-disable-next-line no-unused-vars
          },err=>{
            this.tableloding=false;
          })
    },

    queryUser() {
      //列表数据加载
      this.$axios.post(this.$httpUrl + '/dcx/querydcx', {
        pageSize: this.pageSize,
        pageNum: this.pageNum,
        param: this.param,
      }).then(res => res.data)
          .then(res => {
            if (res.code == 200) {
              this.tableData = res.data
              this.total = res.total
            } else {
              this.$message.error('获取数据失败');
            }

            // eslint-disable-next-line no-unused-vars
          },err=>{
            this.tableloding=false;
          })

    },
    find(){
      this.queryUser();
    },
    Allquesr(){
      //查询按钮
      if(this.checked){
        this.isShow=true;
      }else {
        this.isShow=false;
      }
    },
    rest() {
      //条件查询重置
      this.checked=false;
      this.isShow=false;
      this.param={};
    },
  }
}
</script>
<style scoped>

</style>
