<template>
  <w-grid
    ref="announcementGridRef"
    :title="$t('system.announcementManager.grid.title')"
    :config-button="true"
    selection="multiple"
    :checkbox-selection="true"
    :data-url="Environment.apiContextPath('/api/system/announcement')"
    :sort-by="['-lastModifyDate']"
    :query-form-cols-num="2"
    :query-form-fields="[{ name: 'title', label: $t('title'), type: 'text' }]"
    :toolbar-configure="{ noIcon: false }"
    :toolbar-actions="['query', 'refresh', 'separator', 'add', 'clone', 'edit', 'remove', 'separator', 'view', 'separator', 'export']"
    :columns="[
      { width: 300, name: 'title', label: $t('title') },
      { width: '100%', name: 'content', label: $t('content'), sortable: false },
      { width: 120, name: 'lastModifier', label: $t('lastModifier') },
      { width: 120, name: 'lastModifyDate', label: $t('lastModifyDate'), format: Formater.dateOnly() },
    ]"
    :editor="{
      dialog: {
        width: '600px',
        height: '380px',
      },
      form: {
        colsNum: 1,
        fields: [
          { name: 'title', label: $t('title'), type: 'text', required: true },
          { name: 'content', label: $t('content'), type: 'q-editor', required: true, minHeight: '10rem', defaultValue: '' },
        ],
      },
    }"
    :viewer="{
      panel: {
        columnNum: 1,
        fields: [
          { name: 'id', label: $t('id') },
          { name: 'title', label: $t('title') },
          { name: 'content', label: $t('content') },
          { 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() },
          { name: 'corporationCode', label: $t('corporationCode') },
        ],
      },
    }"
  ></w-grid>
</template>
<script setup lang="ts">
import { Environment, Formater } from 'platform-core';
</script>
