<template>
  <div id="searchPl" ref="searchPl">
    <ProjectSelect ref="projectSelectRef" clearable :_style="{width:'115px'}"/>
    <VxeInput v-model="queryParam.dcPl" clearable placeholder="请输入批量"/>
    <VxeInput v-model="queryParam.sllsh" clearable placeholder="单据号"/>
    <VxeSelect v-model="queryParam.slkcdw" ref="slkcdwSelectRef" clearable :options="kwOptions" :style="{width:'110px'}" placeholder="垮位"/>
    <VxeSelect v-model="queryParam.zylx" ref="gylxSelectRef" clearable :options="zylx" :style="{width:'110px'}" placeholder="选择流向"/>
    <VxeInput v-if="ljbs" v-model="queryParam.fd" clearable placeholder="请输入分段"/>
    <VxeButton status="primary" content="查询" @click="search" />
    <VxeSelect v-if="ljbs" v-model="gylxSelectData" ref="gylxSelectRef" clearable :options="gylx" placeholder="选择工艺路线"/>
    <VxeSelect v-if="ljbs" v-model="worker.pscry" ref="pkSelectRef" clearable :options="sgry" placeholder="坡口施工"/>
    <VxeSelect v-if="ljbs" v-model="worker.qscry" ref="qmSelectRef" clearable :options="sgry" placeholder="曲面施工"/>
    <VxeSelect v-if="ljbs" v-model="worker.dscry" ref="dmSelectRef" clearable :options="sgry" placeholder="打磨施工"/>
    <VxeButton v-if="ljbs" status="primary" content="批量" @click="plGylx" />
    <VxeButton v-if="ljbs" status="success" content="派工" @click="paigong" />
  </div>
</template>
<script>
import ProjectSelect from "@/components/ProjectSelect/index.vue";
import {dict} from "@/api/zyjh";

export default {
  name:'SliaoSearch',
  components:{ProjectSelect},
  props:{
    workers:{
      type:Array,
      default:[]
    }
  },
  data(){
    return{
      sgry:[],
      worker:{
        pscry:'',
        qscry:'',
        dscry:'',
      },
      kwShow:true,
      ljbs:false,
      queryParam:{
        zt:'11',
        dcCh:'',
        dcPl:'',
        dcFd:'',
        sllsh:'',
        zylx:'',
        slkcdw:'',
      },
      gylxSelectData:'',
      zylx:[],
      kwOptions:[
        {label:'A',value:'A'},
        {label:'B',value:'B'},
        {label:'C',value:'C'},
      ],
      gylx:[
        {label:'坡口',value:['pkbs']},
        {label:'打磨',value:['dmbs']},
        {label:'坡口->曲面',value:['pkbs','qbs']},
        {label:'坡口->打磨',value:['pkbs','dmbs']},
        {label:'坡口->曲面->打磨',value:['pkbs','qbs','dmbs']},
      ],
    }
  },
  created(){
    const path=this.$route.path.replace('/','')
    if (path==='ljian'){
      this.ljbs=true
    }
    this.sgry=this.$props.workers.map(item=>{
      return {label:item.userName,value:item.userCode}
    })
    this.initZylxBm()
  },
  methods:{
    initZylxBm(){
      dict({bmlb:'ZYLX'}).then(res=>{
        const zylx=[]
        res.data.forEach(item=>{
          const data={label:item.bmsm,value:item.bm}
          zylx.push(data)
        })
        this.zylx=zylx
      })
    },
    plGylx(){
      this.$emit('plGylx',this.gylxSelectData,this.worker)
    },
    paigong(){
      this.$emit('paigong')
    },
    search(){
      this.queryParam.dcCh=this.$refs.projectSelectRef.getDcch()
      this.$emit('search',this.queryParam)
    },
    getQueryParam(){
      return this.queryParam
    }
  }
}
</script>

<style scoped>

</style>
