Pārlūkot izejas kodu

完成bug修复

yuanmingze 1 mēnesi atpakaļ
vecāks
revīzija
58ac1239b0

+ 26 - 4
src/pages-common/entity-selector/index.vue

@@ -20,7 +20,7 @@
 
     <view v-if="isSurveyTarget" class="entity-tabs">
       <view
-        v-for="tab in surveyTargetTabs"
+        v-for="tab in visibleSurveyTargetTabs"
         :key="tab.alias"
         class="entity-tab"
         :class="{ 'entity-tab--active': activeEntityAlias === tab.alias }"
@@ -131,6 +131,7 @@ import type {
   PharmacyItem,
   ScorePackageDrugItem,
   SurveyTargetItem,
+  SurveyTargetSelection,
 } from '@/services/modules/task/entitySelector/type'
 const entityAliasConfig = {
   pharmacyName: {
@@ -157,13 +158,21 @@ const surveyTargetTabs: ReadonlyArray<{ alias: EntityAlias; label: string }> = [
   { alias: 'companyName', label: '选择商业公司' },
 ]
 
+const surveyTargetTypeByAlias: Record<EntityAlias, SurveyTargetSelection['targetType']> = {
+  yymc: 'hospital',
+  pharmacyName: 'pharmacy',
+  companyName: 'company',
+}
+
 interface PageQuery {
   alias?: string
   packageId?: string
+  targetMode?: string
 }
 
 const pageAlias = ref<PageAlias>('pharmacyName')
 const packageId = ref('')
+const hospitalOrPharmacyOnly = ref(false)
 const activeEntityAlias = ref<EntityAlias>('yymc')
 const keyword = ref('')
 const list = ref<EntityItem[]>([])
@@ -181,6 +190,11 @@ const addName = ref('')
 const addError = ref('')
 
 const isSurveyTarget = computed(() => pageAlias.value === 'surveyTarget')
+const visibleSurveyTargetTabs = computed(() =>
+  hospitalOrPharmacyOnly.value
+    ? surveyTargetTabs.filter((tab) => tab.alias !== 'companyName')
+    : surveyTargetTabs
+)
 const isSurveyCategory = computed(() => pageAlias.value === 'surveyCategory')
 const canAddEntity = computed(() => !isSurveyTarget.value && !isSurveyCategory.value)
 const currentEntityAlias = computed<EntityAlias>(() =>
@@ -316,7 +330,12 @@ const emitSelectedItem = (item: EntityItem | string) => {
     eventName = entityAliasConfig[currentEntityAlias.value].eventName
   }
 
-  eventChannel?.emit(eventName, item)
+  const selectedItem =
+    isSurveyTarget.value && typeof item !== 'string'
+      ? { ...item, targetType: surveyTargetTypeByAlias[currentEntityAlias.value] }
+      : item
+
+  eventChannel?.emit(eventName, selectedItem)
 }
 
 const selectItem = (item: EntityItem) => {
@@ -327,7 +346,10 @@ const selectItem = (item: EntityItem) => {
 }
 
 const switchSurveyTargetTab = (alias: EntityAlias) => {
-  if (alias === activeEntityAlias.value) {
+  if (
+    alias === activeEntityAlias.value ||
+    !visibleSurveyTargetTabs.value.some((tab) => tab.alias === alias)
+  ) {
     return
   }
 
@@ -415,6 +437,7 @@ onLoad((query?: PageQuery) => {
       : 'pharmacyName'
 
   packageId.value = String(query?.packageId ?? '').trim()
+  hospitalOrPharmacyOnly.value = isSurveyTarget.value && query?.targetMode === 'hospitalOrPharmacy'
 
   if (isSurveyTarget.value) {
     uni.setNavigationBarTitle({
@@ -450,7 +473,6 @@ onPullDownRefresh(async () => {
     uni.stopPullDownRefresh()
   }
 })
-
 </script>
 
 <style lang="scss" scoped>

+ 1 - 0
src/pages-task/task-form/components/DynamicTaskFormFields.vue

@@ -227,6 +227,7 @@ const {
 const shouldRenderField = (field: TaskFieldConfigViewItem) => {
   return (
     field.show &&
+    field.invisible !== true &&
     isSupported(field.taskFiledType) &&
     !hiddenFieldTypeSet.value.has(field.taskFiledType) &&
     !hiddenFieldAliasSet.value.has(field.alias ?? '')

+ 1 - 1
src/pages-task/task-form/composables/useTaskFormAction.ts

@@ -267,7 +267,7 @@ export const useTaskFormAction = ({
 
   const validateSubmitForm = (): boolean => {
     for (const field of taskFieldConfigList.value) {
-      if (!field.show) continue
+      if (!field.show || field.invisible === true) continue
 
       if (!validateField(field)) {
         return false

+ 31 - 8
src/pages-task/task-form/composables/useTaskSelectHandlers.ts

@@ -7,6 +7,7 @@ import type {
   PharmacyItem,
   ScorePackageDrugItem,
   SurveyTargetItem,
+  SurveyTargetSelection,
 } from '@/services/modules/task/entitySelector/type'
 import {
   getListDrugTableApi,
@@ -69,8 +70,20 @@ const PACKAGE_DEPENDENT_FIELD_ALIASES: Readonly<Record<string, readonly string[]
   '37': ['surveyCategory'],
   '47': ['drugs', 'realTaskTypeId'],
   '64': ['drugs'],
-  '75': ['drugs', 'hospitalOrPharmacy', 'hospitalOrPharmacyAddress'],
-  '76': ['drugs', 'hospitalOrPharmacy', 'hospitalOrPharmacyAddress'],
+  '75': [
+    'drugs',
+    'hospitalOrPharmacy',
+    'hospitalOrPharmacyAddress',
+    'hospitalOrPharmacyFlag',
+    'address',
+  ],
+  '76': [
+    'drugs',
+    'hospitalOrPharmacy',
+    'hospitalOrPharmacyAddress',
+    'hospitalOrPharmacyFlag',
+    'address',
+  ],
   '81': ['drugs', 'hospitalOrPharmacy', 'address'],
   '85': ['drugs', 'hospital', 'level'],
 }
@@ -191,9 +204,10 @@ export const useTaskSelectHandlers = ({
 
   const openSurveyTargetSelector = (
     targetAlias: 'surveyTarget' | 'hospitalOrPharmacy',
-    addressAlias?: string
+    addressAliases: readonly string[] = [],
+    hospitalOrPharmacyOnly = false
   ): false => {
-    return openEntitySelector<SurveyTargetItem>(
+    return openEntitySelector<SurveyTargetSelection>(
       'surveyTarget',
       'surveyTargetSelect',
       (selectedItem) => {
@@ -201,10 +215,15 @@ export const useTaskSelectHandlers = ({
 
         setFieldTextByAlias(targetAlias, name)
 
-        if (addressAlias) {
+        for (const addressAlias of addressAliases) {
           setFieldTextByAlias(addressAlias, formatDetailedAddress(selectedItem))
         }
-      }
+
+        if (hospitalOrPharmacyOnly) {
+          setFieldTextByAlias('hospitalOrPharmacyFlag', selectedItem.targetType)
+        }
+      },
+      hospitalOrPharmacyOnly ? { targetMode: 'hospitalOrPharmacy' } : {}
     )
   }
 
@@ -347,7 +366,7 @@ export const useTaskSelectHandlers = ({
         return false
       }
 
-      return openSurveyTargetSelector('hospitalOrPharmacy', 'address')
+      return openSurveyTargetSelector('hospitalOrPharmacy', ['address'])
     }
 
     if (
@@ -358,7 +377,11 @@ export const useTaskSelectHandlers = ({
         return false
       }
 
-      return openSurveyTargetSelector('hospitalOrPharmacy', 'hospitalOrPharmacyAddress')
+      return openSurveyTargetSelector(
+        'hospitalOrPharmacy',
+        ['hospitalOrPharmacyAddress', 'address'],
+        true
+      )
     }
 
     if (field.taskTypeId === '18' && field.alias === 'entName') {

+ 4 - 0
src/services/modules/task/entitySelector/type.d.ts

@@ -51,6 +51,10 @@ export interface SurveyTargetItem {
   address: string
 }
 
+export interface SurveyTargetSelection extends SurveyTargetItem {
+  targetType: 'hospital' | 'pharmacy' | 'company'
+}
+
 export interface PharmacyItem {
   /**
    * 主键 ID