import VillageInfoApi, { CommonInfoModel, VillageBulidingInfo } from "@/api/inhert/VillageInfoApi"; import type { GroupForm, SingleForm } from "../forms"; import type { IDynamicFormItemCallback, IDynamicFormItemCallbackAdditionalProps } from "@imengyu/vue-dynamic-form"; import { useAliOssUploadCo } from "@/common/components/upload/AliOssUploadCo"; import { villageCommonContent } from "./common"; import { goFormStatic } from "@/pages/composeable/TaskEntryForm"; import type { SelectIdProps } from "@imengyu/vue-dynamic-form-ant"; import type { DataModel } from "@imengyu/js-request-transform"; import type { ButtonProps } from "ant-design-vue"; import { h } from "vue"; export function villageInfoFolkCultureForm(title: string) : SingleForm { return [VillageBulidingInfo, (m) => ({ formItems: [ { label: title + '名称', name: 'name', type: 'text', defaultValue: '', additionalProps: { placeholder: '请输入名称', }, rules: [{ required: true, message: '请输入名称', }] }, { label: '村落非遗项目', name: 'ichId', type: 'select-id', defaultValue: null, additionalProps: { loadData: { callback: (m, r, p, i) => async () => (await VillageInfoApi.getList( 'ich', undefined, undefined, i.formGlobalParams.villageId as number, i.formGlobalParams.villageVolunteerId as number )).map((p) => ({ value: p.id, text: p.title, raw: p, })) }, } as IDynamicFormItemCallbackAdditionalProps>, rules: [], }, ...villageCommonContent(m, { title: title, showTitle: false, contentKey: 'details' }).formItems ] })]; } export const villageInfoCulture : GroupForm = { [1]: [CommonInfoModel, (m) => villageCommonContent(m, { title: '建村历史', showTitle: true })], [2]: [CommonInfoModel, (m) => villageCommonContent(m, { title: '历史事件', showTitle: true })], [3]: [CommonInfoModel, (m) => ({ formItems: [ ...(villageCommonContent(m, { title: '历史文献', showTitle: true }).formItems.slice(0, 1)), { label: '扫描件或图片', name: 'images', type: 'uploader', defaultValue: '', additionalProps: { upload: useAliOssUploadCo('xiangyuan/cultural/scan'), maxFileSize: 1024 * 1024 * 20, maxUploadCount: 20, }, rules: [{ required: true, message: '请上传扫描件或图片', }] }, ], })], [4]: [CommonInfoModel, (m) => ({ formItems: [ ...villageCommonContent(m, { title: '口述历史', showTitle: true }).formItems.slice(0, 1), { label: '口述人', name: 'speakerId', type: 'select-id', additionalProps: { loadData: { callback(_, m, p, i) { return async () => (await VillageInfoApi.getList('speaker', undefined, undefined, i.formGlobalParams.villageId as number, i.formGlobalParams.villageVolunteerId as number )) .map((p) => ({ value: p.id, text: p.name, raw: p, })) } } } as IDynamicFormItemCallbackAdditionalProps>, rules: [{ required: true, message: '请选择口述人', }], }, { label: '口述人管理', type: 'button', name: 'manage', defaultValue: '', additionalSlot: { default: () => h('span', {}, '口述人管理'), }, additionalProps: { onClick: { callback(v, m, p, i) { return () => { goFormStatic( i.formGlobalParams.villageId as number, i.formGlobalParams.villageVolunteerId as number, 'speaker', 1, undefined, undefined, '口述人管理' ); } } } as IDynamicFormItemCallback<() => void>, } as IDynamicFormItemCallbackAdditionalProps, formProps: { inputAlign: 'right' }, }, { label: '口述历史视频/录音', name: 'video', type: 'uploader', defaultValue: '', additionalProps: { upload: useAliOssUploadCo('xiangyuan/cultural/video'), chooseType: 'video', maxFileSize: 1024 * 1024 * 20, single: true, }, formProps: { extra: '您可以上传已经录制好的口述历史视频/录音来更生动地介绍历史。', }, }, /* { label: '', name: 'video1', type: 'recorder', defaultValue: '', additionalProps: { onRecordDone: (path: string) => { (m.value.getFormItemControlRef('video')?.getUploaderRef() as UploaderInstance).addItemAndUpload({ filePath: path, state: 'notstart', }); } }, }, */ ], })], }