<template>
  <div class="avoid_">
    <div class="avoid">
      <el-form>
        <el-row>
          <el-col :span="24">
            <h2 class="title_style">被查单位</h2>
          </el-col>
        </el-row>
        <br />
        <el-row>
          <el-col :span="9">
            <span>被检单位名称：</span>
            <el-input style="width: 70%;" v-model="dwmcss"></el-input>
          </el-col>
          <el-col :span="3">
            <el-button type="primary" @click="gbqymclistcx()">查询</el-button>
          </el-col>
          <el-col :span="10">
            <span>规避区域：</span>
            <el-cascader
                    :options="dwoptions"
                    :props="dwprops"
                    style="width: 75%;"
                    collapse-tags
                    clearable></el-cascader>
          </el-col>
          <el-col :span="2">
            <el-button type="primary">选择</el-button>
          </el-col>
        </el-row>
        <br />
        <el-row>
          <el-col :span="24">
            <el-table
                    ref="multipleTable"
                    :data="qyxx"
                    tooltip-effect="dark"
                    style="width: 100%"
                    :border="true"
                    @selection-change="handleSelectionChange">
              <el-table-column type="selection">
              </el-table-column>
              <el-table-column prop="qymc" label="被检单位名称"></el-table-column>
            </el-table>
          </el-col>
        </el-row>
        <br />
        <br />
        <div v-show="this.$route.query.status != 2">
          <el-row>
            <el-col :span="24">
              <h2 class="title_style">检察人员</h2>
            </el-col>
          </el-row>
          <br />
          <el-row>
            <el-col :span="9">
              <span>人员名称：</span>
              <el-input style="width: 70%;" v-model="rymxs"></el-input>
            </el-col>
            <el-col :span="3">
              <el-button type="primary" @click="gbrymccx()">查询</el-button>
            </el-col>
            <el-col :span="10">
              <span>规避区域：</span>
              <el-input style="width: 75%;"></el-input>
            </el-col>
            <el-col :span="2">
              <el-button type="primary">选择</el-button>
            </el-col>
          </el-row>
          <br />
          <el-row>
            <el-col :span="24">
              <el-table
                      ref="multipleTable"
                      :data="tableData"
                      tooltip-effect="dark"
                      style="width: 100%"
                      :border="true"
                      @selection-change="handleSelectionChange1">
                <el-table-column type="selection">
                </el-table-column>
                <el-table-column label="姓名">
                  <template slot-scope="scope">
                    {{ scope.row.ryxm }}
                  </template>
                </el-table-column>
                <el-table-column prop="bmmc" label="所属部门"></el-table-column>
              </el-table>
            </el-col>
          </el-row>
        </div>
      </el-form>
    </div>
    <div class="btn_operation">
      <el-button type="primary" @click="go_dailyinspection()">取消</el-button>
      <el-button type="primary" @click="next_checkExtraction()">下一步</el-button>
    </div>
  </div>
</template>

<script>
  import {gbrylb,gbrylbcx,gbqylb,bjdwmchq} from "@/api/missionDispatchManage/dailyinspection/index.js";
  import {inspectionUnit} from "@/api/setTask/index.js"
  export default {
    name: "taskGeneration",
    components:{

    },
    mounted(){
      // this.gbrymcList()//规避人员列表获取
      // this.gbqymclist()//规避企业名称获取
      this.get_gbqylist()//规避区域列表获取companyTypeList
      console.log(this.$route)
    },
    methods:{
      //规避区域
      get_gbqylist(){
        inspectionUnit(sessionStorage.getItem("orgCode")).then(res=>{
          console.log(res)
          this.dwoptions.push(res.data)
        }).catch(err=>{
          console.log(err)
        })
      },
      //规避单位名称list
      gbqymclistcx(){
        let params = {
          qymc:this.dwmcss,
          qyjgdm:sessionStorage.getItem("orgCode")
        }
        gbqylb(params).then(res=>{
          this.qyxx = res.data
        }).catch(err=>{
          console.log(err)
        })
      },
      //规避人员名称名单
      gbrymcList(){
        let params = {
        }
        gbrylb(params).then(res=>{
          this.tableData = res.data
        }).catch(err=>{
          console.log(err)
        })
      },
      //规避人员模糊查询
      gbrymccx(){
        var formData = new FormData();
        formData.append("rymc", this.rymxs);
        gbrylbcx(formData).then(res=>{
          this.tableData = res.data
        }).catch(err=>{
          console.log(err)
        })
      },
      //选中时触发的事件
      //单位
      handleSelectionChange(val) {
        this.dwlb = val;
        console.log(this.dwlb)
      },
      //人员
      handleSelectionChange1(val) {
        this.rylb = val;
        console.log(this.rylb)
      },

      //跳转到抽取
      next_checkExtraction(){

        let arr = []
        let arr1 = []
        this.dwlb.forEach(item=>{
          arr.push({
            gbCode:item.tyshxydm,
            gbName:item.qymc
          })
        })
        this.rylb.forEach(item=>{
          arr1.push({
            gbCode:item.id,
            gbName:item.ryxm,

          })
        })
        this.$router.push({
          path:"/inspection/specialcheckExtraction",
          query:{
            status:this.$route.query.status,
            gbdwArr:JSON.stringify(arr),
            gbryArr:JSON.stringify(arr1),
            companyTypeList:this.$route.query.bjdwlx,
            bjqyxzfs:this.$route.query.bjqyxzfs,
            rwid:this.$route.query.rwid
          }
        })
      },
      go_dailyinspection(){
        this.$router.push("/inspection/specialInspectionSupervise")
      },
    },
    data(){
      return{
        dwmultipleSelection:[],
        //携带的规避单位列表
        dwlb:[],
        //携带的规避人员列表
        rylb:[],
        //单位options
        dwoptions:[],
        //单位props
        dwprops:{
          multiple: true,
          label: "orgName",
          value: "orgCode",
          children: "children",
        },
        //企业名称搜索
        dwmcss:"",
        //企业信息
        qyxx:[],
        //人员名称
        rymxs:"",
        tableData:[{
          name:"111",
          asd:"861523"
        }],//人员信息
        checked:"",
        procuratorialPersonnelList:[
          {}
        ],
        form: {
          name: '',
          region: '',
          date1: '',
          date2: '',
          delivery: false,
          type: [],
          resource: '',
          desc: '',
          resource2:"",
          resource3:""
        },

      }
    }
  }
</script>

<style scoped>
  .avoid{
    /*border: 1px solid #dadada;*/
    border-radius: 3px;
    margin-top: 10px;
    padding: 18px 18px 28px 18px;

  }
  .avoid_{
    margin-left: 10px;
    overflow-y: auto;
    height: calc(100vh - 218px);
    width: calc(100% - 40px);
    overflow-x: hidden;
    background: #f6f7f9;
    border: 1px solid #efeded;
    padding: 0 10px;
  }
  .inspectionUnit_border{
    border: 1px dashed #ccc;
    border-radius: 8px;
    padding: 10px 10px 20px 20px;
  }
  .table_span{
    padding-left: 10px;
  }
  .title_style{
    border-left: 3px solid #409EFF;
    padding-left: 4px;
    font-size: 15px;
    margin-bottom: 10px;
  }
  .btn_operation{
    text-align: center;
  }
</style>
