<template>
  <w-grid
    ref="treeGridRef"
    :title="$t('standard.bussinessProduct.grid.title')"
    hide-bottom
    :config-button="true"
    selection="multiple"
    :checkbox-selection="true"
    dense
    :tree="false"
    :tree-icon="
      (row) => {
        return { name: 'folder', color: 'amber' };
      }
    "
    primary-key="code"
    :data-url="Environment.apiContextPath('/api/standard/bussinessProduct')"
    :pageable="true"
    :sort-by="['code']"
    :toolbar-configure="{ noIcon: false }"
    :toolbar-actions="[
      'refresh',
      'separator',
      [
        {
          extend: 'add',
          click: undefined,
        },
        {
          extend: 'addTop',
          label: $t('standard.bussinessProduct.grid.toolbar.addTop'),
        },
        {
          extend: 'addChild',
          label: $t('standard.bussinessProduct.grid.toolbar.addChild'),
        },
      ],
      'edit',
      'remove',
      'separator',
      'view',
      'separator',
      'export',
    ]"
    :columns="[
      {
        name: 'target',
        label: $t('standard.entity.target'),
        columns: [
          { width: 100, name: 'code', label: $t('code') },
          { width: 250, name: 'name', label: $t('name') },
        ],
      },
      {
        name: 'source',
        label: $t('standard.entity.source'),
        columns: [
          { width: 100, name: 'mappingCode', label: $t('code') },
          { width: 250, name: 'mappingName', label: $t('name') },
        ],
      },
    ]"
    :editor="{
      dialog: {
        width: '600px',
      },
      form: {
        colsNum: 1,
        fields: [
          { name: 'code', label: $t('standard.entity.code'), type: 'w-text', requiredIf: true },
          { name: 'name', label: $t('standard.entity.name'), type: 'w-text', requiredIf: true },
          { name: 'description', label: $t('standard.entity.description'), type: 'w-textarea', rows: 3 },
          { name: 'mappingCode', label: $t('standard.entity.mappingCode'), type: 'w-text', requiredIf: true },
          { name: 'mappingName', label: $t('standard.entity.mappingName'), type: 'w-text' },
          { name: 'mappingDescription', label: $t('standard.entity.mappingDescription'), type: 'w-textarea', rows: 3 },
        ],
      },
    }"
    :viewer="{
      panel: {
        columnNum: 1,
        fields: [
          { name: 'code', label: $t('standard.entity.code') },
          { name: 'name', label: $t('standard.entity.name') },
          { name: 'description', label: $t('standard.entity.description') },
          { name: 'mappingCode', label: $t('standard.entity.mappingCode') },
          { name: 'mappingName', label: $t('standard.entity.mappingName') },
          { name: 'mappingDescription', label: $t('standard.entity.mappingDescription') },

          { name: 'dataComeFrom', label: $t('dataComeFrom') },
          { 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 'tailwindcss/utilities.css';
import { Environment, Formater } from 'platform-core';
</script>
