|
|
@@ -15,7 +15,7 @@
|
|
|
/>
|
|
|
</view>
|
|
|
|
|
|
- <button v-if="!isSurveyTarget" class="add-btn" @click="openAddDialog">新增</button>
|
|
|
+ <button v-if="canAddEntity" class="add-btn" @click="openAddDialog">新增</button>
|
|
|
</view>
|
|
|
|
|
|
<view v-if="isSurveyTarget" class="entity-tabs">
|
|
|
@@ -38,8 +38,8 @@
|
|
|
|
|
|
<view class="item-content">
|
|
|
<text class="item-name">{{ getItemName(item) }}</text>
|
|
|
- <text v-if="item.address" class="item-address">
|
|
|
- {{ item.address }}
|
|
|
+ <text v-if="getItemAddress(item)" class="item-address">
|
|
|
+ {{ getItemAddress(item) }}
|
|
|
</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
@@ -121,6 +121,7 @@ import {
|
|
|
getWmDaPharmacyByNameApi,
|
|
|
listDistributionByNameApi,
|
|
|
listHospitalByNameApi,
|
|
|
+ listScorePackageDrugsApi,
|
|
|
listWmDaPharmacyByNameApi,
|
|
|
} from '@/services/modules/task/entitySelector'
|
|
|
import type {
|
|
|
@@ -128,6 +129,7 @@ import type {
|
|
|
EntitySelectorRequest,
|
|
|
HospitalItem,
|
|
|
PharmacyItem,
|
|
|
+ ScorePackageDrugItem,
|
|
|
SurveyTargetItem,
|
|
|
} from '@/services/modules/task/entitySelector/type'
|
|
|
|
|
|
@@ -147,8 +149,8 @@ const entityAliasConfig = {
|
|
|
} as const
|
|
|
|
|
|
type EntityAlias = keyof typeof entityAliasConfig
|
|
|
-type PageAlias = EntityAlias | 'surveyTarget'
|
|
|
-type EntityItem = PharmacyItem | HospitalItem | DistributionItem
|
|
|
+type PageAlias = EntityAlias | 'surveyTarget' | 'surveyCategory'
|
|
|
+type EntityItem = PharmacyItem | HospitalItem | DistributionItem | ScorePackageDrugItem
|
|
|
|
|
|
const surveyTargetTabs: ReadonlyArray<{ alias: EntityAlias; label: string }> = [
|
|
|
{ alias: 'yymc', label: '选择医院' },
|
|
|
@@ -158,9 +160,11 @@ const surveyTargetTabs: ReadonlyArray<{ alias: EntityAlias; label: string }> = [
|
|
|
|
|
|
interface PageQuery {
|
|
|
alias?: string
|
|
|
+ packageId?: string
|
|
|
}
|
|
|
|
|
|
const pageAlias = ref<PageAlias>('pharmacyName')
|
|
|
+const packageId = ref('')
|
|
|
const activeEntityAlias = ref<EntityAlias>('yymc')
|
|
|
const keyword = ref('')
|
|
|
const list = ref<EntityItem[]>([])
|
|
|
@@ -180,23 +184,44 @@ const addError = ref('')
|
|
|
let requestVersion = 0
|
|
|
|
|
|
const isSurveyTarget = computed(() => pageAlias.value === 'surveyTarget')
|
|
|
+const isSurveyCategory = computed(() => pageAlias.value === 'surveyCategory')
|
|
|
+const canAddEntity = computed(() => !isSurveyTarget.value && !isSurveyCategory.value)
|
|
|
const currentEntityAlias = computed<EntityAlias>(() =>
|
|
|
isSurveyTarget.value ? activeEntityAlias.value : (pageAlias.value as EntityAlias)
|
|
|
)
|
|
|
-const entityName = computed(() => entityAliasConfig[currentEntityAlias.value].entityName)
|
|
|
+const entityName = computed(() =>
|
|
|
+ isSurveyCategory.value ? '药品' : entityAliasConfig[currentEntityAlias.value].entityName
|
|
|
+)
|
|
|
const searchPlaceholder = computed(() => `搜索${entityName.value}名称`)
|
|
|
const addTitle = computed(() => `新增${entityName.value}`)
|
|
|
const addPlaceholder = computed(() => `请输入${entityName.value}名称`)
|
|
|
|
|
|
const getItemName = (item: EntityItem): string => {
|
|
|
+ if ('drugname' in item) {
|
|
|
+ return item.drugname
|
|
|
+ }
|
|
|
+
|
|
|
const surveyTargetItem: SurveyTargetItem = item
|
|
|
|
|
|
return surveyTargetItem.yymc || surveyTargetItem.gsmc || surveyTargetItem.pharmacyName || ''
|
|
|
}
|
|
|
|
|
|
+const getItemAddress = (item: EntityItem): string => {
|
|
|
+ return 'address' in item ? item.address || '' : ''
|
|
|
+}
|
|
|
+
|
|
|
const requestEntityPage = async (
|
|
|
params: EntitySelectorRequest
|
|
|
): Promise<{ records: EntityItem[]; pages: number }> => {
|
|
|
+ if (isSurveyCategory.value) {
|
|
|
+ const { data } = await listScorePackageDrugsApi({
|
|
|
+ ...params,
|
|
|
+ packageId: packageId.value,
|
|
|
+ })
|
|
|
+
|
|
|
+ return data
|
|
|
+ }
|
|
|
+
|
|
|
if (currentEntityAlias.value === 'pharmacyName') {
|
|
|
const { data } = await listWmDaPharmacyByNameApi(params)
|
|
|
|
|
|
@@ -215,6 +240,10 @@ const requestEntityPage = async (
|
|
|
}
|
|
|
|
|
|
const loadList = async (reset = false) => {
|
|
|
+ if (isSurveyCategory.value && !packageId.value) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
if (!reset && (loading.value || finished.value)) {
|
|
|
return
|
|
|
}
|
|
|
@@ -293,9 +322,15 @@ const getOpenerEventChannel = () => {
|
|
|
|
|
|
const emitSelectedItem = (item: EntityItem | string) => {
|
|
|
const eventChannel = getOpenerEventChannel()
|
|
|
- const eventName = isSurveyTarget.value
|
|
|
- ? 'surveyTargetSelect'
|
|
|
- : entityAliasConfig[currentEntityAlias.value].eventName
|
|
|
+ let eventName: string
|
|
|
+
|
|
|
+ if (isSurveyTarget.value) {
|
|
|
+ eventName = 'surveyTargetSelect'
|
|
|
+ } else if (isSurveyCategory.value) {
|
|
|
+ eventName = 'surveyCategorySelect'
|
|
|
+ } else {
|
|
|
+ eventName = entityAliasConfig[currentEntityAlias.value].eventName
|
|
|
+ }
|
|
|
|
|
|
eventChannel?.emit(eventName, item)
|
|
|
}
|
|
|
@@ -388,18 +423,35 @@ onLoad((query?: PageQuery) => {
|
|
|
|
|
|
pageAlias.value =
|
|
|
alias === 'surveyTarget' ||
|
|
|
+ alias === 'surveyCategory' ||
|
|
|
alias === 'pharmacyName' ||
|
|
|
alias === 'yymc' ||
|
|
|
alias === 'companyName'
|
|
|
? alias
|
|
|
: 'pharmacyName'
|
|
|
|
|
|
+ packageId.value = String(query?.packageId ?? '').trim()
|
|
|
+
|
|
|
if (isSurveyTarget.value) {
|
|
|
uni.setNavigationBarTitle({
|
|
|
title: '选择调查对象',
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+ if (isSurveyCategory.value) {
|
|
|
+ uni.setNavigationBarTitle({
|
|
|
+ title: '选择药品',
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isSurveyCategory.value && !packageId.value) {
|
|
|
+ uni.showToast({
|
|
|
+ title: '缺少积分包信息',
|
|
|
+ icon: 'none',
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
void loadList(true)
|
|
|
})
|
|
|
|