Selaa lähdekoodia

refactor(merchant): 重构设计师档案页面

- 修改了列表组件的使用方式,优化了数据加载和渲染逻辑
- 调整了日期选择器的使用,增加了必填项验证
- 优化了圆环图的数据处理,提高了数据准确性和展示效果
- 改进了错误提示的显示方式,提升了用户体验
EvilDragon 1 kuukausi sitten
vanhempi
commit
e7df84acc5

+ 3 - 2
packages/app/src/pages/messages/components/message-card.vue

@@ -53,7 +53,9 @@ const init = async () => {
   }
 }
 const handleJump = () => {
-  console.log(props)
+  if ((props.options.linkUrl ?? '') !== '') {
+    return router.push(props.options.linkUrl)
+  }
   const query: Record<string, string> = {}
   switch (props.options.messageSubType) {
     case 5:
@@ -66,7 +68,6 @@ const handleJump = () => {
       break
   }
   console.log(stringify(query))
-  // return
   router.push(getMessageType(props.options.messageSubType)?.path + '?' + stringify(query))
 }
 watch(

+ 7 - 6
packages/app/src/pages/mine/authentication/index.vue

@@ -108,13 +108,12 @@ const setReferrerExisting = (value: string) => {
       '3': '请填写材料商名称',
     }[value]
   }
-  formData.value.referrer = ''
 }
 const handleSubmit = async () => {
   console.log(formData.value)
   if (formData.value.channelSource && formData.value.channelSource !== '4' && !userAuthInfo.value) {
     if ((formData.value.referrer ?? '') === '') {
-      uni.showToast({ title: messages.mine.authentication.referrerErrorText, icon: 'none' })
+      await uni.showToast({ title: messages.mine.authentication.referrerErrorText, icon: 'none' })
       return
     }
     const { data, code: status } = await requestToast(() =>
@@ -124,7 +123,7 @@ const handleSubmit = async () => {
       }),
     )
     if (data === false || status !== 0) {
-      uni.showToast({ title: '推荐人编号不正确', icon: 'none' })
+      await uni.showToast({ title: '推荐人编号不正确', icon: 'none' })
       return
     }
   }
@@ -150,7 +149,7 @@ const handleSubmit = async () => {
     .map(([key, value]) => value.message)
   console.log(errors)
   if (errors.length > 0) {
-    uni.showToast({ title: errors[0], icon: 'none' })
+    await uni.showToast({ title: errors[0], icon: 'none' })
     return
   }
 
@@ -165,7 +164,7 @@ const handleSubmit = async () => {
       spatialExpertiseType: formData.value.spatialExpertiseType?.join(','),
     })
     if (code === 0) {
-      router.replace(`/pages/mine/authentication/submit/success/index`)
+      await router.replace(`/pages/mine/authentication/submit/success/index`)
     } else {
       error(msg)
     }
@@ -179,7 +178,7 @@ const handleSubmit = async () => {
     }
     const { code } = await requestToast(() => updateUserAuthInfo({ ...toBeUpdate, auditStatus: 1 }))
     if (code === 0) {
-      router.replace(`/pages/mine/authentication/submit/success/index`)
+      await router.replace(`/pages/mine/authentication/submit/success/index`)
     }
   }
 }
@@ -199,6 +198,7 @@ onLoad(async (query?: Record<string | 'scene', string>) => {
     }
   }
   await setUserAuthInfo()
+  console.log(userAuthInfo.value)
   if (userAuthInfo.value) {
     formData.value = {
       ...pick(userAuthInfo.value, [
@@ -224,6 +224,7 @@ onLoad(async (query?: Record<string | 'scene', string>) => {
   schema.value.spatialExpertiseType.props.columns = res
   formInited.value = true
   if (userInfo.value.userAuthStatus === 1) {
+    console.log(formData.value)
     Object.entries(schema.value).forEach(([key]) => {
       schema.value[key].props.disabled = true
     })

+ 30 - 10
packages/merchant/src/components/list-helper-evo.vue

@@ -1,5 +1,5 @@
 <script setup lang="ts" generic="T extends AnyObject">
-import { UnwrapRef } from 'vue'
+import { onUnmounted, UnwrapRef } from 'vue'
 
 const props = withDefaults(
   defineProps<{
@@ -19,6 +19,7 @@ const props = withDefaults(
 )
 const slot = defineSlots<{
   default(props: { item: UnwrapRef<T>; index: number; isLast: boolean }): any
+  list(props: { list: UnwrapRef<T[]> }): any
 }>()
 const request = computed(() => {
   if (props.request) {
@@ -29,10 +30,15 @@ const request = computed(() => {
     }
   }
 })
-const { data, run: setData } = useRequest(() => request.value({ ...props.query }), {
-  immediate: false,
-})
+const data = ref()
+const setData = async () => {
+  data.value = []
+  const { data: resData } = await request.value({ ...props.query })
+  data.value = resData
+}
+const list = ref([])
 onMounted(async () => {
+  console.log('mounted')
   if (props.mockList) {
     data.value = props.mockList as T[]
     return
@@ -57,11 +63,21 @@ watch(
     data.value = props.items
   },
 )
+watch(
+  () => data.value,
+  () => {
+    list.value = data.value
+  },
+  { deep: true },
+)
 defineExpose({
   reload: async () => {
     await setData()
   },
 })
+onUnmounted(() => {
+  console.log('unmounted')
+})
 </script>
 <script lang="ts">
 export default {
@@ -75,13 +91,17 @@ export default {
 <template>
   <div class="flex-grow relative flex flex-col" :class="customClass">
     <div :class="contentClass">
-      <template v-for="(it, index) in data" :key="index">
-        <slot
-          :item="it as UnwrapRef<T>"
-          :index="index"
-          :isLast="index == (data?.length ?? 0) - 1"
-        ></slot>
+      <!--      {{ list }}-->
+      <template v-if="slot.default">
+        <template v-for="(it, index) in list" :key="index">
+          <slot
+            :item="it as UnwrapRef<T>"
+            :index="index"
+            :isLast="index == (list?.length ?? 0) - 1"
+          ></slot>
+        </template>
       </template>
+      <slot name="list" :list="list"></slot>
     </div>
     <div
       v-if="mockList"

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

@@ -374,14 +374,14 @@ export const getDesignerActivities = (query = {}) =>
     data: [
       ...(res.data.study as any[]).map((it) => ({
         type: '',
-        label: it.type,
+        label: it.name,
         value: it.quantity + '次',
         path: '',
       })),
       { type: 'line', label: '', value: '' },
-      ...(res.data.study as any[]).map((it) => ({
+      ...(res.data.activity as any[]).map((it) => ({
         type: '',
-        label: it.type,
+        label: it.name,
         value: it.quantity + '次',
         path: '',
       })),

+ 2 - 1
packages/merchant/src/pages/agent/designer/archives/activity/others/index.vue

@@ -30,6 +30,7 @@ const schema = ref<DataFormSchema<Omit<DesignerEvent, 'id' | 'createTime' | 'use
     required: true,
     props: {
       defaultValue: new Date(),
+      type: 'date',
     },
   },
   name: {
@@ -41,7 +42,7 @@ const schema = ref<DataFormSchema<Omit<DesignerEvent, 'id' | 'createTime' | 'use
 const rules = ref({
   participationDate: [
     {
-      type: 'date',
+      required: true,
       message: '请选择活动时间',
     },
   ],

+ 0 - 1
packages/merchant/src/pages/agent/designer/archives/basic-info/index.vue

@@ -120,7 +120,6 @@ const handleSubmit = async () => {
       updateDesignerBasicInfo({
         ...formData.value,
         userId: id.value,
-        id: basicData.value.id,
       }),
     {
       success: true,

+ 143 - 139
packages/merchant/src/pages/agent/designer/archives/index.vue

@@ -54,6 +54,8 @@ const formData = ref({})
 const submitType = ref<'family' | 'award'>()
 const familyPageRef = ref<ComponentExposed<typeof PageHelperEvo>>()
 const awardsListRef = ref<ComponentExposed<typeof ListHelperEvo>>()
+const saleListRef = ref<ComponentExposed<typeof ListHelperEvo>>()
+const activityListRef = ref<ComponentExposed<typeof ListHelperEvo>>()
 // const {} = useRequest()
 const handleEditBasicInfo = async () => {
   await uni.navigateTo({ url: `/pages/agent/designer/archives/basic-info/index?id=${id.value}` })
@@ -92,7 +94,7 @@ const handleAddFamilyInfo = async () => {
         type: 'date',
         placeholder: `请选择${messages.objects.designerFamilyInfo.familyBirthday}`,
         minDate: new Date('1925-01-01').getTime(),
-        defaultVale: new Date('1990-01-01').getTime(),
+        // defaultVale: new Date('1990-01-01').getTime(),
       },
     },
     familyInterset: {
@@ -139,6 +141,7 @@ const handleAddAward = async () => {
       props: {
         defaultValue: dayjs().toDate(),
         placeholder: messages.objects.designerAward.awardsTimePlaceHolder,
+        type: 'date',
       },
     },
     awardsFileUrl: {
@@ -202,7 +205,19 @@ onLoad(async (query?: Record<string | 'id', any>) => {
   id.value = query?.id
 })
 onShow(async () => {
-  console.log(id.value)
+  switch (tab.value) {
+    case 'basic':
+      await setBasicData()
+      break
+    case 'sale':
+      await saleListRef.value?.reload()
+      break
+    case 'activity':
+      await activityListRef.value?.reload()
+      break
+    default:
+      break
+  }
   await setBasicData()
 })
 </script>
@@ -248,41 +263,45 @@ onShow(async () => {
             </div>
           </div>
           <ListHelperEvo ref="familyPageRef" :request="getDesignerFamilyInfo" :query="query">
-            <template #default="{ item, isLast }">
-              <div class="flex flex-col gap-4 py-4">
-                <SectionHeading
-                  title="关系"
-                  size="base"
-                  :end-text="item.familyRelation"
-                ></SectionHeading>
-                <SectionHeading
-                  title="姓名"
-                  size="base"
-                  :end-text="item.familyName"
-                ></SectionHeading>
-                <SectionHeading
-                  title="性别"
-                  size="base"
-                  :end-text="item.familySex"
-                ></SectionHeading>
-                <SectionHeading
-                  title="生日"
-                  size="base"
-                  :end-text="item.familyBirthday && dayjs(item.familyBirthday).format('YYYY-MM-DD')"
-                ></SectionHeading>
-                <SectionHeading
-                  title="爱好"
-                  size="base"
-                  :end-text="item.familyInterset"
-                ></SectionHeading>
-                <SectionHeading
-                  title="职业"
-                  size="base"
-                  :end-text="item.familyOccupation"
-                ></SectionHeading>
-                <wd-button type="text" @click="handleDeleteFamilyInfo(item)">删除</wd-button>
-                <div v-if="!isLast" class="w-full h-1 bg-[#dadada]"></div>
-              </div>
+            <template #list="{ list }">
+              <template v-for="(item, index) in list" :key="index">
+                <div class="flex flex-col gap-4 py-4">
+                  <SectionHeading
+                    title="关系"
+                    size="base"
+                    :end-text="item.familyRelation"
+                  ></SectionHeading>
+                  <SectionHeading
+                    title="姓名"
+                    size="base"
+                    :end-text="item.familyName"
+                  ></SectionHeading>
+                  <SectionHeading
+                    title="性别"
+                    size="base"
+                    :end-text="item.familySex"
+                  ></SectionHeading>
+                  <SectionHeading
+                    title="生日"
+                    size="base"
+                    :end-text="
+                      item.familyBirthday && dayjs(item.familyBirthday).format('YYYY-MM-DD')
+                    "
+                  ></SectionHeading>
+                  <SectionHeading
+                    title="爱好"
+                    size="base"
+                    :end-text="item.familyInterset"
+                  ></SectionHeading>
+                  <SectionHeading
+                    title="职业"
+                    size="base"
+                    :end-text="item.familyOccupation"
+                  ></SectionHeading>
+                  <wd-button type="text" @click="handleDeleteFamilyInfo(item)">删除</wd-button>
+                  <div v-if="!(index === list.length - 1)" class="w-full h-1 bg-[#dadada]"></div>
+                </div>
+              </template>
             </template>
           </ListHelperEvo>
           <!--          <PageHelperEvo ref="familyPageRef" :request="getDesignerFamilyInfo" :query="query">-->
@@ -307,42 +326,51 @@ onShow(async () => {
           <!--          },-->
           <!--          ]"-->
           <ListHelperEvo ref="awardsListRef" :request="getAwards" :query="{ userId: id }">
-            <template #default="{ item, isLast }">
-              <div class="flex flex-col gap-4 py-4">
-                <SectionHeading
-                  title="奖项名称"
-                  size="base"
-                  :end-text="item.awardsName"
-                ></SectionHeading>
-                <SectionHeading
-                  title="奖项日期"
-                  :end-text="item.awardsTime && dayjs(item.awardsTime).format('YYYY-MM-DD')"
-                ></SectionHeading>
-                <SectionHeading title="奖项名次" :end-text="item.awardsRank"></SectionHeading>
-                <SectionHeading
-                  title="奖项照片"
-                  end-arrow
-                  :path="`/pages/agent/designer/archives/award/photos/index?urls=${item.awardsFileUrl ?? ''}`"
-                ></SectionHeading>
-                <wd-button type="text" @click="handleDeleteAward(item)">删除</wd-button>
-                <div v-if="!isLast" class="w-full h-1 bg-[#dadada]"></div>
-              </div>
+            <!--            <template #default="{ item, isLast }">-->
+            <!--              <div class="flex flex-col gap-4 py-4">-->
+            <!--                <SectionHeading-->
+            <!--                  title="奖项名称"-->
+            <!--                  size="base"-->
+            <!--                  :end-text="item.awardsName"-->
+            <!--                ></SectionHeading>-->
+            <!--                <SectionHeading-->
+            <!--                  title="奖项日期"-->
+            <!--                  :end-text="item.awardsTime && dayjs(item.awardsTime).format('YYYY-MM-DD')"-->
+            <!--                ></SectionHeading>-->
+            <!--                <SectionHeading title="奖项名次" :end-text="item.awardsRank"></SectionHeading>-->
+            <!--                <SectionHeading-->
+            <!--                  title="奖项照片"-->
+            <!--                  end-arrow-->
+            <!--                  :path="`/pages/agent/designer/archives/award/photos/index?urls=${item.awardsFileUrl ?? ''}`"-->
+            <!--                ></SectionHeading>-->
+            <!--                <wd-button type="text" @click="handleDeleteAward(item)">删除</wd-button>-->
+            <!--                <div v-if="!isLast" class="w-full h-1 bg-[#dadada]"></div>-->
+            <!--              </div>-->
+            <!--            </template>-->
+            <template #list="{ list }">
+              <template v-for="(item, i) in list" :key="i">
+                <div class="flex flex-col gap-4 py-4">
+                  <SectionHeading
+                    title="奖项名称"
+                    size="base"
+                    :end-text="item.awardsName"
+                  ></SectionHeading>
+                  <SectionHeading
+                    title="奖项日期"
+                    :end-text="item.awardsTime && dayjs(item.awardsTime).format('YYYY-MM-DD')"
+                  ></SectionHeading>
+                  <SectionHeading title="奖项名次" :end-text="item.awardsRank"></SectionHeading>
+                  <SectionHeading
+                    title="奖项照片"
+                    end-arrow
+                    :path="`/pages/agent/designer/archives/award/photos/index?urls=${item.awardsFileUrl ?? ''}`"
+                  ></SectionHeading>
+                  <wd-button type="text" @click="handleDeleteAward(item)">删除</wd-button>
+                  <div v-if="!isLast" class="w-full h-1 bg-[#dadada]"></div>
+                </div>
+              </template>
             </template>
           </ListHelperEvo>
-          <!--          <template v-for="(it, index) in source?.list" :key="index">-->
-          <!--            <div>-->
-          <!--            </div>-->
-          <!--          </template>-->
-          <!--          <PageHelperEvo-->
-          <!--            class="flex-grow flex flex-col"-->
-          <!--            :request="async () => ({data: { list: [{}], total: 0 }, msg: 0, code: 0})"-->
-          <!--            :query="eventsQuery"-->
-          <!--            custom-class="flex-grow flex flex-col"-->
-          <!--          >-->
-          <!--            <template #default="{ source }">-->
-          <!--              -->
-          <!--            </template>-->
-          <!--          </PageHelperEvo>-->
         </div>
       </template>
 
@@ -350,83 +378,59 @@ onShow(async () => {
         <div class="bg-white p-4 mt-4 flex-grow flex flex-col">
           <div class="flex items-center justify-between">
             <div>销售信息</div>
-            <!--            <div>-->
-            <!--              <wd-button type="text" icon="add-circle1" @click="handleAddAward">-->
-            <!--                添加获奖信息-->
-            <!--              </wd-button>-->
-            <!--            </div>-->
           </div>
           <ListHelperEvo ref="saleListRef" :request="getSalesOrdersCounts" :query="{ userId: id }">
-            <template #default="{ item, isLast }">
-              <div class="flex flex-col gap-4 py-4">
-                <div v-if="isLast" class="w-full h-1 bg-[#dadada]"></div>
-                <SectionHeading
-                  :title="item.label"
-                  size="base"
-                  :end-text="String(item.value)"
-                  end-arrow
-                  :path="
-                    !isLast
-                      ? `/pages/agent/designer/archives/sale-info/index?id=${id}`
-                      : `/pages/agent/designer/archives/sale-info/others/index?id=${id}`
-                  "
-                ></SectionHeading>
-              </div>
+            <template #list="{ list }">
+              <template v-for="(item, index) in list" :key="index">
+                <div class="flex flex-col gap-4 py-4">
+                  <div v-if="index === list.length - 1" class="w-full h-1 bg-[#dadada]"></div>
+                  <SectionHeading
+                    :title="item.label"
+                    size="base"
+                    :end-text="String(item.value)"
+                    end-arrow
+                    :path="
+                      !(index === list.length - 1)
+                        ? `/pages/agent/designer/archives/sale-info/index?id=${id}`
+                        : `/pages/agent/designer/archives/sale-info/others/index?id=${id}`
+                    "
+                  ></SectionHeading>
+                </div>
+              </template>
             </template>
           </ListHelperEvo>
-          <!--          <template v-for="(it, index) in source?.list" :key="index">-->
-          <!--            <div>-->
-          <!--            </div>-->
-          <!--          </template>-->
-          <!--          <PageHelperEvo-->
-          <!--            class="flex-grow flex flex-col"-->
-          <!--            :request="async () => ({data: { list: [{}], total: 0 }, msg: 0, code: 0})"-->
-          <!--            :query="eventsQuery"-->
-          <!--            custom-class="flex-grow flex flex-col"-->
-          <!--          >-->
-          <!--            <template #default="{ source }">-->
-          <!--              -->
-          <!--            </template>-->
-          <!--          </PageHelperEvo>-->
         </div>
       </template>
       <template v-if="tab === 'activity'">
         <div class="bg-white p-4 mt-4 flex-grow flex flex-col">
           <SectionHeading title="游学/活动信息"></SectionHeading>
-          <ListHelperEvo :request="getDesignerActivities" :query="{ userId: id }">
-            <template #default="{ item, isLast }">
-              <div class="">
-                <template v-if="item.type === 'line'">
-                  <div class="w-full h-1 bg-[#dadada]"></div>
-                </template>
-                <template v-else>
-                  <div class="py-4">
-                    <SectionHeading
-                      :title="item.label"
-                      :end-text="item.value"
-                      :path="
-                        isLast
-                          ? `/pages/agent/designer/archives/activity/others/index?id=${id}`
-                          : ''
-                      "
-                    ></SectionHeading>
-                  </div>
-                </template>
-                <div v-if="!isLast" class="w-full h-.25 bg-[#f4f4f4]"></div>
-                <!--                </template>-->
-
-                <!--                <SectionHeading-->
-                <!--                  :title="item.label"-->
-                <!--                  size="base"-->
-                <!--                  :end-text="String(item.value)"-->
-                <!--                  end-arrow-->
-                <!--                  :path="-->
-                <!--                    !isLast-->
-                <!--                      ? `/pages/agent/designer/archives/sale-info/index?id=${id}`-->
-                <!--                      : `/pages/agent/designer/archives/sale-info/others/index?id=${id}`-->
-                <!--                  "-->
-                <!--                ></SectionHeading>-->
-              </div>
+          <ListHelperEvo
+            ref="activityListRef"
+            :request="getDesignerActivities"
+            :query="{ userId: id }"
+          >
+            <template #list="{ list }">
+              <template v-for="(item, index) in list" :key="index">
+                <div class="">
+                  <template v-if="item.type === 'line'">
+                    <div class="w-full h-1 bg-[#dadada]"></div>
+                  </template>
+                  <template v-else>
+                    <div class="py-4">
+                      <SectionHeading
+                        :title="item.label"
+                        :end-text="item.value"
+                        :path="
+                          index === list.length - 1
+                            ? `/pages/agent/designer/archives/activity/others/index?id=${id}`
+                            : ''
+                        "
+                      ></SectionHeading>
+                    </div>
+                  </template>
+                  <div v-if="!(index === list.length - 1)" class="w-full h-.25 bg-[#f4f4f4]"></div>
+                </div>
+              </template>
             </template>
           </ListHelperEvo>
         </div>

+ 1 - 0
packages/merchant/src/pages/agent/designer/archives/sale-info/others/index.vue

@@ -29,6 +29,7 @@ const schema = ref<DataFormSchema<Omit<DesignerOrderSaleOther, 'id' | 'createTim
     required: true,
     props: {
       defaultValue: new Date(),
+      type: 'date',
     },
   },
   supplierName: {

+ 14 - 6
packages/merchant/src/pages/mine/components/agent-mine.vue

@@ -47,10 +47,15 @@ const bgClass = [
 const units = [
   // { },
   // 单位、 换算率
-  { unit: '万', rate: 10000 },
-  { unit: '万', rate: 10000 },
-  { unit: '次', rate: 1 },
-  { unit: '次', rate: 1 },
+  // { unit: '万', rate: 1 },
+  // { unit: '万', rate: 1 },
+  // { unit: '次', rate: 1 },
+  // { unit: '次', rate: 1 },
+
+  { unit: '', rate: 1 },
+  { unit: '', rate: 1 },
+  { unit: '', rate: 1 },
+  { unit: '', rate: 1 },
 ]
 const toSettings = () => {
   uni.navigateTo({ url: '/pages/mine/agent/settings/index' })
@@ -118,7 +123,8 @@ onMounted(async () => {
                     <wd-circle
                       :model-value="
                         it.thisYearComplete && it.target
-                          ? (Number(it.thisYearComplete) / Number(it.target)) * 100
+                          ? Number((Number(it.thisYearComplete) / Number(it.target)).toFixed(0)) *
+                            100
                           : 0
                       "
                       :size="50"
@@ -131,7 +137,9 @@ onMounted(async () => {
                         >
                           {{
                             it.thisYearComplete && it.target
-                              ? (Number(it.thisYearComplete) / Number(it.target)) * 100
+                              ? (
+                                  Number(Number(it.thisYearComplete) / Number(it.target)) * 100
+                                ).toFixed(1)
                               : 0
                           }}%
                         </div>