cultural.ts 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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. }), { title: title, typeName: 'folkCultureType', }];
  60. }
  61. export const villageInfoCulture : GroupForm = {
  62. [1]: [CommonInfoModel, (m) => villageCommonContent(m, {
  63. title: '建村(社)历史',
  64. showTitle: true
  65. }), { title: '建村(社)历史', typeName: 'culturalType', }],
  66. [2]: [CommonInfoModel, (m) => villageCommonContent(m, {
  67. title: '历史事件',
  68. showTitle: true
  69. }), { title: '历史事件', typeName: 'culturalType', }],
  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. }), { title: '历史文献', typeName: 'culturalType', }],
  93. [4]: [CommonInfoModel, (m) => {
  94. const common = villageCommonContent(m, {
  95. title: '口述历史',
  96. showTitle: true,
  97. noCloseExtra: true,
  98. }).formItems;
  99. common.splice(1, 1);
  100. return {
  101. formItems: [
  102. ...common,
  103. {
  104. label: '口述人',
  105. name: 'speakerId',
  106. type: 'select-id',
  107. additionalProps: {
  108. loadData: {
  109. callback(_, m, p, i) {
  110. const collectStore = useCollectStore();
  111. return async () => (await VillageInfoApi.getList(
  112. collectStore.getCollectModuleId('speaker'),
  113. 'speaker', undefined, undefined,
  114. i.formGlobalParams.villageId,
  115. i.formGlobalParams.villageVolunteerId
  116. ))
  117. .map((p) => ({
  118. value: p.id,
  119. text: p.name,
  120. }))
  121. }
  122. },
  123. } as IDynamicFormItemCallbackAdditionalProps<PickerIdFieldProps>,
  124. formProps: { showRightArrow: true } as FieldProps,
  125. rules: [{
  126. required: true,
  127. message: '请选择口述人',
  128. }],
  129. },
  130. {
  131. label: '口述人管理',
  132. type: 'button',
  133. name: 'manage',
  134. defaultValue: '',
  135. additionalProps: {
  136. text: '口述人管理',
  137. onClick: { callback(v, m, p, i) {
  138. return () => {
  139. const collectStore = useCollectStore();
  140. if (!collectStore.getCollectModuleId('speaker')) {
  141. uni.showToast({
  142. title: '您暂无权限采编口述人,请联系管理员。',
  143. icon: 'none',
  144. duration: 3000
  145. });
  146. return;
  147. }
  148. goFormStatic(
  149. i.formGlobalParams.villageId,
  150. i.formGlobalParams.villageVolunteerId,
  151. 'speaker',
  152. 1,
  153. undefined,
  154. undefined,
  155. '口述人管理'
  156. );
  157. }
  158. } } as IDynamicFormItemCallback<() => void>,
  159. } as IDynamicFormItemCallbackAdditionalProps<ButtonProp>,
  160. formProps: {
  161. inputAlign: 'right'
  162. } as FieldProps,
  163. },
  164. {
  165. label: '口述历史视频/录音',
  166. name: 'video',
  167. type: 'uploader',
  168. defaultValue: '',
  169. additionalProps: {
  170. upload: useAliOssUploadCo('xiangyuan/cultural/video'),
  171. chooseType: '',
  172. maxFileSize: 1024 * 1024 * 1000, // 1000MB
  173. single: true,
  174. } as UploaderFieldProps,
  175. formProps: {
  176. extraMessage: '您可以上传已经录制好的口述历史视频/录音,也可以点击下方按钮录制新的音频。但小程序中录音时长最长10分钟,如需更长时间,请使用系统相机或者录音机拍摄。',
  177. } as FieldProps,
  178. },
  179. {
  180. label: '',
  181. name: 'video1',
  182. type: 'recorder',
  183. defaultValue: '',
  184. additionalProps: {
  185. onRecordDone: (path: string) => {
  186. if (m.value.getValueByPath('video')) {
  187. (m.value.getFormItemControlRef<UploaderFieldInstance>('annex')?.getUploaderRef() as UploaderInstance).addItemAndUpload({
  188. filePath: path,
  189. state: 'notstart',
  190. });
  191. } else {
  192. (m.value.getFormItemControlRef<UploaderFieldInstance>('video')?.getUploaderRef() as UploaderInstance).addItemAndUpload({
  193. filePath: path,
  194. state: 'notstart',
  195. });
  196. }
  197. }
  198. },
  199. },
  200. ],
  201. }
  202. }, { title: '口述历史', typeName: 'culturalType', }],
  203. }