cultural.ts 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. import VillageInfoApi, { CommonInfoModel, VillageBulidingInfo } from "@/api/inhert/VillageInfoApi";
  2. import type { GroupForm, SingleForm } from "../forms";
  3. import type { IDynamicFormItemCallback, IDynamicFormItemCallbackAdditionalProps } from "@/components/dynamic";
  4. import type { PickerIdFieldProps } from "@/components/dynamic/wrappers/PickerIdField";
  5. import type { FieldProps } from "@/components/form/Field.vue";
  6. import type { UploaderInstance } from "@/components/form/Uploader.vue";
  7. import type { UploaderFieldProps, UploaderFieldInstance } from "@/components/form/UploaderField.vue";
  8. import { useAliOssUploadCo } from "@/common/components/upload/AliOssUploadCo";
  9. import { villageCommonContent } from "./common";
  10. import { goFormStatic } from "../composeable/TaskEntryForm";
  11. import type { ButtonProp } from "@/components/basic/Button.vue";
  12. import { useCollectStore } from "@/store/collect";
  13. export function villageInfoFolkCultureForm(title: string) : SingleForm {
  14. return [VillageBulidingInfo, (m) => ({
  15. formItems: [
  16. {
  17. label: title + '名称',
  18. name: 'name',
  19. type: 'text',
  20. defaultValue: '',
  21. additionalProps: {
  22. placeholder: '请输入名称',
  23. },
  24. rules: [{
  25. required: true,
  26. message: '请输入名称',
  27. }]
  28. },
  29. {
  30. label: '村落非遗项目',
  31. name: 'ichId',
  32. type: 'select-id',
  33. defaultValue: null,
  34. additionalProps: {
  35. loadData: {
  36. callback: (m, r, p, i) => async () => {
  37. const collectStore = useCollectStore();
  38. return (await VillageInfoApi.getList(
  39. collectStore.getCollectModuleId('ich'),
  40. 'ich', undefined, undefined,
  41. i.formGlobalParams.villageId,
  42. i.formGlobalParams.villageVolunteerId
  43. )).map((p) => ({
  44. value: p.id,
  45. text: p.title,
  46. }))
  47. }
  48. },
  49. } as IDynamicFormItemCallbackAdditionalProps<PickerIdFieldProps>,
  50. formProps: { showRightArrow: true } as FieldProps,
  51. rules: [],
  52. },
  53. ...villageCommonContent(m, {
  54. title: title,
  55. showTitle: false,
  56. contentKey: 'details'
  57. }).formItems
  58. ]
  59. })];
  60. }
  61. export const villageInfoCulture : GroupForm = {
  62. [1]: [CommonInfoModel, (m) => villageCommonContent(m, {
  63. title: '建村历史',
  64. showTitle: true
  65. })],
  66. [2]: [CommonInfoModel, (m) => villageCommonContent(m, {
  67. title: '历史事件',
  68. showTitle: true
  69. })],
  70. [3]: [CommonInfoModel, (m) => ({
  71. formItems: [
  72. ...(villageCommonContent(m, {
  73. title: '历史文献',
  74. showTitle: true
  75. }).formItems.slice(0, 1)),
  76. {
  77. label: '扫描件或图片',
  78. name: 'images',
  79. type: 'uploader',
  80. defaultValue: '',
  81. additionalProps: {
  82. upload: useAliOssUploadCo('xiangyuan/cultural/scan'),
  83. maxFileSize: 1024 * 1024 * 20,
  84. maxUploadCount: 20,
  85. } as UploaderFieldProps,
  86. rules: [{
  87. required: true,
  88. message: '请上传扫描件或图片',
  89. }]
  90. },
  91. ],
  92. })],
  93. [4]: [CommonInfoModel, (m) => ({
  94. formItems: [
  95. ...villageCommonContent(m, {
  96. title: '口述历史',
  97. showTitle: true
  98. }).formItems.slice(0, 1),
  99. {
  100. label: '口述人',
  101. name: 'speakerId',
  102. type: 'select-id',
  103. additionalProps: {
  104. loadData: {
  105. callback(_, m, p, i) {
  106. const collectStore = useCollectStore();
  107. return async () => (await VillageInfoApi.getList(
  108. collectStore.getCollectModuleId('speaker'),
  109. 'speaker', undefined, undefined,
  110. i.formGlobalParams.villageId,
  111. i.formGlobalParams.villageVolunteerId
  112. ))
  113. .map((p) => ({
  114. value: p.id,
  115. text: p.name,
  116. }))
  117. }
  118. },
  119. } as IDynamicFormItemCallbackAdditionalProps<PickerIdFieldProps>,
  120. formProps: { showRightArrow: true } as FieldProps,
  121. rules: [{
  122. required: true,
  123. message: '请选择口述人',
  124. }],
  125. },
  126. {
  127. label: '口述人管理',
  128. type: 'button',
  129. name: 'manage',
  130. defaultValue: '',
  131. additionalProps: {
  132. text: '口述人管理',
  133. onClick: { callback(v, m, p, i) {
  134. return () => {
  135. const collectStore = useCollectStore();
  136. if (!collectStore.getCollectModuleId('speaker')) {
  137. uni.showToast({
  138. title: '您暂无权限采编口述人,请联系管理员。',
  139. icon: 'none',
  140. duration: 3000
  141. });
  142. return;
  143. }
  144. goFormStatic(
  145. i.formGlobalParams.villageId,
  146. i.formGlobalParams.villageVolunteerId,
  147. 'speaker',
  148. 1,
  149. undefined,
  150. undefined,
  151. '口述人管理'
  152. );
  153. }
  154. } } as IDynamicFormItemCallback<() => void>,
  155. } as IDynamicFormItemCallbackAdditionalProps<ButtonProp>,
  156. formProps: {
  157. inputAlign: 'right'
  158. } as FieldProps,
  159. },
  160. {
  161. label: '口述历史视频/录音',
  162. name: 'video',
  163. type: 'uploader',
  164. defaultValue: '',
  165. additionalProps: {
  166. upload: useAliOssUploadCo('xiangyuan/cultural/video'),
  167. chooseType: 'video',
  168. maxFileSize: 1024 * 1024 * 20,
  169. single: true,
  170. } as UploaderFieldProps,
  171. formProps: {
  172. extraMessage: '您可以上传已经录制好的口述历史视频/录音,也可以点击下方按钮录制新的音频。但小程序中录音时长最长10分钟,如需更长时间,请使用系统相机拍摄。',
  173. } as FieldProps,
  174. },
  175. {
  176. label: '',
  177. name: 'video1',
  178. type: 'recorder',
  179. defaultValue: '',
  180. additionalProps: {
  181. onRecordDone: (path: string) => {
  182. (m.value.getFormItemControlRef<UploaderFieldInstance>('video')?.getUploaderRef() as UploaderInstance).addItemAndUpload({
  183. filePath: path,
  184. state: 'notstart',
  185. });
  186. }
  187. },
  188. },
  189. ],
  190. })],
  191. }