template.data.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
  2. import { dateFormatter } from '@/utils/formatTime'
  3. import { TableColumn } from '@/types/table'
  4. import * as MailAccountApi from '@/api/system/mail/account'
  5. // 邮箱账号的列表
  6. const accountList = await MailAccountApi.getSimpleMailAccountList()
  7. // 表单校验
  8. export const rules = reactive({
  9. name: [required],
  10. code: [required],
  11. accountId: [required],
  12. label: [required],
  13. content: [required],
  14. params: [required],
  15. status: [required]
  16. })
  17. // CrudSchema:https://doc.iocoder.cn/vue3/crud-schema/
  18. const crudSchemas = reactive<CrudSchema[]>([
  19. {
  20. label: '模板编码',
  21. field: 'code',
  22. isSearch: true,
  23. search: {
  24. componentProps: {
  25. style: {
  26. width: '240px'
  27. }
  28. }
  29. }
  30. },
  31. {
  32. label: '模板名称',
  33. field: 'name',
  34. isSearch: true,
  35. search: {
  36. componentProps: {
  37. style: {
  38. width: '240px'
  39. }
  40. }
  41. }
  42. },
  43. {
  44. label: '模板标题',
  45. field: 'title'
  46. },
  47. {
  48. label: '模板内容',
  49. field: 'content',
  50. form: {
  51. component: 'Editor',
  52. componentProps: {
  53. valueHtml: '',
  54. height: 200
  55. }
  56. }
  57. },
  58. {
  59. label: '邮箱账号',
  60. field: 'accountId',
  61. width: '200px',
  62. formatter: (_: Recordable, __: TableColumn, cellValue: number) => {
  63. return accountList.find((account) => account.id === cellValue)?.mail
  64. },
  65. search: {
  66. show: true,
  67. component: 'Select',
  68. api: () => accountList,
  69. componentProps: {
  70. optionsAlias: {
  71. labelField: 'mail',
  72. valueField: 'id'
  73. },
  74. style: {
  75. width: '240px'
  76. }
  77. }
  78. },
  79. form: {
  80. component: 'Select',
  81. api: () => accountList,
  82. componentProps: {
  83. optionsAlias: {
  84. labelField: 'mail',
  85. valueField: 'id'
  86. }
  87. }
  88. }
  89. },
  90. {
  91. label: '发送人名称',
  92. field: 'nickname'
  93. },
  94. {
  95. label: '开启状态',
  96. field: 'status',
  97. isSearch: true,
  98. dictType: DICT_TYPE.COMMON_STATUS,
  99. dictClass: 'number',
  100. search: {
  101. componentProps: {
  102. style: {
  103. width: '240px'
  104. }
  105. }
  106. }
  107. },
  108. {
  109. label: '备注',
  110. field: 'remark',
  111. isTable: false
  112. },
  113. {
  114. label: '创建时间',
  115. field: 'createTime',
  116. isForm: false,
  117. formatter: dateFormatter,
  118. search: {
  119. show: true,
  120. component: 'DatePicker',
  121. componentProps: {
  122. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  123. type: 'daterange',
  124. defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')],
  125. style: {
  126. width: '240px'
  127. }
  128. }
  129. }
  130. },
  131. {
  132. label: '操作',
  133. field: 'action',
  134. isForm: false
  135. }
  136. ])
  137. export const { allSchemas } = useCrudSchemas(crudSchemas)