<template>
  <div style="height: 100%">
    <w-grid
      ref="appDebtRatingGridRef"
      title="债项评级列表"
      :fetch-data-url="Environment.apiContextPath('api/irbs/appDebtRating/queryPage')"
      :sort-no="true"
      :checkbox-selection="false"
      :query-form-cols-num="4"
      :query-form-fields="appDebtRatingGrid.queryFormFields"
      :columns="appDebtRatingGrid.columns"
      :toolbar-actions="appDebtRatingGrid.buttons"
      :pagination="{
        sortBy: 'lastModifyDate',
        descending: true,
      }"
    ></w-grid>
    <LaunchExposureDialog ref="launchExposureDialogRef" @refresh="refreshTable"></LaunchExposureDialog>
    <HandmadeExposureDialog ref="handmadeExposureDialogRef" @refresh="refreshTable"></HandmadeExposureDialog>
  </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 LaunchExposureDialog from '@/views/riskExposure/LaunchExposureDialog.vue';
import HandmadeExposureDialog from '@/views/riskExposure/HandmadeExposureDialog.vue';

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

const appDebtRatingGrid = {
  buttons: [
    ['query', 'separator', 'moreQuery'],
    'reset',
    'separator',
    {
      extend: 'view',
      click: (args) => {
        handmadeExposureDialogRef.value.show(args.selected, true, 'riskExposure');
      },
    },
    'separator',
  ],
  queryFormFields: [
    { label: '债项编号', name: 'contractNo', type: 'text' },
    { label: '客户号', name: 'custNo', type: 'text' },
    { label: '客户名称', name: 'custName', type: 'text' },
  ],
  columns: [
    { name: 'contractNo', label: '债项编号' },
    { name: 'custNo', label: '客户号' },
    { name: 'custName', label: '客户名称' },
    { name: 'orgType', label: '客户类型' },
    { name: 'productType', label: '产品类型' },
    { name: 'contractAmt', label: '债项金额' },
    { name: 'lowRiskFlg', label: '是否低风险业务' },
    { name: 'interestDebtFlg', label: '是否利率债' },
    { name: 'financeDebtLevel', label: '金融机构债权等级' },
    { name: 'creditGrade', label: '借款人评级' },
    { name: 'industryType', label: '借款人行业类型' },
    { name: 'corpSize', label: '借款人企业规模' },
    { name: 'corpType', label: '借款人企业性质' },
    { name: 'regionCode', label: '借款人所在区域' },
    { name: 'guaranteeType', label: '担保类型' },
    { name: 'pledgeClass', label: '保证担保形式' },
    { name: 'regionCode', label: '借款人所在区域' },
    { name: 'lgd', label: 'LGD' },
    { name: 'managerCode', label: '业务经办人' },
  ],
};

const refreshTable = () => {
  appDebtRatingGridRef.value.refresh();
};
</script>
