import type { QualityComponentDefinition } from '../core/types';

import { escapeHtmlMultiline } from '../core/html';
import { QUALITY_ICONS } from '../core/icons';
import { QUALITY_CATEGORY } from '../core/types';

export const reportFooterDefinition: QualityComponentDefinition = {
  type: 'ReportFooter',
  name: 'reportFooter',
  label: '报告页脚',
  category: QUALITY_CATEGORY.HEADER,
  icon: QUALITY_ICONS.footer,
  aiHint:
    '文档最底部的落款块：检验员/审核人/日期签署行、厂址与联系电话。整份报告最多一个，放在最后。' +
    '签署行即使排在检验表格的最后一行，也属于落款而不是检验数据，要取出来放进我这里；' +
    '原件页脚与签署行合成一处。签署行里的人名与日期留空，不要写死某一份报告的值。',
  contentKey: 'text',
  defaults: { text: '检验员：__________　　审核：__________　　日期：__________' },
  propertySchema: [
    {
      key: 'text',
      label: '页脚文字',
      type: 'string',
      defaultValue: '检验员：__________　　审核：__________　　日期：__________',
      bindable: true,
    },
  ],
  dataSchema: [{ key: 'text', label: '页脚文字', type: 'string', bindable: true }],
  buildContent: (properties) => ({
    tagName: 'div',
    content: escapeHtmlMultiline(properties.text),
    style: {
      'font-size': '11px',
      color: '#8c8c8c',
      'text-align': 'center',
      padding: '8px 0',
      'border-top': '1px solid #d9d9d9',
      margin: '12px 0 0',
    },
  }),
};