<template>
  <w-grid
    :title="$t('io.sc.engine.mv.config.threshold.grid.title')"
    :config-button="true"
    selection="multiple"
    :checkbox-selection="true"
    :data-url="Environment.apiContextPath('/api/mv/configure/threshold')"
    :pageable="false"
    :toolbar-configure="{ noIcon: false }"
    :toolbar-actions="['refresh', 'separator', 'add', 'edit', 'remove', 'separator', 'resetDefaultValues', 'separator', 'view', 'separator', 'export']"
    :columns="[
      { width: '100%', name: 'name', label: $t('io.sc.engine.mv.config.threshold.grid.entity.name') },
      { width: 120, name: 'level', label: $t('io.sc.engine.mv.config.threshold.grid.entity.level'), align: 'right' },
      {
        width: 100,
        name: 'color',
        label: $t('io.sc.engine.mv.config.threshold.grid.entity.color'),
        format: (value) => {
          return '<div style=\'color:' + value + '\'>' + value + '<div>';
        },
      },
      { width: 120, name: 'range', label: $t('io.sc.engine.mv.config.threshold.grid.entity.range') },
      { width: 150, name: 'quantitativeRange', label: $t('io.sc.engine.mv.config.threshold.grid.entity.quantitativeRange') },
      { width: 150, name: 'qualitativeRange', label: $t('io.sc.engine.mv.config.threshold.grid.entity.qualitativeRange') },
      { width: 100, name: 'lastModifier', label: $t('lastModifier') },
      { width: 150, name: 'lastModifyDate', label: $t('lastModifyDate'), format: Formater.dateOnly() },
    ]"
    :editor="{
      dialog: {
        width: '600px',
        height: '400px',
      },
      form: {
        colsNum: 1,
        fields: [
          { name: 'name', label: $t('io.sc.engine.mv.config.threshold.grid.entity.name'), type: 'text' },
          { name: 'level', label: $t('io.sc.engine.mv.config.threshold.grid.entity.level'), type: 'text' },
          { name: 'color', label: $t('io.sc.engine.mv.config.threshold.grid.entity.color'), type: 'text' },
          { name: 'range', label: $t('io.sc.engine.mv.config.threshold.grid.entity.range'), type: 'text' },
          { name: 'quantitativeRange', label: $t('io.sc.engine.mv.config.threshold.grid.entity.quantitativeRange'), type: 'text' },
          { name: 'qualitativeRange', label: $t('io.sc.engine.mv.config.threshold.grid.entity.qualitativeRange'), type: 'text' },
        ],
      },
    }"
    :viewer="{
      panel: {
        columnNum: 1,
        fields: [
          { name: 'id', label: $t('id') },
          { name: 'name', label: $t('io.sc.engine.mv.config.threshold.grid.entity.name') },
          { name: 'level', label: $t('io.sc.engine.mv.config.threshold.grid.entity.level') },
          { name: 'color', label: $t('io.sc.engine.mv.config.threshold.grid.entity.color'), format: Formater.none() },
          { name: 'range', label: $t('io.sc.engine.mv.config.threshold.grid.entity.range') },
          { name: 'quantitativeRange', label: $t('io.sc.engine.mv.config.threshold.grid.entity.quantitativeRange') },
          { name: 'qualitativeRange', label: $t('io.sc.engine.mv.config.threshold.grid.entity.qualitativeRange') },
          { name: 'creator', label: $t('creator') },
          { name: 'createDate', label: $t('createDate') },
          { name: 'lastModifier', label: $t('lastModifier') },
          { name: 'lastModifyDate', label: $t('lastModifyDate'), format: Formater.none() },
        ],
      },
    }"
  ></w-grid>
</template>
<script setup lang="ts">
import { Environment, Formater } from 'platform-core';
</script>
