Преглед на файлове

积分包详情页完成

yuanmingze преди 4 месеца
родител
ревизия
b39510eecd
променени са 4 файла, в които са добавени 42 реда и са изтрити 28 реда
  1. 0 1
      components.d.ts
  2. 2 1
      src/composables/useFormValidator.ts
  3. 40 24
      src/pages-task/task-package/detail.vue
  4. 0 2
      src/pages/login/index.vue

+ 0 - 1
components.d.ts

@@ -16,7 +16,6 @@ declare module 'vue' {
     WdDialog: typeof import('@wot-ui/ui/components/wd-dialog/wd-dialog.vue')['default']
     WdEmpty: typeof import('@wot-ui/ui/components/wd-empty/wd-empty.vue')['default']
     WdIcon: typeof import('@wot-ui/ui/components/wd-icon/wd-icon.vue')['default']
-    WdInput: typeof import('@wot-ui/ui/components/wd-input/wd-input.vue')['default']
     WdLoading: typeof import('@wot-ui/ui/components/wd-loading/wd-loading.vue')['default']
     WdNavbar: typeof import('@wot-ui/ui/components/wd-navbar/wd-navbar.vue')['default']
     WdNoticeBar: typeof import('@wot-ui/ui/components/wd-notice-bar/wd-notice-bar.vue')['default']

+ 2 - 1
src/composables/useFormValidator.ts

@@ -1,5 +1,6 @@
 import { ref } from 'vue'
-import Schema, { type Rules, type RuleItem, type ValidateError } from 'async-validator'
+
+import Schema, { type RuleItem, type Rules, type ValidateError } from 'async-validator'
 
 export function useFormValidator<T extends Record<string, any>>(rules: Rules, model: T) {
   const schema = new Schema(rules)

+ 40 - 24
src/pages-task/task-package/detail.vue

@@ -27,9 +27,13 @@
       <view v-for="section in ruleSections" :key="section.title" class="rule-section">
         <view class="rule-section__title">{{ section.title }}</view>
 
-        <view v-for="item in section.items" :key="item.id" class="rule-item">
-          <text class="rule-item__name">{{ item.taskTypeName }}</text>
-          <text class="rule-item__score">+{{ item.score }} 积分</text>
+        <view
+          v-for="(item, index) in section.items"
+          :key="item.id || `${item.taskTypeName || 'rule'}-${index}`"
+          class="rule-item"
+        >
+          <text class="rule-item__name">{{ item.taskTypeName || EMPTY_TEXT }}</text>
+          <text class="rule-item__score">+{{ item.score || 0 }} 积分</text>
         </view>
       </view>
     </view>
@@ -102,6 +106,8 @@ import {
 
 import { useUserStore } from '@/stores/modules/user'
 
+const EMPTY_TEXT = '无'
+
 const userStore = useUserStore()
 
 const id = ref('')
@@ -111,25 +117,31 @@ const exportPopupVisible = ref(false)
 const emailInputFocus = ref(false)
 const emailError = ref('')
 const email = ref('')
-const packageDetail = ref(null)
-const ruleSections = ref([])
 
-const EMPTY_TEXT = '无'
+const packageDetail = ref<any>(null)
+const ruleSections = ref<any[]>([])
 
-const roles = computed(() => userStore.currentUserInfo?.roles || [])
+const roles = computed<any[]>(() => {
+  return userStore.currentUserInfo?.roles || []
+})
 
 const showExportButton = computed(() => {
   return roles.value.includes(6) && packageDetail.value?.exportFlag === '1'
 })
 
-const formatDrugList = (val) => {
+const formatDrugList = (val: any): string => {
   if (!val) return EMPTY_TEXT
-  if (Array.isArray(val)) return val.join('、') || EMPTY_TEXT
+
+  if (Array.isArray(val)) {
+    return val.filter(Boolean).join('、') || EMPTY_TEXT
+  }
+
   return (
     String(val)
       .replace(/^\[|\]$/g, '')
       .replace(/"/g, '')
       .split(',')
+      .map((item) => item.trim())
       .filter(Boolean)
       .join('、') || EMPTY_TEXT
   )
@@ -137,11 +149,12 @@ const formatDrugList = (val) => {
 
 const areaName = computed(() => {
   const area = packageDetail.value?.area
+
   if (!Array.isArray(area) || area.length === 0) return EMPTY_TEXT
 
   return (
     area
-      .map((item) => `${item.province ?? ''}${item.city ?? ''}${item.area ?? ''}`)
+      .map((item: any) => `${item.province ?? ''}${item.city ?? ''}${item.area ?? ''}`)
       .filter(Boolean)
       .join(',') || EMPTY_TEXT
   )
@@ -149,17 +162,18 @@ const areaName = computed(() => {
 
 const quizNames = computed(() => {
   const list = packageDetail.value?.quizRelations
+
   if (!Array.isArray(list) || list.length === 0) return EMPTY_TEXT
 
   return (
     list
-      .map((item) => item.title)
+      .map((item: any) => item.title)
       .filter(Boolean)
       .join(',') || EMPTY_TEXT
   )
 })
 
-const detailRows = computed(() => {
+const detailRows = computed<any[]>(() => {
   const d = packageDetail.value
 
   return [
@@ -190,7 +204,7 @@ const detailRows = computed(() => {
   ]
 })
 
-onLoad((query) => {
+onLoad((query: any) => {
   const packageId = String(query?.id || '')
 
   if (!packageId) {
@@ -202,7 +216,7 @@ onLoad((query) => {
   initPage()
 })
 
-const initPage = async () => {
+const initPage = async (): Promise<void> => {
   loading.value = true
   uni.showLoading({ title: '加载中' })
 
@@ -214,18 +228,20 @@ const initPage = async () => {
   }
 }
 
-const getScorePackagePageById = async () => {
-  const res = await getScorePackagePageByIdApi(id.value)
+const getScorePackagePageById = async (): Promise<void> => {
+  const res: any = await getScorePackagePageByIdApi(id.value)
+
   packageDetail.value = res.data || null
   email.value = res.data?.email || ''
 }
 
-const getPackageCanTaskList = async () => {
-  const res = await getPackageCanTaskListApi(id.value)
+const getPackageCanTaskList = async (): Promise<void> => {
+  const res: any = await getPackageCanTaskListApi(id.value)
+
   ruleSections.value = normalizeRuleSections(res.data)
 }
 
-const openExportPopup = async () => {
+const openExportPopup = async (): Promise<void> => {
   resetExportError()
   exportPopupVisible.value = true
 
@@ -236,12 +252,12 @@ const openExportPopup = async () => {
   }, 300)
 }
 
-const resetExportError = () => {
+const resetExportError = (): void => {
   emailError.value = ''
   emailInputFocus.value = false
 }
 
-const submitExportReport = async () => {
+const submitExportReport = async (): Promise<void> => {
   const value = email.value.trim()
 
   if (!validateEmail(value)) {
@@ -269,11 +285,11 @@ const submitExportReport = async () => {
   }
 }
 
-const validateEmail = (value) => {
+const validateEmail = (value: string): boolean => {
   return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)
 }
 
-const normalizeRuleSections = (raw) => {
+const normalizeRuleSections = (raw: any): any[] => {
   if (!raw) return []
 
   if (Array.isArray(raw)) {
@@ -282,7 +298,7 @@ const normalizeRuleSections = (raw) => {
 
   if (Object.prototype.toString.call(raw) === '[object Object]') {
     return Object.entries(raw)
-      .filter(([, v]) => Array.isArray(v) && v.length > 0)
+      .filter(([, value]) => Array.isArray(value) && value.length > 0)
       .map(([title, items]) => ({ title, items }))
   }
 

+ 0 - 2
src/pages/login/index.vue

@@ -24,8 +24,6 @@
         <AuthInputItem
           label="密码"
           v-model="form.password"
-          type="number"
-          :maxlength="11"
           placeholder="请输入密码"
           passwordToggle
           :error="errors.password"