submit.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <template>
  2. <!-- 项目申报 -->
  3. <div class="about main-background main-background-type0">
  4. <div class="nav-placeholder"></div>
  5. <!-- 表单 -->
  6. <section class="main-section ">
  7. <div class="content">
  8. <div class="title">
  9. <h2>项目申报</h2>
  10. </div>
  11. <DynamicForm
  12. ref="form"
  13. :model="formModel"
  14. :options="formOptions"
  15. />
  16. <a-button type="primary" block @click="handleSubmit">提交</a-button>
  17. </div>
  18. </section>
  19. </div>
  20. </template>
  21. <script setup lang="ts">
  22. import CommonContent from '@/api/CommonContent';
  23. import { RecommendForm } from '@/api/inheritor/SubmitApi';
  24. import type { IdAsValueDropdownProps } from '@/components/dynamicf/Dropdown/IdAsValueDropdown';
  25. import type { DataModel } from '@imengyu/js-request-transform';
  26. import { DynamicForm, type IDynamicFormOptions, type IDynamicFormRef } from '@imengyu/vue-dynamic-form';
  27. import { Modal, type FormInstance } from 'ant-design-vue';
  28. import { ref } from 'vue';
  29. const form = ref<IDynamicFormRef>();
  30. const formModel = ref(new RecommendForm());
  31. const formOptions = ref<IDynamicFormOptions>({
  32. formLabelCol: { span: 6 },
  33. formWrapperCol: { span: 24 },
  34. formAdditionaProps: {
  35. layout: 'vertical'
  36. },
  37. formItems: [
  38. {
  39. label: '证件照',
  40. name: 'idPhoto',
  41. type: 'single-image',
  42. additionalProps: {
  43. },
  44. },
  45. {
  46. label: '传承人姓名',
  47. name: 'name',
  48. type: 'text',
  49. additionalProps: {
  50. placeholder: '请输入姓名'
  51. },
  52. },
  53. {
  54. label: '项目名称',
  55. name: 'ichName',
  56. type: 'text',
  57. additionalProps: {
  58. placeholder: '请输入项目名称'
  59. }
  60. },
  61. {
  62. label: '类型',
  63. name: 'type',
  64. type: 'select-id',
  65. additionalProps: {
  66. placeholder: '请选择类型',
  67. loadData: async () =>
  68. (await CommonContent.getCategoryList(4)).map(p => ({
  69. label: p.title,
  70. value: p.id,
  71. raw: p
  72. }))
  73. } as IdAsValueDropdownProps<DataModel>,
  74. },
  75. {
  76. label: '保护单位',
  77. name: 'unit',
  78. type: 'text',
  79. additionalProps: {
  80. placeholder: '请输入保护单位'
  81. }
  82. },
  83. {
  84. label: '性别',
  85. name: 'gender',
  86. type: 'select',
  87. additionalProps: {
  88. options: [
  89. { text: '男', value: '男' },
  90. { text: '女', value: '女' },
  91. ]
  92. },
  93. },
  94. {
  95. label: '生日',
  96. name: 'birthday',
  97. type: 'date',
  98. additionalProps: {
  99. placeholder: '请输入出生日期'
  100. }
  101. },
  102. {
  103. label: '民族',
  104. name: 'nation',
  105. type: 'text',
  106. additionalProps: {
  107. placeholder: '请输入民族'
  108. }
  109. },
  110. {
  111. label: '传承人姓名',
  112. name: 'name',
  113. type: 'text',
  114. additionalProps: {
  115. placeholder: '请输入姓名'
  116. }
  117. },
  118. {
  119. label: '职业',
  120. name: 'job',
  121. type: 'text',
  122. additionalProps: {
  123. placeholder: '请输入职业'
  124. }
  125. },
  126. {
  127. label: '职务职称',
  128. name: 'jobTitle',
  129. type: 'text',
  130. additionalProps: {
  131. placeholder: '请输入职务职称'
  132. }
  133. },
  134. ],
  135. formRules: {
  136. name: [
  137. { required: true, message: '请输入姓名' },
  138. { min: 2, max: 5, message: '长度在 2 到 5 个字符' }
  139. ],
  140. // idPhoto: [
  141. // { required: true, message: '请上传证件照' }
  142. // ],
  143. ichName: [
  144. { required: true, message: '请输入项目名称' }
  145. ],
  146. type: [
  147. { required: true, message: '请选择类型' }
  148. ],
  149. unit: [
  150. { required: true, message: '请输入保护单位' }
  151. ],
  152. gender: [
  153. { required: true, message: '请选择性别' }
  154. ],
  155. birthday: [
  156. { required: true, message: '请输入出生日期' }
  157. ],
  158. job: [
  159. { required: true, message: '请输入职业' }
  160. ],
  161. jobTitle: [
  162. { required: true, message: '请输入职业' }
  163. ],
  164. nation: [
  165. { required: true, message: '请输入民族' }
  166. ]
  167. },
  168. });
  169. function handleSubmit() {
  170. (form.value?.getFormRef() as FormInstance).validate().then(() => {
  171. Modal.success({
  172. title: '提交成功',
  173. content: '您的项目申报已提交成功。请耐心等待审核!',
  174. });
  175. });
  176. }
  177. </script>