common.ts 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. import { useAliOssUploadCo } from "@/common/components/upload/AliOssUploadCo";
  2. import type { IDynamicFormOptions, IDynamicFormRef } from "@/components/dynamic";
  3. import type { PickerIdFieldProps } from "@/components/dynamic/wrappers/PickerIdField";
  4. import type { FieldProps } from "@/components/form/Field.vue";
  5. import type { UploaderFieldProps } from "@/components/form/UploaderField.vue";
  6. import type { Ref } from "vue";
  7. export function villageCommonContent (ref: Ref<IDynamicFormRef>, options: {
  8. title: string,
  9. showTitle?: boolean,
  10. showContent?: boolean,
  11. noType?: boolean,
  12. noCloseExtra?: boolean,
  13. contentKey?: string,
  14. } = {
  15. title: '文章',
  16. showTitle: true,
  17. }) : IDynamicFormOptions {
  18. options.title = '';
  19. return {
  20. formItems: [
  21. {
  22. name: 'a',
  23. type: 'flat-group',
  24. childrenColProps: { span: 24 },
  25. children: [
  26. ...(options.showTitle ? [{
  27. label: `${options.title}标题`,
  28. name: 'name',
  29. type: 'text',
  30. defaultValue: '',
  31. additionalProps: {
  32. placeholder: `请输入${options.title}标题`,
  33. },
  34. rules: [{
  35. required: true,
  36. message: `请输入${options.title}标题`,
  37. }]
  38. }]: []),
  39. ...(options.showContent !== false ? [{
  40. label: `${options.title}内容`,
  41. name: options.contentKey || 'content',
  42. type: 'richtext',
  43. defaultValue: '',
  44. additionalProps: {
  45. placeholder: '请输入介绍内容正文',
  46. maxLength: 1000,
  47. },
  48. rules: [{
  49. required: true,
  50. message: '请输入介绍内容',
  51. }]
  52. },
  53. ...(options.noType !== true ? [{
  54. label: `${options.title}类型`,
  55. name: 'type',
  56. type: 'select-id',
  57. defaultValue: 1,
  58. additionalProps: {
  59. loadData: async () => [
  60. { text: '文章', value: 1 },
  61. { text: '图片', value: 2 },
  62. { text: '视频', value: 3 },
  63. { text: '相册', value: 4 },
  64. { text: '数字档案', value: 5 },
  65. ],
  66. } as PickerIdFieldProps,
  67. formProps: { showRightArrow: true },
  68. rules: [{
  69. required: true,
  70. message: '请选择类型',
  71. }]
  72. },
  73. {
  74. label: '来源(可选)',
  75. name: 'source',
  76. type: 'text',
  77. defaultValue: '',
  78. additionalProps: {
  79. placeholder: '如果是转载文章可以输入来源',
  80. },
  81. }] : []),
  82. ]: []),
  83. ],
  84. },
  85. {
  86. name: 'b',
  87. type: 'flat-group',
  88. childrenColProps: { span: 24 },
  89. children: [
  90. {
  91. label: `${options.title}相关图片(可选)`,
  92. name: 'images',
  93. type: 'uploader',
  94. defaultValue: '',
  95. additionalProps: {
  96. upload: useAliOssUploadCo('xiangyuan/common'),
  97. maxFileSize: 1024 * 1024 * 20, // 20MB
  98. maxUploadCount: 20,
  99. } as UploaderFieldProps,
  100. rules: [],
  101. formProps: {
  102. extraMessage: '建议分辨率:1920*1080以上',
  103. },
  104. },
  105. {
  106. label: `${options.title}介绍视频(可选)`,
  107. name: 'video',
  108. type: 'uploader',
  109. defaultValue: '',
  110. additionalProps: {
  111. upload: useAliOssUploadCo('xiangyuan/video'),
  112. maxFileSize: 1024 * 1024 * 1000, // 1000MB
  113. single: true,
  114. chooseType: 'video',
  115. } as UploaderFieldProps,
  116. formProps: {
  117. extraMessage: '您还可以上传介绍视频,建议使用MP4格式1080P分辨率',
  118. },
  119. rules: []
  120. },
  121. ],
  122. },
  123. {
  124. name: 'c',
  125. type: 'flat-group',
  126. label: '其他附件(可选)',
  127. formProps: {
  128. showLabel: false,
  129. },
  130. additionalProps: {
  131. collapsible: options.noCloseExtra !== true,
  132. collapsed: options.noCloseExtra !== true,
  133. },
  134. childrenColProps: { span: 24 },
  135. children: [
  136. {
  137. label: `${options.title}数字档案(可选)`,
  138. name: 'archives',
  139. type: 'uploader',
  140. defaultValue: '',
  141. additionalProps: {
  142. upload: useAliOssUploadCo('xiangyuan/archives'),
  143. maxFileSize: 1024 * 1024 * 200, // 200MB
  144. chooseType: '',
  145. single: true,
  146. } as UploaderFieldProps,
  147. rules: [],
  148. formProps: {
  149. extraMessage: '建议上传项目相关文件,如项目合同、项目计划等',
  150. },
  151. },
  152. {
  153. label: `${options.title}其他附件(可选)`,
  154. name: 'annex',
  155. type: 'uploader',
  156. defaultValue: '',
  157. additionalProps: {
  158. upload: useAliOssUploadCo('xiangyuan/annex'),
  159. maxFileSize: 1024 * 1024 * 1000, // 1000MB
  160. maxUploadCount: 20,
  161. chooseType: '',
  162. } as UploaderFieldProps,
  163. rules: [],
  164. formProps: {
  165. extraMessage: '建议上传项目相关文件,如项目合同、项目计划等',
  166. },
  167. },
  168. {
  169. label: `关键字`,
  170. name: 'keywords',
  171. type: 'text-tag',
  172. defaultValue: '',
  173. rules: [],
  174. additionalProps: {
  175. placeholder: '可以输入关键字',
  176. tagJoinType: ';',
  177. },
  178. formProps: {
  179. extraMessage: '用于采集系统内部处理优化关键字搜索,可以不填写',
  180. },
  181. },
  182. ],
  183. }
  184. ],
  185. }
  186. }