<template>
  <div class="main-content market">
    <DetailHead result="综合查询" class="border0" />
    <div class="search-box">
      <el-row>
        <el-col :span="8">
          <div class="search-field">
            <p>管理片区  包括下属片区：<el-checkbox v-model="searchForm.checked" /></p>
            <el-cascader
              v-model="searchForm.regulatory"
              size="mini"
              class="custom"
              style="width: 100%"
              :options="bustypeOptions"
              :props="{ checkStrictly: true }"
              clearable
              filterable
            />
          </div>
        </el-col>
        <el-col :span="8">
          <div class="search-field">
            <p>注册码</p>
            <el-input v-model="searchForm.uniscid" placeholder="注册码/统一社会信用代码" @keyup.enter.native="submitSearch" />
          </div>
        </el-col>
        <el-col :span="8">
          <div class="search-field">
            <p>统一社会信用代码</p>
            <el-input v-model="searchForm.uniscid" placeholder="注册码/统一社会信用代码" @keyup.enter.native="submitSearch" />
          </div>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <div class="search-field">
            <p>企业名称</p>
            <el-input v-model="searchForm.entName" style="width:100%" placeholder="企业名称" @keyup.enter.native="submitSearch" />
          </div>
        </el-col>
        <el-col :span="16">
          <div class="search-field">
            <p style="width:118px">经营地址</p>
            <el-input v-model="searchForm.address" style="width:100%" placeholder="经营地址" @keyup.enter.native="submitSearch" />
          </div>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <div class="search-field">
            <p>检查人员</p>
            <el-input v-model="searchForm.checkPeople" placeholder="检查人员" @keyup.enter.native="submitSearch" />
          </div>
        </el-col>
        <el-col :span="8">
          <div class="search-field">
            <p>经营范围</p>
            <el-input v-model="searchForm.OPSCOPE" placeholder="经营范围" @keyup.enter.native="submitSearch" />
          </div>
        </el-col>
        <el-col :span="8">
          <div class="search-field">
            <p>实际经营项目</p>
            <el-input v-model="searchForm.businessName" placeholder="实际经营项目" @keyup.enter.native="submitSearch" />
          </div>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <div class="search-field">
            <p>实际经营项目备注</p>
            <el-input v-model="searchForm.businessNameRemark" placeholder="实际经营项目备注" @keyup.enter.native="submitSearch" />
          </div>
        </el-col>
        <el-col :span="8">
          <div class="search-field">
            <p>行业类别</p>
            <!--            <el-input v-model="searchForm.INDUSTRYPHY" placeholder="行业类别" @keyup.enter.native="submitSearch" />-->
            <el-select v-model="searchForm.INDUSTRYPHY" style="width: 100%" clearable size="mini" placeholder="请选择" class="custom">
              <el-option
                v-for="item in INDUSTRYPHYList"
                :key="item.code"
                :label="item.name"
                :value="item.code"
              />
            </el-select>
          </div>
        </el-col>
        <el-col :span="8">
          <div class="search-field">
            <p>登记机关</p>
            <el-select v-model="searchForm.REGORG" style="width: 100%" filterable clearable size="mini" placeholder="请选择" class="custom">
              <el-option
                v-for="item in REGORGList"
                :key="item.code"
                :label="item.name"
                :value="item.code"
              />
            </el-select>
          </div>
        </el-col>

      </el-row>
      <el-row>
        <el-col :span="8">
          <div class="search-field">
            <p>管理类别</p>
            <el-select v-model="searchForm.manageType" style="width: 100%" clearable size="mini" placeholder="请选择" class="custom">
              <el-option
                v-for="item in manageTypeList"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </div>
        </el-col>
        <el-col :span="8">
          <div class="search-field">
            <p>是否年检验照</p>
            <el-select v-model="searchForm.isnjyz" style="width: 100%" clearable size="mini" placeholder="请选择" class="custom">
              <el-option
                v-for="item in isnjyzList"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </div>
        </el-col>
        <el-col :span="8">
          <div class="search-field">
            <p>未认领</p>
            <el-select v-model="searchForm.noClaim" style="width: 100%" clearable size="mini" placeholder="请选择" class="custom">
              <el-option
                v-for="item in noClaimList"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </div>
        </el-col>

      </el-row>
      <el-row>
        <el-col :span="8">
          <div class="search-field">
            <p>风险监管级别</p>
            <el-select v-model="searchForm.risklevel" style="width: 100%" clearable size="mini" placeholder="请选择" class="custom">
              <el-option
                v-for="item in risklevelList"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </div>
        </el-col>
        <el-col :span="8">
          <div class="search-field">
            <p>监管检查结果</p>
            <el-select v-model="searchForm.checkRs" style="width: 100%" clearable size="mini" placeholder="请选择" class="custom">
              <el-option
                v-for="item in checkRsList"
                :key="item.code"
                :label="item.name"
                :value="item.code"
              />
            </el-select>
          </div>
        </el-col>
        <el-col :span="8">
          <div class="search-field">
            <p>企业类型</p>
            <el-select v-model="searchForm.ENTTYPE" style="width: 100%" clearable size="mini" placeholder="请选择" class="custom">
              <el-option
                v-for="item in ENTTYPEList"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </div>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <div class="search-field">
            <p>法定代表人</p>
            <el-input v-model="searchForm.name" placeholder="法定代表人" @keyup.enter.native="submitSearch" />
          </div>
        </el-col>
        <el-col :span="8">
          <div class="search-field">
            <p>成立日期</p>
            <el-date-picker
              v-model="searchForm.establishDate"
              size="mini"
              value-format="yyyy-MM-dd"
              type="daterange"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              style="width:100%"
            />
          </div>
        </el-col>
        <el-col :span="8">
          <div class="search-field">
            <p>变更（注销）日期</p>
            <el-date-picker
              v-model="searchForm.changeDate"
              size="mini"
              value-format="yyyy-MM-dd"
              type="daterange"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              style="width:100%"
            />
          </div>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <div class="search-field">
            <p>业户状态</p>
            <el-select v-model="searchForm.REGSTATE" style="width: 100%" clearable size="mini" placeholder="请选择" class="custom">
              <el-option
                v-for="item in REGSTATEList"
                :key="item.code"
                :label="item.name"
                :value="item.code"
              />
            </el-select>
          </div>
        </el-col>
        <el-col :span="8">
          <div class="search-field">
            <p>是否国家（省）局执照</p>
            <el-select v-model="searchForm.license" style="width: 100%" clearable size="mini" placeholder="请选择" class="custom">
              <el-option
                v-for="item in licenseList"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </div>
        </el-col>
        <el-col :span="8">
          <div class="search-field">
            <p>是否无照经营</p>
            <el-select v-model="searchForm.iswzjy" style="width: 100%" clearable size="mini" placeholder="请选择" class="custom">
              <el-option
                v-for="item in iswzjyList"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </div>
        </el-col>
      </el-row>
    </div>
    <!-- <DetailHead result="经营异常查询" class="border0" /> -->
    <el-row class="search-box">
      <el-col :span="8">
        <div class="search-field">
          <p>列异原因：</p>
          <el-select v-model="searchForm.specause" style="width: 80%" clearable size="mini" placeholder="请选择" class="custom">
            <el-option
              v-for="item in reasonList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </div>
      </el-col>
      <el-col :span="8">
        <div class="search-field">
          <p>列异日期：</p>
          <el-date-picker
            v-model="searchForm.searchDate"
            size="mini"
            value-format="yyyy-MM-dd"
            type="daterange"
            :unlink-panels="true"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          />
        </div>
      </el-col>
      <el-col :span="8">
        <el-radio v-model="searchForm.type" label="abn">因实地查无列异两年</el-radio>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <el-radio v-model="searchForm.type" style="padding:30px 10px" label="wnbSdcw">一年未年报实地查无</el-radio>
        <el-radio v-model="searchForm.type" style="padding:30px 10px" label="wnb2">连续两年未年报</el-radio>
        <el-radio v-model="searchForm.type" style="padding:30px 10px" label="wnb5">连续5年未年报</el-radio>
        <el-radio v-model="searchForm.type" style="padding:30px 10px" label="abn">因地址原因纳入经营异常名录两年以上</el-radio>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <el-radio v-model="searchForm.isGRDZ" style="padding:30px 10px" label="GRDZ">个人独资企业</el-radio>
        <el-radio v-model="searchForm.isGRDZ" style="padding:30px 10px" label="NOGRDZ">除个人独资企业外</el-radio>
      </el-col>
    </el-row>
    <div class="func-box">
      <div class="btn-box">
        <el-button type="primary" icon="el-icon-search" size="mini" @click="submitSearch">查询</el-button>
        <el-button type="info" icon="el-icon-refresh-left" size="mini" @click="resetForm">重置</el-button>
      </div>
    </div>
    <!--    <div class="main-body">-->
    <!--      <div class="func-box">-->
    <!--        <div class="btn-box">-->
    <!--          <el-button type="primary" icon="el-icon-search" size="mini" @click="submitSearch">查询</el-button>-->
    <!--          <el-button type="info" icon="el-icon-refresh-left" size="mini" @click="resetForm">重置</el-button>-->
    <!--        </div>-->
    <!--      </div>-->
    <!--    </div>-->
  </div>
</template>
<script>
import DetailHead from '@/components/DetailHead'
import { getDataType, getBaseCodeList, getRegOrgList } from '@/api/constant'
import { getRegulatory } from '@/api/abnormal'
import { getConstant } from '@/api/system'
export default {
  components: {
    DetailHead
  },
  data() {
    return {
      bustypeOptions: [],
      searchForm: {
        isGRDZ: '',
        specause: '',
        searchDate: '',
        checked: '',
        regulatory: '',
        uniscid: '',
        entName: '',
        address: '',
        name: '',
        checkPeople: '',
        OPSCOPE: '',
        businessName: '',
        businessNameRemark: '',
        INDUSTRYPHY: '',
        REGORG: '',
        manageType: '',
        isnjyz: '',
        noClaim: '',
        risklevel: '',
        checkRs: '',
        establishDate: '',
        changeDate: '',
        ENTTYPE: '',
        REGSTATE: '',
        license: '',
        iswzjy: '',
        type: ''
      },
      INDUSTRYPHYList: [],
      regOrgOptions: [],
      REGORGList: [],
      reasonList: [],
      manageTypeList: [],
      isnjyzList: [{
        value: '0',
        label: '否'
      }, {
        value: '1',
        label: '是'
      }],
      noClaimList: [{
        value: '0',
        label: '否'
      }, {
        value: '1',
        label: '是'
      }],
      risklevelList: [{
        value: '高风险',
        label: '高风险'
      }, {
        value: '中风险',
        label: '中风险'
      }, {
        value: '低风险',
        label: '低风险'
      }],
      checkRsList: [],
      ENTTYPEList: [{
        value: 'individual',
        label: '个体户'
      }, {
        value: 'farmer',
        label: '农专'
      }, {
        value: 'company',
        label: '企业'
      }],
      REGSTATEList: [],
      licenseList: [{
        value: '0',
        label: '否'
      }, {
        value: '1',
        label: '是'
      }],
      iswzjyList: [{
        value: '0',
        label: '否'
      }, {
        value: '1',
        label: '是'
      }]
    }
  },
  mounted() {
    if (this.$route.query.type) {
      this.searchForm.type = this.$route.query.type
    }
    if (this.$route.query.pripid) {
      var pid = this.$route.query.pripid
      var shrink = this.$route.query.shrink
      console.log(shrink)
      this.$router.push({
        path: '/comprehensive/details', query: { pripid: pid, shrink: shrink } // 少带了shrink参数
      })
    }
    // 获取登记机关
    // getDataType('registration').then(res => {
    //   if (res.code === 0) {
    //     this.REGORGList = res.data
    //   }
    // })
    // 获取登记机关
    getRegOrgList().then(res => {
      if (res.code === 0) {
        this.REGORGList = res.data
      }
    })
    // 获取行业门类
    getBaseCodeList('CA05').then(res => {
      if (res.code === 0) {
        this.INDUSTRYPHYList = res.data
      }
    })
    // 获取管辖区域
    getRegulatory().then(res => {
      if (res.code === 0) {
        this.bustypeOptions = res.data
      } else {
        this.$message.error(res.msg)
      }
    })
    // 监管检查结果
    getBaseCodeList('CD29').then(res => {
      if (res.code === 0) {
        this.checkRsList = res.data
      }
    })
    // 监管业务状态
    getBaseCodeList('CA19').then(res => {
      if (res.code === 0) {
        this.REGSTATEList = res.data
      }
    })

    // 获取列异原因
    this.getDifferList()
  },
  methods: {
    getDifferList() {
      getConstant('CD71').then(res => {
        if (res.code === 0) {
          const list = []
          res.data.forEach(each => {
            list.push({
              value: each.code,
              label: each.name
            })
          })
          this.reasonList = list
          console.log(this.reasonList)
          console.log('00000')
        }
      })
    },

    resetForm() {
      for (const key in this.searchForm) {
        this.$set(this.searchForm, key, null)
      }
    },
    submitSearch() {
      const query = {}
      for (const key in this.searchForm) {
        if (this.$util.isEmpty(this.searchForm[key])) continue
        // if (key === 'estDateStart' || key === 'estDateEnd' || key === 'busDateStart' || key === 'busDateEnd') {
        //   query[key] = this.$util.formatDate.format(this.searchForm[key], 'yyyy-MM-dd')
        // } else {
        //   query[key] = this.searchForm[key]
        // }
        query[key] = this.searchForm[key]
      }
      this.$router.push({ path: '/comprehensive/result', query: query })
    }
  }
}
</script>

<style lang="scss" scoped>
  .main-content{
    >div:not(:first-child){
      margin-top:16px;
    }
    .search-box{
      padding:10px 0;
      .search-field{
        display:flex;
        width:100%;
        >p{
          margin:0 10px 10px 0;
          font-family: Microsoft YaHei, Microsoft YaHei-Bold;
          color: #666;
          font-size:16PX;
          width:130px;
          text-align: right;
        }
      }
      >.el-row{
        margin-bottom:10px;
      }
    }
    .btn-box{
      text-align:right;
    }
    .main-body{
      padding:16px 0;
      border-top: 1px dashed #70AEFF;
      .header{
        .header-label{
          font-size: 20PX;
          font-family: Microsoft YaHei, Microsoft YaHei-Bold;
          font-weight: bold;
          color: #243668;
          line-height: 32px;
        }
      }
    }
  }
  /deep/.el-input__inner{
    height: 28px;
  }
  /deep/.el-input__icon{
    line-height: 28px;
  }
</style>
