<template>
  <div class="h-full">
    <w-grid
      ref="appDebtRatingGridRef"
      title="债项评级列表"
      :data-url="Environment.apiContextPath('api/irbs/appDebtRating/queryPage')"
      :fetch-data-url="Environment.apiContextPath('api/irbs/appDebtRating/queryPage')"
      :sort-no="true"
      :checkbox-selection="false"
      :query-form-cols-num="3"
      :query-form-fields="appDebtRatingGrid.queryFormFields"
      :columns="appDebtRatingGrid.columns"
      :toolbar-actions="appDebtRatingGrid.buttons"
      :pageable="true"
    ></w-grid>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { useQuasar } from 'quasar';
import { Environment, EnumTools, DictionaryTools, Options, Formater, axios, NotifyManager } from 'platform-core';
import { Round } from '@/views/custRating/CustRating.ts';

const $q = useQuasar();
const appDebtRatingGridRef = ref();

const appDebtRatingGrid = {
  buttons: ['query', 'reset'],
  queryFormFields: [
    { label: '债项编号', name: 'contractNo', type: 'w-text' },
    { label: '客户编号', name: 'custNo', type: 'w-text' },
    { label: '客户名称', name: 'custName', type: 'w-text' },
  ],
  columns: [
    { name: 'contractNo', label: '债项编号' },
    { name: 'contractAmt', label: '债项金额' },
    { name: 'custNo', label: '客户编号' },
    { name: 'custName', label: '客户名称' },
    { name: 'productType', label: '产品类型' },
    {
      name: 'productRate',
      label: '产品回收率',
      format: (val) => {
        if (val && typeof val === 'number') {
          return Round(val * 100, 2) + '%';
        }
        return val;
      },
    },
    { name: 'lowRiskFlg', label: '是否低风险业务' },
    { name: 'orgType', label: '客户类型' },
    { name: 'interestDebtFlg', label: '是否利率债' },
    { name: 'financeDebtLevel', label: '金融机构债权等级' },
    { name: 'creditGrade', label: '借款人评级' },
    { name: 'creditGradeRate', label: '借款人评级调整系数' },
    { name: 'industryType', label: '借款人行业类型' },
    { name: 'industryTypeRate', label: '行业调整系数' },
    { name: 'corpSize', label: '借款人企业规模' },
    { name: 'corpSizeRate', label: '企业规模调整系数' },
    { name: 'corpType', label: '借款人企业性质' },
    { name: 'corpTypeRate', label: '企业性质调整系数' },
    { name: 'regionCode', label: '借款人所在区域' },
    { name: 'regionCodeRate', label: '区域调整系数' },
    { name: 'yxzczwl', label: '借款人有形资产债务率' },
    { name: 'yxzczwlRate', label: '有形资产债务率调整系数' },
    { name: 'pledgeClass', label: '保证担保形式' },
    { name: 'guaranteeType', label: '担保类型' },
    {
      name: 'recrate',
      label: '借款人整体回收率',
      format: (val) => {
        if (val && typeof val === 'number') {
          return Round(val * 100, 2) + '%';
        }
        return val;
      },
    },
    {
      name: 'pledgeRecRate',
      label: '保证人整体回收率',
      format: (val) => {
        if (val && typeof val === 'number') {
          return Round(val * 100, 2) + '%';
        }
        return val;
      },
    },
    {
      name: 'guarantyRecRate',
      label: '押品整体回收率',
      format: (val) => {
        if (val && typeof val === 'number') {
          return Round(val * 100, 2) + '%';
        }
        return val;
      },
    },
    {
      name: 'lgd',
      label: 'LGD',
      format: (val) => {
        if (val && typeof val === 'number') {
          return Round(val * 100, 2) + '%';
        }
        return val;
      },
    },
    { name: 'managerCode', label: '业务经办人' },
  ],
};
</script>
