Pārlūkot izejas kodu

feat: 添加设计师家庭信息接口;更新相关请求和页面以支持家庭信息管理

EvilDragon 1 mēnesi atpakaļ
vecāks
revīzija
b85fc45dc9

+ 38 - 0
packages/app/src/core/libs/models.ts

@@ -767,6 +767,44 @@ export interface DesignerBasicInfo {
   maritalStatus: number
   maritalStatusStr: string
 }
+/**
+ * 设计师家庭信息接口
+ */
+export interface DesignerFamilyInfo {
+  id: number
+  userId: number
+
+  /**
+   * 家庭成员与用户的关系(例如,父母,兄弟姐妹)。
+   */
+  familyRelation: string
+
+  /**
+   * 家庭成员的姓名。
+   */
+  familyName: string
+
+  /**
+   * 家庭成员的性别。
+   */
+  familySex: string
+
+  /**
+   * 家庭成员的出生日期。
+   */
+  familyBirthday: string
+
+  /**
+   * 家庭成员的兴趣爱好。
+   */
+  familyInterset: string
+
+  /**
+   * 家庭成员的职业。
+   */
+  familyOccupation: string
+  createTime: string
+}
 export interface DesignerEvent {
   name: string
   applyTime: string

+ 11 - 0
packages/merchant/src/core/libs/agent-requests.ts

@@ -10,6 +10,7 @@ import {
   FollowUp,
   DesignerBasicInfo,
   DesignerEvent,
+  DesignerFamilyInfo,
 } from '@designer-hub/app/src/core/libs/models'
 /**
  * 通过ID获取用户信息
@@ -59,6 +60,16 @@ export const getDesignerBasicInfo = (userId: number) =>
 export const updateDesignerBasicInfo = (data: Partial<DesignerBasicInfo>) =>
   httpPut('/app-api/member/stylist-basic-info/update', data)
 /**
+ * 获取设计师家庭信息
+ */
+export const getDesignerFamilyInfo = (query) =>
+  httpGet<ResPageData<DesignerFamilyInfo>>('/app-api/member/stylist-family/list', query)
+/**
+ * 保存设计师家庭信息
+ */
+export const saveDesignerFamilyInfo = (data: Partial<DesignerFamilyInfo>) =>
+  httpPost('/app-api/member/stylist-family/save', data)
+/**
  * 获取设计师额外事件
  */
 export const getDesignerExtraEvents = (query = {}) =>

+ 11 - 1
packages/merchant/src/core/libs/messages.ts

@@ -40,6 +40,16 @@ export const messages = {
       maritalStatus: '婚姻状况',
       maritalStatusStr: '婚姻状况描述',
     },
+    designerFamilyInfo: {
+      id: 'ID',
+      userId: '用户ID',
+      familyRelation: '关系',
+      familyName: '姓名',
+      familySex: '性别',
+      familyBirthday: '生日',
+      familyInterset: '兴趣爱好',
+      familyOccupation: '职业',
+      createTime: '创建时间',
+    },
   },
-  // 写出上面对象的显示文案 如:designerBasiceInfo: { id: 'ID', userId: '用户ID', avatar: '头像'}
 }

+ 93 - 4
packages/merchant/src/pages/designer/archives/index.vue

@@ -7,14 +7,23 @@
 }
 </route>
 <script setup lang="ts">
-import SectionHeading from '@designer-hub/app/src/components/section-heading.vue'
-import { getDesignerBasicInfo, getDesignerExtraEvents } from '../../../core/libs/agent-requests'
+import {
+  getDesignerBasicInfo,
+  getDesignerExtraEvents,
+  getDesignerFamilyInfo,
+  saveDesignerFamilyInfo,
+} from '../../../core/libs/agent-requests'
 import { messages } from '../../../core/libs/messages'
 import { omit } from 'radash'
 import BottomAppBar from '@/components/bottom-app-bar.vue'
 import { renders } from '../../../core/libs/renders'
 import DataRender from '@/components/data-render.vue'
 import PageHelperEvo from '@/components/page-helper-evo.vue'
+import { DataFormSchema } from '../../../components/data-form'
+import { DesignerFamilyInfo } from '@designer-hub/app/src/core/libs/models'
+import DataForm from '@/components/data-form.vue'
+import { requestToast } from '@designer-hub/app/src/core/utils/common'
+import { ComponentExposed } from 'vue-component-type-helpers'
 
 const tab = ref('basic')
 // 基础信息 家庭信息 奖项信息 销售信息 游学/活动信息
@@ -28,11 +37,74 @@ const tabs = [
 ]
 const id = ref()
 const { data: basicData, run: setBasicData } = useRequest(() => getDesignerBasicInfo(id.value))
+const query = computed(() => ({ userId: id.value }))
 const eventsQuery = computed(() => ({ type: '3' }))
+const actionSheetStatus = ref(false)
+const schema = ref<DataFormSchema>()
+const formData = ref({})
+const submitType = ref<'family'>()
+const familyPageRef = ref<ComponentExposed<typeof PageHelperEvo>>()
 // const {} = useRequest()
 const handleEditBasicInfo = async () => {
   await uni.navigateTo({ url: `/pages/designer/archives/basic-info/index?id=${id.value}` })
 }
+const handleAddFamilyInfo = async () => {
+  submitType.value = 'family'
+  const familySchema: DataFormSchema<Omit<DesignerFamilyInfo, 'userId' | 'createTime' | 'id'>> = {
+    familyRelation: {
+      type: 'TextField',
+      label: messages.objects.designerFamilyInfo.familyRelation,
+    },
+    familyName: {
+      type: 'TextField',
+      label: messages.objects.designerFamilyInfo.familyName,
+    },
+    familySex: {
+      type: 'Radio',
+      label: messages.objects.designerFamilyInfo.familySex,
+      props: {
+        columns: [
+          { label: '男', value: '1' },
+          { label: '女', value: '2' },
+        ],
+      },
+    },
+    familyBirthday: {
+      type: 'TextField',
+      label: messages.objects.designerFamilyInfo.familyBirthday,
+    },
+    familyInterset: {
+      type: 'TextField',
+      label: messages.objects.designerFamilyInfo.familyInterset,
+    },
+    familyOccupation: {
+      type: 'TextField',
+      label: messages.objects.designerFamilyInfo.familyOccupation,
+    },
+  }
+  schema.value = familySchema
+  actionSheetStatus.value = true
+}
+const handleSubmit = async () => {
+  switch (submitType.value) {
+    case 'family': {
+      const { code } = await requestToast(
+        () => saveDesignerFamilyInfo({ ...formData.value, userId: id.value }),
+        {
+          success: true,
+          successTitle: '保存成功',
+        },
+      )
+      if (code === 0) {
+        actionSheetStatus.value = false
+        familyPageRef.value?.reload()
+      }
+      break
+    }
+    default:
+      break
+  }
+}
 onLoad(async (query: { id: string }) => {
   id.value = query.id
   await setBasicData()
@@ -66,7 +138,13 @@ onLoad(async (query: { id: string }) => {
         </template>
       </template>
       <template v-if="tab === 'family'">
-        <template></template>
+        <PageHelperEvo ref="familyPageRef" :request="getDesignerFamilyInfo" :query="query">
+          <template #default="{ source }">
+            <template v-for="(it, index) in source.list" :key="index">
+              <div>{{ it }}</div>
+            </template>
+          </template>
+        </PageHelperEvo>
       </template>
       <template v-if="tab === 'events'">
         <PageHelperEvo :request="getDesignerExtraEvents" :query="eventsQuery">
@@ -79,7 +157,18 @@ onLoad(async (query: { id: string }) => {
       </template>
     </div>
     <BottomAppBar fixed placeholder>
-      <wd-button block :round="false" @click="handleEditBasicInfo">编辑</wd-button>
+      <wd-button v-if="tab === 'basic'" block :round="false" @click="handleEditBasicInfo">
+        编辑
+      </wd-button>
+      <wd-button v-if="tab === 'family'" block :round="false" @click="handleAddFamilyInfo">
+        新增
+      </wd-button>
     </BottomAppBar>
+    <wd-action-sheet v-model="actionSheetStatus">
+      <div class="p-4">
+        <DataForm :schema="schema" :direction="'horizontal'" v-model="formData"></DataForm>
+        <wd-button :round="false" block @click="handleSubmit">提交</wd-button>
+      </div>
+    </wd-action-sheet>
   </div>
 </template>