|
|
@@ -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 }))
|
|
|
}
|
|
|
|