<template>
  <div>
    <el-breadcrumb separator="/" class="my-breadcrumb">
      <el-breadcrumb-item>市信用信息平台查询</el-breadcrumb-item>
      <el-breadcrumb-item>法人信息详情</el-breadcrumb-item>
    </el-breadcrumb>
  </div>
  <div class="back" @click="$emit('changeOperation','',{})"><span class="fa fa-reply cur-po " >返回</span></div>
  <common-layout  ref="layoutRef" :table-attrs="{
     'has-operation':false
   }" :form-attrs="{
     'span-attrs':{
       span:4
     }
   }" :table-header="creditRepairEditHeader" :get-table-list="getTableData" :filter-form="formConfig">
    <template #ZTMC="{data}">
      <span class="table-num" @click="getDetail(data)">{{data.ZTMC}}</span>
    </template>
    <template #SJZT="{data}">
      <span>{{getStateName(data.SJZT)}}</span>
    </template>
  </common-layout>
  <template v-if="isEditDialogShow">
    <credit-repair-setting-dialog @getTableData="getTableData" :dialog-operation-type="dialogOperationType" :current-dialog-obj="currentDialogOpObj" v-model:dialog-visible="isEditDialogShow"/>
  </template>
</template>

<script>
import commonLayout from "@/components/CommonLayout.vue";
import {onBeforeMount, onMounted, ref} from "vue";
import {creditRepairEdit} from "@/data/all-form";
import {creditRepairEditHeader} from "@/data/all-table-header";
import {useRootStore} from "@/pinia/useStore";
import {selectAdsZjwXyxfSqxfbPageList} from "@/service/credit-data/credit-repair/credit-repair";
import CreditRepairSettingDialog from "@/views/main/c-views/credit-data/credit-repair/CreditRepairSettingDialog.vue";
import {useDetailOrEdit} from "@/units/use-method/usePagination";
import {InsertSyslog} from "@/units/use-method/user-log";

export default {
  name: "CreditRepairEdit",
  components:{CreditRepairSettingDialog, commonLayout},
  props:{
    currentOpObj:{

    },
    operationType:{

    }
  },
  setup(props,{emit}) {
    const layoutRef = ref(null);
    const formConfig = ref({...creditRepairEdit});
    const isEditDialogShow = ref(false);
    const store = useRootStore();
    const {changeOperation,currentOpObj:currentDialogOpObj,operationType:dialogOperationType} = useDetailOrEdit();
    const dialogData = ref({...props.currentOpObj})
    function getTableData(){
      debugger
      let tempCfjgqx = "";
      if(props.currentOpObj.CFJGQX !="ZJ"){
        tempCfjgqx = props.currentOpObj.CFJGQX;
      }
      dialogData.value.START_TIME = layoutRef.value.form.START_DATE;
      dialogData.value.END_TIME = layoutRef.value.form.END_DATE;
      let paraJson ={
        START_TIME:layoutRef.value.form.START_DATE,
        END_TIME:layoutRef.value.form.END_DATE,
        ZTMC:"",
        CFJGQX:tempCfjgqx,
        appkey:store.userInfo.xyxx_userkeycode,
        pageIndex:layoutRef.value.pageIndex,
        pageSize:layoutRef.value.pageSize
      }
      if(props.currentOpObj.TYPE == "ALL_NUM"){
        paraJson.SJZT = "5";
      }
      if(props.currentOpObj.TYPE == "JS_NUM"){
        paraJson.SJZT = "5";
        paraJson.CFJG = "建设";
      }
      if(props.currentOpObj.TYPE == "CGZFJ_NUM"){
        paraJson.SJZT = "5";
        paraJson.CFJG = "";
        paraJson.NOT_CFJG = "建设";
      }
      if(props.currentOpObj.TYPE == "JJXF_NUM"){
        paraJson.SJZT = "6";
      }
      if(props.currentOpObj.TYPE == "BYSL_NUM"){
        paraJson.SJZT = "7";
      }
      selectAdsZjwXyxfSqxfbPageList(paraJson).then(res =>{
        InsertSyslog(localStorage.getItem("xyxx_usercode"),localStorage.getItem("xyxx_unitcode"), "信息查询", "信用修复查询成功", "信用修复", "")
        layoutRef.value.getResData(res.msg[0].Rows,res.msg[0].TotalRowCount);
      })
    }
    function getDetail(data){
      isEditDialogShow.value = true;
      dialogData.value.ZTMC = data.ZTMC;
      debugger
      changeOperation("detail",dialogData.value)
    }
    function getStateName(state){
      switch (state){
        case "0":
          return "已退回";
        case "1":
          return "已申请";
        case "2":
          return "已转办";
        case "3":
          return "已受理";
        case "4":
          return "已处理";
        case "5":
          return "同意修复";
        case "6":
          return "拒绝修复";
        case "7":
          return "不予受理";
      }
    }
    onMounted(() =>{
      layoutRef.value.form.START_DATE = props.currentOpObj.START_TIME;
      layoutRef.value.form.END_DATE = props.currentOpObj.START_TIME;
    })
    return {
      layoutRef,
      getTableData,
      creditRepairEditHeader,
      formConfig,
      getDetail,
      getStateName,
      isEditDialogShow,
      dialogOperationType,
      currentDialogOpObj
    }
  }
}
</script>

<style scoped lang="scss">
.table-num{
  color:#23527c
}
</style>