<template>
  <w-grid
    :title="$t('menu.engine.mv.result')"
    :config-button="true"
    selection="multiple"
    :checkbox-selection="true"
    :data-url="Environment.apiContextPath('/api/mv/result')"
    :pageable="false"
    :toolbar-configure="{ noIcon: false }"
    :toolbar-actions="['refresh', 'separator', 'add', 'edit', 'remove', 'separator', 'view', 'separator', 'export']"
    :columns="[
      { width: 150, name: 'validateDate', label: $t('io.sc.engine.mv.result.grid.entity.validateDate') },
      {
        width: 200,
        name: 'runtimeParameters',
        label: $t('io.sc.engine.mv.result.grid.entity.runtimeParameters'),
        format: (value) => {
          let result = '';
          for (const item of value) {
            result +=
              $t('io.sc.engine.mv.result.grid.entity.runtimeParameters.' + item.name) + ':' + (Tools.isUndefinedOrNull(item.value) ? '' : item.value) + '<br/>';
          }
          return result;
        },
      },
      { width: 100, name: 'modelId', label: $t('io.sc.engine.mv.result.grid.entity.modelId') },
      { width: 120, name: 'modelName', label: $t('io.sc.engine.mv.result.grid.entity.modelName') },
      { width: 100, name: 'executeMode', label: $t('io.sc.engine.mv.result.grid.entity.executeMode') },
      { width: 100, name: 'totalSampleCount', label: $t('io.sc.engine.mv.result.grid.entity.totalSampleCount'), align: 'right' },
      { width: 100, name: 'defaultSampleCount', label: $t('io.sc.engine.mv.result.grid.entity.defaultSampleCount'), align: 'right' },
      {
        width: 900,
        name: 'discrimination',
        label: $t('io.sc.engine.mv.result.grid.entity.discrimination'),
        columns: [
          {
            name: 'total',
            label: $t('io.sc.engine.mv.result.grid.entity.total'),
            columns: [
              { width: 100, name: 'auc', label: $t('io.sc.engine.mv.result.grid.entity.auc') },
              { width: 100, name: 'ar', label: $t('io.sc.engine.mv.result.grid.entity.ar') },
              { width: 100, name: 'ks', label: $t('io.sc.engine.mv.result.grid.entity.ks') },
            ],
          },
          {
            name: 'quantitative',
            label: $t('quantitative'),
            columns: [
              { width: 100, name: 'aucQuantitative', label: $t('io.sc.engine.mv.result.grid.entity.auc') },
              { width: 100, name: 'arQuantitative', label: $t('io.sc.engine.mv.result.grid.entity.ar') },
              { width: 100, name: 'ksQuantitative', label: $t('io.sc.engine.mv.result.grid.entity.ks') },
            ],
          },
          {
            name: 'qualitative',
            label: $t('qualitative'),
            columns: [
              { width: 100, name: 'aucQualitative', label: $t('io.sc.engine.mv.result.grid.entity.auc') },
              { width: 100, name: 'arQualitative', label: $t('io.sc.engine.mv.result.grid.entity.ar') },
              { width: 100, name: 'ksQualitative', label: $t('io.sc.engine.mv.result.grid.entity.ks') },
            ],
          },
        ],
      },
      {
        width: 200,
        name: 'stability',
        label: $t('io.sc.engine.mv.result.grid.entity.stability'),
        columns: [
          { width: 100, name: 'svd', label: $t('io.sc.engine.mv.result.grid.entity.svd') },
          { width: 100, name: 'psi', label: $t('io.sc.engine.mv.result.grid.entity.psi') },
        ],
      },
      {
        width: 200,
        name: 'scaleValidate',
        label: $t('io.sc.engine.mv.result.grid.entity.scaleValidate'),
        columns: [
          { width: 100, name: 'chiSquare', label: $t('io.sc.engine.mv.result.grid.entity.chiSquare') },
          { width: 100, name: 'binomial', label: $t('io.sc.engine.mv.result.grid.entity.binomial') },
        ],
      },
    ]"
    :editor="{
      dialog: {
        width: '600px',
        height: '300px',
      },
      form: {
        colsNum: 1,
        fields: [
          { name: 'significanceLevel', label: $t('significanceLevel'), type: 'text' },
          { name: 'confidenceLevel', label: $t('confidenceLevel'), type: 'text' },
          { name: 'zUpper', label: $t('zUpper'), type: 'text' },
          { name: 'zLower', label: $t('zLower'), type: 'text' },
        ],
      },
    }"
    :viewer="{
      panel: {
        columnNum: 1,
        fields: [
          { name: 'id', label: $t('id') },
          { name: 'significanceLevel', label: $t('significanceLevel') },
          { name: 'confidenceLevel', label: $t('confidenceLevel') },
          { name: 'zUpper', label: $t('zUpper') },
          { name: 'zLower', label: $t('zLower') },
          { name: 'creator', label: $t('creator') },
          { name: 'createDate', label: $t('createDate') },
          { name: 'lastModifier', label: $t('lastModifier') },
          { name: 'lastModifyDate', label: $t('lastModifyDate') },
        ],
      },
    }"
  ></w-grid>
</template>
<script setup lang="ts">
import { Environment, Tools, Formater } from 'platform-core';
</script>
