
<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-input type="textarea" v-model="param.BILLCODE" :rows="1"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="工单号:" >
              <el-input  type="textarea" v-model="param.pt_code" :rows="1"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="SAP类型:">
              <el-input type="text" v-model="param.sourceType" :rows="1"></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="4">
            <el-form-item label="拣货库区">
              <el-select v-model="param.z_name"  multiple filterable placeholder="请选择库区" style="width: 100%;">
                <el-option
                    v-for="item in Ku"
                    :key="item.index"
                    :label="item.name"
                    :value="item.name"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="4">
            <el-form-item label="所在库位:">
              <el-input type="textarea" v-model="param.lc2_code" :rows="1"></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="4">
            <el-form-item label="料号:">
              <el-input type="textarea" v-model="param.i_code" :rows="1"></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="24" v-show="isShow">
          <el-col :span="4">
            <el-form-item label="单据类型">
              <el-select v-model="param.bt_name"  multiple filterable placeholder="请选择库区" style="width: 100%;">
                <el-option
                    v-for="item in Dj"
                    :key="item.index"
                    :label="item.name"
                    :value="item.name"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="4">
            <el-form-item label="工作站">
              <el-select v-model="param.END_REGION"  multiple filterable placeholder="请选择库区" style="width: 100%;">
                <el-option
                    v-for="item in Gz"
                    :key="item.index"
                    :label="item.END_REGION"
                    :value="item.END_REGION"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="4">
            <el-form-item label="拣货人">
              <el-select v-model="param.w4_name"  multiple filterable placeholder="请选择库区" style="width: 100%;">
                <el-option
                    v-for="item in Jhr"
                    :key="item.index"
                    :label="item.name"
                    :value="item.name"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="4">
            <el-form-item label="波次号:">
              <el-input type="text" v-model="param.wd_code"></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="4">
            <el-form-item label="容器码:">
              <el-input type="text" v-model="param.LP"></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="4">
            <el-form-item label="拣货库位">
              <el-select
                  v-model="param.lc1_code"
                  multiple
                  filterable
                  remote
                  reserve-keyword
                  placeholder="请输入关键词"
                  :remote-method="remoteMethod"
                  :loading="loading">
                <el-option
                    v-for="item in Kw"
                    :key="item.index"
                    :label="item.CODE"
                    :value="item.CODE">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="24" v-show="isShow">
        <el-col :span="8">
          <el-form-item label="需求日期:">
            <el-date-picker style="width: 325px"
                            v-model="param.ORDER_DATE"
                            type="daterange"
                            align="right"
                            unlink-panels
                            range-separator="至"
                            start-placeholder="开始日期"
                            end-placeholder="结束日期"
                            :picker-options="pickerOptions">
            </el-date-picker>
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="分配日期:">
            <el-date-picker style="width: 325px"
                            v-model="param.CREATE_TIME"
                            type="daterange"
                            align="right"
                            unlink-panels
                            range-separator="至"
                            start-placeholder="开始日期"
                            end-placeholder="结束日期"
                            :picker-options="pickerOptions">
            </el-date-picker>
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="拣货日期:">
            <el-date-picker style="width: 325px"
                            v-model="param.OPERATE_TIME"
                            type="daterange"
                            align="right"
                            unlink-panels
                            range-separator="至"
                            start-placeholder="开始日期"
                            end-placeholder="结束日期"
                            :picker-options="pickerOptions">
            </el-date-picker>
          </el-form-item>
        </el-col>

          <el-col :span="4">
            <el-form-item label="拣货状态:">
              <el-select v-model="param.Status"  placeholder="请选择" style="width: 100%;">
                <el-option
                    v-for="item in Zt"
                    :key="item.label"
                    :label="item.values"
                    :value="item.label"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="4">
            <el-form-item label="加急标记">
              <el-select v-model="param.equated_Quantity"   placeholder="请选择库区" style="width: 100%;">
                <el-option
                    v-for="item in Bj"
                    :key="item.index"
                    :label="item.equated_Quantity"
                    :value="item.equated_Quantity"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="4">
            <el-form-item label="下发人">
              <el-select v-model="param.strBill1"  multiple filterable placeholder="请选择库区" style="width: 100%;">
                <el-option
                    v-for="item in Xf"
                    :key="item.index"
                    :label="item.strBill1"
                    :value="item.strBill1"
                >
                </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-checkbox v-model="checked" @change="Allquesr">是否显示全部查询条件</el-checkbox>
      </el-form>
    </div>

    <el-table
        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.id }}</span>
        </template>
      </el-table-column>
<!--      <el-table-column-->
<!--          label="ID"-->
<!--          width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <div slot="reference" class="name-wrapper">-->
<!--            <span>{{ scope.row.id}}</span>-->
<!--          </div>-->
<!--        </template>-->
<!--      </el-table-column>-->
      <el-table-column
          label="工单号"
          width="120">
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <span>{{ scope.row.pt_code }}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column
          label="需求日期"
          width="100">
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <span>{{ new Date(scope.row.ORDER_DATE).toISOString().replace('T','').substring(0,10)}}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column
          label="工作站"
          width="60">
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <span>{{ scope.row.END_REGION }}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column
          label="分拨墙"
          width="100">
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <span>{{ scope.row.s_name }}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column
          label="库区"
          width="100">
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <span>{{ scope.row.z_name }}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column
          label="SAP类型"
          width="80">
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <span>{{ scope.row.sourceType  }}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column
          label="单据类型"
          width="80">
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <span>{{ scope.row.bt_name }}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column
          label="子任务号"
          width="130">
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <span>{{ scope.row.BILLCODE}}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column
          :show-overflow-tooltip="true"
          label="描述"
          width="180">
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <span>{{ scope.row.i_name }}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column
          label="料号"
          width="140">
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <span>{{ scope.row.i_code }}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column
          label="单位"
          width="60">
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <span>{{ scope.row.UNIT }}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column
          label="价值等级"
          width="50">
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <span>{{ scope.row.SHIP_RULES }}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column
          label="源库位"
          width="100">
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <span>{{ scope.row.lc1_code }}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column
          label="容器"
          width="80">
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <span>{{ scope.row.LP }}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column
          label="目标容器"
          width="80">
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <span>{{ scope.row.lc2_code }}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column
          label="合单位置"
          width="100">
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <span>{{ scope.row.strBill4 }}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column
          label="下发数量"
          width="100">
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <span>{{ scope.row.yc_qty }}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column
          label="分配数量"
          width="100">
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <span>{{ scope.row.PLAN_QUANTITY_MU }}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column
          label="拣货数量"
          width="100">
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <span>{{ scope.row.MOVED_QUANTITY_MU }}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column
          label="状态"
          width="100">
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <span>{{ scope.row.Status }}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column
          label="批次号"
          width="100">
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <span>{{ scope.row.PROP_C1 }}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column
          label="LOC"
          width="80">
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <span>{{ scope.row.PROP_C2 }}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column
          label="特殊标记"
          width="80">
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <span>{{ scope.row.PROP_C3 }}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column
          label="供应商编号"
          width="100">
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <span>{{ scope.row.PROP_C5}}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column
          label="申请编号"
          width="100">
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <span>{{ scope.row.PROP_C6 }}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column
          label="申请人"
          width="60">
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <span>{{ scope.row.PROP_C7}}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column
          label="暂存原因"
          width="100">
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <span>{{ scope.row.PROP_C8 }}</span>
          </div>
        </template>
      </el-table-column><el-table-column
        label="工厂"
        width="100">
      <template slot-scope="scope">
        <div slot="reference" class="name-wrapper">
          <span>{{ scope.row.PROP_C9}}</span>
        </div>
      </template>
    </el-table-column>
      <el-table-column
          label="加急标记"
          width="80">
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <span>{{ scope.row.equated_Quantity }}</span>
          </div>
        </template>
      </el-table-column><el-table-column
        label="序列号"
        width="120">
      <template slot-scope="scope">
        <div slot="reference" class="name-wrapper">
          <span>{{ scope.row.BAR_CODE }}</span>
        </div>
      </template>
    </el-table-column>
      <el-table-column
          label="单号状态"
          width="80">
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <span>{{ scope.row.INVENTORY_STATUS}}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column
          label="项号"
          width="80">
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <span>{{ scope.row.LINE_NUMBER}}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column
          label="指定拣货人"
          width="80">
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <span>{{ scope.row.w1_name }}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column
          label="实际拣货人"
          width="80">
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <span>{{ scope.row.w4_name }}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column
          label="操作日期"
          width="100">
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <span>{{new Date(scope.row.OPERATE_TIME).toISOString().replace('T','').substring(0,10) }}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column
          label="操作时间"
          width="100">
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <span>{{ new Date(scope.row.OPERATE_TIME).toISOString().replace('T','').substring(10,18) }}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column
          label="分配日期"
          width="100">
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <span>{{new Date(scope.row.CREATE_TIME).toISOString().replace('T','').substring(0,10) }}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column
          label="分配时间"
          width="100">
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <span>{{ new Date(scope.row.CREATE_TIME).toISOString().replace('T','').substring(10,18)  }}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column
          label="波次号"
          width="180">
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <span>{{ scope.row.wd_code}}</span>
          </div>
        </template>
      </el-table-column>
<!--      <el-table-column-->
<!--          label="SAP状态 "-->
<!--          width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <div slot="reference" class="name-wrapper">-->
<!--            <span>{{ scope.row.statusCode  }}</span>-->
<!--          </div>-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column-->
<!--          label="AGV状态"-->
<!--          width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <div slot="reference" class="name-wrapper">-->
<!--            <span>{{ scope.row.agv_Status }}</span>-->
<!--          </div>-->
<!--        </template>-->
<!--      </el-table-column> <el-table-column-->
<!--        label="sap扣料"-->
<!--        width="180">-->
<!--      <template slot-scope="scope">-->
<!--        <div slot="reference" class="name-wrapper">-->
<!--          <span>{{ scope.row.popular}}</span>-->
<!--        </div>-->
<!--      </template>-->
<!--    </el-table-column>-->
      <el-table-column
          label="任务号"
          width="180">
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <span>{{ scope.row.t_code }}</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 {
      pickerOptions: {
        shortcuts: [{
          text: '最近一周',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '最近一个月',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '最近三个月',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
            picker.$emit('pick', [start, end]);
          }
        }]
      },
      tableloding: false,
      isShow:false,//是否展示全部搜索条件
      value1: '',
      value2: '',
      tableData: [],
      pageSize: 50,
      pageNum: 1,
      total: 3,
      param: {
        //子任务号
       BILLCODE: '',
        //工单号
       pt_code: '',
        //SAP类型
       sourceType: '',
        //拣货库区
       z_name: [],
        //所在库位
        lc2_code: '',
        //料号
        i_code: '',
        //单据类型
        bt_name: [],
        //工作站
        END_REGION: [],
        //拣货人
         w4_name: [],
        //波次号
         wd_code: '',
        //容器码
         LP: '',
        //拣货库位
        lc1_code: [],
        //需求日期
        ORDER_DATE: [],
        //分配日期
        CREATE_TIME: [],
        //拣货日期
        OPERATE_TIME: [],
        //加急标记
        equated_Quantity: '',
        //下发人
        strBill1: [],
        //拣货状态
        Status: '',
      },
      Ku: [],
      //单据类型
      Dj: [],
      //工作站
      Gz: [],
      //拣货人
       Jhr: [],
      //库位
       Kw: [],
      loading: false,
      //加急标记
       Bj: [],
      //下发人
       Xf: [],
      //状态
      Zt: [
          {
            label: '处理完成',
            values: '处理完成'
          },
        {
          label: '未处理',
          values: '未处理'
        },
        {
          label: '处理中',
          values: '处理中'
        }
      ],

      checked: false,
    }
  },computed:{
    MaxHeight(){
      return  window.innerHeight - 240 +"px";
    }
  },
  mounted: function () {
    this.queryUser();
    this.KuS();
    this.DjS();
    this.GzS();
    this.JhrS();
    this.BjS();
    this.XfS();
  },
  methods: {

    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();
    },
    KuS(){
      //库区下拉列表数据加载
      this.$axios.post(this.$httpUrl + '/Kucunhuizong/ku', {

      }).then(res => res.data)
          .then(res => {
            if (res.code == 200) {
              this.Ku = res.data;
            } else {
              this.$message.error('获取数据失败');
            }

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

      this.$axios.post(this.$httpUrl + '/Jianhuojiemian/dj', {

      }).then(res => res.data)
          .then(res => {
            if (res.code == 200) {
              this.Dj = res.data;
            } else {
              this.$message.error('获取数据失败');
            }

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

      this.$axios.post(this.$httpUrl + '/Jianhuojiemian/gz', {

      }).then(res => res.data)
          .then(res => {
            if (res.code == 200) {
              this.Gz = res.data;
            } else {
              this.$message.error('获取数据失败');
            }

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

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

      if (query !== '') {
        if(query.length>2) {

          this.$axios.post(this.$httpUrl + '/Jianhuojiemian/kw', {
            query
          }).then(res => res.data)
              .then(res => {
                if (res.code == 200) {
                  this.Kw = res.data;
                } else {
                  this.$message.error('获取数据失败');
                }

                // eslint-disable-next-line no-unused-vars
              }, err => {
                this.tableloding = false;
              })
        }
      } else {
        this.Kw = [];
      }
    },
    XfS(){
      this.$axios.post(this.$httpUrl + '/Jianhuojiemian/xf', {

      }).then(res => res.data)
          .then(res => {
            if (res.code == 200) {
              this.Xf = res.data;
            } else {
              this.$message.error('获取数据失败');
            }

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

      this.$axios.post(this.$httpUrl + '/Jianhuojiemian/bj', {

      }).then(res => res.data)
          .then(res => {
            if (res.code == 200) {
              this.Bj = res.data;
            } else {
              this.$message.error('获取数据失败');
            }

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

    queryUser() {
      //列表数据加载
      this.$axios.post(this.$httpUrl + '/Jianhuojiemian/queryJian', {
        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>
