cultural.ts 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. import VillageInfoApi, { CommonInfoModel, VillageBulidingInfo } from "@/api/inhert/VillageInfoApi";
  2. import type { GroupForm, SingleForm } from "../forms";
  3. import type { IDynamicFormItemCallback, IDynamicFormItemCallbackAdditionalProps } from "@imengyu/vue-dynamic-form";
  4. import { useAliOssUploadCo } from "@/common/components/upload/AliOssUploadCo";
  5. import { villageCommonContent } from "./common";
  6. import { goFormStatic } from "@/pages/composeable/TaskEntryForm";
  7. import type { SelectIdProps } from "@imengyu/vue-dynamic-form-ant";
  8. import type { DataModel } from "@imengyu/js-request-transform";
  9. import type { ButtonProps } from "ant-design-vue";
  10. import { h } from "vue";
  11. export function villageInfoFolkCultureForm(title: string) : SingleForm {
  12. return [VillageBulidingInfo, (m) => ({
  13. formItems: [
  14. {
  15. label: title + '名称',
  16. name: 'name',
  17. type: 'text',
  18. defaultValue: '',
  19. additionalProps: {
  20. placeholder: '请输入名称',
  21. },
  22. rules: [{
  23. required: true,
  24. message: '请输入名称',
  25. }]
  26. },
  27. {
  28. label: '村落非遗项目',
  29. name: 'ichId',
  30. type: 'select-id',
  31. defaultValue: null,
  32. additionalProps: {
  33. loadData: {
  34. callback: (m, r, p, i) => async () =>
  35. (await VillageInfoApi.getList(
  36. 'ich', undefined, undefined,
  37. i.formGlobalParams.villageId as number,
  38. i.formGlobalParams.villageVolunteerId as number
  39. )).map((p) => ({
  40. value: p.id,
  41. text: p.title,
  42. raw: p,
  43. }))
  44. },
  45. } as IDynamicFormItemCallbackAdditionalProps<SelectIdProps<DataModel>>,
  46. rules: [],
  47. },
  48. ...villageCommonContent(m, {
  49. title: title,
  50. showTitle: false,
  51. contentKey: 'details'
  52. }).formItems
  53. ]
  54. })];
  55. }
  56. export const villageInfoCulture : GroupForm = {
  57. [1]: [CommonInfoModel, (m) => villageCommonContent(m, {
  58. title: '建村历史',
  59. showTitle: true
  60. })],
  61. [2]: [CommonInfoModel, (m) => villageCommonContent(m, {
  62. title: '历史事件',
  63. showTitle: true
  64. })],
  65. [3]: [CommonInfoModel, (m) => ({
  66. formItems: [
  67. ...(villageCommonContent(m, {
  68. title: '历史文献',
  69. showTitle: true
  70. }).formItems.slice(0, 1)),
  71. {
  72. label: '扫描件或图片',
  73. name: 'images',
  74. type: 'uploader',
  75. defaultValue: '',
  76. additionalProps: {
  77. upload: useAliOssUploadCo('xiangyuan/cultural/scan'),
  78. maxFileSize: 1024 * 1024 * 20,
  79. maxUploadCount: 20,
  80. },
  81. rules: [{
  82. required: true,
  83. message: '请上传扫描件或图片',
  84. }]
  85. },
  86. ],
  87. })],
  88. [4]: [CommonInfoModel, (m) => ({
  89. formItems: [
  90. ...villageCommonContent(m, {
  91. title: '口述历史',
  92. showTitle: true
  93. }).formItems.slice(0, 1),
  94. {
  95. label: '口述人',
  96. name: 'speakerId',
  97. type: 'select-id',
  98. additionalProps: {
  99. loadData: {
  100. callback(_, m, p, i) {
  101. return async () => (await VillageInfoApi.getList('speaker', undefined, undefined,
  102. i.formGlobalParams.villageId as number,
  103. i.formGlobalParams.villageVolunteerId as number
  104. ))
  105. .map((p) => ({
  106. value: p.id,
  107. text: p.name,
  108. raw: p,
  109. }))
  110. }
  111. }
  112. } as IDynamicFormItemCallbackAdditionalProps<SelectIdProps<DataModel>>,
  113. rules: [{
  114. required: true,
  115. message: '请选择口述人',
  116. }],
  117. },
  118. {
  119. label: '口述人管理',
  120. type: 'button',
  121. name: 'manage',
  122. defaultValue: '',
  123. additionalSlot: {
  124. default: () => h('span', {}, '口述人管理'),
  125. },
  126. additionalProps: {
  127. onClick: { callback(v, m, p, i) {
  128. return () => {
  129. goFormStatic(
  130. i.formGlobalParams.villageId as number,
  131. i.formGlobalParams.villageVolunteerId as number,
  132. 'speaker',
  133. 1,
  134. undefined,
  135. undefined,
  136. '口述人管理'
  137. );
  138. }
  139. } } as IDynamicFormItemCallback<() => void>,
  140. } as IDynamicFormItemCallbackAdditionalProps<ButtonProps>,
  141. formProps: {
  142. inputAlign: 'right'
  143. },
  144. },
  145. {
  146. label: '口述历史视频/录音',
  147. name: 'video',
  148. type: 'uploader',
  149. defaultValue: '',
  150. additionalProps: {
  151. upload: useAliOssUploadCo('xiangyuan/cultural/video'),
  152. chooseType: 'video',
  153. maxFileSize: 1024 * 1024 * 20,
  154. single: true,
  155. },
  156. formProps: {
  157. extra: '您可以上传已经录制好的口述历史视频/录音来更生动地介绍历史。',
  158. },
  159. },
  160. /* {
  161. label: '',
  162. name: 'video1',
  163. type: 'recorder',
  164. defaultValue: '',
  165. additionalProps: {
  166. onRecordDone: (path: string) => {
  167. (m.value.getFormItemControlRef<UploaderFieldInstance>('video')?.getUploaderRef() as UploaderInstance).addItemAndUpload({
  168. filePath: path,
  169. state: 'notstart',
  170. });
  171. }
  172. },
  173. }, */
  174. ],
  175. })],
  176. }