common.ts 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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,
  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 * 100,
  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: '',
  138. name: 'extra',
  139. type: 'static-text',
  140. defaultValue: '',
  141. additionalProps: {
  142. text: '额外信息用于采集系统内部处理,可以不填写',
  143. },
  144. },
  145. {
  146. label: `${options.title}数字档案(可选)`,
  147. name: 'archives',
  148. type: 'uploader',
  149. defaultValue: '',
  150. additionalProps: {
  151. upload: useAliOssUploadCo('xiangyuan/archives'),
  152. maxFileSize: 1024 * 1024 * 20,
  153. chooseType: '',
  154. single: true,
  155. } as UploaderFieldProps,
  156. rules: [],
  157. formProps: {
  158. extraMessage: '建议上传项目相关文件,如项目合同、项目计划等',
  159. },
  160. },
  161. {
  162. label: `${options.title}其他附件(可选)`,
  163. name: 'annex',
  164. type: 'uploader',
  165. defaultValue: '',
  166. additionalProps: {
  167. upload: useAliOssUploadCo('xiangyuan/annex'),
  168. maxFileSize: 1024 * 1024 * 20,
  169. maxUploadCount: 20,
  170. chooseType: '',
  171. } as UploaderFieldProps,
  172. rules: [],
  173. formProps: {
  174. extraMessage: '建议上传项目相关文件,如项目合同、项目计划等',
  175. },
  176. },
  177. {
  178. label: `关键字`,
  179. name: 'keywords',
  180. type: 'text-tag',
  181. defaultValue: '',
  182. rules: [],
  183. additionalProps: {
  184. placeholder: '可以输入关键字',
  185. tagJoinType: ';',
  186. },
  187. formProps: {
  188. extraMessage: '用于系统优化关键字搜索',
  189. },
  190. },
  191. ],
  192. }
  193. ],
  194. }
  195. }