<template>
  <common-layout  ref="layoutRef" :table-attrs="{
     'has-operation':true
   }" :form-attrs="{
     'span-attrs':{
       span:4
     }
   }" :immediate-search=false :table-header="matterSearchHomeHeaderZrr" :get-table-list="getTableData" :filter-form="formConfig">
    <template #operation="{data}">
      <el-button  type="info" @click="$emit('changeOperation','detail',data)">查看</el-button>
    </template>
  </common-layout>
</template>

<script>
import {onBeforeMount, ref} from "vue";
import CommonLayout from "@/components/CommonLayout.vue";
import {matterSearchHome} from "@/data/all-form";
import {matterSearchHomeHeaderZrr} from "@/data/all-table-header";
import {useRootStore} from "@/pinia/useStore";
import {
  querySxList
} from "@/service/credit-information/commission-credit-information-database-search/matter-search/matter-search";
import {InsertSyslog} from "@/units/use-method/user-log";
export default {
  name: "MatterSearchHome",
  components: {CommonLayout},
  setup(){
    const layoutRef = ref(null);
    const formConfig = ref ({...matterSearchHome});
    const store = useRootStore();
    function getTableData(){
      layoutRef.value.isValidate(queryData)
    }
    function queryData(){
      querySxList({
        "xdrmc":layoutRef.value.form.NAME,
        "UNIT_NAME":layoutRef.value.form.XXLY,
        "DATA_TYPE":layoutRef.value.form.XXLB,
        "appkey":store.userInfo.xyxx_userkeycode
      }).then(res =>{
        InsertSyslog(localStorage.getItem("xyxx_usercode"),localStorage.getItem("xyxx_unitcode"), "信息查询", "委信用信息查询成功", "委信用信息", "");
        layoutRef.value.getResData(res.msg[0].Rows,res.msg[0].TotalRowCount)
      })
    }
    function getDifferentXXLB(type){
      debugger
      let xxlbItem = formConfig.value.formItemsArr.find(i => i.modelValue ==="XXLB");
      let option = [];
      switch(type){
        case "":
          option = [
            {
              label:"全部",
              value:""
            },
            {
              label:"行政处罚",
              value:"1"
            },
            {
              label:"行政许可",
              value:"2"
            },
            {
              label:"市公积金贷款逾期信息",
              value:"3"
            },
          ]
          break
        case "AH0021":
        case "AH0200":
          option = [
            {
              label:"全部",
              value:""
            },
            {
              label:"行政处罚",
              value:"1"
            },
            {
              label:"行政许可",
              value:"2"
            }
          ]
          break
        case "AH0022":
          option = [
            {
              label:"全部",
              value:""
            },
            {
              label:"市公积金贷款逾期信息",
              value:"3"
            },
          ]
          break
      }
      xxlbItem.options = [...option]
    }
    onBeforeMount(()=>{
      getDifferentXXLB("")
      let xxlyItem = formConfig.value.formItemsArr.find(i => i.modelValue ==="XXLY");
      xxlyItem.events = {
        'change'(val){
          getDifferentXXLB(val)
        }
      }
    })
    return{
      layoutRef,
      formConfig,
      getTableData,
      matterSearchHomeHeaderZrr
    }
  }
}
</script>

<style scoped>

</style>