index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <route lang="json">
  2. {
  3. "style": {
  4. "navigationBarTitleText": "编辑基本信息",
  5. "navigationBarBackgroundColor": "#ffffff"
  6. }
  7. }
  8. </route>
  9. <script setup lang="ts">
  10. import {
  11. getDesignerBasicInfo,
  12. updateDesignerBasicInfo,
  13. } from '../../../../../core/libs/agent-requests'
  14. import { messages } from '../../../../../core/libs/messages'
  15. import BottomAppBar from '@/components/bottom-app-bar.vue'
  16. import DataForm from '@/components/data-form.vue'
  17. import { DataFormSchema } from '../../../../../components/data-form'
  18. import { DesignerBasicInfo } from '@designer-hub/app/src/core/libs/models'
  19. import { requestToast } from '@designer-hub/app/src/core/utils/common'
  20. import { omit } from 'radash'
  21. const tab = ref('basic')
  22. // 基础信息 家庭信息 奖项信息 销售信息 游学/活动信息
  23. const tabs = [
  24. { label: '基础信息', value: 'basic' },
  25. { label: '家庭信息', value: 'family' },
  26. { label: '奖项信息', value: 'award' },
  27. { label: '销售信息', value: 'sale' },
  28. { label: '游学/活动信息', value: 'activity' },
  29. { label: '其他活动信息', value: 'events' },
  30. ]
  31. const id = ref()
  32. const { data: basicData, run: setBasicData } = useRequest(() => getDesignerBasicInfo(id.value))
  33. const formData = ref({})
  34. const schema = ref<
  35. DataFormSchema<
  36. Pick<
  37. DesignerBasicInfo,
  38. | 'companyAddress'
  39. | 'idCardNumber'
  40. | 'passportNumber'
  41. | 'householdAddress'
  42. | 'cooperationTime'
  43. | 'circle'
  44. | 'hobbies'
  45. | 'sharingIntent'
  46. // | 'imageUrl'
  47. // | 'maritalStatus'
  48. | 'maritalStatusStr'
  49. >
  50. >
  51. >({
  52. companyAddress: {
  53. type: 'TextField',
  54. label: messages.objects.designerBasiceInfo.companyAddress,
  55. labelWidth: 120,
  56. props: undefined,
  57. },
  58. idCardNumber: {
  59. type: 'TextField',
  60. label: messages.objects.designerBasiceInfo.idCardNumber,
  61. labelWidth: 120,
  62. },
  63. passportNumber: {
  64. type: 'TextField',
  65. label: messages.objects.designerBasiceInfo.passportNumber,
  66. labelWidth: 120,
  67. },
  68. householdAddress: {
  69. type: 'TextField',
  70. label: messages.objects.designerBasiceInfo.householdAddress,
  71. labelWidth: 120,
  72. },
  73. cooperationTime: {
  74. type: 'TimePick',
  75. label: messages.objects.designerBasiceInfo.cooperationTime,
  76. labelWidth: 120,
  77. props: {
  78. type: 'date',
  79. },
  80. },
  81. circle: {
  82. type: 'TextField',
  83. label: messages.objects.designerBasiceInfo.circle,
  84. labelWidth: 120,
  85. },
  86. hobbies: {
  87. type: 'TextField',
  88. label: messages.objects.designerBasiceInfo.hobbies,
  89. labelWidth: 120,
  90. },
  91. sharingIntent: {
  92. type: 'TextField',
  93. label: messages.objects.designerBasiceInfo.sharingIntent,
  94. labelWidth: 120,
  95. },
  96. // imageUrl: {
  97. // type: 'ImageUploader',
  98. // label: messages.objects.designerBasiceInfo.imageUrl,
  99. // },
  100. maritalStatusStr: {
  101. type: 'TextField',
  102. label: messages.objects.designerBasiceInfo.maritalStatusStr,
  103. labelWidth: 120,
  104. props: {
  105. // columns: [
  106. // { label: '未婚', value: 1 },
  107. // { label: '已婚', value: 2 },
  108. // { label: '离婚', value: 3 },
  109. // { label: '丧偶', value: 4 },
  110. // ],
  111. },
  112. },
  113. })
  114. const eventsQuery = computed(() => ({ type: '3' }))
  115. const handleSubmit = async () => {
  116. console.log(formData.value)
  117. const { code } = await requestToast(
  118. () =>
  119. updateDesignerBasicInfo({
  120. ...formData.value,
  121. userId: id.value,
  122. id: basicData.value.id,
  123. }),
  124. {
  125. success: true,
  126. successTitle: '保存成功',
  127. },
  128. )
  129. if (code === 0) {
  130. await setBasicData()
  131. await uni.navigateBack()
  132. }
  133. }
  134. onLoad(async (query: { id: string }) => {
  135. id.value = query.id
  136. await setBasicData()
  137. formData.value = {
  138. ...omit(basicData.value, ['sex']),
  139. }
  140. })
  141. </script>
  142. <template>
  143. <div class="flex-grow bg-white p-4">
  144. <DataForm :schema="schema" v-model="formData" :direction="'horizontal'"></DataForm>
  145. <BottomAppBar fixed placeholder>
  146. <wd-button block :round="false" @click="handleSubmit">保存</wd-button>
  147. </BottomAppBar>
  148. </div>
  149. </template>