<template>
  <div class="h-full">
    <w-grid
      ref="rptRatingAdjustGridRef"
      title="客户评级特例调整情况报表"
      :data-url="Environment.apiContextPath('api/irbs/rptRatingAdjust/list')"
      :sort-no="true"
      :checkbox-selection="false"
      :query-form-cols-num="4"
      :query-form-fields="rptRatingAdjustGrid.queryFormFields"
      :columns="rptRatingAdjustGrid.columns"
      :toolbar-actions="rptRatingAdjustGrid.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 rptRatingAdjustGridRef = ref();

const rptRatingAdjustGrid = {
  buttons: [
    {
      extend: 'query',
      click: () => {
        const QueryParams = rptRatingAdjustGridRef.value.getQueryForm().getData();
        axios.get(Environment.apiContextPath('api/irbs/rptRatingAdjust/list'), { params: QueryParams }).then((resp) => {
          rptRatingAdjustGridRef.value.setLocalData(resp.data);
        });
      },
    },
    'reset',
    'separator',
    'export',
  ],
  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支行' },
      ],
    },
  ],
  columns: [
    { label: '评级时间', name: 'ratingMonth', align: 'center' },
    { label: '评级客户数', name: 'custCnt', align: 'center' },
    { label: '调整客户数', name: 'adjCnt', align: 'center' },
    { label: '调整客户占比', name: 'adjRatio', align: 'center' },
    {
      label: '调整级别',
      name: 'adjustLevelHeader',
      columns: [
        { label: '1级', name: 'oneLvlRatio' },
        { label: '2级', name: 'twoLvlRatio' },
        { label: '3级', name: 'threeLvlRatio' },
        { label: '3级以上', name: 'threeMoreLvlRatio' },
      ],
    },
  ],
};
</script>
