<template>
  <div class="h-full">
    <w-grid
      ref="rptRatingNumberMigrateRef"
      title="客户评级迁移报表(客户数)"
      :data-url="Environment.apiContextPath('api/irbs/rptRatingNumberMigrate/list')"
      :sort-no="true"
      :checkbox-selection="false"
      :query-form-cols-num="2"
      :query-form-fields="rptRatingNumberMigrateGrid.queryFormFields"
      :columns="rptRatingNumberMigrateGrid.tableColumns"
      :toolbar-actions="rptRatingNumberMigrateGrid.buttons"
      :pageable="false"
    ></w-grid>
  </div>
</template>

<script setup lang="ts">
import { ref, reactive } from 'vue';
import { useQuasar } from 'quasar';
import { Environment, EnumTools, DictionaryTools, Options, Formater, axios, NotifyManager } from 'platform-core';

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

const rptRatingNumberMigrateGrid = {
  buttons: [
    {
      extend: 'query',
      click: () => {
        const QueryParams = rptRatingNumberMigrateRef.value.getQueryForm().getData();
        axios.get(Environment.apiContextPath('api/irbs/rptRatingNumberMigrate/list'), { params: QueryParams }).then((resp) => {
          rptRatingNumberMigrateRef.value.setLocalData(resp.data);
        });
      },
    },
    'reset',
    'separator',
  ],
  queryFormFields: [
    { label: '报表日期', name: 'ratingMonth', type: 'date', defaultValue: '2023-07-01' },
    {
      label: '模型敞口',
      name: 'modelCode',
      type: 'select',
      options: [
        { value: 'WHM1', label: '政府投融资平台' },
        { value: 'WHM2', label: '事业单位' },
        { value: 'WHM3', label: '银行类金融机构' },
        { value: 'WHM41', label: '金融租赁与消费金融公司' },
        { value: 'WHM42', label: '证券公司' },
        { value: 'WHM43', label: '其他非银行金融机构' },
        { value: 'WHM44', label: '基金公司' },
        { value: 'WHM5', label: '新建企业' },
        { value: 'WHM6', label: '综合性集团' },
        { value: 'WHM7', label: '大型其他行业' },
        { value: 'WHM8', label: '中小微其他行业' },
        { value: 'WHM9', label: '大中型租赁和商务服务行业' },
        { value: 'WHM10', label: '小微租赁和商务服务业' },
        { value: 'WHM12', label: '房地产业' },
        { value: 'WHM13', label: '大中型农林牧渔业' },
        { value: 'WHM14', label: '小微农林牧渔业' },
        { value: 'WHM15', label: '大型建筑业' },
        { value: 'WHM16', label: '中小微建筑业' },
        { value: 'WHM17', label: '大中型制造业' },
        { value: 'WHM18', label: '小微制造业' },
        { value: 'WHM19', label: '大中型批发和零售业' },
        { value: 'WHM20', label: '小微批发和零售业' },
        { value: 'WHM22', label: '科技行业' },
      ],
    },
    {
      label: '分支机构',
      name: 'managerOrgCode',
      type: 'select',
      options: [
        { value: '01002', label: '总行营业部' },
        { value: '01003', label: 'JJJS开发区支行' },
        { value: '01005', label: 'XF支行' },
        { value: '01006', label: 'GCZ支行' },
        { value: '01007', label: 'ZL支行' },
        { value: '01008', label: 'HKJ支行' },
        { value: '01009', label: 'HL支行' },
        { value: '01010', label: 'LJ支行' },
        { value: '01012', label: 'GG分行' },
        { value: '01013', label: 'ZY支行' },
        { value: '01014', label: 'ZD支行' },
        { value: '01015', label: 'HK支行' },
        { value: '01016', label: 'DS支行' },
        { value: '01017', label: 'LF支行' },
        { value: '01018', label: 'GS支行' },
        { value: '01019', label: 'LX支行' },
        { value: '01020', label: 'BX支行' },
        { value: '01021', label: 'ZQ支行' },
        { value: '01022', label: 'JF支行' },
        { value: '01023', label: 'CC支行' },
        { value: '01024', label: 'LQ支行' },
        { value: '01025', label: 'DH支行' },
        { value: '01027', label: 'SGH支行' },
      ],
    },
  ],
  tableColumns: [
    { label: '上期客户评级分布', name: 'ratingLevel', align: 'center' },
    {
      name: 'currRatingDist',
      label: '本期客户评级分布',
      columns: [
        { label: 'AAA', name: 'aaaCnt', align: 'center' },
        { label: 'AA', name: 'aaCnt', align: 'center' },
        { label: 'A+', name: 'aPlusCnt', align: 'center' },
        { label: 'A', name: 'aCnt', align: 'center' },
        { label: 'A-', name: 'aMinusCnt', align: 'center' },
        { label: 'BBB', name: 'bbbCnt', align: 'center' },
        { label: 'BB+', name: 'bbPlusCnt', align: 'center' },
        { label: 'BB', name: 'bbCnt', align: 'center' },
        { label: 'BB-', name: 'bbMinusCnt', align: 'center' },
        { label: 'B+', name: 'bPlusCnt', align: 'center' },
        { label: 'B', name: 'bCnt', align: 'center' },
        { label: 'CCC', name: 'cccCnt', align: 'center' },
        { label: 'CC', name: 'ccCnt', align: 'center' },
        { label: 'C', name: 'cCnt', align: 'center' },
        { label: 'D', name: 'dCnt', align: 'center' },
        { label: '未评级', name: 'notRatingCnt', align: 'center' },
      ],
    },
    {
      name: 'ratingUpMigrate',
      label: '向上迁移',
      columns: [
        { label: '客户数', name: 'upCnt', align: 'center' },
        { label: '占比', name: 'upRatio', align: 'center' },
      ],
    },
    {
      name: 'ratingDownMigrate',
      label: '向下迁移',
      columns: [
        { label: '客户数', name: 'downCnt', align: 'center' },
        { label: '占比', name: 'downRatio', align: 'center' },
      ],
    },
    { label: '迁移指数', name: 'chgExponent', align: 'center' },
  ],
};
</script>
