<template>
  <el-dialog
      :modal="true"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      destroy-on-close
      :title="currentDialogObj.ZTMC"
      :model-value="dialogVisible"

      :before-close="handleClose"
  >
      <my-table border
                :has-operation="false"
                :table-data="tableData"
                :headers="headerConfig">
      </my-table>
      <ele-pagination  ref="refEl"
                       @sizeOrPageChange="handleSizeChange"
                       class="page"
                       :default-page-size="pageSize"
                       :layout="'slot,sizes,prev,pager,next'"
                       :total-count="totalCount">
        <template #default>
          <div class="m-s">
            显示第 {{pageSize * (pageIndex -1) + 1 }} 到第 {{pageSize * pageIndex}} 条记录，总共 {{totalCount}} 条记录 共显示

          </div>
        </template>
      </ele-pagination>
  </el-dialog>
</template>

<script>
import ElePagination from "@/components/common/ElePagination.vue";
import MyTable from "@/components/common/MyTable.vue";
import {Close, Delete, Edit, Plus, Search, SuccessFilled} from "@element-plus/icons-vue";
import {onBeforeMount, ref} from "vue";
import {creditRepairEditHeader} from "@/data/all-table-header";
import {usePagination} from "@/units/use-method/usePagination";
import {selectAdsZjwXyxfSqxfbPageList} from "@/service/credit-data/credit-repair/credit-repair";
import {useRootStore} from "@/pinia/useStore";
import {InsertSyslog} from "@/units/use-method/user-log";

export default {
  name: "CreditRepairSettingDialog",
  components: {ElePagination, MyTable},
  computed: {
    Delete() {
      return Delete
    },
    Edit() {
      return Edit
    },
    Plus() {
      return Plus
    },
    SuccessFilled() {
      return SuccessFilled
    },
    Close() {
      return Close
    },
    Search(){
      return Search
    }
  },
  props:{
    dialogVisible:{  //是否可见

    },
    dialogOperationType:{   //操作类型

    },
    currentDialogObj:{   //当前选中信息

    },
  },
  setup(props,{emit}){
    const headerConfig = ref([...creditRepairEditHeader]);
    const {pageIndex,pageSize,tableData,totalCount,initSearch,handleSizeChange,refEl}  = usePagination(getTableData.bind(null));
    const store = useRootStore();
    function getTableData(){
      let tempCfjgqx = "";
      if(props.currentDialogObj.CFJGQX !="ZJ"){
        tempCfjgqx = props.currentDialogObj.CFJGQX;
      }
      let paraJson ={
        START_TIME:props.currentDialogObj.START_TIME,
        END_TIME:props.currentDialogObj.END_TIME,
        ZTMC:props.currentDialogObj.ZTMC,
        CFJGQX:tempCfjgqx,
        appkey:store.userInfo.xyxx_userkeycode,
        pageIndex:pageIndex.value,
        pageSize:pageSize.value
      }
      if(props.currentDialogObj.TYPE == "ALL_NUM"){
        paraJson.SJZT = "5";
      }
      if(props.currentDialogObj.TYPE == "JS_NUM"){
        paraJson.SJZT = "5";
        paraJson.CFJG = "建设";
      }
      if(props.currentDialogObj.TYPE == "CGZFJ_NUM"){
        paraJson.SJZT = "5";
        paraJson.CFJG = "";
        paraJson.NOT_CFJG = "建设";
      }
      if(props.currentDialogObj.TYPE == "JJXF_NUM"){
        paraJson.SJZT = "6";
      }
      if(props.currentDialogObj.TYPE == "BYSL_NUM"){
        paraJson.SJZT = "7";
      }
      selectAdsZjwXyxfSqxfbPageList(paraJson).then(res =>{
        let msg = res.msg[0];
        InsertSyslog(localStorage.getItem("xyxx_usercode"),localStorage.getItem("xyxx_unitcode"), "信息查询", "信用修复查询成功", "信用修复", "")
        if(msg.TotalRowCount  > 0){
          let tempData = msg.Rows;
          tableData.value = tempData;
          totalCount.value = res.msg[0].TotalRowCount;
        }
      })
    }
    function handleClose(){
      emit('update:dialogVisible',false);
    }
    onBeforeMount(()=>{
      getTableData()
    })
    return{
      headerConfig,
      handleClose,
      pageIndex,pageSize,tableData,totalCount,handleSizeChange,refEl,initSearch,
    }
  }
}
</script>

<style scoped>

</style>