<template>
  <w-grid
    ref="announcementGridRef"
    :title="$t('system.announcementManager.grid.title')"
    selection="multiple"
    :data-url="Environment.apiContextPath('/api/system/announcement')"
    :pagination="{
      sortBy: 'lastModifyDate',
      descending: true,
    }"
    :query-form-fields="[
      { name: 'title', label: $t('title'), type: 'text' },
      { name: 'dataComeFrom', label: $t('dataComeFrom'), type: 'select', options: Options.enum(DataComeFromEnum), queryOperator: 'equals' },
    ]"
    :toolbar-configure="{ noIcon: false }"
    :toolbar-actions="['query', 'refresh', 'separator', 'add', 'clone', 'edit', 'remove', 'separator', 'view', 'export']"
    :columns="[
      { width: 300, name: 'title', label: $t('title') },
      { width: '100%', name: 'content', label: $t('content') },
      { name: 'dataComeFrom', label: $t('dataComeFrom'), format: Formater.enum(DataComeFromEnum) },
      { name: 'lastModifier', label: $t('lastModifier') },
      { 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' },
        ],
      },
    }"
    :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'), format: Formater.enum(DataComeFromEnum) },
          { name: 'creator', label: $t('creator') },
          { name: 'createDate', label: $t('createDate') },
          { name: 'lastModifier', label: $t('lastModifier') },
          { name: 'lastModifyDate', label: $t('lastModifyDate') },
          { name: 'corporationCode', label: $t('corporationCode') },
        ],
      },
    }"
  ></w-grid>
</template>
<script setup lang="ts">
import { Environment, EnumTools, Options, Formater } from 'platform-core';

const DataComeFromEnum = await EnumTools.fetch('io.sc.platform.orm.api.enums.DataComeFrom');
</script>
